Looking for a pre-made example of making an object move
|
a lost user
Join date: ?
Posts: ?
|
08-11-2005 12:32
I've seen many-an-object that can move when clicked or otherwise. I'm not talking about simple rotation, either, I'm talking a limb moves on a penguin or the wheels of an airplane rise up.
How is that done?
Does a certain scripting method "slowly" change the position of objects from points A,B,C to points D,E,F through sort of "tween" ?
Thanks a ton!
|
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
|
08-11-2005 12:39
From: Kujila Maltz I've seen many-an-object that can move when clicked or otherwise. I'm not talking about simple rotation, either, I'm talking a limb moves on a penguin or the wheels of an airplane rise up.
How is that done?
Does a certain scripting method "slowly" change the position of objects from points A,B,C to points D,E,F through sort of "tween" ?
Thanks a ton! Hey there, i think what you are looking for is llSetPos and llSetRot . That should give you a good example of how to do what you are looking for 
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
08-11-2005 12:45
Ahh, you speak of child prim kinematics. That is simply using llSetPos() in a different context. Instead of moving the prim in relation to the sim, you're moving it in relation to the root prim. So, one easy way to move it, say one meter "up" is: llSetPos( llGetLocalPos() + <0.0, 0.0, 1.0>  ; You can still use absolute positioning ( llSetPos(<1.0, 1,0. -1.0>) ). Rotating the prim is also done in relation to the root prim. llSetLocalRot(ZERO_ROTATION); Hope this helps some!
|
a lost user
Join date: ?
Posts: ?
|
08-11-2005 13:01
Thanks to both of you for your quick and informative responses! =D From: Jillian Callahan Ahh, you speak of child prim kinematics. That is simply using llSetPos() in a different context. Instead of moving the prim in relation to the sim, you're moving it in relation to the root prim. So, one easy way to move it, say one meter "up" is: llSetPos( llGetLocalPos() + <0.0, 0.0, 1.0>  ; You can still use absolute positioning ( llSetPos(<1.0, 1,0. -1.0>) ). Rotating the prim is also done in relation to the root prim. llSetLocalRot(ZERO_ROTATION); Hope this helps some! So setting the position... would that make it "jerk" or jump over to the new position? If so, could I use a for loop to make the movement look more fluid? Sorry, I have no LSL knowledge, but a bit of C++
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
08-11-2005 13:12
From: Kujila Maltz So setting the position... would that make it "jerk" or jump over to the new position? If so, could I use a for loop to make the movement look more fluid? Sorry, I have no LSL knowledge, but a bit of C++ Yes and no. Sometimes it's fluid, but quick, sometimes it's instant. Depends on the conditions its operating in. Yes, a for loop and some vector math would let you make it somewhat more smooth, however llSetPos and llSetLocalRot sleep the script (halt it) for 0.2 seconds, so there's always just a leetle jerk to it.
|
a lost user
Join date: ?
Posts: ?
|
08-11-2005 13:21
Thanks =) How do you tell it where to hinge on, however? I made a crappy little diagram up in mspaint to explain what I mean: View imageWhere the black circle is would be where I would want an object to "hinge" on... Light grey lines indicate motion from down to up.
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
08-11-2005 13:28
Sadly, you don't get to tell it, really. The axes toodle stright through the middle of the prim. However, you can fudge that in some cases by cutting a prim in half. And you can cut prims in unusual ways by razing the prim, changing it to a sphere, dimpling it to half, then switching it back to the original shape. The "dimple" remains as an unusual axis cut. Or you can do the math to figure out where the center of the prim is supposed to go, then rotate the prim. With the 0.2 second delay, that looks like poo every time  .
|
a lost user
Join date: ?
Posts: ?
|
08-11-2005 13:36
From: Jillian Callahan Sadly, you don't get to tell it, really. The axes toodle stright through the middle of the prim. However, you can fudge that in some cases by cutting a prim in half. And you can cut prims in unusual ways by razing the prim, changing it to a sphere, dimpling it to half, then switching it back to the original shape. The "dimple" remains as an unusual axis cut. Or you can do the math to figure out where the center of the prim is supposed to go, then rotate the prim. With the 0.2 second delay, that looks like poo every time  . So could I just do this? View ImageWhere the purple line is the center of the maroon colored movable object and the part of the maroon colored movable object inside the grey box is invisible to us do to the grey box's opaqueness.
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
08-11-2005 13:47
No, that's what I'm trying to say doesn't work well. Position and rotation are all about the center of the prim. You can fake moving the axes to an edge by cutting. See attached for examples.
|
a lost user
Join date: ?
Posts: ?
|
08-11-2005 14:00
Woaho. 0_0 I've never seen that trick! =) Then again, I've been around for like... four days =P Thanks a lot 
|
Blain Candour
Registered User
Join date: 17 Jun 2005
Posts: 83
|
08-12-2005 06:08
It is called prim torturing. There are other things you can do as well. Torus advanced cut is fun to play with switching and back. If you get really interested in it the following script is useful. http://secondlife.com/badgeo/wakka.php?wakka=LibraryPrimTorture
|
a lost user
Join date: ?
Posts: ?
|
08-13-2005 20:17
Hi again! I was experimenting with this stuff... How do you manipulate llSetLocalRot(ZERO_ROTATION); ? ZERO_ROTATION is some data type I can't modify. For instance, it isn't an integer so I can't slap "+ 50" in there because it won't work. Can I just do llSetLocalRot(<1,1,1>  ; or something? Thanks all! =D
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
08-13-2005 21:10
ZERO_ROTATION is a constant of the type rotation. You'd need to multiply or divide it by another rotation, or just replace it.
|
a lost user
Join date: ?
Posts: ?
|
08-13-2005 21:32
In llSetLocalRot(<1,1,1>  ; form?
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
08-13-2005 21:59
Well, no. Rotations are quaternions, and those have four numbers in the set, and ... well, I don't quite have the hang of them exactly yet. Read all about them on the page I linked for you above.
|
a lost user
Join date: ?
Posts: ?
|
08-13-2005 22:14
0_0
*gulp*
Ok, thanks... XD
|
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
|
08-13-2005 22:30
From: Kujila Maltz 0_0
*gulp*
Ok, thanks... XD llEuler2Rot can help ya out with the rotations From: someone Returns the rotation (a quaternion) represented by Euler angle vec (in radians).
vector eul = <0, 0, 45>; //45 degrees around the z-axis, in Euler form eul *= DEG_TO_RAD; //convert to radians rotation rotation quat = llEuler2Rot( eul ); //convert to quaternion llSetRot( quat ); //rotate the object
|
a lost user
Join date: ?
Posts: ?
|
08-13-2005 22:35
Oh thank God! XD
Oh thanks very much all of you!!!
|