OpenBVE icon indicating copy to clipboard operation
OpenBVE copied to clipboard

[Question?] Animated variable cameraXDistance, cameraYDistance, cameraZDistance

Open Kenny-Hui opened this issue 2 years ago • 6 comments

Description

On the OpenBVE Documentation, these variable are listed as: The non-negative cartesian distance measured on the <AXIS> axis from the object to the camera in meters.

But when I did some basic testing, it seems that it is capable of detecting whether the camera is infront/behind and it does return a negative value.

On the other hand, when I use them in conjunction with the [Sound] section, it seems that the orientation of the [Sound] section is rotated weirdly, something like 100deg?

I am assuming that the orientation depends on the first station, is there any way to orient them on where they actually play? Thanks in advance

Related information

  • Operating system: Windows 10 21H2
  • OpenBVE Version: 1.8.3.0

Kenny-Hui avatar Mar 25 '22 07:03 Kenny-Hui

Dangerous thing reading the documentation ;)

Looking in the code, it definitely just returns the raw distance. Not sure whether that was an oversight when writing the documentation (copy + paste error when copying from distance I'd guess), but I think the documentation probably wants amending in this case.

Sounds appear to be consistant with objects from a very brief dig- My first thought would be wondering whether this is being affected by the position within the train or something (don't forget that some sounds are located at the cab position, others elsewhere by default)

leezer3 avatar Mar 25 '22 10:03 leezer3

I've done a little bit of testing, it's not relevant to the train. (And I think I can also confirm the orientation is fixed to the start of the route)

I've put the animated sound object in the colored dots shown below. (Represents a station .stop position) image

And my .animated file:

[Sound]
FileName = YMT.wav 
Position = 0, 0, 0
; Plays with 1.0 volume if the camera is 2.4m behind, otherwise follow the door ;
VolumeFunction=if[CameraZDistance < -2.4, 1, doors] 
Radius = 100

On the Pink Dot, the sound plays when the camera is behind the object by 2.4m precisely. (Which is intended by the code) On the Green Dot, the sound plays when the camera is on the left by approx. 2.4m. (But since the route in Green Dot is not a full 90 degree from the start, there will be differences when you go infront/behind)

Kenny-Hui avatar Mar 25 '22 15:03 Kenny-Hui

Now that's interesting....

Looks like it's not rotating the vector in that case. Can't see an immediate reason for this, will have to investigate somewhat.

leezer3 avatar Mar 25 '22 15:03 leezer3

I think this should now be fixed as of 1.8.4.1 https://github.com/leezer3/OpenBVE/commit/5b1f0792161b14fd2136c2abd07e5866cd341600

leezer3 avatar Sep 02 '22 16:09 leezer3

Odd it's still the same weird behavior I am using it without any object at all, the entire .animated file is just the section mentioned above

Here's a reproduction, I've placed the animated sound at the end stop at Mei Foo

  1. Close the train door
  2. Move the camera to where the .stop is placed on (Usually the front of the train)
  3. Move your camera to the left until you can hear some sort of ambient sound I've put in
  4. Slightly move your camera back to right, until you can no longer hear the sound
  5. Move your camera backwards, you will notice that the sound plays again (Where I only checked the cameraXDistance, moving along the z-axis shouldn't touch anything) And the offset gets worse as further away.

It still feels like the origin is at the start of the route for some reason and is not transformed

Railway.zip

Kenny-Hui avatar Sep 02 '22 16:09 Kenny-Hui

Now that might actually be a separate bug- I wonder if it's now CameraXDistance that's broken, or some sort of wierd interaction between the two.

The case I fixed was where the sound file was positioned in the object file using the Position statement, and the object subsequently rotated. Will try and take a look over the weekend.

leezer3 avatar Sep 02 '22 17:09 leezer3