PDA

View Full Version : Curve to Spline while maintaning orientation?



squarewulf
01-28-2016, 02:49 PM
132093

So I have a track that does a sort of loop, I want my vehicle to follow that loop. I've converted a curve to spline in layout except the orientation is off. I'm sure this has to do with my curve in modeler but I'm unsure how to preserve point normals while creating splines. Do curves have normals?

gerry_g
01-28-2016, 04:17 PM
only way I have ever done this is with an exported path where I attached the follower plugin to it or my object rather and selected the path and set the object to match orientation to keep it true, very old school

squarewulf
01-28-2016, 10:07 PM
only way I have ever done this is with an exported path where I attached the follower plugin to it or my object rather and selected the path and set the object to match orientation to keep it true, very old school

Follower plugin to a path? You mean Curve Constraint? If that is what you mean; I can't do that because I need my vehicle to have variable speeds. The Curve Constrain is a linear progression 1-100% over a set amount of frames. Further more CC only allows for heading and pitch to be affected by path, I need my vehicle to bank and spin with the track/path.

MonroePoteet
01-29-2016, 02:50 AM
You might be able to use the spline to set the vehicle's X,Y,Z, but then use the RayCastGeometry node and the ConvertHitNormal2HPB node to set the vehicle's Heading, Pitch and Bank. This thread:

http://forums.newtek.com/showthread.php?148434-Roving-over-surface-help

talks about roving over a surface, and your track could be considered just a very well-defined surface. I've included the sample scene I attached to that thread.

mTp

squarewulf
01-29-2016, 11:33 AM
I can't use raycast because it is one directional ray. My track is nearly upside down at one point which would be Y=1, then the track as flat which would be Y=-1. This should be really simple, i don't know why i'm struggling with this.

squarewulf
01-29-2016, 12:49 PM
I tried making my spline in modeler, then point normal moving the geometry a bit and making another spline.
132108
I assumed I could have two nulls, one driving on the bottom track, then another at the same point in z space on the top track to drive the normal. But nope, they don't line up because the tracks relative length is slightly shorter. I tried offsetting it but it wont line up at every point because of math. I feel like i'm missing something super simple here.

MonroePoteet
01-29-2016, 04:40 PM
Since your curve looks very smooth, in Modeler you could try reducing the number of points to the minimum required to maintain the curve, and then adjust the Bank of each resulting Spline node in Layout. I've had some success reducing the number of points in a curve by using successive Merge Points incrementing the distance until it "corrupts" the curve and adjusting the resulting merged points or undoing. For example, start out with Merge Points at 1cm, then 2cm, then 3cm, etc. using CTRL-T to fix the points to match the curve (original curve in BG layer).

You could also make two splines in Modeler, but based upon two "rails" in the track. By selecting two points on one edge down the track and hitting right-arrow, you select that "rail", CTRL-P to create a curve, which you cut-n-paste to a new object. Then, in Layout, you could have two bones on base of the vehicle, and assign each bone to the appropriate rail.

Trying this myself, I still get HPB "flips" in the Spline which would need to be repaired, so I'd recommend trying to reduce the point count in the Modeler Spline first anyway.

Good luck!
mTp

squarewulf
01-29-2016, 05:14 PM
Thats basically what I ended up doing. Made a simpler curve/spline and manually tweaked each null to match my curve. It's a shame though, I planned on doing more complex curvy roads for this spot, i guess i'll just settle for simple.

MonroePoteet
01-30-2016, 01:57 AM
The HPB flips on the Splines generated in Layout are pretty frustrating. I hope at some point LWDG exposes the Spline creation functions to LScript or plug-ins, or make the generated Splines a little more well-behaved and "localized", i.e. sanitize the next node's HPB values against the previous node's values without radical changes as happens now. Without the HPB flips, I think the dual-track spline with the bones I suggested earlier might be feasible for any sort of complex track.

mTp