General Question cloaking ideas/help

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,736
Reaction score
2,707
Points
203
Location
Dallas, TX
I need help/ideas on how to cloak a vessel?

I know one can set the mesh to not be seen. BUT any ships/cargo attach are seen.

I have tried adding a transparent mesh to block the vessels attached but it casts a shadow while the main craft doesn't.

Is there a function to not show any vessel with in a distance?
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
104
Points
78
if you are looking for vessels attached you can get the handle of the vessels from the attachments, then get the interface of each vessels and the set the meshes visibility mode to never for all the meshes of each vessel. Maybe you want also to save the visibility modes of all the meshes before resetting it so you can get back and restore it.

That's only an idea, hope it helps
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,883
Reaction score
2,135
Points
203
Location
between the planets
I know one can set the mesh to not be seen. BUT any ships/cargo attach are seen.

walk through all attachmed/docked vessels and make all their meshes invisible.
The major problem will be to have them turn back to visible when they're undocked, but it's solvable.
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
Or you could try to put an actual cloak around your ship: enclose it in a transparent sphere and let the z-buffer do the rest.

Except you can't, since this requires that the sphere is rendered before any of the attached vessels, and you don't have control over the rendering order. (you might get away with putting a sphere around each of the attached vessels individually).

An even neater way to do this would be to render an opaque shell around the vessel, and update its texture dynamically so that it mimics the background. Of course, this would only work for a particular direction, just like a real cloaking device.

Certainly not a trivial option, and I don't know if it is even possible with the current graphics interface. A black shell might be a good compromise, which works well enough in deep space.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,637
Reaction score
2,353
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
A custom shader for such a shell might also be an option, but again, this fails on the implementation of the graphics interface.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,736
Reaction score
2,707
Points
203
Location
Dallas, TX
Thanks. This vessel will be in atmosphere on Earth.

I made a cover for the deck to cover all the planes on the deck. But it cast a shadow. So I made a mesh of the carrier and set the transparency to .1 then if cloak wanted turn main mesh off and this mesh on. And the cover. But the cover looks different. It also cast a shadow so you still see the shadow.

The planes are sc3 so not sure one could turn the mesh off
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
You can prevent a mesh group from casting a shadow by setting a bitflag (can't remember which, but it should be documented).
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,736
Reaction score
2,707
Points
203
Location
Dallas, TX
Thanks I thought it was 4. I know if if is not textured you get a white material. it is textured and set as 4 and still a shadow

---------- Post added 12-02-15 at 04:03 AM ---------- Previous post was 12-01-15 at 08:34 AM ----------

Here are some images to maybe help.
helicarrier1_zpswzkyaouv.jpg


then I cloak
helicarrier2_zpspgyhwoc9.jpg


Mesh setting for main transparent mesh

MATERIALS 1
transparent
MATERIAL transparent
0.878431 0.878431 0.878431 0.098039
0.878431 0.878431 0.878431 0.098039
0.000000 0.000000 0.000000 0.1 20
0.000000 0.000000 0.000000 0.1
TEXTURES 0

then the cover:
MSHX1
GROUPS 1
LABEL mesh27
MATERIAL 1
TEXTURE 1
FLAG 4
....
MATERIALS 1
Helica0151
MATERIAL Helica0151
0.878431 0.878431 0.878431 0.098039
0.878431 0.878431 0.878431 0.098039
0.000000 0.000000 0.000000 0.1 20
0.000000 0.000000 0.000000 0.1
TEXTURES 1
Helica01.dds

I need to turn beacons off and turn exhaust off
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,736
Reaction score
2,707
Points
203
Location
Dallas, TX
Thanks to fred18:thumbup:
I can turn off all meshes;
Code:
void HELICARRIER::CLOAK()
{
	for (UINT i = 0; i < 13; i++)
	{
		ATTACHMENTHANDLE ah = GetAttachmentHandle(false, i);
		OBJHANDLE hvessel = GetAttachmentStatus(ah);
		if (oapiIsVessel(hvessel))
		{
			VESSEL2 *v;
			v = (VESSEL2*)oapiGetVesselInterface(hvessel);
			for (UINT j = 0; j < v->GetMeshCount(); j++)
			{
				v->SetMeshVisibilityMode(j, MESHVIS_NEVER);
			}
		}
	}
}

But when I try the reverse I get a CTD. :(

Code:
void HELICARRIER::UNCLOAK()
{
	for (UINT i = 0; i < 13; i++)
	{
		ATTACHMENTHANDLE ai = GetAttachmentHandle(false, i);
		OBJHANDLE hvessel = GetAttachmentStatus(ai);
		if (oapiIsVessel(hvessel))
		{
			VESSEL2 *v;
			v = (VESSEL2*)oapiGetVesselInterface(hvessel);
			for (UINT j = 0; j < v->GetMeshCount(); j++)
			{
				v->SetMeshVisibilityMode(j, MESHVIS_ALWAYS);
			}
		}
	}
}

fred18 has suggested that I may need build an array or structure to store all info about the meshes as there may be a virtual cockpit mesh. I see because the mesh might be set as cockpit,....

So can someone help me here?
 
Last edited:

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,736
Reaction score
2,707
Points
203
Location
Dallas, TX
Thanks to Lisias.
Now the all vessels are not seen. The last step is to turn off exhaust. I have it if cloak then add exhaust 0,0 rather than the regular length.

Code:
void HELICARRIER::CLOAK()
{





	//attached_vessels_mesh_states.clear(); // Forgets everything
	for (UINT i = 0; i < 12; i++)
	{
		ATTACHMENTHANDLE ah = GetAttachmentHandle(false, i);
		OBJHANDLE hvessel = GetAttachmentStatus(ah);
		if (oapiIsVessel(hvessel))
		{
			VESSEL2 *v = (VESSEL2*)oapiGetVesselInterface(hvessel);
			std::vector<WORD> list(v->GetMeshCount());
			for (UINT j = 0; j < v->GetMeshCount(); j++)
			{
				//list[j] = 0;
				list[j] = v->GetMeshVisibilityMode(j);
				v->SetMeshVisibilityMode(j, MESHVIS_NEVER);
			}
			attached_vessels_mesh_states[v] = list;
		}
	}

	AddExhaust(th_hover[0], 0, 0, _V(-140, -40, 113), _V(0, -1, 0));
	AddExhaust(th_hover[0], 0, 0, _V(143, -40, 113), _V(0, -1, 0));
	AddExhaust(th_hover[0], 0, 0, _V(-164, -40, -212), _V(0, -1, 0));
	AddExhaust(th_hover[0], 0, 0, _V(166, -40, -212), _V(0, -1, 0));
	//turn beacons off

	for (int i = 0; i < 8; i++)


		beacon[i].active = false;

	this->is_cloaked = true;
}

void HELICARRIER::DECLOAK()
{
	for (std::map<VESSEL2*, std::vector<WORD>>::iterator it = attached_vessels_mesh_states.begin(); it != attached_vessels_mesh_states.end(); ++it)
	{
		for (UINT i = 0; i < it->second.size(); i++)
		{
			it->first->SetMeshVisibilityMode(i, it->second[i]);
		}
	}
	this->is_cloaked = false;
	attached_vessels_mesh_states.clear(); // Forgets everything (and save memory)

	AddExhaust(th_hover[0], 150, 50, _V(-140, -40, 113), _V(0, -1, 0));
	AddExhaust(th_hover[0], 150, 50, _V(143, -40, 113), _V(0, -1, 0));
	AddExhaust(th_hover[0], 150, 50, _V(-164, -40, -212), _V(0, -1, 0));
	AddExhaust(th_hover[0], 150, 50, _V(166, -40, -212), _V(0, -1, 0));
	for (int i = 0; i < 8; i++)
		beacon[0].active = false;
	beacon[1].active = true;
	beacon[2].active = false;
	beacon[3].active = false;
	beacon[4].active = false;
	beacon[5].active = true;
	beacon[6].active = true;
	beacon[7].active = true;

}
 
Top