• 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.

TeTE

Problem with ... normals?

5 posts in this topic

Look the picture at http://www4.uji.es/~al024870/misc/cube.jpg and you will see what''s my problem. It''s a cube with light and a green texture. I use vertex arrays with the vertices, the texture coordinates and the normals. All is read from an OBJ file. And the models are made with Nendo. What''s wrong? May be the normals? I think they are per vertex normals. I have tried more complex objects (airplanes, buildings). All look similar and no one is smooth even with GL_SMOOTH enabled.
0

Share this post


Link to post
Share on other sites
In order for GL_SMOOTH to take effect, you must calculate, and send the normals to OpenGL. Here is the function that I use to calculate a normal:


void ComputeNormal(VECTOR3D* v1, VECTOR3D* v2, VECTOR3D* v3)
{
VECTOR3D a(0.0f, 0.0f, 0.0f);
VECTOR3D b(0.0f, 0.0f, 0.0f);
VECTOR3D result(0.0f, 0.0f, 0.0f);
float length;

a.vertex[0]= v1->vertex[0] - v2->vertex[0];
a.vertex[1]= v1->vertex[1] - v2->vertex[1];
a.vertex[2]= v1->vertex[2] - v2->vertex[2];

b.vertex[0]= v1->vertex[0] - v3->vertex[0];
b.vertex[1]= v1->vertex[1] - v3->vertex[1];
b.vertex[2]= v1->vertex[2] - v3->vertex[2];

result.vertex[0]= (a.vertex[1]*b.vertex[2]) - (b.vertex[1]*a.vertex[2]);
result.vertex[1]= (b.vertex[0]*a.vertex[2]) - (a.vertex[0]*b.vertex[2]);
result.vertex[2]= (a.vertex[0]*b.vertex[1]) - (b.vertex[0]*a.vertex[1]);

//Calculate the length of the normal
length= (float)sqrt(SQUARE(result.vertex[0]) +
SQUARE(result.vertex[1]) +
SQUARE(result.vertex[2]));

//Normalize, and send to OpenGL
glNormal3f(result.vertex[0]/length, result.vertex[1]/length, result.vertex[2]/length);


Note that this function is *REALLY* a speed hazard. Especially the call to sqrt(...) . Owwww

------------------------------
Trent (ShiningKnight)
E-mail me
OpenGL Game Programming Tutorials

Edited by - ShiningKnight on June 21, 2001 4:26:55 PM
0

Share this post


Link to post
Share on other sites
I know that I have to send the normals. I read them from the file.

But I don''t know why, I get this strange image. May be the program has a "bug" and doesn''t saves them correctly.
0

Share this post


Link to post
Share on other sites
I know that I have to send the normals. I read them from the file.

But I don''t know why, I get this strange image. May be the program has a "bug" and doesn''t saves them correctly.
0

Share this post


Link to post
Share on other sites
Maybe you could draw the normals.

VECTOR3 a,b,c; // the points for a triangle
VECTOR3 m = (a + b + c) / 3.0; // center of the triangle
VECTOR3 e = m + normal * 10.0; // end of normal line

glBegin(GL_LINES);
glVertex3f(m.x, m.y, m.z);
glVertex3f(e.x, e.y, e.z);
glEnd();

But from the look of the cube i would guess the x and z (or other combination) coordinates are swaped...
0

Share this post


Link to post
Share on other sites
The problem was that Nendo saves the normals incorrectly, because when using a converter I get the expected results. Well, not exactly what I expected ...

Now I have another problem. All is tinted in blue!! I don''t use alpha and nor the light nor the materials have a great blue component. Any idea of what is the error?

Thanks for the tip of drawing the normals!!
0

Share this post


Link to post
Share on other sites