PDA

View Full Version : Textures, rotation & transformations, skyboxes & scale.



Dire_Avenger
03-06-2001, 06:01 AM
Bit of a pick 'n mix, this one: if anyone could answer any of the following questions, i'd be grateful.
1:Textures) Okay, so I load the texture, init. the texture, then bind it: but how do I get it to display on the INSIDE of the object(aka. skyboxes). Also, how should I pre-warp the textures('strech'the corners out?) to make it display properly. There was a post on it a while back, but it didn't say http://www.opengl.org/discussion_boards/ubb/frown.gif http://www.opengl.org/discussion_boards/ubb/frown.gif
2:Rotation) Whenever I rotate up(-1.0 y, 15'), I go off on an angle(like rotating diagonally algon X & Y. Is this supposed to happen, and how do I make it stop?)
3:Transformation) Transforming along the Z axis dosen't seem to work(for 'walk-around' demo)
4:Skyboxes) About what size is reasonable for a skybox? 50x50x50? 500x500x500?

5:Scale) Since OGL dosen't display what isn't in the viewpoint, would it be reasonable to create a(massive) sphere, call that the world, surround it with an even bigger skybox, then populate the entire thing with the people, or would it just not work?

Sorry if any of these questions seem stupid, but they're really buggin' me http://www.opengl.org/discussion_boards/ubb/smile.gif

--Dire_Avenger

Bob
03-06-2001, 06:28 AM
1: You can use Terragen to render the textures for a skybox. It will render the images properly for you (distorted properly that is). Don't remember address to Terragen, but a search on the net should do the work. And to display the texture on the inside of a cube, just bind the texture and draw a standard cube, either with changed winding order or disabled backface culling.

3: It doesn't?

4: It highly depends on what size your world is. Remember that a skybox is usualy drawn first, with depthbuffer test and writes disabled, so size does not matter (heard that one before? http://www.opengl.org/discussion_boards/ubb/smile.gif ), the visual effect is the same.

5: It would work, but probably not the way you think. There is a HUGE difference between not draw, and not process objects. If you know an object is not visible, you don't care about it at all, and therefore you don't waste any more time on the object. If you just draw everything, the object won't be drawn but it will be processed by OpenGL, and therefore be a complete waste of expensive time. In other words, no, it's not reasonable if you want speed.

The difference is: "This object is not visible, so we forget about it", and "Oops, it seems like this object wasn't visible, guess I shouldn't have processed it..."

Bob
03-06-2001, 06:30 AM
Oh, by the way...

2: I, sort of, didn't understand your question...

Dire_Avenger
03-06-2001, 07:34 AM
Thanx, Bob!
For 2: as an example, say i've got a (tiny) corridor, maybe a total of 6.0 on the Z, 4.0 on the X, & 4.0 on the Y: When I call glRotatef(-15, 0.0, 1.0, 0.0) the display rotates up and left, as if I was calling glRotatef(15, -1.0, 1.0, 0.0). Not good...
and for 3: It dosen't seem to work properly: or rather, I never seem to move anywhere http://www.opengl.org/discussion_boards/ubb/smile.gif I'll have another check & get back to you.
By the way, what's this 'winding order'?

Bob
03-06-2001, 08:38 AM
Well, I still don't know what actually happens, more that an object rotates in a way you don't want it to. What's wrong with the rotation you get now? More code is always appreciated.

Winding order is the order in which you pass vertices. A front facing triangle in OpenGL's default settings got it's vertices in counter clockwise order. So if you look at the front face of a polygon, it will have it's vertices in CCW order. OpenGL uses this information to determine wether a triangle is facing the viewer or not. If the triangle, as projected on the screen, got it's vertices in CW order, it is not facing the viewer.

Changing the winding order simple means drawing the triangle in CW order instead.

Deiussum
03-06-2001, 11:57 AM
For point 2, it sounds like you probably just have to change the order you do your rotation(s)/translation(s).

Dire_Avenger
03-09-2001, 05:13 AM
Hah! I thought winding order sounded familiar: so all I have to do is draw the skybox clockwise, with depth-testing & culling turned off?

for thedead rotations, I haven't got the code here right now, but I think that I do 2 rotations(one for X, one for Y), along an angle that's changeable with the left & right keys for the x, & up & down keys, for the y: then call the rotates within glPushMatrix(); & glPopMatrix(); : after i've rotated, I do the transforms. It SHOULD work, but it dosen't.

BTW, what's the use of rotating along the z-axis?