• 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

The problem seems to be that the range of movement is only the +/- 5 degrees in the code. The pan and tilt positions are not being updated

To check it out I made a small gauge and got it to move a box representing camera position to the mouse position in 5 degree steps. When it gets there it stays there until the mouse is moved to another position.
It also has Tilt and Pan readouts.
Here is the code:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Gauge Name="CameraLogic">
	<Image Name="TurretInput.bmp" Bright="Yes"/>
	<Element>
		<Select>
			<Value>(L:init_TiltPan,bool) 0 == if{ 50 (&gt;L:camera_TiltPos, number) 50 (&gt;L:camera_PanPos, number) (L:init_TiltPan,bool) ! (&gt;L:init_TiltPan,bool)</Value>
		</Select>
	</Element>
	<Element>
		<Position X="10" Y="10"/>
		<Text X="90" Y="15" Bright="Yes" Length="9" Font="Arial" Color="#FFFFFF" Adjust="Center" VerticalAdjust="Center" Multiline="No">
			<String>Tilt %((L:camera_TiltPos, number))%!3d!</String>
		</Text>
	</Element>
	<Element>
		<Position X="10" Y="25"/>
		<Text X="90" Y="15" Bright="Yes" Length="11" Font="Arial" Color="#FFFFFF" Adjust="Center" VerticalAdjust="Center" Multiline="No">
			<String>Pan %((L:camera_panPos, number))%!3d!</String>
		</Text>
	</Element>
	<Element>
		<Position X="10" Y="10"/>
		<Polyline Color="White" LineWidth="2">
			<Point X="-5" Y="5"/>
			<Point X="5" Y="5"/>
			<Point X="5" Y="-5"/>
			<Point X="-5" Y="-5"/>
			<Point X="-5" Y="5"/>
		</Polyline>
		<Shift>
			<Value>(L:camera_TiltPos, number)</Value>
			<Scale X="0" Y="1"/>
		</Shift>
		<Shift>
			<Value>(L:camera_PanPos, number)</Value>
			<Scale X="1" Y="0"/>
		</Shift>
	</Element>
	<Mouse>
		<Area Left="10" Top="10" Width="100" Height="100">
			<Tooltip>Camera Pan/Tilt</Tooltip>
			<Cursor Type="Hand"/>
			<Click>
			 (L:camera_panPos, number) (M:X) &lt; if{ 5 + } els{ 5 - }  (&gt;L:camera_pandelta, number) (L:camera_pandelta, number)  (L:camera_panPos, number) + (&gt;L:camera_panPos, number) 
			(L:camera_TiltPos, number) (M:Y) &lt; if{ 5 + } els{ 5 - }  (&gt;L:camera_tiltdelta, number) (L:camera_tiltdelta, number)  (L:camera_TiltPos, number) + (&gt;L:camera_TiltPos, number)  
			
    </Click>
		</Area>
	</Mouse>
</Gauge>

At the top is an init section that sets the Tilt and Pan position in the center of the 120 by 120 image (Image is attached)
Then you have the numeric readouts and polyline box.

The mouse code compares the current pan value (L:camera_panPos, number)to where the mouse is (M:X) and if the pan value is less it stores 5 in "pandelta", els it stores -5 . The current pan value is added to pandelta and used to update (L:camera_panPos, number).

The tilt logic is the same.

Not tried it in modeldef, but it should help

Roy
 
Hey Roy,

I haven't read everything but one thing caught my eye:

Code:
(L:camera_panPos, number) (M:X) &lt; if{ 5 + } els{ 5 - }  (&gt;L:camera_pandelta, number)

here is what happens:
1. L:camera_panPos is loaded to the stack
2. M:X is loaded to the stack
3. the two stack variables are beeing compared and DROPPED from the stack, if the L: variable is smaller than M:X, "1" is put in the stack, otherwise "0".
4. if "1" is in the stack, 5 is loaded to the stack
5. and added to..... well nothing, because the stack is empty ;)
...

You see the problem?
 
Roy,

I tried your gauge and works, but the camera still moves at 5 degrees down and doesn't move after that. I will keep experimenting to see what else I can do.
 
Hey Vitus,
You are right, though the code works. If I change it to if{ 5 } els{ -5 } which looks better, it does not change the result, still increments or decrements by 5. Perhaps nothing plus 5 is 5 and nothing minus 5 is -5?

This works and looks tidier
Code:
(L:camera_panPos, number) s0 (M:X) &lt; if{ 5 } els{ -5 } l0 + (&gt;L:camera_panPos, number)

Thanks
Roy
 
Last edited:
Nice! Another option would be to use the double-operator, which copies the last entry of the stack:
Code:
(L:camera_panPos, number) [B]d[/B] (M:X) &lt; if{ 5 } els{ -5 } + (&gt;L:camera_panPos, number)

That way you don't have to keep track of the register. :twocents:
 
My problem is working out what is at the top of the stack, so I try to keep it simple even if it results in 4 characters longer code!

Seriously though, I'd appreciate any pointers/tutorials/tips on keeping track of the "top of the stack" situation.

Roy
 
A little help!

Here is what your trying to do...... I download that TV news chopper and tested the camera.


I made you a gmax file so you can use it as a reference.....
http://www.flysim.us/help/camera.gmax

Make sure to see how i assigned the animation keys for the turret to go up and down.
This method keeps the animation alive and will rotate backwards as you continue to turn the knob 1 direction.
You can tweak the code adding a bias to have the turret stop at each direction. I prefer the method i used.

camera.png


Code:
<!--                      Camera & Controls                         -->


<Animation name="camera_knobLftRht" guid="ed1d0169-ea79-41f8-af15-dd70b3784d76" length="100" type="Sim" typeParam2="camera_knobLftRht" typeParam="AutoPlay" />
<Animation name="camera_knobUpDwn" guid="c41add38-c711-47e5-89c4-6ea27b6612b5" length="100" type="Sim" typeParam2="camera_knobUpDwn" typeParam="AutoPlay" />

Code:
<!--                      Camera & Controls                         -->


<PartInfo>
  <Name>camera_knobLftRht</Name>
	<AnimLength>100</AnimLength>
  <Animation>
    <Parameter>
      <Code>(L:camera1, percent)</Code>
    </Parameter>
  </Animation>
  <MouseRect>
    <Cursor>Hand</Cursor>
    <TooltipText>Camera Left Right</TooltipText>
      <MouseFlags>LeftSingle+RightSingle+WheelUp+WheelDown+DownRepeat</MouseFlags>
    <CallbackCode>
      (M:Event) 'LeftSingle' scmp 0 ==
      if{ (L:camera1, percent) -- 0 max (>L:camera1, percent) }
      (L:camera1, percent) 100 == if{ 0 (>L:camera1, percent) }

      (M:Event) 'RightSingle' scmp 0 ==
      if{ (L:camera1, percent) ++  100 min (>L:camera1, percent) }
      (L:camera1, percent) 0 == if{ 100 (>L:camera1, percent) }

      (M:Event) 'WheelDown' scmp 0 ==
      if{ (L:camera1, percent) -- 0 max (>L:camera1, percent) }
      (L:camera1, percent) 100 == if{ 0 (>L:camera1, percent) }

      (M:Event) 'WheelUp' scmp 0 ==
      if{ (L:camera1, percent) ++  100 min (>L:camera1, percent) }
      (L:camera1, percent) 0 == if{ 100 (>L:camera1, percent) }
    </CallbackCode>    
  </MouseRect>
</PartInfo>


<PartInfo>
  <Name>camera_knobUpDwn</Name>
	<AnimLength>100</AnimLength>
  <Animation>
    <Parameter>
      <Code>(L:camera2, percent)</Code>
    </Parameter>
  </Animation>
  <MouseRect>
    <Cursor>Hand</Cursor>
    <TooltipText>Camera Up Down</TooltipText>
      <MouseFlags>LeftSingle+RightSingle+WheelUp+WheelDown+DownRepeat</MouseFlags>
    <CallbackCode>
      (M:Event) 'LeftSingle' scmp 0 ==
      if{ (L:camera2, percent) -- 0 max (>L:camera2, percent) }
      (L:camera2, percent) 100 == if{ 0 (>L:camera2, percent) }

      (M:Event) 'RightSingle' scmp 0 ==
      if{ (L:camera2, percent) ++  100 min (>L:camera2, percent) }
      (L:camera2, percent) 0 == if{ 100 (>L:camera2, percent) }

      (M:Event) 'WheelDown' scmp 0 ==
      if{ (L:camera2, percent) -- 0 max (>L:camera2, percent) }
      (L:camera2, percent) 100 == if{ 0 (>L:camera2, percent) }

      (M:Event) 'WheelUp' scmp 0 ==
      if{ (L:camera2, percent) ++  100 min (>L:camera2, percent) }
      (L:camera2, percent) 0 == if{ 100 (>L:camera2, percent) }
    </CallbackCode>    
  </MouseRect>
</PartInfo>

DG:eek:
 
Last edited:
Here is what your trying to do...... I download that TV news chopper and tested the camera.


I made you a gmax file so you can use it as a reference.....
http://www.flysim.us/help/camera.gmax

Make sure to see how i assigned the animation keys for the turret to go up and down.
This method keeps the animation alive and will rotate backwards as you continue to turn the knob 1 direction.
You can tweak the code adding a bias to have the turret stop at each direction. I prefer the method i used.

camera.png


Code:
<!--                      Camera & Controls                         -->


<Animation name="camera_knobLftRht" guid="ed1d0169-ea79-41f8-af15-dd70b3784d76" length="100" type="Sim" typeParam2="camera_knobLftRht" typeParam="AutoPlay" />
<Animation name="camera_knobUpDwn" guid="c41add38-c711-47e5-89c4-6ea27b6612b5" length="100" type="Sim" typeParam2="camera_knobUpDwn" typeParam="AutoPlay" />

Code:
<!--                      Camera & Controls                         -->


<PartInfo>
  <Name>camera_knobLftRht</Name>
	<AnimLength>100</AnimLength>
  <Animation>
    <Parameter>
      <Code>(L:camera1, percent)</Code>
    </Parameter>
  </Animation>
  <MouseRect>
    <Cursor>Hand</Cursor>
    <TooltipText>Camera Left Right</TooltipText>
      <MouseFlags>LeftSingle+RightSingle+WheelUp+WheelDown+DownRepeat</MouseFlags>
    <CallbackCode>
      (M:Event) 'LeftSingle' scmp 0 ==
      if{ (L:camera1, percent) -- 0 max (>L:camera1, percent) }
      (L:camera1, percent) 100 == if{ 0 (>L:camera1, percent) }

      (M:Event) 'RightSingle' scmp 0 ==
      if{ (L:camera1, percent) ++  100 min (>L:camera1, percent) }
      (L:camera1, percent) 0 == if{ 100 (>L:camera1, percent) }

      (M:Event) 'WheelDown' scmp 0 ==
      if{ (L:camera1, percent) -- 0 max (>L:camera1, percent) }
      (L:camera1, percent) 100 == if{ 0 (>L:camera1, percent) }

      (M:Event) 'WheelUp' scmp 0 ==
      if{ (L:camera1, percent) ++  100 min (>L:camera1, percent) }
      (L:camera1, percent) 0 == if{ 100 (>L:camera1, percent) }
    </CallbackCode>    
  </MouseRect>
</PartInfo>


<PartInfo>
  <Name>camera_knobUpDwn</Name>
	<AnimLength>100</AnimLength>
  <Animation>
    <Parameter>
      <Code>(L:camera2, percent)</Code>
    </Parameter>
  </Animation>
  <MouseRect>
    <Cursor>Hand</Cursor>
    <TooltipText>Camera Up Down</TooltipText>
      <MouseFlags>LeftSingle+RightSingle+WheelUp+WheelDown+DownRepeat</MouseFlags>
    <CallbackCode>
      (M:Event) 'LeftSingle' scmp 0 ==
      if{ (L:camera2, percent) -- 0 max (>L:camera2, percent) }
      (L:camera2, percent) 100 == if{ 0 (>L:camera2, percent) }

      (M:Event) 'RightSingle' scmp 0 ==
      if{ (L:camera2, percent) ++  100 min (>L:camera2, percent) }
      (L:camera2, percent) 0 == if{ 100 (>L:camera2, percent) }

      (M:Event) 'WheelDown' scmp 0 ==
      if{ (L:camera2, percent) -- 0 max (>L:camera2, percent) }
      (L:camera2, percent) 100 == if{ 0 (>L:camera2, percent) }

      (M:Event) 'WheelUp' scmp 0 ==
      if{ (L:camera2, percent) ++  100 min (>L:camera2, percent) }
      (L:camera2, percent) 0 == if{ 100 (>L:camera2, percent) }
    </CallbackCode>    
  </MouseRect>
</PartInfo>

DG:eek:


You are my new best friend!!!! I have the camera working now on 3 models in the exterior and interior models. I can now relax, take a deep breath and finish up my Bell 206;):cool:. Thanks a million for the help:cool:
 
That's what i noticed. You guys were going way to complicated....

When i tried that news chopper, i thought it was some special animation.
So the first thing i noticed is that this is very simple. Basically the turret and
the knobs can run off the same code, which makes the animation simple.

The style codes you guys were attempting is for mouse drag. So i noticed
there is no need for drag....Go simple....

Nice chopper by the way! Glad your stress is gone.....

DG:eek:
 
Back
Top