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
aileron trim 3-way switch (Read 2403 times)
30th May, 2005 at 7:20am

Willem   Offline
LDV Engineer
Gmax... can't live with
it, can't live without
it.
Netherlands

Posts: 266
****
 
Hi,
i asked this question a while ago, but never received any response. Hopefully someone can help me this time around (again  Grin)

I'm looking for a switch to control aileron trim. Actually it is exactly the same thing as it is in the default Lear VC for the rudder trim. Too bad this thing is a gauge and not a 3d object...  Sad

What i need is a switch that stays in the left or right position as long as it is clicked and returns to the center position when the click is released.
While it is in left or right position it operates the aileron trim actuator accordingly.

I now have a click and drag setup (the switch stays in position) but i'm not happy with it because it is not realistic. The tag i use now is rocker_aileron_trim unmodified.

Any help is greatly appreciated as ever!!!!  Wink

grtz
Willem.

 

Multimedia File Viewing and Clickable Links are available for Registered Members only!!  You need to Login or Register
IP Logged
 
Reply #1 - 30th May, 2005 at 10:54am

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

Gender: male
Posts: 5426
*****
 
What you want would involve using the M:Event code syntax.  This means that you specify a specific action to occur during the "mouse down" event, and another specific action to occur during the "mouse release" event.  Note that this exact same structure may be used either in an XML gauge or as part of a code segment in the makemdl.parts.xml file!  8)

There are several instances of this buried among the examples provided in the default makemdl.parts.xml file.

Without writing the actual code for you though, here is (perhaps) a clearer example of the usage and syntax.  First, note that there are two items required: a <mouse_flags> list, where you declare each mouse event type you are going to describe, and then the <callback_code> section where you describe what action will be done for each of the mouse events:

<mouse_flags>LeftSingle+LeftRelease</mouse_flags>

<callback_code>
           
(M:Event) 'LeftSingle' scmp 0 !=
    if{  (do something)  }          
           
(M:Event) 'LeftRelease' scmp 0 ==
    if{ (do something else) }

</callback_code>

Each (M:Event) has two possible outcomes, and the variable "scmp" provides a way to determine which is active.

It should be obvious that through use of this structure, you could actually define up to eight separate "things to be done" in any single <mouse_rect>: one for each button (remember, the "wheel" may also be clicked up/down!), plus whatever you want to happen if the "wheel" is rotated!  Grin

I hope this will help!  Cheesy
 

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
 
Reply #2 - 30th May, 2005 at 7:11pm

Willem   Offline
LDV Engineer
Gmax... can't live with
it, can't live without
it.
Netherlands

Posts: 266
****
 
Wow!!

going a little bit over my head here  Wink
But you gave me a good starting point.
Thank you for not giving me a complete solution here...  Grin
I always like to fiddle around and sometimes need some directions.

I will dig into this!!!

Thanks.
grtz
Willem.
 

Multimedia File Viewing and Clickable Links are available for Registered Members only!!  You need to Login or Register
IP Logged
 
Reply #3 - 31st May, 2005 at 12:23am

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

Gender: male
Posts: 5426
*****
 
Well, if you get lost don't hesitate to ask for directions.

It would be real easy to simply provide a working code segment, but that's really not a good way to learn... Wink
 

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
 
Reply #4 - 31st May, 2005 at 10:32am

Paco Sanchez   Offline
Inspecteur des Polygonnes
I want axis-driven animations
back NOW!!!
Vigo, Spain

Gender: male
Posts: 1686
*****
 
Willem, if you're planing to include a VC in your project, and add this switch as a xml part, be careful! xml language seems to differ from gauges to parts. The use of (M:event) seems to be one of the differences, at least when using L: variables.

I'd suggest that youfirst make the try to implement the switch as xml part, and if it works, then use the same code on the xml gauge and see if it works.

Paco
 

Paco.&&Multimedia File Viewing and Clickable Links are available for Registered Members only!!  You need to Login or Register
IP Logged
 
Reply #5 - 31st May, 2005 at 5:06pm

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

Gender: male
Posts: 5426
*****
 
This is the same schema in "Gauge XML."  As you can see, there isn't much difference at all:

<Click Kind="LeftSingle+Leave">

(M:Event) 'LeftSingle' scmp 0 ==
if{ 1 (>L:StarterToggled,bool) (>K:TOGGLE_STARTER1) }

(M:Event) 'Leave' scmp 0 == if{ 0 (>L:StarterToggled,bool) }
</Click>

The "Leave" works exactly the same as "LeftRelease."  In fact, you can use either one of them interchangably... Wink
 

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
 
Reply #6 - 1st Jun, 2005 at 7:58am

Paco Sanchez   Offline
Inspecteur des Polygonnes
I want axis-driven animations
back NOW!!!
Vigo, Spain

Gender: male
Posts: 1686
*****
 
In most cases there will be no difference as you say, but in some cases, when you include some additional logics in the xml gauge, the results can be frustrating:

For example, you know that FS provides 4 variables for fuel pump switches, each one can take status 0 or 1 (on or off). But the Connie has 9 fuel pump switches instead, 5 of them have high-off-low position, and 4 have on-off position.

The easiest case, pump 1a and 4a: I programmed the gauges so that an L: variable would take values -1, 0, 1 for high, off, low positions, when in high or low position (value 1 or -1), the FS pump would be on, and when in off position, the FS pump would switch off. When starting the sim with the FS pump on, the switch defaults to high position. An upper clickable area makes the cycle low > off > high, a lower clickable area cycles high > off > low.

Quite simple, and works flawlessly in the 2d panel; but when I ported the code to the parts.xml and made the animated part, the behaivour was quite strange: when clicking the upper area, the switch clycles as expected : from low to off, then from off to high. But the lower clickable area makes the switch go from high to off (correct) and if clicked again, the switch will randomly go either to high or to low position. In fact, most of the time it goes to high instead of low, and only 10% of the times it will go to the low (correct) position.

The most funny thing is that, if I display the 2d panel at the same time as the VC, clicking on the 2D sitch will correctly animate the 2D switch and still the 3D switch will move randomly as explained. Clicking on the 3d switch does the same: the 2d switch moves OK, the 3d switch doesn't.

I re-did the code for both the gauge and the xml part several times starting from scratch, and tried different solutions, by using if statements, select-case statements... all with the same exact result.

Then I started to think that there might be some flaw in the FS animation engine, and I got this hypotesis confirmed when I tried to make a slow propeller animation: Whenever there is any logical or mathematical operation involving more than one variable (in a xml gauge or even in the xml parts itself), the animation goes crazy: Try to animate one part to rotate using (E: ZULU TIME, second). The part smoothly rotates at 1 revolution per second (or was it per minute?  ???). Try then to animate using (E: ZULU TIME, second) (A: PROP RPM:1, rpm) * k / , where k is a number of your choice. The result with k= 100 should be a part which smoothly rotates at 1 rpm when the propeller rotates at 100...  but when compiling the model, the part will start an erratic movement, regardless the value of k chosen, and regardless the actual rpm.

Weird...
Paco
 

Paco.&&Multimedia File Viewing and Clickable Links are available for Registered Members only!!  You need to Login or Register
IP Logged
 
Reply #7 - 1st Jun, 2005 at 8:41am

Willem   Offline
LDV Engineer
Gmax... can't live with
it, can't live without
it.
Netherlands

Posts: 266
****
 
I think i need some more guidance here guys!!
I have been trying for two days straight and am getting somewhere in that i now understand a little bit of how XML must be read and used.
I even managed to make a box appear and disappear in relation to the landing gear extension percentage and the nav light state.  Grin

But that's where it ends i'm afraid.
I have been looking into the switch_ignition_magnetos_dc3 in XMLparts and understand the first bit where the left,right,both or off pieces are, but what does this exactly do in the sim?
My guess is that it's related to the animating keyframes in gmax.
But any further into the code i get lost just a teeny bit  Grin

I'm getting desperate here..  Wink

BTW i have analyzed all the xml segments on the XML page (and quite understand most of them) and have the SDK and XMLgau01 at hand as well.

grtz
Willem
 

Multimedia File Viewing and Clickable Links are available for Registered Members only!!  You need to Login or Register
IP Logged
 
Reply #8 - 1st Jun, 2005 at 11:20am

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

Gender: male
Posts: 5426
*****
 
OK, we were discussing "mouse stuff," but now you are wanting to know about "animation."  Fair enough, as animation is an interesting topic...  Grin

Here is an important concept/formula to keep in mind:

SIM: Converts simvar to keyframes: simvar * scale + bias = keyframes

Let's examine one of the easiest animations possible, that of a simple switch that uses a custom L:var for control:

<animation>
  <parameter>
      <code>
          (L:BatteryOne,bool) 100 *
      </code>
  </parameter>
</animation>

In this case, we need to take the bool value of the L:var and apply a 100 multiplier because we wish to generate 100 animation keyframes.  By adding a single additional line, we can control the "speed" of the animation:

      </code>
      <lag>320</lag>
  </parameter>

The relative value of the <lag> sets the speed: 320 would be very slow, 40 would be quick, but not yet an instant "snap."

The second case to look at would be if we are going to use a "stock FS variable" to control animation.  This is a bit more complex, because we need to convert the variable's output so that it will relate to a discrete number of keyframes.  Take careful note of the change in syntax construction!

<animation>
   <parameter>
       <sim>
          <variable>GENERAL ENG MASTER ALTERNATOR:1</variable>
          <units>bool</units>
          <scale>50</scale>
       </sim>
       <lag>400</lag>
    </parameter>
</animation>

In this case, we are using the bool variable GENERAL ENG MASTER ALTERNATOR:1, so we are going to use the <sim> construct to convert the bool to keyframes.  We use a <scale> of 50 to subdivide the available keyframes into two segments: 0-50 and 50-100 (assuming that we are using 100 keyframes, of course!).

For this case, since the sim variable is boolean, it would make no logical sense to provide three or more possible positions, so the <scale> will always be 50... Wink

As before, the <lag> parameter simply sets the speed of the animation.

Yet a third type of animation is one based on a sim variable, but this time one that uses "percent" for an output.  Since percent is always 0 - 100, this is once again an easy one to code!

<animation>
   <parameter>
      <sim>
         <variable>TURB ENG REVERSE NOZZLE PERCENT:1</variable>
         <units>percent</units>
      </sim>
      <lag>100</lag>
   </parameter>
   <minvalue>1</minvalue>
</animation>

In this example, we've introduced a new command, namely <minvalue>.  The purpose of this is to prevent the part from moving unless the variable is at least 1 percent or greater.  This will prevent "spikes" in the variable (caused mostly by joystick or yoke control noise) from causing the part (in this case thrust reverser buckets) from "trembling" while supposedly closed and locked!

There are at least twenty more examples I can think of off the top of my head, but by now you should see a "pattern" developing.  Hopefully, you will be able to use this to evaluate the examples in the makemdl.parts.xml file with "new eyes," and with greater understanding... Wink

As always, if you get stuck and have a specific case you need help with, just ask!
 

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
 
Reply #9 - 1st Jun, 2005 at 11:48am

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

Gender: male
Posts: 5426
*****
 
Quote:
I have been looking into the switch_ignition_magnetos_dc3 in XMLparts and understand the first bit where the left,right,both or off pieces are, but what does this exactly do in the sim?
My guess is that it's related to the animating keyframes in gmax.


Remember this?

"SIM: Converts simvar to keyframes: simvar * scale + bias = keyframes"

<animation>
    <parameter>
      <!-- 0 = Off, 25 = Left, 50 = Right, 75 = Both -->
      <code>(A:Recip eng right magneto:1,bool) 2 * (A:Recip eng left magneto:1,bool) + 25 *</code>
      <lag>200</lag>
    </parameter>
</animation>

In this case, we want to create 100 keyframes, and sub-divide them into four discrete positions.  What makes it a bit more complex is that we are combining the output of TWO different variables in the process.  Don't be confused by the "left" and "right" parts of the variables.  Both are still connected to ENG1... Wink

The "trick" is being able to evaluate the RPN math expression...  In "shorthand pseudo code" we get this:

( (LeftEng1,bool * 2) + (RightEng1,bool) ) * 25

There are four possible outcomes:

( (0 * 2) + (0) ) * 25 = 0
( (0 * 2) + (1) ) * 25 = 25
( (1 * 2) + (0) ) * 25 = 50
( (1 * 2) + (1) ) * 25 = 75
 

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
 
Reply #10 - 2nd Jun, 2005 at 6:40am

Paco Sanchez   Offline
Inspecteur des Polygonnes
I want axis-driven animations
back NOW!!!
Vigo, Spain

Gender: male
Posts: 1686
*****
 
Fastantic good explanation! I wish I'd had it some months ago...  Smiley I think this deserves a place in the tips or tutorials section.
 

Paco.&&Multimedia File Viewing and Clickable Links are available for Registered Members only!!  You need to Login or Register
IP Logged
 
Reply #11 - 2nd Jun, 2005 at 11:22am

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

Gender: male
Posts: 5426
*****
 
Quote:
Fastantic good explanation! I wish I'd had it some months ago...  Smiley I think this deserves a place in the tips or tutorials section.


Thanks... Actually, writing these helps me to clarify some of the issues in my own mind as well, so they are actually quite helpful for me as much as anyone else... Wink
 

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