PDA

View Full Version : Spline question


JeBuS27
11-26-2003, 08:56 PM
Hi, first off I'd just like to say thanks for reading this. OK, I've never really used MaxScript before, and what little I've done is only emulating the basic creation of objects that the MaxScript Listener shows.

I'm trying to create a spline line that goes from point A to point B. Pretty simple stuff right? I need the line to be renderable. Pretty much I have a spreadsheet of points in space, and I need lines to connect these points.

Question 1 is how do I input the vertex position data?

line pos:[0,0,0] isSelected:on wirecolor:(color 255 255 255)
That's what the MaxScript Listener shows when I create a new line, no matter what the points are. But I don't see where the 2 vertices get input.

Question 2 is how do I make the line renderable?

MaxScript Listener doesn't show anything when I use the check box for renderable option.

I'm more of a data input type guy myself, and couldn't figure this out if you gave me month on my own.

Max 5.0

LFShade
11-27-2003, 07:08 PM
-- first you have to create a shape
s = splineshape()

-- it seems backwards, but next you have to add
-- a spline segment to the shape
idx = addNewSpline s

-- now you can start adding knots to the spline.
-- this code assumes you already have an array
-- of point3 values for your knot positions
for k in knot_positions do addKnot s idx #smooth #curve k

-- now, after updating the shape, you should
-- see your spline in the viewports!
updateShape s

-- here's how you set the renderable and thickness properties
s.baseobject.renderable = true
s.thickness = 0.5

-- and you can display the render mesh in the
-- viewports like this
s.displayrendermesh = true


:D
RH

Bobo
11-30-2003, 12:20 PM
Originally posted by JeBuS27

Question 2 is how do I make the line renderable?

MaxScript Listener doesn't show anything when I use the check box for renderable option.
....

Max 5.0


Short addition to Roger's excellent answer.

First, you have hit one of the few "special cases" in MAXScript that required additional explanations and large NOTE paragraphs in the Help. ;)

The .renderable property of the splines was implemented after the original MAXScript implementation during Max 1.x times. At that point, every geometry object already had a .renderable property in the Object Properties dialog that controlled the visibility to the renderer.
When the Spline's renderable property was introduced, it was given the same name which led to an internal name conflict. (I assume this could be seen as a bug, but when it was noticed, it was probably too late to change the system without breaking old scripts, so it remained this way up until 6.0)

That's why you cannot just flip the state of the yourSpline.renderable property (which toggles the checkbox in the Object Properties), you MUST use yourSpline.baseObject.renderable which references the base object seen at the bottom of the modifier stack and will toggle the correct checkbox to turn the spline into a renderable mesh...

And a second point - the Question "How do I create a line between two points" was added to the new FAQ section in the MAXScript Online Help for Max 6.0 along with answers to many other typical questions posted to this and other forums. JFYI, should you upgrade to 6.x someday...

Cheers,
Bobo

JeBuS27
11-30-2003, 08:44 PM
Hey, thanks for the responses guys. I ended up finding a work-around for my problem while waiting for the first response. And it is working out quite well for me. I just used planes with the angle figured out by using a little trigonometry.

LFShade
12-03-2003, 10:53 AM
Hah! Your "short addition" might be longer than my answer, Bobo:p

RH

pauldillion
01-16-2004, 05:51 PM
Can one assign different thicknessess along the rendermesh?

Sorry for butting in but this is something I have being trying to solve for some time. Beleive me I am king novice here.

PM

LFShade
01-16-2004, 07:11 PM
Unfortunately, you can't do that. To do something like that, you'd have to write a custom extrusion routine that follows the spline, which would be far from trivial for the novice programmer. However, if you've got the fortitude to try it, I'd recommend looking at the extrude along spline code from Meshtools (or was it csPolyTools, my memory fails me!) for some pointers about how to tackle such a thing. Somebody (I think it was Chris Johnson) also wrote some sort of "draw extrusion" script that might prove useful, so long as it's not an encrypted source. These tools should be available at www.scriptspot.com.

If you go for it, best of luck to you:thumbsup:


RH

pauldillion
01-16-2004, 07:39 PM
Custom extrusion routine??!

:eek:
Thank you for the pointer.

It looks like too many sleepless nights, but it is good to know the limits.

Although I will checkout the links you offered.

Pm

CGTalk Moderation
01-16-2006, 06:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.