OpenBVE
OpenBVE copied to clipboard
[Question?] Animated variable cameraXDistance, cameraYDistance, cameraZDistance
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
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)
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)
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)
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.
I think this should now be fixed as of 1.8.4.1 https://github.com/leezer3/OpenBVE/commit/5b1f0792161b14fd2136c2abd07e5866cd341600
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
- Close the train door
- Move the camera to where the .stop is placed on (Usually the front of the train)
- Move your camera to the left until you can hear some sort of ambient sound I've put in
- Slightly move your camera back to right, until you can no longer hear the sound
- 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
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.