Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

124 Neutral

About ashstampede

  • Rank

Personal Information

  • Interests
  1. You just need to apply for jobs. You’ve got a lot of experience. Three shipped game titles is Big. You’re underselling your past game experience, even in your post here asking others to review. I’m in the same mind set as youself and doing the night/weekend games programmer and a Day time business programmer. If I had already complied up a portfolio like you have. I would have already applied to all game companies in my area.
  2. ashstampede

    model loader really slow

    Quote: You have to duplicate vertices because the same vertex may have different normal or texture coordinate for different triangles it is shared by. If you do it this way then building the buffers is trivial. that to me sounds like I should just have the data as is in the VBO, and dont do indices.
  3. ashstampede

    model loader really slow

    looking over your code, that you supplied that isnt where I have my problem, I load in the mesh data into my program fast and fine. Its when I am building Vertex Buffer with Indices and I dont want duplicates vertices.
  4. ashstampede

    building VBO from model data

    SO i have attempted at reading the vertex,uv and normals and creating a IBO to cross reference the VBO. But It doesnt seem to work at all, now this is taken from robthebloke.org obj loader. http://www.robthebloke.org/opengl_programming.html#5 But I have altered it as he used C style malloc and realloc to change the original uv,vertex and normal arrays which were pointers. I use vectors and my model loading is different from his example. As it stands, small objects, like billboards dont show in the scene and large object go out of bounds. The code below does this gets the mesh data faces,uv,normal,vertex. checks if they have appeared before, if they havnt get the index and assign it to the vertex buffer index array. then create the VBO. But this doesnt work at all, Am i on the right track or is there a simpler way? void ModelManager::ConstructVBO(Object3D &currentMesh) { /* **Create a temporary set of pointers to the old data. * we use the fact that a vector is contiguos set of data */ Vertex *pVT; Vertex *pNT; TexUV *pUT; //short hand pointer Triangle pf; /* ** This is used to keep track of the actual vertex array size created. ** Once the data has been organised into */ unsigned int ActualVertexArraySize=0; /* ** Allocate memory for the vertex array indices */ currentMesh.triangleIndexBuffer = new unsigned int[currentMesh.meshData->numFaces*3]; /*loop the the total number of faces of an object * test each vertex/normal/and uv co-ordinate out of the old data for cross referencing to the index buffer */ bool reuse_element = false; bool end_element = false; unsigned int unreadIndices,m; unreadIndices = m = 0; for(unsigned int currentIn= 0; currentIn < currentMesh.meshData->numFaces; currentIn++) { bool hasNormal =false; bool hasUV = false; //short hand reference pf = currentMesh.meshData->faceList[currentIn]; pVT = &currentMesh.meshData->vertexList[currentIn]; pNT = &currentMesh.meshData->normalList[currentIn]; pUT = &currentMesh.meshData->uvList[currentIn]; //test if we have normals or uvs if(currentMesh.meshData->numUV > 0) hasUV = true; if(currentMesh.meshData->numNormals > 0) hasNormal = true; //loop through a complete triangle, even though this is opengl we have triangulated everything for(unsigned int k = 0 ; k < 3; k++,unreadIndices++) { //temp holders float verts[3]={0},norms[3]={0},uvs[2]={0}; verts[0] = pVT[ pf.vertIndices[k] ].x; verts[1] = pVT[ pf.vertIndices[k] ].y; verts[2] = pVT[ pf.vertIndices[k] ].z; //do we have normals if(hasNormal) { norms[0] = pNT[ pf.normalIndices[k] ].x; norms[1] = pNT[ pf.normalIndices[k] ].y; norms[2] = pNT[ pf.normalIndices[k] ].z; } //do we have textures if(hasUV) { uvs[0] = pUT[ pf.uvIndices[k] ].u; uvs[1] = pUT[ pf.uvIndices[k] ].v; } //if we have incremented the IBO we check against the indices and vertex we have crossed referenced //with the other vertex data of the obj. for(unsigned int l = 0; l < ActualVertexArraySize; l++) { //always have vertices so compare what we have in the VBO and what in the MeshData if( AreEqualRelative( currentMesh.meshData->vertexList[unreadIndices].x, verts[0] ) && AreEqualRelative( currentMesh.meshData->vertexList[unreadIndices].y, verts[1] ) && AreEqualRelative( currentMesh.meshData->vertexList[unreadIndices].z, verts[2] ) ) { //the object has normal data, check if we alreadh have it if(hasNormal) { if( AreEqualRelative(currentMesh.meshData->normalList[unreadIndices].x, norms[0] ) && AreEqualRelative( currentMesh.meshData->normalList[unreadIndices].y, norms[1] ) && AreEqualRelative( currentMesh.meshData->normalList[unreadIndices].z, norms[2] ) ) { //it has texture data as well if(hasUV) { if( AreEqualRelative( currentMesh.meshData->uvList[unreadIndices].u, uvs[0] ) && AreEqualRelative( currentMesh.meshData->uvList[unreadIndices].v, uvs[1] ) ) { reuse_element = true; } } else reuse_element = true; } } //didnt have normal data but still might have texture data else if(hasUV) { if( AreEqualRelative( currentMesh.meshData->uvList[unreadIndices].u, uvs[0] ) && AreEqualRelative( currentMesh.meshData->uvList[unreadIndices].v, uvs[1] ) ) { reuse_element = true; } } else reuse_element = true; }//end the compare of vertex data if(reuse_element) break; }//end l++ actaulvertexarraysize if(!reuse_element) { //populate the currentMesh arrays Vertex tempVT; tempVT.x = verts[0]; tempVT.y = verts[1]; tempVT.z = verts[2]; currentMesh.meshData->vertexList.push_back(verts); if(currentMesh.meshData->numNormals > 0) { Vertex tempNT; tempNT.x = norms[0]; tempNT.y = norms[1]; tempNT.z = norms[2]; currentMesh.meshData->normalList.push_back(tempNT); } if(currentMesh.meshData->numUV > 0) { TexUV tempUV; tempUV.u = uvs[0]; tempUV.v = uvs[1]; currentMesh.meshData->uvList.push_back(tempUV); } //we jumped out of the array, so move our counter forward currentMesh.triangleIndexBuffer[m] = ActualVertexArraySize++; end_element = true; } else { currentMesh.triangleIndexBuffer[m] = unreadIndices; reuse_element = false; } if(end_element) { ++m; end_element = false; } }//end k++ face triangle loop pVT = NULL; pNT = NULL; pUT = NULL; }// end i++ less the total faces currentMesh.meshData->numFaces *=3; /* ** Zero the data counts as they are shared in a union */ currentMesh.meshData->numNormals = 0; currentMesh.meshData->numUV = 0; currentMesh.meshData->numVerts = 0; currentMesh.meshData->vboSize = ActualVertexArraySize; if(GL_ARB_vertex_buffer_object) { /* generate 2 buffers for the vertex buffer objects */ glGenBuffers( 1, &currentMesh.meshData->vboNum ); /* generate a vertex buffer object for the index array */ glGenBuffers( 1, &currentMesh.meshData->vboElemNum ); glBindBuffer( GL_ARRAY_BUFFER, currentMesh.meshData->vboNum ); /* set vertex buffer object size */ glBufferData( GL_ARRAY_BUFFER, 8 * ActualVertexArraySize * sizeof(float), NULL, GL_STATIC_DRAW ); /* load the seperate vertex, normal & tex coord arrays */ glBufferSubData( GL_ARRAY_BUFFER, 0, 3 * ActualVertexArraySize * sizeof(float), &currentMesh.meshData->vertexList[0] ); glBufferSubData( GL_ARRAY_BUFFER, 3 * ActualVertexArraySize * sizeof(float), 3 * ActualVertexArraySize * sizeof(float),&currentMesh.meshData->normalList[0] ); glBufferSubData( GL_ARRAY_BUFFER, 6 * ActualVertexArraySize * sizeof(float), 2 * ActualVertexArraySize * sizeof(float), &currentMesh.meshData->uvList[0]); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, currentMesh.meshData->vboElemNum ); glBufferData( GL_ELEMENT_ARRAY_BUFFER, currentMesh.meshData->numFaces * sizeof(float), currentMesh.triangleIndexBuffer, GL_STATIC_DRAW ); } }//end constuct vbo
  5. ashstampede

    std string bad ptr behaviour

    yeah I went the vector root and that didnt work at all, well the algorithm didnt work in a Vector situation, I originally set out to change some C model loading code to c++. so went with c++ pointer arrays declared with new, when i came to resizing the it corrupted the heap. So i tried vectors and that was a no go simply based on the algorith used in the original.
  6. ashstampede

    std string bad ptr behaviour

    I figured that was the reason, so my problem is bigger than this question, will repost the larger problem at hand.
  7. ashstampede

    model "instancing" with opengl

    goodperiodical, well that is what i dont know how to do, i have gldrawelements as the call to render whats in the vbo. the code is structured as INIT: load model from file, create the size of the vbo and index array, fill vbo,delete local model data, Update: render. is it just a simple as when you are in the update,call render 100 times with different glrot and gltrans? What i had planned was to have a texture, like a height map texture where ever there was white on the texture draw a tree. a side note isn't glDrawRangeElement better than glDrawElements. I ended up using glDrawElements because i couldnt get the data glDrawRangeElements need correctly.
  8. ashstampede

    defining glext functions in two source files?

    glActiveTextureARB(GLenum texture); glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t); glMultiTexCoord2fvARB(GLenum target, const GLfloat *v); glClientActiveTextureARB(GLenum); these above needs a return type specified in you function prototype, at lease that is what that error is.
  9. yeah it will, I realized that "didnt have the results I would have hoped." it just gave me a different memory address for the norms array so I got to the conclusion that the size declaration of [length * width] was giving me the same memory block for two arrays that i only want the same size for.
  10. ashstampede

    OpenGL Vector Based Camera Class Troubles

    Quote: if not please explain(didnt get it): can you move the camera around normally with your mouse? or does a problem only occur if you try to walk left right up or down? or do you only get a problem walking around if you face a certain angle? well my rotation is done with the mouse and it does rotate correctly , so yeah the problems happen with the translation, so when i am walking around when i face the opposite direction its starts to go wrong, as in I look down the camera 0,0,-1 z axis. when i look down the 0,0,1 everything messes up
  11. ashstampede

    [SOLVED]namespace troubles

    Solved, it had to do with my defines, I had some include in between the namespace brackets.
  12. thanks deafman, so it was the #define WIN32_LEAN_AND_MEAN, originally I removed WIN32_EXTRA_LEAN as i assumsed that was the super stripping defines of windows.h code. but i still got a build error, and then i just didnt try the other define like i should have.
  13. yeah ok I have done all of that even before posting. so anyway, i include windows.h as i am making a windowed application i have a define.h that is this #ifdef _WIN32 //define to include mouse wheel #define _WIN32_WINDOWS 0x0400 //define to include extra mouse bottuns //only supported in win 2000/xp and above #define _WIN32_WINNT 0x0500 #define WIN32_LEAN_AND_MEAN #define WIN32_EXTRA_LEAN #include <windows.h> //opengl up to 2.1 and extentions #include <gl/glee.h> #include <gl/glu.h> #include <gl/glaux.h> #elif defined(__APPLE__) || defined(__APPLE_CC__) #include <OpenGL/OpenGL.h> #include <GLUT/glut.h> #endif complie error about timeGettime() did a google serach and then I linked/included the LIBC.lib to my project still get the error about my post.
  14. Currently I am toes deep into my 3rd year project/game/game engine. This is my attempt to mull together what i know and learn what i dont. But the first and formost I am hit with the dreaded graphics engine. The dilemma is that for my finale year project at uni the stipulation is you have to build your own renderer. I dont like graphics, i've never played a game for graphics i comprehend the basic and thus what to build a game engine with a simple renderer. So i have been trying to learn opengl after a years worth of unversity being taught directx. I am also trying to develope genericlly so i can port my work to the mac os x once i get a new one having sold my bottom of the line underpowered ibook. Not being a fan or impressed by graphics in game i plan to make a cel shaded renderer simply because at the heart... or rather at the sight its basic and your gameplay has to shine through other wise you just have months and months of work on a gimmick. I hopefully building a very object oriented project right now I only have the renderer which only creates a window. It tends to complain when i exit out and try to return to my native resolution. I dont know if I should be concerned about that at this stage seeing as i dont even have a cube to the screen. In making the renderer of my game engine I mulling over the archetiture and things I can cut or dont need but a simple renderer. In my head I just want a camera and models loaded. Questions like is there a point to creating a primitive draw class to dynamically draw 3d shapes? Should i load more than one kind of image file or model file etc. Basically how much is need for the bare minimum for a renderer but not to minimum that i hurt myself.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!