Meshing Question Getting MESH group by Label

Lisias

Space Traveller Wanna-be
Joined
May 31, 2015
Messages
346
Reaction score
3
Points
18
Website
www.youtube.com
Hi.

Is there any already implemented means to address a Group on the Mesh by LABEL, and not by index?

So, in exchange on using this:
Code:
	SURFHANDLE suface = oapiGetTextureHandle (vcmesh_tpl, 16);

I want to use something as:
Code:
	SURFHANDLE suface = [I]customapiGetTextureHandle[/I] (vcmesh_tpl, "PILOT_LEFT_MFD_SCREEN");

Where vcmesh_tpl is the handler to a previously loaded mesh where the 16th group has the label "PILOT_LEFT_MFD_SCREEN" and the italiced identifier is my hypothetical function.

Alternatively, one could manage this by:

Code:
	uint groupIndex = [I]customapiGetIndexByLabel[/I](vcmesh_tpl, "PILOT_LEFT_MFD_SCREEN");
	SURFHANDLE suface = oapiGetTextureHandle (vcmesh_tpl, groupIndex);
 
Last edited:

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
Yes there is. You use the meshc utility (located in Orbitersdk/utils) to generate a header file that maps group labels to correspondingly named integer constants. See the project files for DeltaGlider or Atlantis for examples. By binding the invocation of meshc into the makefile you make sure that the label-index map is always up to date even if the mesh structure changes.

This method is more efficient than storing and accessing the labels as strings (and it doesn't require any additional API functions).
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,612
Reaction score
2,330
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Yes there is. You use the meshc utility (located in Orbitersdk/utils) to generate a header file that maps group labels to correspondingly named integer constants. See the project files for DeltaGlider or Atlantis for examples. By binding the invocation of meshc into the makefile you make sure that the label-index map is always up to date even if the mesh structure changes.

This method is more efficient than storing and accessing the labels as strings (and it doesn't require any additional API functions).

In the SSU project repository is also an improved version of meshc (ssumeshc), which does some additional tricks, like replacing special characters that are illegal in C++ identifiers and renaming duplicate labels. Also it creates the constants as C++ constants and not as preprocessor defines, so type checking is active.

Also, it does not poll for inputs like (at least the current version of) meshc does, since it can be completely controlled by command line arguments.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,702
Reaction score
2,679
Points
203
Location
Dallas, TX
Yes there is. You use the meshc utility (located in Orbitersdk/utils) to generate a header file that maps group labels to correspondingly named integer constants. See the project files for DeltaGlider or Atlantis for examples. By binding the invocation of meshc into the makefile you make sure that the label-index map is always up to date even if the mesh structure changes.

This method is more efficient than storing and accessing the labels as strings (and it doesn't require any additional API functions).

On this. Can one have multiple of these? Like 1 h for the main mesh and another h for the vc?

Since one can't combine them into one h as the number would be off
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
Yes. I can't quite remember the command line syntax offhand, but there are options to specify the name of the .h output file. There is also an option to put a prefix on the generated names of the constants, so they don't conflict with each other. The DG and Atlantis samples should show how to use this.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,612
Reaction score
2,330
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
On this. Can one have multiple of these? Like 1 h for the main mesh and another h for the vc?

Of course you can.

BUT: Make sure the files have their own prefixes or suffixes for the identifiers of the mesh group constants, because otherwise, a later included header file can replace the identifiers of the header file included earlier.

In ssumeshc, you would get compiler errors, should two files contain the same identifiers, in meshc, you would usually get only a warning. If you ignore the warning, you could be using the wrong meshgroup for an animation, despite using the correct constant.
 
Last edited:
Top