Jump to content
Sign in to follow this  
Varmint007

<Visibility> modeldef problems

Recommended Posts

Hey guys,I've got some strange things going on in a Gmax project that I just can't figure out. I'm just now getting into the FSX (acceleration) SDK, and the differences from FS9 in terms of modeldef.xml seem easy enough. It seems like I've figured out the whole attachpoint/animation manager paradigm and I can get custom animations to work as expected. The trouble I'm having is with visibility attachpoints.I define the visibility condition in modeldef.xml

<PartInfo><name>some_visibility_label</name><Visibility><Parameter><Code>(L:some custom variable, bool)</Code></Parameter></Visibility></PartInfo>

In Gmax:I select an object, then select the attachpoint tool.some_visibility_label appears in the list of visibility items.I choose it and press attach to selected geometryI then do a properties on the object and confirm the userdefined entry for the visibility condition.Compile the model.When run, the object is always visible, as if the visibility attachment never stuck.Now I'm no noob to XML and FS9. I've been doing it for 5 years, so I know when XML code is well formed or not, and my visibility code is also fine (at the very least an object would be INvisible if that was incorrect). My problem must be with not understanding how to properly tag an object, although I'm doing exactly what the SDK says to do.In fact I have an animation which has visibility associated with it:

<PartInfo><Name>some_animated_part</Name><AnimLength>100</AnimLength><Visibility><Parameter><Code>some_visibility_condition</Code></Parameter></Visibility><Animation><Parameter><Code>some_animation_code</Code><lag>30</lag></Parameter></Animation></PartInfo>

That visibility condition shows up (and WORKS) just fine when using the attachtool. So what is it about attaching visibility elements by themselves? They don't have a GUID associated with them that I can see from the sample modeldef. They show up in the list, the code is well formed, yet once you attach them they have no effect. So here are a couple questions that are killin' me!:1) Why would an object which has been tagged with visibility and is confirmed to have been tagged by verifying it through the object properties, ALWAYS appear after having been compiled? At the very least one would expect that A) The visibility "object" must be well formed in order to show up in the attachtool visibility list at all, and B), even if the <code> was incorrect (which it's not), the object would default to NOT appearing because the resultant value would always be 0. Again, I know the XML is well-formed and I know the code is correct. I have even tried simple "0" or "1". The visibility tag isn't sticking to the object after compiling.2) What is the purpose of the Attach Name field? The SDK says nothing about it and it always produces the same value (undefined_6) after tagging. Even if I type something in there it invariably appends _6!. Where is this used and why?3) What is the purpose of the Create New Attach Point! button? Again, simply not in the SDK and despite repeated trials, I can't figure out what that option does.Thanks guys, I'm just stumped on these. --Jon

Share this post


Link to post
Share on other sites

There's a lot of points to address, but in an effort to keep it simple, here are some basic guidelines:1. All XML scripts that are strictly <Visibility> do not require a corresponding <Animation...guid=xxx...</Animation> entry. They will appear in the list as you've noted.2. All XML scripts that include an <Animation> do require a corresponding <Animation...guid=xxx...</Animation> entry, as it is the latter that enables the name to appear in the Animation Manager.3. As noted, all (L:var,unit) variables initialize with zero (false). Therefore, any part that is supposed to be normally hidden will appear in Preview and Spot View. If this is undesired, simply invert the conditions for display in the XML script.4. There are instances where the objects seem not to respond reliably using only the value of the (L:var,unit) or (A:Something,unit) variables. I've found it more reliable when explicitly declared in the script. For example:

   <PartInfo>	<Name>panel_lights_on</Name>	<Visibility>			<Parameter>				<Code>(A:LIGHT PANEL,bool) 0 > if{ 1 } els{ 0 }</Code>			</Parameter>	</Visibility>   </PartInfo>	<PartInfo>	  <Name>pitot_covers</Name>			<Visibility>		   <Parameter>				<Code>(L:PitotCover,number) 0 > if{ 1 } els{ 0 }</Code>		   </Parameter>		</Visibility>	</PartInfo>

5. Note that in both examples, I've specified that they should be displayed anytime that the control variable is greater than zero... According to ACES, the only "guaranteed value" for any L:var is zero! Therefore, to make this 100% reliable, I've used the aforementioned trick to overcome this (occasional) problem.


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
5. Note that in both examples, I've specified that they should be displayed anytime that the control variable is greater than zero... According to ACES, the only "guaranteed value" for any L:var is zero! Therefore, to make this 100% reliable, I've used the aforementioned trick to overcome this (occasional) problem.
Hi Bill!Right, I think I understand the differences pretty well now (GUID required for animations, none for visibility alone, etc.). And as you say, the only "guaranteed" value for an L:Var is zero, which is why it's driving me nuts trying to understand why some part would be visible under any circumstances once tagged with a value I know to be zero. Indeed, I've even tried explicitly using a zero value "0" in the the <Code> elements and the part still shows up! Again, it's like it's not tagged at all or somehow the tags aren't being compiled.Is there any way (using Gmax) to examine the X file? It looks like it goes stright to .MDL and you can only get access to the .X file if you use the 3DS exporter. Do you know if I'm right about that?Thanks my friend,--Jon

Share this post


Link to post
Share on other sites

OK! Looks like it's sorted out.For some bizarre reason code within <Code> tags like this:<Code>Some code</Code>Was not parsing (probably throwing a syntax error without any feedback). But this works:<Code>Some code</Code>It seems without the line breaks, and only in the case of a visibility structure, it wasn't working. The really strange part is there ARE example <Code>somecode</Code> structures in the default modeldef.xml, but it seems they only exist in that form (on the same line) when they're part of a containing animation and not a visibility-only.Gotta love the quirks :(, and thanks for your help Bill!Edit: I'll also bear in mind what you said about explicitly adding if{ } els{ } to the boolean code. It's hard to accept superfluous things like that since they're so inefficient when used by the hundreds, but lesson learned.--Jon

Share this post


Link to post
Share on other sites

Odd that... Here's one I've used for quite awhile now with no problem...

   <PartInfo>	<Name>show_vc</Name>	<Visibility>	   <Parameter>			 <Code>(L:ShowVC,bool) 0 ==</Code>	   </Parameter>	</Visibility>   </PartInfo>


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
Odd that... Here's one I've used for quite awhile now with no problem...
   <PartInfo>	<Name>show_vc</Name>	<Visibility>	   <Parameter>			 <Code>(L:ShowVC,bool) 0 ==</Code>	   </Parameter>	</Visibility>   </PartInfo>

Hmm, maybe it's similar in quirkiness to the if{ 1 } els{ 0 } - sometimes it works, sometimes it doesn't? I do have a LOT of code in there, so it's possible a hair was out of place someplace else, but I can't think of what else I might have done to "fix" it.Anyway, I've got my kid gloves on now and I'll see if there's enough room between the fingers to cross them while I'm at it:)

Share this post


Link to post
Share on other sites

Well, come to think of it, as I recall this will NOT work:<Code>(L:ShowVC,bool</Code>...but, this does:<Code>(L:ShowVC,bool) 0 ==</Code>


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...