🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

HELP!!!!! Visibility of a face of a rotating cube

Started by
8 comments, last by KappaMic 24 years ago
How can i determine if a face is visible ? I''m working on tutor 6, and i want to change the bitmap of each fave that is not visible... Can some help me?? I''m a newbie and i want to learn!
Advertisement
Hmm,

I saw your first post and was going to try and answer your question, but I don''t have my Reference manual in front of me as I''m sure there''s a rather easy solve for this.

However, you should try on your own.. One thing I was thinking about, if you were rotating on only one axis, it''d be real easy.

The face that starts completly out of view gets changed, and then everytime you rotate 90 degrees, the next face gets changed.. This could be done in about five minutes if you were rotating on one axis..

Like I said.. I''m sure there''s a depth and/or visible test you can do.. But I''m pretty new too..

bosco()
--leader of the free world .. or something ..
Hummmm, i ''think'' i understood your question.
the math you need is easy:
each face have a normal vector. You first get one vector that as the origin in your eye and then destination on one any point of the face you are processing. Then just do the dot product(i think it is in english) of the normal and then last vector.
example:

float eyex,eyey,eyez; //eye
float nx,ny,nz; //normal vector
float x,y,z; //coordinates of one point of the face

if( (x-eyex)*nx + (y-eyey)*ny + (z-eyez)*nz > 0)
{
//its visible
}else
{
//not visible
}

i think this it is! bye


PROgrammer
Can someone teach me what a "normal" is? I couldn''t fix my problem... :(( I''m a newbie and i want to learn!
Sorry... I know this is annoying but..

A normal is a vector that is parallel to the face of a polygon.
      ^   ___/____  /   /   / /_______/ 


That's the best I can explain it maybe someone else could add a little more detail

- Edit is because the bloody ASCII art is crap!
-Chris Bennett ("Insanity" of Dwarfsoft)

Check our site:
http://www.crosswinds.net/~dwarfsoft/
and our eGroup:
http://www.egroups.com/group/dwarfsoft


Edited by - dwarfsoft on July 3, 2000 6:57:06 PM
dwarfsoft is wrong

A normal vector is a vector that is perpendicular to a polygon, in this case, to a face of the cube (again sorry bad english)

imagine that the face is the top face of the cube:
(-1,-1,1)
(-1,1,1)
(1,1,1)
(1,-1,1)

So the normal vector is: (0,0,1) the lenght is 1

Some advice: the graphics programming need lots of math, and if some guy dont understand a fuck of math, he is fucked.
So first study math, geometry and matrices and more and more and more of math, and then mix that math with the computer language (algoritmia *in portuguese), and then you are ready to do nice things and that stuff. if you didn''t understand forget it

BYE

PROgrammer
dwarfsoft, is this good enough??

I think there is a simple way to find out if you''re facing the front or the back of your polygon. Find out the normals, apply your rotations (other transformations wont have any importance, I think) and if you end up with a positive depth number, then you''re looking to the back of your poly, while a negative Z will make you look at its front (or is it the other way around?).

This is only an idea, but I think it might be interresting. Sorry if I don''t do the maths, I have to leave my computer and I''m taking a break from algebra until the classes.

EL
----------------------------------------"Inash neteia haeg joa kavari quilm..." SD4
If you want to learn more about normals, then check out one of Nate''s (nate.scuzzy.net) docs on normals and planes (or something like that). It''ll give you a basic idea, but you will also need to learn about dot products and cross products from a different source.

Morgan
The dot-product of two vectors gives you the angle between them.

Take the dot-product between each face normal and your camera angle. If the resulting value (angle) between the view vector and the face normal is 90 (perpendicular) or greater, than it can't be seen.

Edited by - revolver on July 5, 2000 4:06:09 PM
Creativity is a bloody nuisance and an evil curse that will see to it that you die from stress and alcohol abuse at a very early age, that you piss off all your friends, break appointments, show up late, and have this strange bohemian urge (you know that decadent laid-back pimp-style way of life). The truly creative people I know all live lousy lives, never have time to see you, don't take care of themselves properly, have weird tastes in women and behave badly. They don't wash and they eat disgusting stuff, they are mentally unstable and are absolutely brilliant. (k10k)

This topic is closed to new replies.

Advertisement