Elvas Tower: Why "Position" in 3D-cvf - Elvas Tower

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Why "Position" in 3D-cvf Rate Topic: -----

#1 User is offline   jonas 

  • Engineer
  • Group: Status: Contributing Member
  • Posts: 548
  • Joined: 04-April 14
  • Gender:Male
  • Simulator:MSTS & OR
  • Country:

Posted 29 March 2023 - 08:31 PM

Hi,
Maybe more a question than a bug - but what is the Position parameter at a 3D-control in the 3D-cvf file actually necessary for?
    	Lever (
    		Type ( TRAIN_BRAKE LEVER )
    		Position ( 457 335 153 95  )
    		Graphic ( CV_TRAIN_BRAKE_Jm.ace )
    		Style ( NOT_SPRUNG )
    		MouseControl ( 1 )
    		NumFrames ( 16 4 4 )
    		NumPositions ( 0 )
    		NumValues ( 0 )
    		Orientation ( 1 )
    		DirIncrease ( 0 )
    		ScaleRange ( 0 1 )
    	)

If I delete the Position parameter for the train-brake in the 3D-cvf file, the brake will crash and shows "def %" as soon as I operate the train-brake with the mouse in the 3D-cab.

Attached Image: 230330 3D-cvf Position Kopie.jpg

I was deleting all "Position" and "Graphic" parameter in the control blocks while finalizing my 3D-cvf-file, because I thought these entries have no function in 3D.
So can one explain what function the "Position" parameter at a control entry have in the 3D-cvf-file?

Greetings
Jonas

#2 User is offline   superheatedsteam 

  • Engineer
  • Group: Status: Contributing Member
  • Posts: 508
  • Joined: 28-June 08
  • Location:Perth, WA
  • Country:

Posted 29 March 2023 - 10:19 PM

I found that numbers in the position parameter influenced how sensitive the control of a lever was to mouse movements in the 3D cab view.

For example, when my train brake lever control that has 100 frames of animation had Position ( 1 1 1 1 ), the brake lever would instantly toggle between 0 and 100% travel with any amount of mouse input.

When the lever had Position ( 100 100 100 100 ) I could control the lever with an expected proportional level of mouse control.

When the lever had Position ( 1000 1000 1000 1000) it took multiple sweeps of the mouse in order to move the lever a small amount.

Cheers,

Marek.

#3 User is offline   Aldarion 

  • Engineer
  • PipPipPipPipPip
  • Group: ET Owner
  • Posts: 630
  • Joined: 11-February 13
  • Gender:Male
  • Location:Lisbon, Portugal
  • Simulator:Open Rails
  • Country:

Posted 30 March 2023 - 05:06 AM

The Position parameter indicates the coordinates (in pixels) were the CV_TRAIN_BRAKE_Jm.ace will be placed in the screen ( rather in the backgroung cab image. It also indicates the dimension of the image shown since a cab control's ace file normaly contains multiples images of tha control is several positions

#4 User is offline   Weter 

  • Member, Board of Directors
  • PipPipPipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 7,045
  • Joined: 01-June 20
  • Gender:Not Telling
  • Simulator:ORTS
  • Country:

Posted 30 March 2023 - 08:55 AM

If so, third and fourth numbers might indicate an area's size, where control can be grabbed and dragged by mouse, while first two numbers - naturally position of that area's corner (but where, if cab is 3d?) Hence, span of area in pixels, related to mouse resolution, will result, as Marek told, the sensitivity/speed of movement.

#5 User is offline   jonas 

  • Engineer
  • Group: Status: Contributing Member
  • Posts: 548
  • Joined: 04-April 14
  • Gender:Male
  • Simulator:MSTS & OR
  • Country:

Posted 30 March 2023 - 10:16 AM

Thanks so far. The meaning of "position" in 2D-cvf was clear to me. The question for me is if somewhere is described which meaning "Position" has in 3D-cvf.

The position (location) of mechanical instruments like trainbrake-levers is already defined in the 3D-s file of a 3D-Cab. So I don't understand the need for "Position" in the 3D-cvf in this case at all.

However, if the "position" information in 3D-Cabs has something to do with the mouse sensitivity, as superheatedsteam describes, then I think this is a bug - at least if it is not documented how exactly it works.

Consider that in the absence of concrete values for "Position" in the 3D cvf, you just normally take the "Position" entry from the 2D cvf and in 3D it will then be evaluated as mouse sensitivity and not as coordinates?

#6 User is offline   Weter 

  • Member, Board of Directors
  • PipPipPipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 7,045
  • Joined: 01-June 20
  • Gender:Not Telling
  • Simulator:ORTS
  • Country:

Posted 30 March 2023 - 08:12 PM

Hello. You must be right, as in 3d cab player's point of view may be from anywhere. Hence, my guess is incorrect, as meaning fixed direction of view.
So, another guess would be - all usual parameters should be in place for *cvf-3d file. And may be, as You told, two last numbers are extrapolated for any view directions, as there are no other definitions of "drag area's span", which then affects mouse sensitivity...

#7 User is offline   jonas 

  • Engineer
  • Group: Status: Contributing Member
  • Posts: 548
  • Joined: 04-April 14
  • Gender:Male
  • Simulator:MSTS & OR
  • Country:

Posted 31 March 2023 - 02:53 PM

Hi,
The "Position ( x y w h )" entry must currently also exist in 3D cvf files and the values w or h must not be 0.As soon as the mouse is moved over the brake lever, the float value "NormalizedMouseMovement" is determined by dividing with either w or h:
    	/// <summary>
    	/// Converts absolute mouse movement to control value change, respecting the configured orientation and increase direction
    	/// </summary>
    	float NormalizedMouseMovement()
    	{
        	return (ControlDiscrete.Orientation > 0
            	? (float)UserInput.MouseMoveY / (float)Control.Height
            	: (float)UserInput.MouseMoveX / (float)Control.Width)
            	* (ControlDiscrete.Direction > 0 ? -1 : 1);
    	}
Code in MSTSLocomotiveViewer.cs

w and h are "Control.Widht" and "Control.Height" and if missing or 0 result in a division by 0 - thus "NaN", which results in "def %" on the screen.

"NormalizedMouseMovement" is to determine the mouse movement value and thus the change value for the brake lever. The function is only effective for mouse movements with pressed left mouse button over the brake lever (also other controls), no matter if you are in 2D or 3D CabView. If you use the keyboard the function "NormalizedMouseMovement" is not used.

---

What superheatedsteam has written about the mouse sensitivity of the lever control has thus been confirmed for me in the OR code.

---

The question remains, what does someone do, who no longer builds a 2D-CabView for a loco, but only a 3D-CabView. How should he then define the w and h values for the "Position" parameter, which is mandatory for 3D? The "Position" parameter values are originally based on the width/height values of the .ace graphic of a control in the 2D-CabView - but there is no such graphic in the 3D-CabView for the individual controls.

When I left out the "Position" parameters in the 3D-cvf-file and this bug occurred, I assumed that the size of a 3D-control will be determined by its actual 3D-dimensions in the s-file of the 3D-CabView. But if this has to be specified manually by a content creator by using a "Position" parameter, even in 3D, then this should at least be mentioned in the manual, I urgently propose. Basically so or so similar, as superheatedsteam writes it.
Or the OR code should be changed so that the "Position" parameter for 3D-cvf is no longer necessary.

Greetings
Jonas



#8 User is offline   Weter 

  • Member, Board of Directors
  • PipPipPipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 7,045
  • Joined: 01-June 20
  • Gender:Not Telling
  • Simulator:ORTS
  • Country:

Posted 31 March 2023 - 09:22 PM

Thanks for this work.
It's now confirmed and made clear for us, who didn't see code.
For now, Manual only tells, that *.cvf-file is compulsory for either 2-d or 3-d cabs.
And since it's so, none of existing numbers inside Position () parameter shouldn't be zero, IMO.
My gratitude and All the best wishes to You too.

#9 User is offline   jonas 

  • Engineer
  • Group: Status: Contributing Member
  • Posts: 548
  • Joined: 04-April 14
  • Gender:Male
  • Simulator:MSTS & OR
  • Country:

Posted 01 April 2023 - 02:15 PM

You are welcome, best wishes to you too, I was happy to examine the OR code for this.
At least the manual does not say that the cvf file is compulsory for 3D cabs. If someone builds only a 3D cab without 2D cab, he has a problem to define the values for the "Position" parameter entry.

#10 User is offline   Weter 

  • Member, Board of Directors
  • PipPipPipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 7,045
  • Joined: 01-June 20
  • Gender:Not Telling
  • Simulator:ORTS
  • Country:

Posted 01 April 2023 - 10:54 PM

Yes, the absence of clear statement about that is a sad fact.

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users