Jump to content

Curve Based Procedural Railway

Recommended Posts

Hey guys! 

I've recently started dabbling a bit in procedural modeling and making tools for creating assets. 
I just decided that I wanted to make a procedural railway as much from scratch as possible with looking as little as possible at tutorials and such, to test my way forward. 

But I have run into a problem I feel is slightly too big for me to try and find and the feature is far too important to just leave flawed. 

When I draw out the curve that is supposed to be the guideline for the railway I just figured I'd have a transform&merge to offset the other one, not thinking of the very obvious problem that this won't work if the railway starts bending. 

Any suggestions on what I could do? 

Thanks and have a great weekend! 


Share this post

Link to post
Share on other sites

Add a Polyframe SOP after resampling your curve. Set Entity to Points, and tick the Bitangent Name Box.

Add a PointWrangle SOP:

float amount = ch("Amount");

@P += -v@tangentv * amount;


Click on the Create Sparse Parameters icon, and offset your curve with the newly created "Amount" parameter.

Merge with original curve.


Share this post

Link to post
Share on other sites

Thanks, Atom - I had a look at it but the asset is locked and since I wanted to do this mainly as a learning experience that defeats the purpose... 

Ryuji , that worked great! Huge thanks for the help! 

Share this post

Link to post
Share on other sites

Since I've already got this going I figure I might ask about the next issue that popped up! 

I used the same curves and a skin for base for he planks under the actual rails. 
It works fine except for when bending the curve since the facet -> primitive that drives them seem to work from a world orientation rather than per normal and therefore the planks melt together when the curve bends 90 degrees. 

Also, if any of you know of any good sources to learn about procedural modeling then I'd love to know about them. 

Thanks again! 


Share this post

Link to post
Share on other sites

After the Polyframe, add an AttributeWrangle:

@N = v@tangentv;


And use this to copy your planks on with a Copy To Points SOP.

You can use a resample before copying to control how many planks you want (with the maximum segments parameter).

Make sure your planks (a box, I assume) are facing the Z axis (the long side should be parallel to the Z axis).


EDIT: Add a normal SOP after the copy, to get your normals back.

Edited by Ryuji

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now