Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 05 Jul 2013
Offline Last Active Dec 13 2013 03:08 PM

Topics I've Started

How to manipulate Normals in Blender?

19 November 2013 - 01:17 PM

Hi there,


I am following this tutorial. Here he loads on an .obj file and converts it into a model.txt which is later read and rendered. He created his own .obj in Maya. Now I tried to do the same with blender. I got it all the faces, normals and vertices. But I guess that there is something wrong with normals. Rastertek writes:


This particular .OBJ model file represents a 3D cube. It has 8 vertices, 24 texture coordinates and normal vectors, and 6 sides made up of 12 faces in total.


It says 24 normals. Does that mean he has his normal on the vertices? Because the model I created has only 12 normals. Plus they look kinda strange. They are not placed on the vertices but on faces. I had to create some extra faces by always selecting three vertices and pressing F.


How can I make blender save a normal for every vertex?

How to setup a project template for freeglut in VS2010?

06 November 2013 - 10:25 AM



as described in the freeglut readme I copied the include and lib folders to CommonFiles->MSVC. Now every time I create a project I have to define additional dependencies for compiler and linker. Btw, the readme doesn't say anything about the fact that you have also to set the linker to not icncremental. I also have to add other header files to every new project.


This is annoying because as a beginner I am creating new projects all the time. So how to setup a template for a project? I am using Microsoft Visual C++ 2010 Express. My projects are created as empty Win32-Console applications.




EDIT: This whole OpenGL thing also takes a number of predefined methods (RenderScene(),Reshape()...). Maybe one could add them to such a template too.

Which OpenGL book to pick?

25 October 2013 - 04:42 AM

Hi there,


I am not new to programming but I am a complete newbie to OpenGL. I played around with XNA for a couple of years now and decided to learn opengl. So I got a copy of the superbible 5th edition. The first 4 chapters were ok. But now there are things which I really don't like. 


1. They use their own libraries and .h-files. And I have the impression of only scratching on the surface all the time.

2. The Shader-chapter got me completely confused not least because of the custom Libs and .h


So is there any OpenGL books you could recommend where one can learn it from scratch? I read about "Beginning Opengl Game Programming" would you recommend this?



How to move a rectangle properly?

10 October 2013 - 06:51 AM

I recently started to learn OpenGL. Right now I finished the first chapter of the "OpenGL SuperBible". There were two examples. The first had the complete code and showed how to draw a simple triangle. The second example is supposed to show how to move a rectangle using SpecialKeys. The only code provided for this example was the SpecialKeys method. I still tried to implement it but I had two problems.


  1. In the previous example I declared and instaciated vVerts in the SetupRC() method. Now as it is also used in the SpecialKeys() method, I moved the declaration and instantiation to the top of the code. Is this proper c++ practice?
  2. I copied the part where vertex positions are recalculated from the book, but I had to pick the vertices for the rectangle on my own. So now every time I press a key for the first time the rectangle's upper left vertex is moved to (-0,5:-0.5). This ok because of:
  3. GLfloat blockX = vVerts[0]; //Upper left X
    GLfloat blockY = vVerts[7]; // Upper left Y

    But I also think that this is the reason why my rectangle is shifted in the beginning. After the first time a key was pressed everything works just fine. Here is my complete code I hope you can help me on those two points.

GLBatch squareBatch;
GLShaderManager shaderManager;
//Load up a triangle    
GLfloat vVerts[] = {-0.5f,0.5f,0.0f,

//Window has changed size, or has just been created.
//We need to use the window dimensions to set the viewport and the projection matrix.
void ChangeSize(int w, int h)

//Called to draw the scene.
void RenderScene(void)
    //Clear the window with the current clearing color

    GLfloat vRed[] = {1.0f,0.0f,0.0f,1.0f};


    //perform the buffer swap to display the back buffer

//This function does any needed initialization on the rendering context.
//This is the first opportunity to do any OpenGL related Tasks.
void SetupRC()
    //Blue Background




//Respond to arrow keys by moving the camera frame of reference
void SpecialKeys(int key,int x,int y)
    GLfloat stepSize = 0.025f;
    GLfloat blockSize = 0.5f;
    GLfloat blockX = vVerts[0]; //Upper left X
    GLfloat blockY = vVerts[7]; // Upper left Y

    if(key == GLUT_KEY_UP)
        blockY += stepSize;

    if(key == GLUT_KEY_DOWN){blockY -= stepSize;}

    if(key == GLUT_KEY_LEFT){blockX -= stepSize;}

    if(key == GLUT_KEY_RIGHT){blockX += stepSize;}

    //Recalculate vertex positions
    vVerts[0] = blockX;
    vVerts[1] = blockY - blockSize*2;

    vVerts[3] = blockX + blockSize * 2;
    vVerts[4] = blockY - blockSize *2;

    vVerts[6] = blockX+blockSize*2;
    vVerts[7] = blockY;

    vVerts[9] = blockX;
    vVerts[10] = blockY;



//Main entry point for GLUT based programs
int main(int argc, char** argv)
    //Sets the working directory. Not really needed
    //Passes along the command-line parameters and initializes the GLUT library.
    //Tells the GLUT library what type of display mode to use, when creating the window.
    //Double buffered window, RGBA-Color mode,depth-buffer as part of our display, stencil buffer also available
    //Window size
    //initialize GLEW library
    GLenum err = glewInit();

    //Check that nothing goes wrong with the driver initialization before we try and do any rendering.
    if(GLEW_OK != err)
        fprintf(stderr,"Glew Error: %s\n",glewGetErrorString);

        return 1;


    return 0;

How to avoid cutting corners with A* pathfinding?

05 July 2013 - 09:44 AM

On my second try with A* I managed to calculate all values needed for traceback. Also marked the starting cell with S, blocked with B and the goal cell with F.






Now for the backtracking I would simply follow the cells with lowest G value, starting from goal cell. Here I would follow G=24 => G=10 => S.

As you can see this solution would create a path which is not valid because it leads throught a wall in this case.


This hangs together with corner cutting when calculating the values for a grid. As you can see here. One would backtrace: G=50 => G= 40 and here one would take G=20 next. This leads to the corner cutting.




I think this issue occurs when calculating the values for each adjacent cell. Maybe I could avoid this if I set some restrictions when adding adjacent cells to the current cell?

public List<Cell> GetAdjacent(Cell _currentCell, List<Cell> _closedList, List<Cell> _gridList) 
        List<Cell> adjacentList = new List<Cell>();
        List<Cell> gridList = _gridList;
        List<Cell> closedList = _closedList;
        Cell currentCell = _currentCell;

        foreach (Cell cell in gridList) 
            bool containedInClosedList = closedList.Any(c => c.id == cell.id);

            if (!cell.blocked && !containedInClosedList && 
                ((cell.positionCR.X == currentCell.positionCR.X - 1 && cell.positionCR.Y == currentCell.positionCR.Y) ||
                (cell.positionCR.X == currentCell.positionCR.X + 1 && cell.positionCR.Y == currentCell.positionCR.Y) ||
                (cell.positionCR.X == currentCell.positionCR.X && cell.positionCR.Y == currentCell.positionCR.Y - 1) ||
                (cell.positionCR.X == currentCell.positionCR.X && cell.positionCR.Y == currentCell.positionCR.Y + 1) ||
                (cell.positionCR.X == currentCell.positionCR.X - 1 && cell.positionCR.Y == currentCell.positionCR.Y - 1) ||
                (cell.positionCR.X == currentCell.positionCR.X - 1 && cell.positionCR.Y == currentCell.positionCR.Y + 1) ||
                (cell.positionCR.X == currentCell.positionCR.X + 1 && cell.positionCR.Y == currentCell.positionCR.Y - 1) ||
                (cell.positionCR.X == currentCell.positionCR.X + 1 && cell.positionCR.Y == currentCell.positionCR.Y + 1)))


        return adjacentList;

Could it also be a problem with the custom costs I defined? I took a G=10 for straight and G=14 for diagonal cells.


I think this is the last thing which stops me from finishing the algorithm, so I am looking forward for any help or constructive input.

Thanks in advance!