Scripting. Adding dirt using random decals and other ideas for my OHLE.

Scripting. Adding dirt using random decals and other ideas for my OHLE.

Postby Nobkins » Mon Jun 30, 2014 9:19 am

Hi everyone,

As you might know I have been making some OHLE. The model side is going well but I now have some ideas and not sure if any of them are possible.

I have touched / asked about them in my OHLE thread but got no responses, probably because they questions are lost in all the info about the OHE :D

I have written them in order of preference. 1st one is the item I most want to achieve.

  1. Can I make a script (or anything else) to add or change the model. I want to add dirt to it randomly so that not every item is identical. I was thinking of using a decal but want to know if I can randomly enable / disable them somehow. The gantry blueprint supports child objects so my idea is to add a fee decal child objects and somehow make a script enable or disable the children. The gantry blueprint does not seem to have an option of adding a linked script but here may be a way arounbd this.
  2. The OHE structures have ID plates. I would like to allow people to be able to enter in the correct ID plate info. I doubt this is possible as the gantries are not track linked items.

Thanks

Jim
TrainSimDev.com YouTube Channel
Video tutorials and other resources
User avatar
Nobkins
Site Admin
 
Posts: 547
Images: 3164
Joined: Wed Feb 05, 2014 12:24 am
Has thanked: 325 times
Been thanked: 185 times

Re: Scripting. Adding dirt using random decals and other ideas for my OHLE.

Postby eyore » Mon Jun 30, 2014 9:40 am

3ds Max allows random textures, which would fulfill point 1, but I've never found a way to apply it to .igs files.

I have to guess that point 2 is impossible or we would have Approach signs, totems and nameplates we could input names to etc etc.
Phil

Image
User avatar
eyore
Passed Fireman
 
Posts: 139
Images: 12
Joined: Tue Apr 01, 2014 6:34 pm
Location: Lake District
Has thanked: 25 times
Been thanked: 67 times

Re: Scripting. Adding dirt using random decals and other ideas for my OHLE.

Postby Nobkins » Mon Jun 30, 2014 10:42 am

eyore wrote:I have to guess that point 2 is impossible or we would have Approach signs, totems and nameplates we could input names to etc etc.

Yeh I think so. One of the most useful missing features is the ability to write on signs etc.

I have an idea for the dirt random textures

Gantry blueprint referencing no IGS directly but do have a child blueprint configured (looked at some RSC gantry blueprints and they do this sometimes) --> Child blueprint (referencing the actual catenary igs shape file). The child blueprint could be a "Scriptable Scenary Blueprint". This would allow me to add an LUA script to the model.

The Scriptable Scenary Blueprint would allow me to turn on and off nodes in the main IGS file and with a little LUA magic this could be randomised. So if I create a few simple dirt quads / objects in the model just above the surface of the main object I could randomly enable or disable them.

I guess a couple of questions result:
  • Is it possible to randomly change the texture referenced as well so that a few objects could randomly choose several "dirt" textures? If not I could just have a few more dirt objects each mapped to a different part of the same "dirt" texture.
  • Is it worth the effort? (I am trying to stop the repetitive nature of items that are very close to the track). In a way this is an exercise in learning new techniques as well as trying to create the best model I can.
  • Would you want the dirt to be random (ie each time the route loads it will randomise the dirt).
  • Is it going to be a big performance hit. There is the potential for loads of gantries all "randomising" dirt when a route loads.

I sense that AndiS might be posting on here soon! He seems to always have the info to hand ;)
TrainSimDev.com YouTube Channel
Video tutorials and other resources
User avatar
Nobkins
Site Admin
 
Posts: 547
Images: 3164
Joined: Wed Feb 05, 2014 12:24 am
Has thanked: 325 times
Been thanked: 185 times

Re: Scripting. Adding dirt using random decals and other ideas for my OHLE.

Postby AndiS » Mon Jun 30, 2014 1:23 pm

The question is not whether Andi posts, but whether he has something to say when he posts!

Regarding randomisation, you already mentioned the only choice - scripted scenery. My experiments on how much of a child gets operational are dated, so better repeat them now, using TS2014. Just make a scripted scenery item child of a gantry post. Script would be something like:
Code: Select all
function Initialise()
Print "It works!"
end

If "It works!" shows up on LogMate, you won.

In that case, I would make different versions of the stanchion named objects inside one IGS, so the script can switch them on and off like lights in a signal, using ActivateNode. Only showing one of them raises hope that there will be only one draw call per post. Showing a decal certainly leads to a second draw call.


Entering ID data will not work since you depend on the world editor to show the input field in the properties box (right-hand fly-out).

I would not try abusing mileposts or signals just to have proper data on the plate.

If you can go with random numbers, you could try to find out if texture sets work with scripted scenery. Just look at some speed sign that is known to work, make a scripted scenario item with exactly the same setup (primary texture set, GeoPcDx) and use SetText to show some value of your choice, just for testing.
Code: Select all
Call ( "SetText", "30", 0 ) -- show 30 using primary texture set

In case that works, you will can start developing the IGS. But remember that these digits might use one draw call per digit, so a performance comparison might tell you after you succeeded that you better call that off. But then again, you only show them for the nearest LOD, so the effect may well be negligible.

Since stanchions cannot ask their neighbour about its number, you would generally end up with a meaningless mess on these plates. However, if your route runs somewhat straight and does not change direction anywhere significantly, you can get the global location using
Code: Select all
x,y,z = Call("getNearPosition")

and divide that by some factor to get the mileage, using the remainder as a proxy to the running number. E.g., if the route runs east-west, dividing x by 1609 would give the mileage. The remainder divided by the typical stanchion distance would provide the running stanchion number for that mile. Of course, some numbers will show double and some will be skipped. But it is possible that people don't follow these figures close enough to notice. At least, there would be some coherence, i.e., the mile figure should continuously increase as you travel along, incrementing by 1 for every mile +/- 50%.

You see that this part of the script is route-specific. So you need to clone the .bin and .lua file for each new route, like you do it often for signals. Also remember to add a suitable number to the coordinates to make sure you get positive figures. On tiles with negative tile number, the location value is negative, of course.

For routes heading to north-east, multiply the coordinate by 1.4 (square root of two) to get an estimate of the location along the route.
AndiS
Top Link Driver!
 
Posts: 736
Joined: Wed Apr 09, 2014 5:48 pm
Has thanked: 268 times
Been thanked: 308 times

Re: Scripting. Adding dirt using random decals and other ideas for my OHLE.

Postby VictoryWorks » Mon Jun 30, 2014 7:54 pm

I think Andi has covered the technical side of it completely.

I would maybe question whether it's necessary. Although it's identikit parts it's still only scenery and you have to consider the overhead of such a massive number of script calls. People complain about loading issues already where they get a short freeze when transitioning areas, I would expect this to get worse if the section contains a few thousand scenery items that all run the update function once when they're loaded.
User avatar
VictoryWorks
Driver
 
Posts: 333
Joined: Mon Apr 07, 2014 1:22 pm
Has thanked: 41 times
Been thanked: 224 times

Re: Scripting. Adding dirt using random decals and other ideas for my OHLE.

Postby Nobkins » Mon Jun 30, 2014 9:35 pm

Yeh that is certainly a concern Pete. I think I might just try it and see how the impact effects things.

Cheers for all the info Andi. Plenty to go on there.

Jim
TrainSimDev.com YouTube Channel
Video tutorials and other resources
User avatar
Nobkins
Site Admin
 
Posts: 547
Images: 3164
Joined: Wed Feb 05, 2014 12:24 am
Has thanked: 325 times
Been thanked: 185 times

Re: Scripting. Adding dirt using random decals and other ideas for my OHLE.

Postby AndiS » Mon Jun 30, 2014 10:28 pm

Pete certainly has a point about the loading delay. In a past approach to very complex signal communication schemes, I put the initialisation logic into half a dozen iterations of Update to somewhat distribute the load, but it was not great anyway. However, I think that after all the waiting, another second should not be a concern for users. But I know that it is easier to say this if you are freeware theorist than when you are payware vendor.

Thinking of it again, Pete does have a point. I mean, what are all my signals against the stanchions of a whole route. It must be a ration of 1:100 or so.
AndiS
Top Link Driver!
 
Posts: 736
Joined: Wed Apr 09, 2014 5:48 pm
Has thanked: 268 times
Been thanked: 308 times

Re: Scripting. Adding dirt using random decals and other ideas for my OHLE.

Postby Nobkins » Tue Jul 01, 2014 11:36 pm

Still mulling over the dirty OHE idea. Not sure if I am going to do anything with it or not.

Quick question relating to reflections in textures.

I want the insulators to reflect light quite a lot. I am currently using TrDiff (TrainBasicOjectDiffuse) shader.

Does anyone now what settings I need to enable that material to reflect light a little. Do I need a different shader? Do I need some special values?

Jim
TrainSimDev.com YouTube Channel
Video tutorials and other resources
User avatar
Nobkins
Site Admin
 
Posts: 547
Images: 3164
Joined: Wed Feb 05, 2014 12:24 am
Has thanked: 325 times
Been thanked: 185 times

Re: Scripting. Adding dirt using random decals and other ideas for my OHLE.

Postby AndiS » Wed Jul 02, 2014 12:11 am

Paul S recently got that working:
viewtopic.php?p=2280#p2280
AndiS
Top Link Driver!
 
Posts: 736
Joined: Wed Apr 09, 2014 5:48 pm
Has thanked: 268 times
Been thanked: 308 times

Re: Scripting. Adding dirt using random decals and other ideas for my OHLE.

Postby Nobkins » Wed Jul 02, 2014 10:27 am

Thanks Andi,

That post and a bit of googling and experimentation has resulted in me getting it to work.

I am using TrainBasicObjectSpecular.fx (In Blender that is TrSpec).

This uses the a normal texture in slot 1 (what ever you want to map it to)
The 2nd slot is a small texture that controls the colour of the specular effect. I so far have just used a 64 x 64 white texture

You then need to set up some UV Arguments in your IGSExpModFile2.txt as follows:
[UVArguments]
MatTrSpec=64.0, 0.0, 0.0, 0.0, 0.0, 0.0

MatTrSpec is the name of my material in blender for the TrSpec shader.

The "64.0" argument controls the size of the specular effect.

Specular Power is also meant to have an effect and this is adjusted from within blender by changing the specular intensity and specular hardness for the material.

So far I have not managed to detect any change when adjusting these values but early days :D

The specular effect really looks nice.

Jim
TrainSimDev.com YouTube Channel
Video tutorials and other resources
User avatar
Nobkins
Site Admin
 
Posts: 547
Images: 3164
Joined: Wed Feb 05, 2014 12:24 am
Has thanked: 325 times
Been thanked: 185 times

Next

Return to Blender

Who is online

Users browsing this forum: No registered users and 2 guests