Hi
all,
I'm trying
to position a cylinder half-way between two prims (boxes, for example) so
that it connects the two together. However, I'm having trouble
figuring out what rotation to set it to, despite the vector/euler/rotation
reviews I did from the lsl wiki site. I'm almost about to pull my hair
out:) I'm not even sure if I'm on the right track for doing this
properly. If one of you smart ones could just set me straight on this, I
woud greatly appreciate it.
Here's my
script:
// function for
rezzing a cylinder between vectors a and b
// vector a =
llGetPos() of prim A
// vector b =
llGetPos() of prim B
rez_cylinder(vector a, vector b) { //check for 2 vertices in the same place if(llVecDist(a,b) < delta ) { //if so, don't try to rez the triangle return; }
// Position
vector cyl_pos = a + (b - a)/2; // Rotation vector left = llVecNorm(b-a); vector up = b % a;
rotation cyl_rot = llAxes2Rot( left, left%up, up );
llRezObject("myCylinder", cyl_pos, ZERO_VECTOR, cyl_rot,
0);
} Thanks,
Joanna
_______________________________________________ Click here to unsubscribe or manage your list subscription: https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters |
Hi Joanna
I pulled my hair out as well trying to get automatic boat vehicles to navigate round an Island and line up with the sim grid. I have got the movement to work (My problem is getting a sensor to scan in front of the vehicle). Since my vehicles were round boats I removed the problem of having to point them in the right direction :), and hence I just needed an angle of rotation to move between the current position and the next position. The code I use to do this is vCurrentPos = llGetPos(); // Get current vector vDisplace = vActiveDests - vCurrentPos; //Calculate displacement vector // Caclulate rotational Bearing to ensure that vehicle moves towards target position fAngle = llAtan2(vDisplace.y,vDisplace.x); if (fAngle < 0.0) fAngle += TWO_PI; rActiveRotate = llEuler2Rot(<0.0,0.0,fAngle>); The above code uses the current pos to constantly ensure the angle is accurate as the boat moves. I guess that may help with the x,y movement if the z co-ords are the same. for the z, i think this is where the 4D may come in. Since this gives you one angle, then at a guess, you could try the same calculation 3 times for y/x, z/x and z/y (i fink, try them the other way round 3 from 6 :) and then convert to the rotation <a1,a2,a3). Murrough <quote author="Joanna Chopard (jchopard)"> Hi all, I'm trying to position a cylinder half-way between two prims (boxes, for example) so that it connects the two together. However, I'm having trouble figuring out what rotation to set it to, despite the vector/euler/rotation reviews I did from the lsl wiki site. I'm almost about to pull my hair out:) I'm not even sure if I'm on the right track for doing this properly. If one of you smart ones could just set me straight on this, I woud greatly appreciate it. Here's my script: // function for rezzing a cylinder between vectors a and b // vector a = llGetPos() of prim A // vector b = llGetPos() of prim B rez_cylinder(vector a, vector b) { //check for 2 vertices in the same place if(llVecDist(a,b) < delta ) { //if so, don't try to rez the triangle return; } // Position vector cyl_pos = a + (b - a)/2; // Rotation vector left = llVecNorm(b-a); vector up = b % a; rotation cyl_rot = llAxes2Rot( left, left%up, up ); llRezObject("myCylinder", cyl_pos, ZERO_VECTOR, cyl_rot, 0); } Thanks, Joanna _______________________________________________ Click here to unsubscribe or manage your list subscription: https://lists.secondlife.com/cgi-bin/mailman/listinfo/secondlifescripters |
Free forum by Nabble | Edit this page |