OpenBVE
OpenBVE copied to clipboard
[Suggestion] Slim thinking for XML trains with multiple carriage types
I'm a little too stingy...
To modify any value, the data of this vehicle must be copied. However, most of the copied data are duplicate, and a few are the changed data of these vehicles, such as model, weight and orientation. It's easy to say if there are few models. Trailers have seat cars, sleeper cars, restaurants, controlled trailers and other differences. Whether the locomotive is started or not and whether the locomotive is modified. The direction of the overturned vehicle will be to double the data of these slightly different vehicles... It's a little big. The $Include preprocessing instruction in the route file allows you to split the duplicate route content into separate files for reference by any route file. apply this method to Train XML.
One more point. I would like to make the vehicle combinations into inclusion files to save the trouble of referencing combinations and making multiple sets of train couplings.
Classic suggest. Each vehicle has an optional sound reference file.
This is a specific demonstration Idea Demonstration.xml
<Car>
<Include>25T-JRegular.xml</Include>
<Include>25TA-JUnique.xml</Include>
<Object>25TDev-J.Animated</Object>
<Reversed>True</IsReversed>
</Car>
Idea Demonstration.xml
<!--25T-JRegular-->
<Include>
<Length>25.5</Length>
<MotorCar>False</MotorCar>
<Cargo>Passenger</Cargo>
<Data... />
</Include>
<!--25TA-JUnique-->
<Include>
<FrontBogie>
<Object>Bogie25TA.animated</Object>
<Reversed>False</Reversed>
</FrontBogie>
<RearBogie>
<Object>Bogie25TA.animated</Object>
<Reversed>True</Reversed>
</RearBogie>
<Data... />
</Include>
Imaginary effect.xml
<Car>
<!--25T-JRegular-->
<Length>25.5</Length>
<MotorCar>False</MotorCar>
<Cargo>Passenger</Cargo>
<Data... />
<!--/25T-JRegular-->
<!--25TA-JUnique-->
<FrontBogie>
<Object>Bogie25TA.animated</Object>
<Reversed>False</Reversed>
</FrontBogie>
<RearBogie>
<Object>Bogie25TA.animated</Object>
<Reversed>True</Reversed>
</RearBogie>
<Data... />
<!--/25TA-JUnique-->
<Object>25TDev-J.Animated</Object>
<Reversed>True</IsReversed>
</Car>
Classic suggest. Each vehicle has an optional sound reference file. In this way, the unit car of tandem dual energy locomotive can have different running noise. Idea Demonstration.xml
<Car>
<SoundReference>SoundDDFXSYK A-J.xml</SoundReference>
</Car>
<Car>
<SoundReference>SoundDDFXSYK B-J.cfg</SoundReference>
</Car>
<Car>
<SoundReference>
<Include>SoundRegularDT25T-J.xml</Include>
<Include>SoundMotorDDFXD3-J.xml</Include>
</SoundReference>
</Car>
If the SoundReference section is not written, search for the SoundXML file from the folder where the TrainXML file is located according to traditional practices.
There is another thing! I am used to using SoundCFG as the sound reference table file, even when playing with the new functions built daily. Just because I don't need to think about the proper sound placement and full power radius. If I can, I want to use the SoundCFG method to use SoundXML. If I want to get these pre calculated values, I can get them by converting SoundCFG to XML through CarXmlConverter. But how to obtain the pre calculated value without using SoundCFG? Calculate by yourself according to the formula of the source code...
There is another thing! I am used to using SoundCFG as the sound reference table file, even when playing with the new functions built daily. Just because I don't need to think about the proper sound placement and full power radius. If I can, I want to use the SoundCFG method to use SoundXML. If I want to get these pre calculated values, I can get them by converting SoundCFG to XML through CarXmlConverter. But how to obtain the pre calculated value without using SoundCFG? Calculate by yourself according to the formula of the source code...
This is one of the fundamental issues with the original formats. They use magic numbers everywhere, most of which go back to BVE2 and beyond. I'm not sure how useful documenting them actually is, but it would be easy enough to add a position / radius column to the table on this page: https://openbve-project.net/documentation_hugo/en/trains/default_sounds.html Same thing could be done on the XML page I suppose?
Essentially, if you're using XML, the solution is for everything to be specified manually to suit the train (although it does use sensible defaults). Defaults and magic numbers whilst helpful in the short-term only lead to messes in the longer term.
It's the same basic issue when implementing a new feature; Most of the sim architecture was designed as a clone of BVE2 / BVE4, not from scratch, and to do something seemingly simple ends up re-writing a massive bunch of stuff which makes assumptions about the original behaviour :)
Default sound radii (as per BVE2) are now documented. Will see about the sound.cfg file / XML tomorrow if I remember, although I'm actually thinking about reformatting that page a little somehow.
I arrange Track. Announce Joint. wav; 45
commands everywhere in the route, and the rear axle of the last vehicle does not make a sound when the train passes the Announce command. I have no reason to fix this problem.
At present, there is no instruction about JoinNoise to place the rail joint sound. I chose the Announce instruction. There are too many instructions to place.
The rail seam sound I use is not the sound of multiple wheel collisions. I use the vehicle to pretend to be a bogie, and then fine tune the axle of the vehicle body to overlap the axle of the pseudo bogie. It seems that each axle of the bogie triggers the sound, and the overlapping axle also solves the problem of sound triggering. If I don't fine tune the axle of the main body of the vehicle, it sounds like a three axle bogie with narrow wheel spacing. At the same time, the problem that the rear axle of the last vehicle doesn't trigger the sound will be repeated. In terms of simple car building, there is no better way than an articulated car with a two axle bogie or a light car with only two axles.
Consider using the Pole command to place the Animated Sound object. The appearance of the rail splint has been solved. How can I make the function of axle triggered sound? Don't loop playback. I only think of adding new functions and pick holes. Look at this command.
- Idea demonstration
Track.Joint SoundIndex;Interval
Track.JointEnd SoundIndex
;SoundIndex: A non-negative integer representing the train's switch sound.
;Interval: An integer multiple of the block length specifying the interval in which sound are placed.
I hope this command can place continuous sound points, and I don't want too many boring commands. However, it is better to use the "Pole" command with Animated objects.
Then I want to know how to use the non-zero index of the switch section? Switch section in Train Sound.
The non-zero index of the switch section is set via the routefile.
https://openbve-project.net/documentation_hugo/en/routes/csv.html#train The Train.Run value controls the switch, flange and run values on a per railtype basis.
This is possibly not clear enough, and I'll see about revising that documentation.
If you want single-trigger animated sounds, I haven't got an immediate good idea- It's not quite setup for this. However, an untested hacky approach off the top of my head (likely not to perform too well either): This will require a StateChangeSound with PlayOnShow set to 1 and PlayOnHide set to 0 and a second state (this would I think have to be a slightly different object to stop the thing being optimised out) Something like the following basic formula for the state change:
if[distance < 0.1 && distance > -0.1 , 0, 1]
This would obviously put it in the center of the car, and the distance value would require tweaking for axle distances.
As a completely different approach, would an animated function passing the distance to the closest axle work? I'm not sure the function language will handle too well selecting axle N from car N.
Conclusion: A lot of what you're thinking about is likey to require radical architectural changes to work properly :/ I'm not going to make any specific promises, but will keep on thinking about things.
I understand. The release milestone for this issue can be delayed and I can wait a long time.
Thank you for the solution (^u^) During the waiting period, I will continue to adhere to Announce command and simulated bogie trigger method, although the sound of the rail joint will be a little grumpy.
I would like to make the vehicle combinations into inclusion files to save the trouble of referencing combinations and making multiple sets of train couplings.
I tried stuffing the data for both cars into one Car.xml file and it only worked for the car with the first set of data, the car with the latter set of data acted like it didn't exist, the reason the car hook section in Car.xml didn't work could be this.
TestCar1.xml
<Car>
<!--Car1 Data...-->
</Car>
<Car><!--Only available in Train.xml-->
<!--Car2 Data...-->
</Car>
I think the features included are similar to the Car file, for multi-unit car file?
TestCar2.xml
<Include>
<Car>
<!--Car1 Data...-->
</Car>
<Coupler />
<Car>
<!--Car2 Data...-->
</Car>
<Coupler />
</Include>
Train.xml
<Train>
<Include><!--TestCar2.xml-->
<Car>
<!--Car1 Data...-->
</Car>
<Coupler />
<Car>
<!--Car2 Data...-->
</Car>
<Coupler />
</Include>
<Car>Car3.xml</Car>
<Coupler />
</Train>