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

FSXA FSX XML issue

euroastar350

Resource contributor
Messages
863
Country
us-delaware
Hi guys,

I am in the process of finishing the FSX conversion of Owen Hewitt's Bell 206 to FSX native and one of the models is a TV news variant that has a movable camera. I have the original FS9 XML for the 3D objects. I have since converted it to FSX native XML in the modeldef file. Problem is that the code somewhat works, but the animations don't....I get a mouse hand to appear over the object. Here is the XML:


FS2004 code
Code:
<part>
    <name>camera_pan</name>
    <animation>
		<parameter>
			<code>(L:camera_panPos, percent)</code>
		</parameter>
    </animation>
    <mouserect>
        <cursor>Hand</cursor>
		<tooltip_text>Pan</tooltip_text>
		<mouse_flags>LeftSingle+LeftDrag+Wheel</mouse_flags>
		<callback_code>
			(M:Event) 'LeftSingle' scmp 0 !=
			if{
			  (L:camera_panX, position) s0 0 !=
			  if{
			    (L:camera_panPos, percent) (M:X) l0 &lt;
			    if{ 5 + 100 min } els{ l0 (M:X) &lt; if{ 5 - 0 max } }
			    (&gt;L:camera_panPos, percent)
			    }
			  }
			(M:X) (&gt;L:camera_panX, position)
		</callback_code>
	</mouserect>
</part>


FSX code
Code:
<PartInfo>
  <Name>Camera_Pan_01</Name>
  <Animation>
    <Parameter>
      <Code>(L:Camera_Pan, percent) 100 *</Code>
    </Parameter>
  </Animation>
  <MouseRect>
    <Cursor>Hand</Cursor>
    <TooltipText>Camera Pan</TooltipText>
    <MouseFlag>LeftSingle+LeftDrag+Wheel</MouseFlag>
    <CallbackCode>
          (M:Event) 'LeftSingle' scmp 0 !=
			if{
			  (L:camera_panX, position) s0 0 !=
			  if{
			    (L:camera_panPos, percent) (M:X) l0 &lt;
			    if{ 5 + 100 min } els{ l0 (M:X) &lt; if{ 5 - 0 max } }
			    (&gt;L:camera_panPos, percent)
			    }
			  }
			(M:X) (&gt;L:camera_panX, position)
    </CallbackCode>    
  </MouseRect>
</PartInfo>

Once I have a fully working code, I can wrap up the models and it's off to the painter for textures and then release. Any help is appreciated.

FS9 XML was done originally by Owen Hewitt.
 
Update...I can get a hand trying to drag (animate) the object, but it doesn't do anything. For this model, there camera controls which is mouse clickable/draggable and then there is the camera itself which is controlled in the VC by the 2 camera controls. I have the controls and camera tagged with the same FSX animation script I posted and it still doesn't do what I want. Any help is truly appreciated.
 
Hey George,

Where in the strings it has 'percent' and 'position', it appears you 'might' have 2 spaces instead of one space from the comma to the words percent and position.



Bill ohhh
 
Well I got the 2 camera controls working, problem is that the camera doen't move in full travel as it should, it only moves 5 degrees down when it should rotate 180 up/down and left/right. Any ideas? Here is the code for all 4 parts:


Camera controls
Code:
<PartInfo>
  <Name>Camera_Pan</Name>
  <AnimLength>100</AnimLength>
  <Animation>
    <Parameter>
	<Code>
	  (L:camera_panPos,number)
	</Code>
	<Lag>200</Lag>
    </Parameter>
  </Animation>
  <MouseRect>
    <Cursor>Hand</Cursor>
    <TooltipText>Camera Pan</TooltipText>
    <MouseFlags>LeftSingle+LeftDrag</MouseFlags>
    <CallbackCode>
	(M:Event) 'LeftSingle' scmp 0 !=
			if{
			  (L:camera_panX, number) s0 0 !=
			  if{
			    (L:camera_panPos, number) (M:X) l0 &lt;
			    if{ 5 + 100 min } els{ l0 (M:X) &lt; if{ 5 - 0 max } }
			    (&gt;L:camera_panPos, number)
			    }
			  }
			(M:X) (&gt;L:camera_panX, number)
    </CallbackCode>
  </MouseRect>
</PartInfo>>


<PartInfo>
  <Name>Camera_Tilt</Name>
  <AnimLength>100</AnimLength>
  <Animation>
    <Parameter>
	<Code>
	  (L:camera_tiltPos,number)
	</Code>
	<Lag>200</Lag>
    </Parameter>
  </Animation>
  <MouseRect>
    <Cursor>Hand</Cursor>
    <TooltipText>Camera Tilt</TooltipText>
    <MouseFlags>LeftSingle+LeftDrag</MouseFlags>
    <CallbackCode>
	(M:Event) 'LeftSingle' scmp 0 !=
			if{
			  (L:camera_tiltX, number) s0 0 !=
			  if{
			    (L:camera_tiltPos, number) (M:X) l0 &lt;
			    if{ 5 + 100 min } els{ l0 (M:X) &lt; if{ 5 - 0 max } }
			    (&gt;L:camera_tiltPos, number)
			    }
			  }
			(M:X) (&gt;L:camera_tiltX, number)
    </CallbackCode>
  </MouseRect>
</PartInfo>

Camera
Code:
<PartInfo>
    <Name>Camera_Tilt_01</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (L:Camera_Tilt_01, number) 100 *
        </Code>
      </Parameter>
    </Animation>
     </PartInfo>

<PartInfo>
    <Name>Camera_Pan_01</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (L:Camera_Pan_01, number) 100 *
        </Code>
      </Parameter>
    </Animation>
     </PartInfo>
 
Last edited:
Anyone? I really want to wrap up this model and move on to the next one, but I can't do it if I can't get an animation working like it should:(
 
Well, looking at the code, it looks like you are using the variable (L:camera_panPos,number) for the actual controls, and (L:Camera_Tilt_01, number) for the camera. Is this difference intentional, or are they meant to be the same variable?
 
Well, looking at the code, it looks like you are using the variable (L:camera_panPos,number) for the actual controls, and (L:Camera_Tilt_01, number) for the camera. Is this difference intentional, or are they meant to be the same variable?

I updated that code to have the same variable and works to some degree. Still only moves 5 degrees down.
 
M:X returns the horizontal value for the mouse. M:Y returns the vertical and it what you need for tilt

Roy
 
I have M:Y set already for tilt and still doesn't do anything for me:confused:

Code:
<PartInfo>
  <Name>Camera_Pan</Name>
  <AnimLength>100</AnimLength>
  <Animation>
    <Parameter>
	<Code>
	  (L:camera_pan,number)
	</Code>
	<Lag>40</Lag>
    </Parameter>
  </Animation>
  <MouseRect>
    <Cursor>Hand</Cursor>
    <TooltipText>Camera Pan</TooltipText>
    <MouseFlags>LeftSingle+LeftDrag</MouseFlags>
    <CallbackCode>
	(M:Event) 'LeftSingle' scmp 0 !=
			if{
			  (L:camera_pan_01, number) s0 0 !=
			  if{
			    (L:camera_pan_01, number) (M:X) l0 &lt;
			    if{ 5 + 100 min } els{ l0 (M:X) &lt; if{ 5 - 0 max } }
			    (&gt;L:camera_pan_01, number)
			    }
			  }
			(M:X) (&gt;L:camera_pan_01, number)
    </CallbackCode>
  </MouseRect>
</PartInfo>>


<PartInfo>
  <Name>Camera_Tilt</Name>
  <AnimLength>100</AnimLength>
  <Animation>
    <Parameter>
	<Code>
	  (L:camera_tilt,number)
	</Code>
	<Lag>40</Lag>
    </Parameter>
  </Animation>
  <MouseRect>
    <Cursor>Hand</Cursor>
    <TooltipText>Camera Tilt</TooltipText>
    <MouseFlags>LeftSingle+LeftDrag</MouseFlags>
    <CallbackCode>
	(M:Event) 'LeftSingle' scmp 0 !=
			if{
			  (L:camera_tilt_01, number) s0 0 !=
			  if{
			    (L:camera_tilt_01, number) (M:Y) l0 &lt;
			    if{ 5 + 100 min } els{ l0 (M:Y) &lt; if{ 5 - 0 max } }
			    (&gt;L:camera_tilt_01, number)
			    }
			  }
			(M:Y) (&gt;L:camera_tilt_01, number)
    </CallbackCode>
  </MouseRect>
</PartInfo>
 
Last edited:
Using different units on L variables makes no difference - they are all stored as FLOAT64, no matter what you specify the unit as.

It's good practice to specify the unit you are using, though, because it makes the code easier to read and debug.
 
I think your min and max statements can only return 5, not sure about FS9 code but for FSX you appear to be asking for the min of 5 and 100 or the max of 5 and 0. Not sure how it's interpreting the +/- sign but I'm fairly sure it's not applying it to the preceding variable.
On my tablet so I can't add some working code but I think something along the lines of
variable 5 + 100 min
and
variable 5 - 0 max
will do what you want.
 
I think your min and max statements can only return 5, not sure about FS9 code but for FSX you appear to be asking for the min of 5 and 100 or the max of 5 and 0. Not sure how it's interpreting the +/- sign but I'm fairly sure it's not applying it to the preceding variable.
On my tablet so I can't add some working code but I think something along the lines of
variable 5 + 100 min
and
variable 5 - 0 max
will do what you want.


Unfortunately, I had those same values and it would work somewhat, but animate the camera turret through it's full animation range. I am still stuck on this and have no way to get them to work correctly for FSX:confused:
 
You seem to have subtly changed the code from the FS9 variety - have a look at the FS9 code and you will see in the Mouse Callbacks there are two confusingly similar but different variables being named, whereas in the FSX code only the same variable is used throughout. Perhaps this has something to do with it?
 
I was trying out different codes to see what would work the best. I have since reverted back to the original code as posted in my first topic. Still trying to figure out the solution on how to make it work flawlessy, but still no joy:confused:
 
If we look at the Camera Pan situation from a systems point of view, we are trying to move the camera left or right from its current position according to the difference between the newly clicked position and the previous one, which put the camera where it currently is in azimuth, as a result of the previous click. This means we need to compare the azimuth of the new click with that of the previous click and move it in increments of 5 to the left or right within bounds of 0 and 100.

Exact same principle applies to Tilt.

The key then is the callback code.

1. (M:Event) 'LeftSingle' scmp 0 !=, the mouse click is valid.
2. If so, store the previous click value (L:camera_panX, position) in register 0 (s0) for later use.
3. Test (L:camera_panX, position) to see if it is not zero "0 !=". If it is zero, (test fails) then just update (L:camera_panX, position) with the current mouse position, no change required. (M:X) (&gt;L:camera_panX, position)
4. If (L:camera_panX, position) is not zero see if it is less than or greater than the new (M:X). Test for less by (M:X) l0 &lt; . l0 being the value for (L:camera_panX, position) stored in S0 earlier. If (L:camera_panX, position) is less than the new mouse position (M:X) then the camera needs to be moved right (incremented) by 5.but not to more than 100 if{ 5 + 100 min } So the output is (&gt;L:camera_panPos, percent) and the camera is moved right.
5. If the first test M:X) l0 &lt fails then the els test reverses the values so it tests for l0 (M:X) &lt and if that is true then the value passed (&gt;L:camera_panPos, percent) is 5 less but not less than 0. The output is again (&gt;L:camera_panPos, percent), but the camera is moved left.

Systems wise the logic is clear and just needs to be implemented in XML

Roy
 
Last edited:
Roy,

I've tried everything, including different units.....but nothing works at all. I get somewhat movement, but nothing more. I may just give up and release this helicopter with a static camera which I don't want to do:confused:
 
Back
Top