• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

P3D v2 Is this correctly written? ModelDef Animation Code

Messages
10,163
Country
us-arizona
Hey all,

Can you check this for me. Is this correct? Particularly the CallbackCode section. Is it all in order?


Code:
    <PartInfo>
        <Name>learjet24_switch_audio_com2</Name>
        <AnimLength>50</AnimLength>
        <Animation>
            <Parameter>
                <Sim>
                    <Variable>COM TRANSMIT:2</Variable>
                    <Units>bool</Units>
                    <Scale>50</Scale>
                </Sim>
                <Lag>900</Lag>
            </Parameter>
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
            <HelpID>HELPID_RADIO_AUDIO</HelpID>
            <TooltipID>TOOLTIPTEXT_COM2_AUDIO_SELECTOR</TooltipID>
      <CallbackCode>
                (>K:COM2_TRANSMIT_SELECT)
              1 (&gt;L:XMLSND12,enum)
      </CallbackCode>
        </MouseRect>
    </PartInfo>
 
I had changed it to enter in a clicksound. It was a stock audio panel code. 'switch_audio_com2'
 
it's a guess, but don't you need a 1 in front of the to actually get com2 to be selected?

1 (>K:COM2_TRANSMIT_SELECT)
 
it's a guess, but don't you need a 1 in front of the to actually get com2 to be selected?

1 (>K:COM2_TRANSMIT_SELECT)
No, for the most part only commands ending with _SET require an input value.

Bill, there is absolutely nothing wrong with your script.
 
Thanks,

Could help me understand what is happening with animations and modeldef. SDK docs suck.

I assume Bill has also added an animation name with new guid and type etc. and hence an animation tag.

The model has an attachpoint that is the mouse rectangle and it has a name.

How are the two linked?

After that magical linking.

Then the user clicks on the mouse rectangle - the animation runs the Sim variable is set in this case (<Sim>) Com Transmit:2 is True(1) scaled to 50 then what - sent to the call back code where 50 is put in the K:COM2_TRANSMIT_SELECT but that a bool - so that can't be right. :banghead:
 
Thanks guys.

Hey Ron, yes, they have a GUID section that goes on the top of the ModelDef sheet. Basically all the top GUID section has is the GUID number, like a serial number. Its the most stupidest thing I have ever seen, because the animation frames that are up there are also below in the script blocks section; name, frames. The GUID, if it is really really really needed, could have just been placed in each script block, but no.... Makes no sense.

Having just the (>K:do this thing.....) causes it to 'fire' like a toggle command. With the SND commands, they have 3 specific inputs as its a defined sound system, so in this case, it required a 1 to work the way I needed it.

The only thing was that I had changed it slightly radically, adapting it so that I could use the sound in there also, a click sound effect for the switch. Here is the original.

Code:
    <PartInfo>
        <Name>switch_audio_com2</Name>
        <AnimLength>50</AnimLength>
        <Animation>
            <Parameter>
                <Sim>
                    <Variable>COM TRANSMIT:2</Variable>
                    <Units>bool</Units>
                    <Scale>50</Scale>
                </Sim>
                <Lag>400</Lag>
            </Parameter>
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
            <HelpID>HELPID_RADIO_AUDIO</HelpID>
            <TooltipID>TOOLTIPTEXT_COM2_AUDIO_SELECTOR</TooltipID>
            <EventID>COM2_TRANSMIT_SELECT</EventID>
        </MouseRect>
    </PartInfo>


It was previously just an EventID. I wanted to make sure I had adapted it properly. Its these adapted switches that are not working right, along with 3 that are custom basic L:vars.
 
Having examined the .max file forensically, I have determined that the underling issue is that the switch and knob objects were scaled down in size, but never had the Reset XForm applied, hence the failure of the <MouseRect> to be active!

Code:
(Sphere046): X:2.10989 Y:2.10989 Z:2.10989
 
instead of
 
(Sphere046): X:100.0 Y:100.0 Z:100.0

As for this:
Code:
  <Sim>
         <Variable>COM TRANSMIT:2</Variable>
         <Units>bool</Units>
         <Scale>50</Scale>
  </Sim>
it applies the <Scale> of 50 to the Boolean return, thus making the animation either 0 or 50 frames.

It is precisely the same as writing it this way, which frankly is much easier on the eyes... :p
Code:
<Code>
     (A:COM TRANSMIT:2,bool) 50 *
</Code>
 
Having examined the .max file forensically, I have determined that the underling issue is that the switch and knob objects were scaled down in size, but never had the Reset XForm applied, hence the failure of the <MouseRect> to be active!

Code:
(Sphere046): X:2.10989 Y:2.10989 Z:2.10989

instead of

(Sphere046): X:100.0 Y:100.0 Z:100.0

A thousand thanks Bill for finding that issue.

The only thing I can think of is that when selecting switches, I had for just a millisecond, held down and accidentally moved the mouse with left click engaged while Scale tool was in select mode causing a super small 'scale' to occur. I never even realized it. It was so small and quick, it went un-noticed and the side effects seemed like something much bigger at fault. sigh.... Mountains from mole hills.
 
Small? 2.10989 is a pretty big change from 100... 97.something in fact. :laughing:
 
That's odd because I never scaled them (intentionally) in months, and they only stopped working about 3 weeks ago. They are the same size (visually, it appears) so I can only think I accidentally changed it by a smidgeon.

So good to have them working again. Man.... That is a load off my shoulders.
 
In the future, any time a <MouseRect> doesn't seem to work, select the part in the GMax/Max scene, then open the DopeSheet, and expand the Scale properties. Scale should always be = X:100.0 Y:100.0 Z:100.0
 
Back
Top