Jump to content

Script for rotating Cube?


EniMausi
 Share

You are about to reply to a thread that has been inactive for 95 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I accidantly post this tread in the wrong forum i guess...haven't saw the script section. My bad :(

 

I found that OmegaTarget script, but it does not work a I want to. The final result should look like this:

http://www.shutterstock.com/video/clip-2933809-stock-footage-abstract-rotating-cube-loop-able-d-anim...

If I turn the cube the rotation axes goes with the object and doesn't stay an the z-axis to earth. Its for a logo in front of a building. The cube should spin on a corner and not an the flat side.... but I just can't get it to work with the omega script. Beside I am a totally noob on scripting. Hope somebody can help.

and sry for my bad english

Link to comment
Share on other sites

You have to do a trick here. Prims rotate around their centre, at least with Omega they do. But you want it to rotate on a corner. So you have to cut the prim so that the centre looks like it is a corner. Rez a prim and on the Object tab in Edit set the rotation to x=45 y=0 z=45

Now set Path Cut to B 0.375 E 0.625 and Slice B to 0.5

Now your Omega will work.

default
{
state_entry()
{
// x y z speed acceleration
llTargetOmega(<0,0,1>,1.0,0.001);
}

}

  • Like 1
Link to comment
Share on other sites

I would simply tell the script to  position the cube as I wanted it, and then rotate it on the region's z axis rather than that of the cube.

Thus:

default{    state_entry()    {        rotation rot = llRotBetween(<1.0,1.0,1.0>,<0.0,0.0,1.0>); //find the angle between the cube's centre and the vertical up        llSetRot(rot); //rotate it to that angle               float speed = (TWO_PI/4.0); // one rotation every 4 seconds       llTargetOmega( <0.0,0.0,1.0>, speed,0.1);           }}

 ETA  I think this is the same as Ron's solution, but mine is a bit more verbose and explicit about the steps involved.

  • Like 2
Link to comment
Share on other sites

That's assuming that the object to be rotated is in fact a cube.  If you squish or elongate the cube along any of its axes, the body diagonal will no longer be <1,1,1>.  You''l have to add a correction and then change one line in Innula's script ...

vector vBody = llGetScale();rotation rot = llRotBetween(vBody,<0.0,0.0,1.0>); //find the angle between the body diagonal and the +Z axis

 

 

  • Like 2
Link to comment
Share on other sites

Thanks, Rolig.   I hadn't considered what to do if it's not a cube, but you're right, of course.

This is one of the things I really like about the Scripting Forum -- someone asks a specific question, and we sometimes end up with a method that's generally applicable and many people must have wondered about in the past.    In fact, I think I remember asking a similar question (at least about how to get the cube resting on its corner) ages ago, soon after I started learning to script, and Dora answering it.

Link to comment
Share on other sites

  • 8 years later...
You are about to reply to a thread that has been inactive for 95 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...