x


3D Cube Face Detection

Hi,

I have a set of 3D cubes placed evenly next to each other with different coloured faces, but I need to detect which face is currently showing towards the user. I have managed to use the "Forward" + "Up" calculations to detect when the cubes are all facing in the extact orientation, however I very urgently need a way to do the same thing with only the the face colour showing the user being the same! I.E. All cube faces have a different colour, as we all know the cube can show the same colour to the user but be of different orientations... This is what I need to do, but currently my game code only allows the "exact" cube orientation to react. I need to find a way to detect for example, when all cubes show the colour "Red" to the user - regardless of the orientation of the cubes. Could anyone please suggest anything or maybe something I have missed with using the "Forward" + "Up" detection method ???? Any help would be greatly appraciated.

Regards, Jimmy.

more ▼

asked May 16 '12 at 01:25 PM

GameDev2012 gravatar image

GameDev2012
0 2 2 2

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You figure out how much a vector is facing another vector by calculating the dot product between the two. In this case, you'd use the camera's facing direction and the normal of the side of the cube that is facing you. There are lots of information and examples around if you look for "Unity Vector3.Dot"

An even easier solution, though, would be to compose the cube out of six individual planes (or parenting them to each side of the cube) - that way, you don't have to bother with extracting the individual face normals from the cube (or trying to compute it based on the cube's rotation).

more ▼

answered May 16 '12 at 02:24 PM

Drakestar gravatar image

Drakestar
916 6 7 14

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x289
x173
x47
x28
x24

asked: May 16 '12 at 01:25 PM

Seen: 671 times

Last Updated: May 16 '12 at 02:24 PM