Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Determine which side is up..

Corster Mousehold
The other white meat
Join date: 18 Jan 2005
Posts: 23
02-04-2005 08:51
Can anyone post some code that determines which side of a prim is up?

Thanks,
-cor-
Rhombur Volos
King of Scripture & Kebab
Join date: 6 Oct 2004
Posts: 102
02-04-2005 09:06
on a six-sided square prim, face 0 is always the one located on the positive side of the z-axis, face 1 is on the negative side. I don't remember the other four, but a basic texture script with a while-loop and some numbered textures should clear that up.
Determining which side is up on a six-sided prim is not so difficult, just find out which value of which axis ends up highest on global z.

Conversion from local to global axis is local position * root rotation

a good representative for face 0 would be <0,0,1>, face 1 would be <0,0,-1>
Corster Mousehold
The other white meat
Join date: 18 Jan 2005
Posts: 23
02-04-2005 09:18
Yes, side 0, and side 5 (assuming a 6 sided prim) are easily determined, however sides 1 through 4 vary their rotations up and down as the prim is rotated so it's not as easy. So it could be characterised as follows:

0 = (0, 0, n) if x and y are about 0 then this is side zero.. n is irrelevant
5 = (+/- 3.14, 0 n) abs(x) seems to always be about 3.14, y is always about 0, n again is irrelevant

1-4 = (any varying number of values shared among x, y, and z)

The 1 - 4 part is what is giving me an aneurysm.
-cor-
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
02-04-2005 11:03
From: Corster Mousehold
Can anyone post some code that determines which side of a prim is up?

While the first two responses here are correct... I have a feeling you're asking for how to find the top of a six-sided die or the like, which is a different problem entirely.

While there are a couple of ways to do this, by far the easiest I know is to code a randomizer in the die itself, then have it turn whichever side you want to face "up." To do this, I would suggest reading the following articles:

http://secondlife.com/badgeo/wakka.php?wakka=llRotLookAt
http://secondlife.com/badgeo/wakka.php?wakka=llFrand

I also have example code that will do this, if you ask me in-world. ;)
_____________________
---
Corster Mousehold
The other white meat
Join date: 18 Jan 2005
Posts: 23
02-05-2005 14:36
Well I finally got it working.. there is a correlation between 2 of the 3 coordinates either x=y or x=z or x=-y or x=-z, etc etc etc.

The trick is that sometimes with a dice in SL it could land at an arbitrary angle throwing off the test alittle (yes i'm using a little deviation and not just if (x==y) The way i fixed this was to add more downward force (gravity/weight) to the dice so that they have to land flat.

Looking to make a yahtzee game sometime in the future :)

-cor-
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
02-05-2005 16:35
There was a really good thread on this about a month ago (or was it two or three?) anyway try a forum search.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Mike Zidane
Registered User
Join date: 10 Apr 2004
Posts: 255
02-05-2005 17:13
Can I read any of thise to mean that the sides of a prim aren't always numbered the same way?

Like that loop that was mentioned... that would number the sides the same way every time, right? And what about cuts & hollows? It seems like I found some inconsistency with this previously.

A link to that old thread would be great if anyone knows where it is.
_____________________
I'm only faking when I get it right. - CC