Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
  YaBB is sponsored by XIMinc!

FFDS Home | TIPS Section | Tutorials Section | Resources Section | Utilities Section

Military | FSDS | Jetliners | Real Planes Section | Gmax | Rotorcraft | Business | Civilian

  HomeHelpSearchLoginRegister  
 
 
Page Index Toggle Pages: 1
Send Topic Print
XML 3 Position Springloaded Switch - Complete (Read 1799 times)
14th Feb, 2011 at 11:24pm

Fr. Bill   Offline
YaBB Moderator
I used to have a life:
now I have GMax...
Hammond, IN

Gender: male
Posts: 5426
*****
 
This mini-tutorial is for FSX XML 3d Animated Switches.

It's not really that difficult to develop XML scripts.  Here then is the process I use to define the task:

1)
I need a unique name for this switch...

<Name>FlapSwitchSpringloaded</Name> will do nicely...

2)
I need a custom (L:var,unit) variable... (L:FlapSwitchSpringloaded,enum) will work...

3)
I will use a keyframe animation from 0-100 in the model for the switch, with 50 being the center position.

4)
All (L:var,unit) variables are initialized to zero on panel load, so I need to script the math around that fact. I can have the (L:var,unit) return values of -1, 0, 1 but I will need values of 0, 50, 100 for the 3d animation.

Down:      (-1 * 50) + 50 = 0
Center:     (0 * 50) + 50 = 50
Up:         (1 * 50) + 50 = 100

<Code>50 (L:FlapSwitchSpringloaded,enum) 50 * +</Code> will work nicely...

5)
I don't want the switch to "snap" instantly, so I'll add some delay...

<Lag>100</Lag> will accomplish that goal. I can change the delay value as needed to fine-tune if needed.

6)
To summarize the first five steps, here is the script so far:

Code:
<PartInfo>
      <Name>FlapSwitchSpringloaded</Name>
	<AnimLength>100</AnimLength>
      <Animation>
         <Parameter>
         <Code>50 (L:FlapSwitchSpringloaded,enum) 50 * +</Code>
            <Lag>100</Lag>
         </Parameter>
      </Animation>

</PartInfo>
 




7)
Next I will need to develop the mouse script.

a.
I will need to have the (L:var,unit) variable only change value whenever the mouse button(s) are held down, but revert to a value of zero when released.

b.
There can only be one mouse area in a 3d script, so I must use left and right mouse buttons for up and down control.

c.
I need a custom tooltip to remind the user which button is which, and display a "hand" cursor!

Code:
    <MouseRect>
         <Cursor>Hand</Cursor>
         <TooltipText>Left-Up/Right-Down</TooltipText>
         <MouseFlags>LeftSingle+LeftRelease+RightSingle+RightRelease</MouseFlags>
         <CallbackCode>

         </CallbackCode>
    </MouseRect>
 



8.
I need to use the (M:Event) function in the mouse script to detect which button is clicked and whether it is up or down, and then declare what happens during each condition.

(M:Event) 'EventTag' scmp 0 == if{  } is the prototype for this schema, so:

Code:
         <CallbackCode>
                  (M:Event) 'LeftSingle' scmp 0 == 
                        if{ 1 (>L:FlapSwitchSpringloaded, enum) (>K:FLAPS_DECR) }

                  (M:Event) 'Leftrelease' scmp 0 == 
                        if{ 0 (>L:FlapSwitchSpringloaded, enum) }

                  (M:Event) 'RightSingle' scmp 0 == 
                        if{ -1 (>L:FlapSwitchSpringloaded, enum) (>K:FLAPS_INCR) }

                  (M:Event) 'RightRelease' scmp 0 == 
                        if{ 0 (>L:FlapSwitchSpringloaded, enum) }
         </CallbackCode>
 



8.
I will need a custom <Animation>....guid....</Animation> for this entire script...

<Animation name="FlapSwitchSpringloaded" guid="54998399-dff8-679c-a659-ab9ef33f4f14" length="100" type="Sim"  typeParam="AutoPlay" />

« Last Edit: 15th Feb, 2011 at 4:00pm by Felix/FFDS »  

Fr. Bill
Gauge Programming - 3d Modeling Eaglesoft Development Group Intel Core 2 Quad Q6600-4 GB DDRII Crucial PC6400-500 GB SATA-ATI Radeon HD2400 Pro 256MB
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print