| arrow with a variable size depending on position and velocity of an object |
dinant |
In a scene, I want to draw an arrow fixed to a movable object for which its size and direction depend on the velocity and speed of that object. I guess that that would be possible using MAXscript, but I have no experience with that. My programming skills are restricted to MATLAB.
read 579 times 3/10/2010 5:46:48 PM (last edit: 3/10/2010 5:46:48 PM)
|
Hua*MuLan~ |
Maybe you need script controller to make this constraint.
Every day is a new day MSN:qq343294964@hotmail.com
read 539 times 3/11/2010 7:50:43 AM (last edit: 3/11/2010 7:50:43 AM)
|
dinant |
thanks for your reply. I was already guessing that I would need MAXscript, but I have no experience and the helpfiles/tutorials doesn't seem to have related topics.
read 521 times 3/11/2010 4:42:56 PM (last edit: 3/11/2010 4:42:56 PM)
|
dinant |
Come on, nobody that can help me?
read 490 times 3/12/2010 6:31:33 PM (last edit: 3/12/2010 6:31:33 PM)
|
dinant |
So, no options?
read 377 times 3/30/2010 9:25:11 PM (last edit: 3/30/2010 9:30:57 PM)
|
dinant |
if only the famous MrGrotey was here...
read 312 times 4/13/2010 6:21:25 PM (last edit: 4/13/2010 6:21:38 PM)
|
9krausec |
I would most definatly play around with wiring constraints a bit. I don't have a definate answer, but I think you may be able to work something out with postion (not really velocity)...
Example... A ball with a arrow with a few bones in it. The first bone is fixed (realitve to the ball and is closest to the ball), the second bone could have a squash like controller on it (there is a bone tool were this can be toggled on and off... Then the end of the second bone could be linked to a dummy... Wiring the controller you could say as position on X axis increases, the dummy will go so far in the same direction just at a pinch less of a speed so it would be trailing behind a little (making the arrow get longer)...
I have no clue if that just made any sense, but it did in my mind. Good luck!
read 306 times 4/13/2010 6:31:58 PM (last edit: 4/13/2010 6:31:58 PM)
|
mrgrotey |
Im always here.
I just dont know what the solution is ;)
read 296 times 4/13/2010 7:27:39 PM (last edit: 4/13/2010 7:27:39 PM)
|
9krausec |
@ MR.G- Did my kind of sort of solution seem to make sense? Could this be done with wiring constrants? Go Mr.G Go!
read 290 times 4/13/2010 7:36:11 PM (last edit: 4/13/2010 7:36:11 PM)
|
dinant |
Well, if MrGrotey doesn't know... But thanks for replying.
@ 9krausec: I'm kinda understanding it a bit. The thing is though that I need to make an arrow with the exact location: Arrow_x=0; Arrow_y=(25*xdot-25*ydot)*(.2-y); Arrow_z=0;
xdot and ydot refer to the x and y velocity of a object and y is the position of that object.
read 280 times 4/13/2010 10:29:40 PM (last edit: 4/13/2010 10:29:40 PM)
|
9krausec |
Thats just it. As far as I know wiring constrants deal with direct correlations-
postion of x=postion of y(1/2*posY) (example, it wont work period, but somewhat of a representation of a direct correlation).
The real trick here is trying to get a variable that changes with the velocity of an object... The only way you would be able to do this without code (that I know of anyways) would be to fake it with simple animation...
Best of luck, sorry I couldn't be more help (I do know however that there are a few people on this forum that are MaxScripting gods, so perhaps they may step in).
read 268 times 4/14/2010 12:09:38 AM (last edit: 4/14/2010 12:09:38 AM)
|
Stephen R. |
I dont do maxscript, but scripting is fairly universal, couldnt you do something like this for each frame?
objectPos_new (Holds the most recent position) objectPos (Holds the previous position) checkPos = myObject.y + myObject. + myObject.z; (checks the current position)
if checkPos > objectPos_new { (check to see if the new position is greater than the last objectPos = objectPos_new known position, and if it is, update the values accordingly) objectPos_new = objectPos; };
ArrowScale = objectPos_new - objectPos; (find the difference between the two positions) Arrow.scaleX = ArrowScale; (Set the scaling to the arrow scale, may need to be divided to Arrow.scaleY = ArrowScale; act properly) Arrow.scaleZ = ArrowScale;
read 262 times 4/14/2010 12:20:52 AM (last edit: 4/14/2010 12:24:41 AM)
|
Dub. |
Here is how to do it.
You need two objects - an animated object and the arrow. I used a pyramid for the arrow.
In the pyramid you need to add a transform script controller into the transform channel.
Paste the following code in:
pos = Sphere.pos at time (F-1) (oldPos = Sphere.pos) dir = normalize ((oldpos - pos) * -1) up = [0,0,1] x = cross dir up y = cross x dir matrix3 -x y dir pos
Create a new variable called "Sphere", click "Assign Node" and pick your animated object.
Hit close and now the pyriamid should point in the direction that the sphere is moving (of course it needs to be animated).
Next you need to add a float script to the height controller on the pyramid. Do the same new variable thing and select the sphere (or whatever your animated object is) and paste in this code:
pos = Sphere.pos at time (F-1) (oldPos = Sphere.pos) length (((oldpos - pos)) * 10.0)
you can adjust the "10.0" in there - it is a multiplier for the length of the arrow. I put 10 so it gets nice and long.
Hit close and you should be done!
Here is the max file. (2010)
http://www.filamentvfx.co.nz/dump/arrow.max
read 245 times 4/14/2010 3:55:11 AM (last edit: 4/14/2010 4:01:59 AM)
|
Garp |
Very nice, Dub!

read 233 times 4/14/2010 4:11:56 AM (last edit: 4/14/2010 4:11:56 AM)
|
Stephen R. |
maxscript is wierd as hell
could you explain what each step of this is doing by any chance?
read 226 times 4/14/2010 5:44:37 AM (last edit: 4/14/2010 5:44:37 AM)
|