View Full Version : Help me!!!
zaq5002 06-22-2007, 09:22 AM Hi!!!
In the topic about CgTalk Maxscript Challenge 005: "Lightning Bolts" link:http://http://forums.cgsociety.org/showthread.php?t=257572
I have a problem: there's code: "track = 3*(k-1)+2", so why do they set "track" value like that? I try to set "track = k" but program not works accurate.
Thank you!
|
|
erilaz
06-25-2007, 02:57 AM
The variable k in the code refers to a knot index. I can only assume the track part is to refer to the correct track number in the controller for that knot.
zaq5002
06-25-2007, 04:40 AM
Thank erilaz!
I know "k" refers to knot index, in that case "k" = 1 to 65. But I don't understand that why variable track = 3*(k-1)+2. How do you use this formula:sad: ? And I try to find code: "#master" in MAXScript Reference but it can't find this code.
please help me again!
guruware
06-25-2007, 10:17 PM
the lighning bolt is made of spline
the vertices are animated
k a knot is a vertex
a knot has an in-vector & an out-vector (aka. bezier-handles)
for each animated vert you have 3 entries in trackview
1 - InVec
2 - Vertex
3 - OutVec
so...
for knot 1 the vertex in track view will be the 2nd
for knot 1 the vertex in track view will be the 5th
ect.
to get the vertex of knot 2
k = 2
3*(2-1)+2 = 5 - the 5th entry in trackview
3* .... 3 entries per knot
+1 the InVec
+2 the vertex
+3 the OutVec
after creating a lightning-bolt check trackview
under
World-Objects-Object__Editable_Spline-Master
you have all this tracks of the animated verts
too much confusing ? :)
guruware
zaq5002
06-26-2007, 04:43 AM
Thank guruware!!!:thumbsup: :applause:
Your help is very useful for me. I try to make a script:
lin = splineshape()
addnewspline lin
addknot lin 1 #corner #line [0,0,0]
addknot lin 1 #corner #line [0,0,0]
updateshape lin
lin
lin.wirecolor=red
animateVertex lin #all
getPos=#()
for i in 1 to 5 do
(
numk = (numsegments lin 1)*2
for j in 1 to numk by 2 do
(
refineSegment lin 1 j 0.5
)
updateshape lin
)
k= numKnots lin 1
for t in 0 to 10 do
(
x0=y0=0
z0=100
for i in 1 to (numKnots lin 1) do
(
setKnotPoint lin 1 i [x0,y0,z0]
setKnotType lin 1 i #corner
x0=random 5 10
y0=random 5 10
z0=z0-random 15 20
getPos[i]=getKnotPoint lin 1 i
updateShape lin
track = 3*(i-1)+2
key= addNewKey lin[#Object__Editable_Spline][#master][track].controller t
key.value = getPos[i]
updateShape lin
)
)
But MAXScript Listener give me a error:
-- Error occurred in i loop; filename: C:\Program Files\Autodesk\3dsMax8\Scripts\tmp.ms; position: 722
-- Frame:
-- i: 3
-- called in t loop; filename: C:\Program Files\Autodesk\3dsMax8\Scripts\tmp.ms; position: 770
-- Frame:
-- t: 0
-- Unknown property: "controller" in undefined
:sad: ???
Why that?:cry: Help Help Help :bowdown:
Zbuffer
06-26-2007, 01:34 PM
That's because of the number of knots in the spline don't match
try replacing
addknot lin 1 #corner #line [0,0,0]
addknot lin 1 #corner #line [0,0,0]
updateshape lin
lin
lin.wirecolor=red
getPos=#()
for i in 1 to 5 do
(
numk = (numsegments lin 1)*2
for j in 1 to numk by 2 do
(
refineSegment lin 1 j 0.5
)
updateshape lin
)
with
for i=1 to 10 do addknot lin 1 #corner #line [0,0,0] so you are sure the spline has 10 knots.
zaq5002
06-26-2007, 03:47 PM
Thank Zbuffer very much!:)
But in my code:
lin = splineshape()
addnewspline lin
addknot lin 1 #corner #line [0,0,0]
addknot lin 1 #corner #line [0,0,0]
updateshape lin
it's just creat a spline with 2 knots. After that I divide this spline by code:
for i in 1 to 5 do
(
numk = (numsegments lin 1)*2
for j in 1 to numk by 2 do
(
refineSegment lin 1 j 0.5
)
updateshape lin
)
Then spline with 33 knots. The "for loop" with "t": mean that "from frame 0 to frame 10"
And the the code:
for i in 1 to (numKnots lin 1) do
(
setKnotPoint lin 1 i [x0,y0,z0]
setKnotType lin 1 i #corner
x0=random 5 10
y0=random 5 10
z0=z0-random 15 20
getPos[i]=getKnotPoint lin 1 i
updateShape lin
track = 3*(i-1)+2
key= addNewKey lin[#Object__Editable_Spline][#master][track].controller t
key.value = getPos[i]
updateShape lin
)
For number of knots, so I think number of knots in spline will match because of "i" is from 1 to "(numKnots lin 1)"
Please show me the mistake in my code!
zaq5002
06-26-2007, 03:55 PM
Dear Zbuffer :D
I've just checked my code and fix it with your way. Result is excellent, it's right.:thumbsup:
May be my the knots in spline don't match.
Thanks again!:applause:
CGTalk Moderation
06-26-2007, 03:55 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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.