• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

october121

Model space vs. world space

12 posts in this topic

I''m new to OpenGL, so this may be an easy question for those of you with more exerience. I have code that loads a model from an .ASE file and renders it in GL. It loads fine, and displays alright, until you rotate it 90 degrees. Once the "front" of the model is pointing away from the camera, strange visual artifacts appear, and it looks like the faces that were the original front are still being drawn last, and they''re overwriting the "back" faces, which should now be occluding them. I think what''s happening is that all of the drawing is still being done as if the model hadn''t been rotated. How do I tell GL to draw and light the model from the perspective of the camera, and not from the perspective of model space?
0

Share this post


Link to post
Share on other sites
it sounds like you dont have depth testing enabled

http://members.xoom.com/myBollux
0

Share this post


Link to post
Share on other sites
Hmm...I _think_ it''s enabled, but I might be doing it wrong. Here''s a snippet of code from My GLInit() function:

-------------------------------------------

glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);

glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);

--------------------------------------------

Any comments?
0

Share this post


Link to post
Share on other sites
Well you have it enabled but are you clearing it every frame?
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

-SirKnight
0

Share this post


Link to post
Share on other sites
Yes, I have that line of code at the top of my DrawScene() function, exactly as you have it there.
0

Share this post


Link to post
Share on other sites
Are you rotating from 0 straight to 90 degrees, or in increments? If you're doing 0 to 90 then try rotating in increments and see what happens, might show you what the problem is. If you're doing it in increments and it only starts to happen when you hit 90 degrees then I'd guess your rotating it wrongly somehow, since everything else looks fine.

One more thing, maybe the back of your model is corrupt, maybe you're not reading it in properly, or perhaps the way you're using whichever OGL drawing function your using is incorrect.

Edited by - outRider on July 5, 2001 7:33:47 PM
0

Share this post


Link to post
Share on other sites
Do you have back face culling enabled? If not, what happens when you turn it on? glEnable(GL_CULL_FACE);

Edited by - Dobbs on July 5, 2001 9:24:14 PM
0

Share this post


Link to post
Share on other sites
When I enabled back face culling, it worked perfectly, except that it always culled the same faces....the ones that were the original, unrotated "back" of the model. So when I rotate it, the back half, as seen from the original camera perspective, isn''t there....if I''m rotating a sphere model, it''s just a hemishpere

In response to outRider, I''m rotating in increments, and the strangeness only appears when the original front of the model is facing more than 90 degrees away from the camera. I think I may be reading the model file incorrectly, but I''m not exactly sure where. Here''s the code where I rotate the view for drawing.

----------------------------------------------

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glLoadIdentity();

glTranslatef(0.0f, 0.0f, zoom);
glRotatef(xrot, 1.0f, 0.0f, 0.0f);
glRotatef(yrot, 0.0f, 1.0f, 0.0f);

drawModel(&theModel);

xrot += xspeed;
yrot += yspeed;

----------------------------------------------

xspeed and yspeed can be changed with the arrow keys, as can zoom. That''s basically the entire contents of my drawScene() function at the moment. Anything glaringly wrong?
0

Share this post


Link to post
Share on other sites
Question: if you apply the transformation matrix for all the vertices and calculate face normals per scene, will the backface culling be ok? (i know it''s costly, but theoratically, if we had super-computers)

"Everything is relative." -- Even in the world of computers.
0

Share this post


Link to post
Share on other sites
Backface culling is depending on the order of the vertices. Clockwise or the other way and you can set which one to use.
0

Share this post


Link to post
Share on other sites
Did you remember to specify a depth buffer when you initialized?

If you are using glut, you need GLUT_DEPTH in glutInitDisplayMode()

-Blackstream

Will you, won''t you, will you, won''t you, won''t you take my virus?

-The Mad Hacker

Blackstream''s Webpage
0

Share this post


Link to post
Share on other sites
Call me crazy but it actually sounds to me like an incomplete model.

If the front shows through with culling disabled, and you see nothing with culling enabled then it is not a depth buffer issue. The front of the model would be completely ignored with culling enabled as far as the depth buffer is concerned.

Well. The only other thing that I can think of is maybe it is a clipping issue. How far away is your model when you view it?

It is possible that when you rotate it you are bringing the model closer than your near clipping plane and it is simply shearing off the back polygons.

Try setting your near clipping distance to 0.001 or something like that. Or try translating your model a little ways along the depth axis.

Seeya
Krippy
0

Share this post


Link to post
Share on other sites
I''ve solved the problem, finally. Thanks for everyone''s help. I had missed a couple lines of code in the drawModel() function, where I was using a modelview matrix to do some calculations. After removing that line, it works fine. Thanks again.
0

Share this post


Link to post
Share on other sites