Elvas Tower: Opening and closing trainset windows - Elvas Tower

Jump to content

Posting Rules

All new threads will be started by members of the Open Rails team, Staff, and/or Admins. Existing threads started in other forums may get moved here when it makes sense to do so.

Once a thread is started any member may post replies to it.
  • 5 Pages +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

Opening and closing trainset windows Rate Topic: -----

#1 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 6,999
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 14 May 2023 - 12:30 PM

This video https://youtu.be/boeWoMF6iTw shows what I'm doing.
The aim is to animate a left and a right 2D- or 3D-cab window, showing the animation both in cabview and in external views. For locomotives also two windows for the rear cab can be defined. I want also to animate carriage windows (a left and a right one).
Full specs will be provided later.
For the video I animated a left window in the 2Dcab of an electric locomotive, as animating on 3D requires either modifying a traincar or 3Dcabview shape to add the related animation, which can be done only by the author of the shape. I'd be happy if I could get from a 3D content developer a traincar with a window animation, so that I can test the feature also for the 3D animations.

As an extra bonus the external sounds and the track sound are reproduced unattenuated with open window. To have a volume difference, two lines as follows
	ORTSExternalSoundPassedThroughPercent ( 30 )
	ORTSTrackSoundPassedThroughPercent ( 25 )

must be added to the wagon section of the .eng or .wag file.
Note that, if you don't have these two lines added, but you have the OR audio option "% of external sound heard internally" set to a value lower than 100, you will still have the above effec with external sounds, but not with the track sound.
Keyboard commands to toggle the window state are Ctrl+Shift+Q for the right window and Ctrl+Q for the left window (this in analogy to commands to toggle door state).

#2 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 6,999
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 14 May 2023 - 12:39 PM

Names of the animations are as follows:
ORTS_2DEXTERNALLEFTWINDOW
ORTS_2DEXTERNALRIGHTTWINDOW
for the window animations as seen from within a 2D cab; the same names are valid for front and rear cab. Left and right are considered as seen from the related cab.

ORTS_EXTERNALLEFTWINDOWFRONT
ORTS_EXTERNALRIGHTWINDOWFRONT
ORTS_EXTERNALLEFTWINDOWREAR
ORTS_EXTERNALRIGHTWINDOWREAR
for the window animations as seen from within a 3D cab; Left and right are considered as seen in the forward direction of the first cab. The convention difference between 2D and 3D cabs is due to the difference in the handling of the cabs. NOTE: these 4 controls are not needed in the .cvf file (same applies also for wipers, doors and so on as seen from within a 3D cab).

LEFTWINDOWFRONT
RIGHTWINDOWFRONT
LEFTWINDOWREAR
RIGHTWINDOWREAR
for the window animations as seen from the external camera views. In case of carriages, only the first two apply.

LEFTWINDOW and RIGHTWINDOW are the names of the controls that can be inserted in the .cvf file and in the 3Dcab .s file to command the state change with the mouse.

Here is what I added to the .cvf file for the animation shown in the YouTube video.
	ORTSCabViewControls
	( 1
			ORTSAnimatedDisplay  (
			Type ( ORTS_2DEXTERNALLEFTWINDOW MULTI_STATE_DISPLAY )
			Position ( 101 69 235 365 )
			Graphic ( ../../Common.Cab/CabE464/FinestraSX.ace )
			ORTSCycleTime ( 0.6 )
				States ( 16 4 4
				State (
					Style ( 0 )
					SwitchVal ( 0 )
				)
				State (
					Style ( 0 )
					SwitchVal ( 0.0625 )
				)
				State (
					Style ( 0 )
					SwitchVal ( 0.125 )
				)
				State (
					Style ( 0 )
					SwitchVal ( 0.1875 )
				)
				State (
					Style ( 0 )
					SwitchVal ( 0.25 )
				)
				State (
					Style ( 0 )
					SwitchVal ( 0.3125 )
				)
				State (
					Style ( 0 )
					SwitchVal ( 0.375 )
				)
				State (
					Style ( 0 )
					SwitchVal ( 0.4375 )
				)
				State (
					Style ( 0 )
					SwitchVal ( 0.5 )
				)
				State (
					Style ( 0 )
					SwitchVal ( 0.5625 )
				)
				State (
					Style ( 0 )
					SwitchVal ( 0.625 )
				)
				State (
					Style ( 0 )
					SwitchVal ( 0.6875 )
				)
				State (
					Style ( 0 )
					SwitchVal ( 0.75 )
				)
				State (
					Style ( 0 )
					SwitchVal ( 0.825 )
				)
				State (
					Style ( 0 )
					SwitchVal ( 0.88 )
				)
				State (
					Style ( 0 )
					SwitchVal ( 0.94 )
				)
			)
			ORTSCabviewpoint ( 1 )
		)
	)

FinestraSX.ace contains the various frames, from window fully close to window fully open. ORTSCycleTime means that the opening/closing time of the window is 0.6 seconds. If one wants to use higher times, more frames are needed to get a smooth animation. Note that the control is within the ORTSCabviewControls block, which is skipped by MSTS and older OR versions to avoid error messages, and note that the ORTSCabviewpoint ( 1 ) line specifies that that animation is in the left cabview.

A simple control block to move a window by clicking the mouse can be as follows:
		TwoState (
			Type ( ORTS_LEFTWINDOW TWO_STATE )
			Position ( 120 425 30 21 )
			Graphic ( cab.ace )
			NumFrames ( 2 2 1 )
			Style ( ONOFF )
			MouseControl ( 1 )
			)

If there is no specific window control in the real cab, you can locate this control on the window itself, using a transparent graphic. So, clicking on the window, you change its state. This is how Geoff did this. It can also be applied for 2Dcab windows.

#3 User is offline   ErickC 

  • Superintendant
  • Group: Status: Elite Member
  • Posts: 1,001
  • Joined: 18-July 17
  • Gender:Male
  • Location:Hastings, MN, US
  • Simulator:ORTS
  • Country:

Posted 14 May 2023 - 07:06 PM

Oh, awesome. I will have to try this on the next new locomotive I build.

#4 User is offline   VAPOR3D 

  • Conductor
  • Group: Status: Active Member
  • Posts: 268
  • Joined: 15-March 20
  • Gender:Male
  • Location:Barcelona, Catalunya
  • Simulator:Open Rails
  • Country:

Posted 14 May 2023 - 07:31 PM

Hello!

Sometimes it seems that we read each other's minds from a distance. I have already several locomotive models (and their 3D cabs) made with animations in the windows, using the ORTS_ITEM1TWOSTATE commands. But of course, that meant losing animations useful for other things, for lack of keys, I was told.

Now I see that we already have keys defined specially for this, which makes me very happy! Also, changing the volume of the external ambient sound is great.

I would soon start updating the models, but I still need to know if the exterior views of the locomotives can also be shown and what would be the names for the parts on the locomotives.

Thank you very much for this new and interesting development, Carlo!

Attached Image: Open Rails NewYear MG 2023-04-06 02-55-36.jpg

Attached thumbnail(s)

  • Attached Image: Open Rails NewYear MG 2023-04-21 01-55-33.jpg


#5 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 6,999
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 14 May 2023 - 11:55 PM

Hi VAPOR3D!
The names of the animations are written in the second post of the thread: the name of the window animations of the locomotive's shape file are
LEFTWINDOWFRONT
RIGHTWINDOWFRONT
LEFTWINDOWREAR
RIGHTWINDOWREAR.

The names of the animations within the 3DCab are
ORTS_EXTERNALLEFTWINDOW
ORTS_EXTERNALRIGHTWINDOW

and use the same rules as any other animation in the 3DCabs.

It would be nice if I could get from you a locomotive equipped with these animations, so that I can test the related part of code.

#6 User is offline   mrmosky 

  • Engineer
  • Group: Status: Contributing Member
  • Posts: 648
  • Joined: 02-October 16
  • Gender:Male
  • Location:Chasetown
  • Simulator:Openrails
  • Country:

Posted 15 May 2023 - 12:03 AM

View PostCsantucci, on 14 May 2023 - 11:55 PM, said:

It would be nice if I could get from you a locomotive equipped with these animations, so that I can test the related part of code.


Hi Carlo


You are welcome to download my 3d cab on this website. It does have opening cab windows.

http://www.elvastowe...uk-with-3d-cab/

Geoff

#7 User is offline   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 6,999
  • Joined: 31-December 11
  • Gender:Male
  • Country:

Posted 15 May 2023 - 12:35 AM

That's great Geoff! I have downloaded it and will report about results. Some days might be needed due to overloads from real life :)

#8 User is offline   Jonatan 

  • Vice President
  • Group: Status: Elite Member
  • Posts: 2,656
  • Joined: 29-March 10
  • Gender:Male
  • Location:Somewhere.
  • Simulator:MSTS and Vehicle Simulator
  • Country:

Posted 15 May 2023 - 07:40 AM

Ok I have wanted something like this for my models as I've begun to prefer running them from the 3D cab instead of using headout view, so I'm absolutely positive to this development. The difference when opening/closing windows is great!

I already have models with external animated cab windows (using the MSTSbin animations nameing convention), but so far I haven't managed to get 3D cab windows to work so these are left in "open" position.

I am asuming the car windows will animate in the passenger view? Agan, I have some modelled in "open" position but not animated.

Awesome work, Carlo! :good:

#9 User is offline   superheatedsteam 

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

Posted 15 May 2023 - 08:11 AM

A welcome addition. Thank you Carlo.

#10 User is offline   VAPOR3D 

  • Conductor
  • Group: Status: Active Member
  • Posts: 268
  • Joined: 15-March 20
  • Gender:Male
  • Location:Barcelona, Catalunya
  • Simulator:Open Rails
  • Country:

Posted 15 May 2023 - 10:04 AM

View PostCsantucci, on 14 May 2023 - 11:55 PM, said:


It would be nice if I could get from you a locomotive equipped with these animations, so that I can test the related part of code.


Great! As soon as I have the animations ready, I'll post a link to download one of my locomotives. Give me some time, please!

  • 5 Pages +
  • 1
  • 2
  • 3
  • Last »
  • 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