• 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.
Sign in to follow this  
Followers 0

tutorial 10 camera code, problem

4 posts in this topic

I used the tutorial 10 camera code in one of my project, as I started OpenGL 3 days ago I'm not sure about my Opengl INIT.

my problem is the following, if I only do translation or Y rotation everything looks fine.
But as soon as I do X rotation my sector get "seprarated"


this is my init

private void initGL() {

GL11.glEnable(GL11.GL_TEXTURE_2D);//texture mapping
GL11.glShadeModel(GL11.GL_SMOOTH);//smooth shading
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);//couleur de fond noire
GL11.glClearDepth(1.0);//setup du buffer de profondeur
GL11.glEnable(GL11.GL_DEPTH_TEST);//permet le test de profondeur
GL11.glDepthFunc(GL11.GL_LEQUAL); //le type de test de profondeur a faire
GL11.glMatrixMode(GL11.GL_PROJECTION);//selectrione la matrice de projection
GL11.glLoadIdentity();//reset la matrice de projection
// Calcul l'aspect ratio de la fenetre
(float) displayMode.getWidth() / (float) displayMode.getHeight(),

GL11.glMatrixMode(GL11.GL_MODELVIEW);//selectionne la modelview Matrix
GL11.glColor4f(1.0f,1.0f,1.0f,0.3f); // Full luminosité, 30% Alpha
GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE); // Blending mode one
// met les melleur parametre

any problem in it? (projection mode or something)

as for the rendering algorythm, I don't think that there is any problem with it.
it's quite simple.

I made a function that draw cube where I want (from the current position).
I have 16x256x16 sectors containing 65k cubes
a world is 9x9 sectors large.

I draw the world line by line

world top view
|Sec Sec Sec <- World line 3
|Sec Sec Sec
|Sec Sec Sec <-World line 1

and a sector is drawed layer by lawer

GL11.glTranslatef(xtrans, ytrans, ztrans); //starting position

//drawing each sector
for (int zsect=0 ; zsect < displayArea; zsect++)
for (int xsect=0 ; xsect < displayArea; xsect++){
chunk = world.getSector((short)xsect, (short)zsect);
//drawing each layer
for(int yc=0; yc<256; yc++){
for(int zc=0; zc<16;zc++){
for(int xc=0; xc<16; xc++){

chunk.drawCube(xc.yc.zc,0.5f) //0.5f is a x translation
GL11.glTranslatef(-16.0f, 0.0f, 1.0f); //goes where line+1 of the layer is starting
GL11.glTranslatef(0.0f, 1.0f, -16.0f); //goes where layer+1 is starting
GL11.glTranslatef(16.0f, -256.0f, 0.0f); //goes where the next chunk on the line is starting
GL11.glTranslatef(-(float)(displayArea*16.0f), 0.0f, 16.0f);//goes at the beginning of the next chunk line


video examples, chunk generation :
world generation

any idea?

thanks =D

Share this post

Link to post
Share on other sites
after several hours af tweaking I am still unsuccessful.

however since each chunk is drawed perfectly and the problem occurs just betwen them, I think the problem here is mathematical precision.

indeed, each chunk is drawed layer by layer, the cursor is only moved from 1f on Y betwen each layer.
but when you want to draw the next chunk you need to get down from 256f on Y.

since the camera is using sin, cos, a precalculation of 1/180*pi [b]may be[/b], a slight offset appears and screw with my grid positioning.

I don't really see how to solve that :/

Share this post

Link to post
Share on other sites

I think the problem is the 1.0f in your glTranslatef calls. Remember that glTranslatef will translate your whole scene about the vector your plug in, and by calling it several times these translations are accumulated. So if you want to stay on one of your grid lines, you just advance x or z by 16, but leave all others 0.

Hope that helps even though we kept you waiting so long.. :)

Share this post

Link to post
Share on other sites
thanks for your awnser, but I still don't get it =p

I have to make some 1.0f translation, because once the first layer of the chunk is displayed I have to draw the next one, wich is 1.0f above.

Share this post

Link to post
Share on other sites
Look into using the built-in matrix stack, specifically glPushMatrix, glLoadIdentity and glPopMatrix.

This will allow you to keep your transforms from interfering with eachother (transforms from other objects).

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0