• 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.

Reversing 'Drag-able' Mouse Levers

Messages
10,163
Country
us-arizona
Hey all,


I am trying to figure out what exactly controls the up/down order for a draggable mouse control on a lever.

This is the one I am working one. It is the stock 'part' Gmax code for the prop pitch lever control. It drags downwards 'first' and upwards second. On my lever, it animates in the opposite direction.

Code;

Code:
<part>
	<name>lever_prop_pitch</name>
	<animation>
		<parameter>
			<sim>
				<variable>GENERAL ENG PROPELLER LEVER POSITION:1</variable>
				<units>percent</units>
				<scale>-1.0</scale>
				<bias>100.0</bias>
			</sim>
		</parameter>
	</animation>
	<mouserect>
		<cursor>Hand</cursor>
		<help_id>HELPID_GAUGE_THROTTLE_PROP</help_id>
		<tooltip_id>TOOLTIPTEXT_THROTTLE_PROPELLER_PERCENT</tooltip_id>
		<mouse_flags>LeftSingle+LeftDrag+Wheel</mouse_flags>
		<callback_dragging>
			<variable>GENERAL ENG PROPELLER LEVER POSITION:1</variable>
			<units>percent</units>
			<scale>163.84</scale>
			<yscale>-163.84</yscale>
			<minvalue>0</minvalue>
			<maxvalue>16384</maxvalue>
			<event_id>PROP_PITCH1_SET</event_id>
		</callback_dragging>
	</mouserect>
</part>


Question one; what does 'Bias' stand for in this case;
<bias>100.0</bias>
Would this mean 'starting point' on the animation track?

///////////////////////////////////////////////////////

Question two; how does the scale functionality work?
<scale>163.84</scale>

///////////////////////////////////////////////////////

Question three; How would you reverse the mouse drag 'direction'? Would it be in flipping the 'scale' and 'y-scale' or the min/max value?

<scale>163.84</scale>
<yscale>-163.84</yscale>
<minvalue>0</minvalue>
<maxvalue>16384</maxvalue>


Question four; What does the 'scale' section in the top 'animation' section refer or command? Does this 'reverse' the animation or...?

<scale>-1.0</scale>



Many thanks,



Bill
 
Last edited:
Oh my. Again?

Please copy/paste this to the top of both makemdl.parts.xml and modeldef.xml files.

Notes on certain tags:

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

CALLBACK_JUMP_DRAGGING: Units are in pixels.

CALLBACK_DRAGGING: Converts simvar units to event units, which are the units of the internal variable.
scale: Scales from simvar units to event units
yscale: Scales movement delta in pixels to event units
minvalue: min event value in event units
maxvalue: max event value in event units

<Scale> is used to multiply the value of the sim variable to adjust it for keyframes

<Bias> is the amount of frames to offset the result of the simvar * scale.

Changing the sign of the <Scale> in the animation section will reverse the lever movement.
 
Awesome...

Thanks Bill.

Copy/pasting to MakeMDL and to my notes section.

EDIT: heh heh... its on the top of the Gmax MakeMDL parts sheet already, setting there, staring at me... argh.


Bill
 
Last edited:
I figured out how to get this reversed, for anyone that is curious about mouse dragging and doesnt have the faintest idea how it works.


In this particular script, one needs only to make the negative <yscale> into a positive in the mouse drag section.

In my case, this keeps the lever at the bottom as animated, bottom to top, from zero to 100 KF's.

Flipping the 'animation' section <scale> here from -1.0 to 1.0 flips travel opposite and the animation is reversed, making the lever to start at the top (KF-100) which in my case, I couldnt use.

Here is the new animation script;

Code:
<part>
	<name>lhc_prop_pitch</name>
	<animation>
		<parameter>
			<sim>
				<variable>GENERAL ENG PROPELLER LEVER POSITION:1</variable>
				<units>percent</units>
                                                                <scale>-1.0</scale>
				<bias>100.0</bias>
			</sim>
		</parameter>
	</animation>
	<mouserect>
		<cursor>Hand</cursor>
		<help_id>HELPID_GAUGE_THROTTLE_PROP</help_id>
		<tooltip_id>TOOLTIPTEXT_THROTTLE_PROPELLER_PERCENT</tooltip_id>
		<mouse_flags>LeftSingle+LeftDrag+Wheel</mouse_flags>
		<callback_dragging>
			<variable>GENERAL ENG PROPELLER LEVER POSITION:1</variable>
			<units>percent</units>
			<scale>163.84</scale>
			<yscale>163.84</yscale>  
			<minvalue>0</minvalue>
			<maxvalue>16384</maxvalue>
			<event_id>PROP_PITCH1_SET</event_id>
		</callback_dragging>
	</mouserect>
</part>

Again, note that <yscale> is changed from negative to positive. Regular <scale> is untouched. So, making <yscale> a negative must make it a 'drag downward', and a positive <yscale> will make it a 'drag upward'.

Positive <yscale>...............up
Negative <yscale>..............down
 
Last edited:
Well.. This gauge (Gmax part code for Throttle:1) completely blows this theory out of the water..

Sorry to 'drag' this on, (no pun intended). I want to learn how and why this works.


Throttle lever from the MakeMDL parts code, FS2004;


Code:
<part>
	<name>lever_throttle</name>
	<animation>
		<parameter>
			<code>
				(A:GENERAL ENG THROTTLE LEVER POSITION:1, part) s0 0 &gt;= if{ l0 -50 * 50 + } els{ l0 (A:THROTTLE LOWER LIMIT, part) / 1 

+ 50 * }
			</code>
		</parameter>
	</animation>
	<mouserect>
		<cursor>Hand</cursor>
		<help_id>HELPID_GAUGE_THROTTLE_THROTTLE</help_id>
		<tooltip_id>TOOLTIPTEXT_THROTTLE_THROTTLE_PERCENT</tooltip_id>
		<mouse_flags>LeftSingle+LeftDrag+Wheel</mouse_flags>
		<callback_dragging>
			<variable>GENERAL ENG THROTTLE LEVER POSITION:1</variable>
			<units>percent</units>
			<scale>163.84</scale>
			<yscale>-163.84</yscale>
			<minvalue>-16384</minvalue>
			<maxvalue>16384</maxvalue>
			<event_id>THROTTLE1_SET</event_id>
		</callback_dragging>
	</mouserect>
</part>


In this one, the <yscale> is 'negative' and yet the mouse drag is upward. There goes my theory on mouse dragging direction setting....


Bill
 
Not really, Bill. Please note that there is no <scale> entry for the part's animation, which is the same as saying <scale>1.0</scale>

So, positive animation <scale> + negative movement <yscale> :D
 
Back
Top