Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Arranging objects in a circle

Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
09-22-2006 11:20
Okay, I have a simple system for spawning objects and then giving them a position to place them in. However, I want to be able to arrange them into a circle, knowing how many objects I have, and how far away from the controller/spawner I want them to be, how would I go about calculating the required position to space them evenly?

Anyone got an ideas?
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
09-22-2006 11:47
CODE

vector unitFwdVector = llRot2Fwd(llGetRot());
float radius = whateverRadiusYouWant;

//therefore:

vector radiusVector = unitFwdVector * radius;

//That gets you the distance (or forward axis) from the rezzer. Then you need an angle:

integer numberOfSteps = howeverManyStepsYouWant;
float angleInRadians = (float)TWO_PI / (float)numberOfSteps;

for (i = 0; i < numberOfSteps; i++)
{
// You want to rotate around the Z axis (assuming you want a horizontal circle), so...

rotation effectiveRot = llAxisAngle2Rot(<0, 0, 1>, angleInRadians * i);

//Now you have a forward vector and a rotation, so...

vector rezOffset = radiusVector * effectiveRotation;

vector rezPos = llGetPos() + rezOffset;
}


That should place them around a circle. Probably has some bugs that need to be worked out :) And some function of effectiveRotation should get you the rotation to place the objects at (I'm assuming they need to all face inwards or outwards or something. Unless they have rotational symmetry, like a cylinder, so they don't 'face' anywhere).

Hope that made some kind of sense :)
Cadroe Murphy
Assistant to Mr. Shatner
Join date: 31 Jul 2003
Posts: 689
09-22-2006 12:30
Haravikk - I don't know if this will be useful to you, but one option is to use my PrimArray tool. It rezzes a series of objects and applies a transformation to each one (position and rotation). By giving it a pivot, you can place things in a circle pretty easily. Here's an example of the commands to use to place 6 objects in a circle of radius 2 (with the objects rotated to "face" the center).

/21 count 6
/21 pivot 2
/21 rot 60
/21 rez
/21 array
/21 freeze

I dropped the tool on your inventory, but it's also available at Dolmere's store at Osterhout(233,16) for L$1. In any case, the source is open, so maybe it will be informative.
_____________________
ShapeGen 1.12 and Cadroe Lathe 1.32 now available through
SLExchange.
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
09-22-2006 13:09
From: Ziggy Puff
Hope that made some kind of sense :)

*slaps head*
I already have that heh, I've already worked out the rotation that each object needs to have (they rotate to face one another, think horizontally long 'sticks' arranging in a circle), didn't occur to me that it's just the same thing but multiplied by some vector, heh.

Cheers for both your answers, and for the item cadroe, I think I've got it working now (that part at least, lol, loads more to do) :)
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)
SirSticky Hornpipe
Registered User
Join date: 24 Jun 2005
Posts: 43
probs with textures
09-23-2006 16:57
Cadroe, I have your prim array tool shapegen .95 but i'm at a los on how to alter the textures.. i have looked at the script in the block and it has a key number where it says textures.
How do i find out the key of the texture i wish to use..
thankyou in advance

I't ok i found another thread you did and it explains how to find the key
thanks again
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
09-23-2006 17:01
From: SirSticky Hornpipe
Cadroe, I have your prim array tool shapegen .95 but i'm at a los on how to alter the textures.. i have looked at the script in the block and it has a key number where it says textures.
How do i find out the key of the texture i wish to use..
thankyou in advance


In inventory right click the texture and click "copy Asset UUID" then you can paste it into the script.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
SirSticky Hornpipe
Registered User
Join date: 24 Jun 2005
Posts: 43
ty jesse
09-23-2006 17:02
:)