|
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
|
11-28-2006 09:22
After messing around with TargetOmega on physical objects I realized that if you could use the current axis of rotation, along with it's current movement vector to update llTargetOmega, you could steer a rolling sphere like a vehicle just using llTargetOmega. right now I'm just getting stumped on the math to determine which new rotation is needed to change the direction of movement along the desired velocity. Right now I just have a simple "Marble Madness" style control that works okay for slow movement, but once the ball gets moving it's very hard to control. drop this into a 0.5x0.5x0.5 sphere integer controlled; float xspin; float yspin; float zspin;
default { on_rez(integer num) { llResetScript(); } state_entry() { llSetRot(ZERO_ROTATION); llTargetOmega(<0,0,0>,0,0); llSetTouchText("Drive"); } touch_start(integer num_detected) { if(llDetectedKey(0)==llGetOwner() && controlled==TRUE)// turns off the controls for our marble { controlled=0; llReleaseControls(); llSetStatus(STATUS_PHYSICS,FALSE); llTargetOmega(<0,0,0>,0,0); llSetRot(ZERO_ROTATION); } else if (llDetectedKey(0)==llGetOwner() && controlled==FALSE)//Turn on the controls for our marble { controlled=1; llSetRot(ZERO_ROTATION); llSleep(.4);//work around for a bug I encountered. llSetStatus(STATUS_PHYSICS | STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE); llSleep(.1);//bug work around llSetTouchText("Turn off"); llCollisionSound("",0); llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS); llOwnerSay("Recieving Signal..."); } } run_time_permissions(integer perm) { if (perm) { llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT, TRUE, FALSE); } } control(key id, integer level, integer edge) { if(level & CONTROL_FWD) { yspin +=.05; } if(level & CONTROL_BACK) { yspin -=.05; } if(level & CONTROL_RIGHT) { zspin +=.05; } if(level & CONTROL_LEFT) { zspin -=.05; } if(level & CONTROL_ROT_RIGHT) { xspin -=.05; } if(level & CONTROL_ROT_LEFT) { xspin +=.05; } if(xspin >=2) { xspin=2; } if(yspin >=2) { yspin=2; } if(zspin >=2) { zspin=2; } if(xspin <=-2) { xspin=-2; } if(yspin <=-2) { yspin=-2; } if(zspin <=-2) { zspin=-2; } llTargetOmega(<xspin,yspin,zspin>,PI/4,1); //llOwnerSay((string)<xspin,yspin,zspin>);//Debugging Shiz }
}
if anyone could figure out the math to determine what is the needed "omega" to apply to the ball to completely reverse it's current movement (most likely using llGetRotVel and llGetVel) it could make this into a plausible (if funky) vehicle to play around with
_____________________
My SLExchange shopTypos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not. The function is working perfectly fine. It's just not working the way you wanted it to work.
|
|
Checho Masukami
UnRez it or use a hammer
Join date: 6 Oct 2006
Posts: 191
|
11-28-2006 09:34
I was working in a similar idea so, in a few hours I will log on and give it a try. At this moment your code looks more accurated (and cleaner) than mine... I let you know if something good happends.
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
11-28-2006 10:26
Used to Love marble madness!!!!! Too the liberty of tidying up the code some integer controlled; float xspin; float yspin; float zspin;
float INCREMENT = 0.05; float LIMIT = 2.0;
float ALIM(float var, float limit) { float value = var; if(value > limit) value = limit; else if(value < - limit) value = - limit; return value; }
default { on_rez(integer num) { llResetScript(); } state_entry() { llSetRot(ZERO_ROTATION); llTargetOmega(<0,0,0>,0,0); llSetTouchText("Drive"); } touch_start(integer num_detected) { key id = llDetectedKey(0); key owner = llGetOwner(); if(id== owner) { if(controlled)// turns off the controls for our marble { controlled=FALSE; llReleaseControls(); llSetStatus(STATUS_PHYSICS,FALSE); llTargetOmega(<0,0,0>,0,0); llSetRot(ZERO_ROTATION); llSetTouchText("Drive"); } else//Turn on the controls for our marble { controlled=TRUE; llSetRot(ZERO_ROTATION); llSleep(.4);//work around for a bug I encountered. llSetStatus(STATUS_PHYSICS | STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE); llSleep(.1);//bug work around llSetTouchText("Turn off"); llCollisionSound("",0); llRequestPermissions(owner , PERMISSION_TAKE_CONTROLS); llOwnerSay("Recieving Signal..."); } } } run_time_permissions(integer perm) { if (perm) { llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT, TRUE, FALSE); } } control(key id, integer level, integer edge) { if(level & CONTROL_FWD) { yspin += INCREMENT; } if(level & CONTROL_BACK) { yspin -= INCREMENT; } if(level & CONTROL_RIGHT) { zspin += INCREMENT; } if(level & CONTROL_LEFT) { zspin -= INCREMENT; } if(level & CONTROL_ROT_RIGHT) { xspin -= INCREMENT; } if(level & CONTROL_ROT_LEFT) { xspin += INCREMENT; } xspin = ALIM(xspin,LIMIT); yspin = ALIM(yspin,LIMIT); zspin = ALIM(zspin,LIMIT); llTargetOmega(<xspin,yspin,zspin>,PI/4,1); //llOwnerSay((string)<xspin,yspin,zspin>);//Debugging Shiz } }
|
|
grumble Loudon
A Little bit a lion
Join date: 30 Nov 2005
Posts: 612
|
11-29-2006 00:48
Why aren’t you using applyImpulse to move the marble? Using friction to control the motion is unpredictable. http://www.lslwiki.com/lslwiki/wakka.php?wakka=llApplyImpulseSet localAxis to false and use a timer to update the speed. I havn't tested this... Set the vector speed using the folowing vector gDirectionLast = <0.0,0.0,0.0>; timer(){ // gTargetPos is in sim cordinates vector vDirection = gTargetPos - llGetPos(); vector vvel2 = vDirection - ((vDirection - gDirectionLast) * 0.1) //dampening gDirectionLast = vDirection;
if (VecMag(v) > .001){ //protect from divide my zero during normize float desiredSpeed = 1.0; //desired speed vector vSpeed = llVecNorm(vvel2) * desiredSpeed; setVel(vSpeed, false); }; } [php/]
The dampening may not be correct.
|
|
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
|
11-29-2006 08:04
From: grumble Loudon Why aren’t you using applyImpulse to move the marble?
This was just an experiment to see what could be done using llTargetOmega to move a ball.
_____________________
My SLExchange shopTypos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not. The function is working perfectly fine. It's just not working the way you wanted it to work.
|
|
2k Suisei
Registered User
Join date: 9 Nov 2006
Posts: 2,150
|
11-29-2006 08:17
From: Senuka Harbinger This was just an experiment to see what could be done using llTargetOmega to move a ball. I tried moving a ball with llShout(). timer() { llShout(0,"MOVE DAMN YOU! MOVE!!"); }
My experiment failed 
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
11-29-2006 13:50
From: 2k Suisei I tried moving a ball with llShout(). timer() { llShout(0,"MOVE DAMN YOU! MOVE!!"); }
My experiment failed  Ahh, but 2K, for it to work the Ball must want to move
|