Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

physical flight with mega prims

Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
10-24-2008 12:54
I was trying to use Mark Coffee's UFO script to power a new vehicle i am working on, it is a little unusual in that it includes three 20x20x20 megas that are heavily dimpled spheres that make up parts of the hull.
the scripts work with 1 mega prim but if i try linking the three megas with the other 15 normal prims making up the rest of the ship i can fly for about 5 seconds before i crash into the ground (very embarrassing in a sandbox with people being crushed underneath)

so in the hopes that i am not asking the impossible here is the script, maybe someone can suggest a solution.

float LINEAR_TAU = 0.75;
float TARGET_INCREMENT = 0.5;
float ANGULAR_TAU = 1.5;
float ANGULAR_DAMPING = 0.85;
float THETA_INCREMENT = 10;// 0.3
integer LEVELS = 0;
vector pos;
vector face;
float brake = 0.5;
key gOwnerKey;
string gOwnerName;
key gToucher;
key Driver;
string Name1 = "Mark Coffee";
string Name2 = "Mom's Paintings";
string gFLYING = "FALSE";
string sound="Sci-Fi-Drone-07";
key id;
integer nudge = FALSE;
vector POSITION;
integer auto=FALSE;
integer CHANNEL = 6;
help()
{
llWhisper(0,"Commands:";);
llWhisper(0,"Left click craft = Start ";);
llWhisper(0,"Left click craft = Stop and release contol";);
llWhisper(0,"/" + (string)CHANNEL + " 1! through" + " /" + (string)CHANNEL + " 9!," + " /" + (string)CHANNEL + " slow or" + " /" + (string)CHANNEL + " warp = Set power";);
llWhisper(0,"/" + (string)CHANNEL + " ask! = Craft asks permission for your control. (Only when outside craft)";);
llWhisper(0,"/" + (string)CHANNEL + " menu = Display this list";);
llWhisper(0,"PgUp or PgDn = Gain or lose altitude";);
llWhisper(0,"Arrow keys = Left, right, Forwards and Back";);
llWhisper(0,"Shift + Left or Right arrow = Rotate but maintain view";);
llWhisper(0,"PgUp + PgDn or combination similar = Set cruise on or off";);
}
default
{
state_entry()
{
gOwnerKey = llGetOwner();
gOwnerName = llKey2Name(llGetOwner());
llSoundPreload(sound);
llStopSound();
llLoopSoundMaster(sound, 0.0);
llSetTimerEvent(0.0);
llMessageLinked(LINK_ALL_CHILDREN, 0, "stop", id);
llSetStatus(STATUS_PHYSICS, FALSE);
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, TRUE);
llSleep(0.1);
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, FALSE);
llSetStatus(STATUS_PHYSICS, FALSE);
llMoveToTarget(llGetPos(), 0);
llRotLookAt(llGetRot(), 0, 0);
llSetStatus(STATUS_PHYSICS, FALSE);
LEVELS = CONTROL_FWD | CONTROL_BACK | CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT | CONTROL_UP | CONTROL_DOWN | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_ML_LBUTTON;
TARGET_INCREMENT = 0.5;
llSitTarget(<0.4, 0.0, 0.4>, ZERO_ROTATION);
llSetCameraEyeOffset(<-10.0, 0.0, 4.0>;);
llSetSitText("Pilot";);
llSetCameraAtOffset(<0, 0.0, 0>;);
llWhisper(0,"Deactivated ... Security conditions set. Type /" + (string)CHANNEL + " menu for a list of options.";);

// this sets a Listen with no callback in this state...
llListen(CHANNEL, "", "", "";);
state Listening;
}

}
state Listening
{
// Here we set up the Listen that is used in the Listening state...
state_entry()
{
llListen(CHANNEL, "", "", "";);
}

// the rest was here before...
// This is the click callback
touch_start(integer total_number)
{
if (llSameGroup(llDetectedKey(total_number - 1))==1 || llDetectedName(total_number - 1)==Name1 || llDetectedName(total_number - 1)==Name2)
{
if (gFLYING == "FALSE";)
{
gFLYING = "TRUE";
llStopSound();
llLoopSoundMaster(sound, 95.0);
llSetStatus(STATUS_PHYSICS, TRUE);
llSetSitText("Ride";);
Driver=llDetectedKey(total_number - 1);
state StateDriving;
}
}
else
{
llWhisper(0,"You must own or belong to this group to fly craft.";);
llStopSound();
llLoopSoundMaster(sound,0.0);
llInstantMessage(gOwnerKey,llDetectedName(total_number - 1) + " is touching your craft";);
}
}

// Here is the Listen callback
listen(integer CHANNEL, string name, key id, string msg)
{
if (llSameGroup(id)==1)
{
if (llToLower(msg) == "menu";)
{
help();
}
}
}

// and this is an on-rez callback
on_rez(integer start_param)
{
llResetScript();
}
}
state StateDriving
{
state_entry()
{
llWhisper(0, "All systems go !!";);
llRequestPermissions(Driver, PERMISSION_TAKE_CONTROLS);
llMoveToTarget(llGetPos(), LINEAR_TAU);
llRotLookAt(llGetRot(), ANGULAR_TAU, 1.0);

// Added listen here as well.... for same reason...
llListen(CHANNEL, "", "", "";);
}

touch_start(integer total_number)
{
if (llDetectedKey(total_number - 1)==Driver)
{
llWhisper(0,"You now have control.";);
gFLYING = "FALSE";
auto=FALSE;
llSleep(1.5);
llStopSound();
llLoopSoundMaster(sound, 0.0);
llSetSitText("Pilot";);
llSetStatus(STATUS_PHYSICS, FALSE);
llMessageLinked(LINK_ALL_CHILDREN, 0, "stop", id);
llSetTimerEvent(0.0);
llReleaseControls();
llResetScript();
}
}

listen(integer CHANNEL, string name, key id, string msg)
{
if (id==Driver)
{
if (llToLower(msg) == "ask!";)
{
llReleaseControls();
llRequestPermissions(Driver, PERMISSION_TAKE_CONTROLS);
}
if (llToLower(msg) == "menu";)
{
help();
}
if (llToLower(msg) == "warp";)
{
TARGET_INCREMENT = 10.0;
string TIspew = (string)TARGET_INCREMENT;
TIspew = llGetSubString(TIspew,0,3);
llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%";);
}
if (llToLower(msg) == "slow";)
{
TARGET_INCREMENT = 0.5;
llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%";);
}
if (llToLower(msg) == "1!";)
{
TARGET_INCREMENT = 0.75;
llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%";);
}
if (llToLower(msg) == "2!";)
{
TARGET_INCREMENT = 1.0;
llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%";);
}
if (llToLower(msg) == "3!";)
{
TARGET_INCREMENT = 1.5;
llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%";);
}
if (llToLower(msg) == "4!";)
{
TARGET_INCREMENT = 2.0;
llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%";);
}
if (llToLower(msg) == "5!";)
{
TARGET_INCREMENT = 3.0;
llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%";);
}
if (llToLower(msg) == "6!";)
{
TARGET_INCREMENT = 4.0;
llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%";);
}
if (llToLower(msg) == "7!";)
{
TARGET_INCREMENT = 5.0;
llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%";);
}
if (llToLower(msg) == "8!";)
{
TARGET_INCREMENT = 6.0;
llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%";);
}
if (llToLower(msg) == "9!";)
{
TARGET_INCREMENT = 7.0;
llWhisper(0,"Power: " + llGetSubString((string)(TARGET_INCREMENT * 10.0),0,3) + "%";);
}
}
}
run_time_permissions(integer perm)
{
if (perm == PERMISSION_TAKE_CONTROLS)
{
llMessageLinked(LINK_ALL_CHILDREN, 0, "slow", id);
llTakeControls(LEVELS, TRUE, FALSE);
}
else
{
llWhisper(0,"Stopped";);
llSetTimerEvent(0.0);
gFLYING = "FALSE";
llSleep(1.5);
llResetScript();
}
}
control(key driver, integer levels, integer edges)
{
pos *= brake;
face.x *= brake;
face.z *= brake;
nudge = FALSE;
llMessageLinked(LINK_ALL_CHILDREN, 0, "slow", id);
if (levels & CONTROL_FWD)
{
if (pos.x < 0) { pos.x=0; }
else { pos.x += TARGET_INCREMENT; }
nudge = TRUE;
}
if (levels & CONTROL_BACK)
{
if (pos.x > 0) { pos.x=0; }
else { pos.x -= TARGET_INCREMENT; }
nudge = TRUE;
}
if (levels & CONTROL_UP)
{
llMessageLinked(LINK_ALL_CHILDREN, 0, "fast", id);
if(pos.z<0) { pos.z=0; }
else { pos.z += TARGET_INCREMENT; }
face.x=0;
nudge = TRUE;
}
if (levels & CONTROL_DOWN)
{
llMessageLinked(LINK_ALL_CHILDREN, 0, "fast", id);
if(pos.z>0) { pos.z=0; }
else { pos.z -= TARGET_INCREMENT; }
face.x=0;
nudge = TRUE;
}
if ((levels) & (CONTROL_LEFT|CONTROL_ROT_LEFT))
{
if (face.z < 0) { face.z=0; }
else { face.z += THETA_INCREMENT; }
nudge = TRUE;
}
if ((levels) & (CONTROL_RIGHT|CONTROL_ROT_RIGHT))
{
if (face.z > 0) { face.z=0; }
else { face.z -= THETA_INCREMENT; }
nudge = TRUE;
}
if ((levels & CONTROL_UP) && (levels & CONTROL_DOWN))
{
if (auto)
{
auto=FALSE;
llWhisper(0,"Cruise off";);
llSetTimerEvent(0.0);
}
else
{
auto=TRUE;
llWhisper(0,"Cruise on";);
llSetTimerEvent(0.5);
}
llSleep(0.5);
}

if (nudge)
{
vector world_target = pos * llGetRot();
llMoveToTarget(llGetPos() + world_target, LINEAR_TAU);

vector eul = face;
eul *= DEG_TO_RAD;
rotation quat = llEuler2Rot( eul );
rotation rot = quat * llGetRot();
llRotLookAt(rot, ANGULAR_TAU, ANGULAR_DAMPING);
}
}

timer()
{
pos *= brake;
if (pos.x < 0) { pos.x=0; }
else { pos.x += TARGET_INCREMENT; }
vector world_target = pos * llGetRot();
llMoveToTarget(llGetPos() + world_target, LINEAR_TAU);
}

}
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Thickbrick Sleaford
Baffled
Join date: 28 Dec 2006
Posts: 26
10-24-2008 14:26
I think you are running out of energy. Your script uses llMoveToTarget, which consumes energy, and because massive objects regenerate energy slower than light objects, you run out of it. You can try to use the linden vehicle funtcions, which are less limited by energy.

http://wiki.secondlife.com/wiki/Energy
http://wiki.secondlife.com/wiki/Linden_Vehicle_Tutorial
Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
10-24-2008 14:59
i understand the problem better now, sadly i lack the skills to do anything about it :(
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
10-24-2008 19:09
can that script be modified to overcome the loss of energy?
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Thickbrick Sleaford
Baffled
Join date: 28 Dec 2006
Posts: 26
10-25-2008 06:13
Hi,
I didn't try this, but maybe you can try different values for LINEAR_TAU. llMoveToTarget consumes energy not just when you call it, but also during its operation, when it moves the object. Maybe larger values will make it move slower and use less energy? Another thing you can try is to hollow and dimple your prims as much as you can, to reduce their mass.
Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
10-25-2008 09:37
ill try that, as they are now the three prims are heavily dimpled and at 95% hollow, I've played around with the build and found the ship can fly with one of those prims linked, but if i undimple it then the ship crashes with just the one mega linked.
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
10-25-2008 10:06
I am not an expert, but I have read that physics mixed with megaprims is a really bad idea.
_____________________
So many monkeys, so little Shakespeare.
Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
10-25-2008 10:08
i believe that before HAVOK 4 was introduced it was. it doesn't seem to be an issue now on sim performance at least not on the scale that i use them which is not excessive
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
10-25-2008 10:57
From: Thickbrick Sleaford
Hi,
I didn't try this, but maybe you can try different values for LINEAR_TAU. llMoveToTarget consumes energy not just when you call it, but also during its operation, when it moves the object. Maybe larger values will make it move slower and use less energy? Another thing you can try is to hollow and dimple your prims as much as you can, to reduce their mass.


this worked to a great extent, i can maintain altitude and climb at a greatly reduced rate of speed, that's ok though. decent can be a little dicey still and sim crossings are still making me fall the ground until the energy is recovered to continue.

is there a way to correct the sim crossing issue?
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Vivito Volare
meddler
Join date: 10 Nov 2006
Posts: 41
10-25-2008 20:37
This is a good script. I've used it in a few vehicles. However, have you tried a script the uses the Linden vehicle parameters? I have a number of craft that use megas and mega sculpties, that work well using the LSL vehicle parameters.
Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
10-29-2008 23:38
I dont think i have any of those scripts, can you send me one?
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
10-30-2008 00:49
might try playing with the material type as well, I think some change the mass of the prim.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -