Adding a mesh unseen

streb2001

Addon Developer
Addon Developer
Donator
Joined
Feb 9, 2008
Messages
326
Reaction score
0
Points
16
Location
North Yorkshire
Within a vessel DLL, is it possible to add a mesh for the vessel so that it is initially invisible? AddMesh() causes the mesh to be rendered immediately and before the DLL has had a chance to set the correct animation states. This is causing a very brief flickering as the unset anims are shown, presumably for one sim frame.

Here is the background: I am coding a DLL for Shenzhou. The DLL animates the unfolding solar panels on the service module. I then jettison the service module from the command module by spawning it as a new vessel and passing it the current anim states. The SM DLL loads its own mesh with AddMesh, rendering the vessel. The anims are then defined using the meshindex returned from AddMesh and set using the passed parameters from the parent vessel. In the time between adding the mesh and defining the anims, the vessel is (very briefly) rendered with its anims reset - FLICKER!

Anyone know a way around this? Can AddMesh be forced to set MESHVIS_COCKPIT or something?

s2k1
 
Last edited:

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,636
Reaction score
2,352
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
You can set the mesh visibility mode to MESHVIS_NEVER.
 

streb2001

Addon Developer
Addon Developer
Donator
Joined
Feb 9, 2008
Messages
326
Reaction score
0
Points
16
Location
North Yorkshire
Close, but no cigar I'm afraid. Same flicker. SetMeshVisibilityMode() uses the meshindex returned by AddMesh(), hence the mesh is initially rendered before it is made invisible. Thanks anyway Urwumpe.

Either AddMesh() needs and extra parameter (mesh visibility mode) or I am going about this the wrong way.
 

n0mad23

Addon Developer
Addon Developer
Joined
Feb 10, 2008
Messages
1,078
Reaction score
17
Points
0
Location
Montesano
Website
soundcloud.com
You can set the mesh visibility mode to MESHVIS_NEVER.

Will this have a significant effect on either CPU use or fps?

I'm wondering about the advantages of making something invisible versus deleting the mesh altogether.

No hijacking intended here, instead I'm trying to tease out a better understanding of the MESHVIS function in different possible uses.

Thanks for asking the question streb2001.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,636
Reaction score
2,352
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
I think in your case, the problem is happening actually somewhere else: How long is the time from creating the vessel to setting the animation states in simulation steps?

For flickering, the SM vessel would need to exist first in it's initial form and get it's animation states changed after the first rendering pass. I would examine if you can reduce the time...

n0mad23: I used MESHVIS_NEVER for implementing a multistage rocket, without any problems or lower fps as the old implementation. I also use this for implementing a city with over 1000 buildings, with each building having actually 3 meshes, with only one of the building meshes being shown at the same time (in different quality levels, depending on camera distance). The problems just came when approaching 10000 buildings, because the algorithm for determining level of detail slowed the system down.
 

streb2001

Addon Developer
Addon Developer
Donator
Joined
Feb 9, 2008
Messages
326
Reaction score
0
Points
16
Location
North Yorkshire
In SetClassCaps() I am calling AddMesh() and SetMeshVisibilityMode(MESHVIS_NEVER) in immediate succession. Shouldn't this set the mesh invisible before the first render pass?
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,636
Reaction score
2,352
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
In SetClassCaps() I am calling AddMesh() and SetMeshVisibilityMode(MESHVIS_NEVER) in immediate succession. Shouldn't this set the mesh invisible before the first render pass?

It should, but when do you make it visible?
 

streb2001

Addon Developer
Addon Developer
Donator
Joined
Feb 9, 2008
Messages
326
Reaction score
0
Points
16
Location
North Yorkshire
In PostStep()

Maybe I should make it visible in the clbkVisualCreated() call?
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,636
Reaction score
2,352
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Better make it visible after setting the animations to their initial values. Usually this happens in post-creation, but I think you can not rely on it being called after you passed the information to the SM.

Better you research the problem. Use oapiWriteLog and record before you create the SM, after you created the SM, before you set the animation states, after you set the animation states and at the beginning of each callback of the SM.
 
Top