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

luckyyyyyy

Members
  • Content count

    116
  • Joined

  • Last visited

Community Reputation

145 Neutral

About luckyyyyyy

  • Rank
    Member
  1. I can successfully read and load the objects like ur code. But I am unable to read Color info.. means color of objects that we reading from the file. actually there are many ways to read 3DS chunks on the internet but in our way how can we read color info ? U can see my code here.. [CODE] //OBJ_TRIMESH //TRI_VERTEXL //TRI_FACEL1 //TRI_MAPPINGCOORS case 0xa020: // diffuse color if(1) { case 0×0010: // Color F fread (&red, sizeof(float), 1, l_file); fread (&green, sizeof(float), 1, l_file); fread (&blue, sizeof(float), 1, l_file); //if (!ReadFloat(fp, red)) return FALSE; //if (!ReadFloat(fp, green)) return FALSE; //if (!ReadFloat(fp, blue)) return FALSE; break; case 0×0011: // Color 24 fread (&red, sizeof(float), 1, l_file); fread (&green, sizeof(float), 1, l_file); fread (&blue, sizeof(float), 1, l_file); //if (!ReadUByte(fp, tmp)) return FALSE; //red = (float) tmp / (float) 255.0; //if (!ReadUByte(fp, tmp)) return FALSE; //green = (float) tmp / (float) 255.0; //if (!ReadUByte(fp, tmp)) return FALSE; //blue = (float) tmp / (float) 255.0; break; } break; [/CODE] [quote] Think of Design with Dimensions http://real3d.pk [/quote]
  2. haha.. NO i dont have any issue now... working like charm.. thanks to u. [quote]Think of Design with Dimensions [url="http://real3d.pk"]http://real3d.pk[/url][/quote]
  3. Thanks for your precious time. Now its solved. I mention the problem below. Usually we used to ignore (float or double) variables during programming, I think we should not. [CODE] GLpoint GetOGLMousePos(GLint x, GLint y) { GLfloat winX = 0.0, winY = 0.0, winZ = 0.0; // never ever make a mistake between float and double. I wasted my 4 days to solve this and the problem was, I was using GLdouble here instead of GLfloat. Try GLdouble here you will see a hell difference in output values. GLdouble posX = 0.0, posY = 0.0, posZ = 0.0; winX = (float)x; winY = (float)OGLMviewport[3] - (float)y; // invert winY so that down lowers value glReadPixels( x, int(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ ); gluUnProject( winX, winY, winZ, OGLMmodelview, OGLMprojection, OGLMviewport, &posX, &posY, &posZ); return GLpoint(posX, posY, -posZ); // invert z value } [/CODE] [quote] Think of Design with Dimensions [url="http://real3d.pk"]http://real3d.pk[/url] [/quote]
  4. haha.. I like the way u teaching.. ;) I got your point.. i do not want any kind of line intersection of whatever. I just want that when I click on model I get 3D coordinates. I did what u said at the end. But didn't get this ? (when want to click) change perspective to 'nicest z_near/z_far aspect ratio) now tell me where I am doing wrong? [CODE] void glPerspective() { glViewport(0, 0, WINDOW_SIZE_W, WINDOW_SIZE_H); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0, (GLdouble)WINDOW_SIZE_W / (GLdouble)WINDOW_SIZE_H, 0.1, 10000.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0.0, 0.0, m_zoom, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); } void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPerspective(); glPushMatrix(); glTranslatef(screenX, 0.0, 0.0); glTranslatef(0.0, screenY, 0.0); glRotatef(spin_y, 1.0, 0.0, 0.0); glRotatef(spin_x, 0.0, 1.0, 0.0); glRotatef(spin_z, 0.0, 0.0, 1.0); glGetDoublev( GL_MODELVIEW_MATRIX, OGLMmodelview ); glGetDoublev( GL_PROJECTION_MATRIX, OGLMprojection ); glGetIntegerv( GL_VIEWPORT, OGLMviewport ); Render_Triangular_model(); glPopMatrix(); glutSwapBuffers(); } GLpoint GetOGLMousePos(GLint x, GLint y) { GLdouble winX = 0.0, winY = 0.0, winZ = 0.0; GLdouble posX = 0.0, posY = 0.0, posZ = 0.0; winX = (float)x; winY = (float)OGLMviewport[3] - (float)y - 1; // invert winY so that down lowers value glReadPixels( x, GLint(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ ); gluUnProject( winX, winY, winZ, OGLMmodelview, OGLMprojection, OGLMviewport, &posX, &posY, &posZ); return GLpoint(posX, posY, posZ); } [/CODE] [quote] Think of Design with Dimensions http://real3d.pk [/quote]
  5. I have tried everything but not getting the exact X and Y values. I am applying glPerspective() in real-time (display function) thats why I think I have to apply it with a specific matrix but i dont know which matrix. I do not want to select vertex or something like that I just need 3D coordinates at the click position. [quote] Think of Design with Dimensions http://real3d.pk [/quote]
  6. I want to get the mouse click position in 3D. Below is my code, its simple, I am not doing wrong in it but I don't know why I am always getting X and Y values are wrong. I think Maximum X = 0.072345664 and Y = 0.04124355 . something like this. where I am doing wrong.. ? Why I am not getting the exact values of x and y ? Z value is OK. Only issue with X and Y. any idea ? Thanks [CODE] void glPerspective() { glViewport(0, 0, WINDOW_SIZE_W, WINDOW_SIZE_H); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0, (GLdouble)WINDOW_SIZE_W / (GLdouble)WINDOW_SIZE_H, 0.1, 100000.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0.0, 0.0, m_zoom, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); } void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glPerspective(); // perspective view Some_rotation_and_translation(); Render_Triangular_model(); glPopMatrix(); swapbuffer(); } GLpoint GetOGLMousePos(GLint x, GLint y) { GLdouble winX = 0.0, winY = 0.0, winZ = 0.0; GLdouble posX = 0.0, posY = 0.0, posZ = 0.0; GLint OGLMviewport[4]; //stores viewport information GLdouble OGLMmodelview[16]; GLdouble OGLMprojection[16]; glGetDoublev( GL_PROJECTION_MATRIX, OGLMprojection ); glGetDoublev( GL_MODELVIEW_MATRIX, OGLMmodelview ); glGetIntegerv( GL_VIEWPORT, OGLMviewport ); //transfers viewport info into viewport array. winX = (float)x; winY = (float)OGLMviewport[3] - (float)y; // invert winY so that down lowers value glReadPixels( x, GLint(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ ); gluUnProject( winX, winY, winZ, OGLMmodelview, OGLMprojection, OGLMviewport, &posX, &posY, &posZ); return GLpoint(posX, posY, posZ); } [/CODE] Output 3D coordinates (top right section of the OpenGL display screen): [CODE]-0.000810418, 0.0011706, 99.9 0.00288149, 0.00126065, 99.9 0.00981506, 0.00144074, 99.9 0.0157581, 0.00171088, 99.9 0.0249429, 0.00171088, 99.9 0.0367389, 0.00180093, 99.9 0.0468241, 0.00180093, 99.9 0.0557387, 0.00225116, 99.9 0.065914, 0.00243125, 99.9 -0.000990511, 0.0105354, 99.9 -0.0013507, 0.017379, 99.9 -0.0013507, 0.0225116, 99.9 -0.00171088, 0.0268338, 99.9 -0.00171088, 0.0313362, 99.9 -0.00207107, 0.0380896, 99.9 0.0724874, 0.0404308, 99.9 0.0744684, 0.0411512, 99.9 // top right corner[/CODE] [quote] Think of Design with Dimensions http://real3d.pk [/quote]
  7. I don't know what's wrong here, everything is working fine except normals. When I use vertex array, model looks perfect but when I switch to VBO, model looks worse because of vertex normals. I spent a lot of time to fix it but do not know what's wrong. VBO generation seems perfect. but still do not know. any idea? [code] #define BUFFER_OFFSET(i) ((char *)NULL + (i)) void InitVBO() { glGenBuffers(1, &vboNormID); glBindBuffer(GL_ARRAY_BUFFER, vboNormID); glBufferData(GL_ARRAY_BUFFER, sizeof(GLpoint)*nb_Vertices, NULL, GL_DYNAMIC_DRAW); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(GLpoint)*nb_Vertices, VertNormals); glNormalPointer(GL_FLOAT, sizeof(GLpoint), BUFFER_OFFSET(12)); glGenBuffers(1, &vboVertID); glBindBuffer(GL_ARRAY_BUFFER, vboVertID); glBufferData(GL_ARRAY_BUFFER, sizeof(GLpoint)*nb_Vertices, NULL, GL_DYNAMIC_DRAW); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(GLpoint)*nb_Vertices, p_VERTICES); glVertexPointer(3, GL_FLOAT, sizeof(GLpoint), BUFFER_OFFSET(0)); glGenBuffers(1, &indexVBOID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexVBOID); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLFace)*nb_Faces, NULL, GL_DYNAMIC_DRAW); glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(GLFace)*nb_Faces, p_indices); //glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLFace)*nb_Faces, p_indices, GL_DYNAMIC_DRAW);} [/code] Rendering code is followed. (VBO + Vertex Array). Vertex array is working perfect. I can see the perfect shape of model with vertex normals, but with VBO there is some issue with vertex normals. I think I am doing something wrong with BUFFER_OFFSET(12). [code] void RenderTringularModel(GLvoid) { if(VertNormals && !MESH_SMOOTH) { glBindBuffer(GL_ARRAY_BUFFER, vboNormID); glBindBuffer(GL_ARRAY_BUFFER, vboVertID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexVBOID); glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT ); glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); glNormalPointer(GL_FLOAT, sizeof(GLpoint), BUFFER_OFFSET(12)); glVertexPointer(3, GL_FLOAT, sizeof(GLpoint), BUFFER_OFFSET(0)); glDrawElements(GL_TRIANGLES, nb_Faces*3, GL_UNSIGNED_INT, BUFFER_OFFSET(0)); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glPopClientAttrib(); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } else { //glShadeModel (GL_FLAT); glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT ); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glVertexPointer(3, GL_FLOAT, sizeof(GLpoint), p_VERTICES); glNormalPointer(GL_FLOAT, sizeof(GLpoint), VertNormals); glDrawElements(GL_TRIANGLES, 3*nb_Faces, GL_UNSIGNED_INT, p_indices); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glPopClientAttrib(); } [/code] [img]http://i.stack.imgur.com/pnY2I.jpg[/img]
  8. I am rendering lines over 3D triangular mesh in order to visualize the mesh triangles. Well-known feature of every 3D modeling software right? but I am drawing the line with glVertex3f, How can I draw with vertex buffer or vertex array. and how can i optimize this code.. because with this code, i am getting very low FPS... just 15.. any idea ? [code] void RenderModelMeshAsLines(GLpoint *P, GLFace *T, int nbF) { if(nbF > 0) { glLineWidth(2.0); // Set The Line Width GLfloat r=0.0f, g=0.0f, b=0.0f; glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_LIGHTING_BIT | GL_LINE_BIT); glPushMatrix(); glBegin(GL_LINE); for (int i=0; i<nbF; i++) { DrawLine(P[T[i].v1], P[T[i].v2], r,g,b); DrawLine(P[T[i].v2], P[T[i].v3], r,g,b); DrawLine(P[T[i].v3], P[T[i].v1], r,g,b); } glEnd(); glPopMatrix(); glPopAttrib(); glLineWidth(1.0); // Set The Line Width } } [/code] Draw a line... [code] void DrawLine(GLpoint a, GLpoint b, float R, float G, float B) { glPushMatrix(); glDisable(GL_LIGHTING); glEnable(GL_LINE_SMOOTH); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_LINES); glColor3f(R, G, B); glVertex3f(a.x, a.y, a.z); glVertex3f(b.x, b.y, b.z); glEnd(); glPopMatrix(); } [/code]
  9. actually my function is working perfectly with both projections if you take individually. but the issue is that when i switch from gluPerspective to glOrtho the model move little far. not at the same position as in perspective view. I don't why but at zoom factor = 60 the model keeps same position in both projections. In my observation, if the zoom factor in gluPerspective mode is 75 then it must be 45 in the glOrho. but if zoom factor 75 in gluPerspective then the model look bigger but in glOrtho the model moves far... but i want that whatever the situation is the model must be at same zoom level when i press swich mode from gluPers to glOrtho OR glOrtho to gluPerspective. I need a relationship between both projections, by using that i can have what i want. means how must i need to scale in glOrtho that i can achieve same zoom as in gluPerspective.
  10. No I am not talking about gluPerspective.... I can zoom in and out with above function.. but I want that the model position should be the same when i switch one to another. I am using glTranslatef on the object.. so i can zoom in and zoom out ... I want the relationship between glortho and gluPerspective in which whatever i select i just see the effect of projection. but now at this time.. when i press the glOrtho the object moves little bit far but in perspective it moves to near .. it must be at same position. right?
  11. Actually I can zoom in and zoom out with both projections.. but the issue is.. i am unable to manage the similar zoom with glortho.. i mean to say the model must be at the same location when i switch to glortho.. zooming should be equal in glPerspective and glortho.. my switch function.. [code] glViewport(0, 0, WIN_WIDTH, WIN_HEIGHT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if(ortho) { double left = -(double)WIN_WIDTH/2.0; double right = (double)WIN_WIDTH/2.0; double bottom = -(double)WIN_HEIGHT/2.0; double top = (double)WIN_HEIGHT/2.0; float scale = 0.005; glOrtho(left*scale*(m_zoom+60.0), right*scale*(m_zoom+60.0), bottom*scale*(m_zoom+60.0), top*scale*(m_zoom+60.0), -10000.0, 10000.0); gluLookAt(0.0, 0.0, 200.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } else { gluPerspective(45.0, aspect, 0.1, 10000.0); gluLookAt(0.0, 0.0, 200.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } in perspective case... i use glTranslatef for zoom in and out... guide me how can i make same zoom with both.. [/code]
  12. Solved.. I have done it. Now i can import stl and can export ply or obj.
  13. Its really simple... I want to load the *.stl vertices and faces into my *.obj or *.ply data structures. Following is the data structure that can be used with *.obj or *.ply. But we can not use this data structure for *.stl. For *.stl we do not know the indices information. I want to extract that information. for example triangle (indic1, indic2, indic3). So this the issue to use the same data structure for *.stl. struct GLpoint { float x, y, z; }; GLpoint *Vertices; struct GLface { unsigned int v1, v2, v3; }; GLface *indinces; Thanks.
  14. Actually, I want to convert *.stl file format into *.ply or *.obj. The reason is that, stl file doesn't contain the triangles information. its just contains vertices. (normals is not an issue here..). But I want the triangular information like *.ply or *.obj has. triangular means..*ply or *obj file format vertex 0 0 0 vertex 0 1 0 vertex 1 1 0 vertex 1 0 0 face 1 2 3 face 1 2 4 above code has two triangles and 4 vertices. right? but *stl file doesn't contain any kind of face information. I don't have any issue to read *stl or write *stl ... I can even render the 3D stl model. My issue is I just want to convert this *.stl file format into *.ply or *obj. I spent too much time on net but didn't find any kind of code or idea relevant to this. Kindly give me some idea that how can I convert it. How can i extract face information from stl ? thanks.