Sign in to follow this  
game_dev01

OpenGL problem with milkshape model loading

Recommended Posts

game_dev01    100
Hey all..

I wanted to laod my milkshape car model in opengl and took help from Nehe's lesson no. 31 for it and though, model was loaded properly but to my grief, its textures are not loaded. and also, when i browsed through Nehe's code, i couldn't find assignment of transparency of the material. Currently, i am getting only "white" car which is looking very sluggish..

Can anybody help me out with it?? I'll be very thankful for ur help!! :)

Share this post


Link to post
Share on other sites
Argo15    122
I believe when you read the file it only gives you the name of the texture (carTex.tga for example). It's up to you to give the location of the texture
("Data/Textures/"+TextureName).

Try just binding the texture manually before the car is drawn.

Share this post


Link to post
Share on other sites
game_dev01    100
Hey.. thanx a lot Agro for ur help.. i changed the directory where i was placing my textures and thus, got the problem solved!! ;) :)
But, now another one faces me!! how can i detect collision of the model i loaded into opengl with any object..
(here i loaded a car in opengl and i have to detect its collision with any obstacle on the road) .. how can i accomplish that???

Share this post


Link to post
Share on other sites
Atrix256    539
How collision is handled for the most part in 3d games is not actually checking if the 3d models (meshes) collide, but rather, they check simplified shapes of the objects.

For instance for a player, they may substitute a cylinder or a box in collision detection.

For a space ship, a sphere may be used.

For a car, a box might work, or a couple boxes.

Sometimes after doing the simplified shape test, games then test versus the individual polygons in a model but that's fairly rare or only used in special circumstances.

collision detection (and response) is an incredibly in depth subject. I suggest starting simple by wrapping your objects in simple shapes and just collision test those simple shapes (:

Share this post


Link to post
Share on other sites
game_dev01    100
hmm.. thanx a lot for ur quick reply.. :)
i think since m just a beginner so taking simple shape should work!! ;)
by the way, can u please also tell me that is there any other way to translate an object in opengl than translating the whole opengl window (using glTranslatef). this also applies for rotation and all other transformations also.. since, i wish to rotate the tyres of my car irrespective of the whole car body.. Can this be done??

Share this post


Link to post
Share on other sites
assainator    685
I know a quick hack but this isn't something you would want to use.

First rotate the model vertices yourself around the center of you object
Then add the translation to the vertices.

This generates the same effect.



But I'm getting the idea you need this snippet

//Load identity matrix, everything will be rendered at (0,0,0)
glLoadIdentity()

//Save the identity matrix by pushing it onto the matrix stack
glPushMatrix();

//Do a translation (also works for rotation), everything will be rendered at (50,100,-10)
glTranslatef(50, 100, -10);

//Render the object
Object->Render();

//Pop back the matrix, everything will be rendered at (0,0,0) again
glPopMatrix();



You can do this multiple times.

Hope it helps

Share this post


Link to post
Share on other sites
Triton    138
Quote:
Original post by game_dev01
hmm.. thanx a lot for ur quick reply.. :)
i think since m just a beginner so taking simple shape should work!! ;)
by the way, can u please also tell me that is there any other way to translate an object in opengl than translating the whole opengl window (using glTranslatef). this also applies for rotation and all other transformations also.. since, i wish to rotate the tyres of my car irrespective of the whole car body.. Can this be done??


Well you can push and pop transformation matrices from a stack (glPush/glPopMatrix) so it only applies to the objects you want.

But the current non-deprecated way to do what you want is by using shaders with your own transformation matrices. That way you can keep each object translation separate and send it to the shader (as the model/view matrix) when you want to draw the object.

Share this post


Link to post
Share on other sites
game_dev01    100
ohk.. so that means i need to perform this push and pop when tyres are drawn.. right??/ bt problem is i am drawing the whole car on loading from milkshape 3d.. so actually i dont know tyres vertices also.. and i wish to rotate tyres only when car is moving that is when "up' arrow key is pressed.. at that tym i wish to move car and at the same time rotate its tyres.. till now i am moving car on dis key event.. where and how shud i add this push/pop matrix function for rotating my tyres??

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  

  • Similar Content

    • By markshaw001
      Hi i am new to this forum  i wanted to ask for help from all of you i want to generate real time terrain using a 32 bit heightmap i am good at c++ and have started learning Opengl as i am very interested in making landscapes in opengl i have looked around the internet for help about this topic but i am not getting the hang of the concepts and what they are doing can some here suggests me some good resources for making terrain engine please for example like tutorials,books etc so that i can understand the whole concept of terrain generation.
       
    • By KarimIO
      Hey guys. I'm trying to get my application to work on my Nvidia GTX 970 desktop. It currently works on my Intel HD 3000 laptop, but on the desktop, every bind textures specifically from framebuffers, I get half a second of lag. This is done 4 times as I have three RGBA textures and one depth 32F buffer. I tried to use debugging software for the first time - RenderDoc only shows SwapBuffers() and no OGL calls, while Nvidia Nsight crashes upon execution, so neither are helpful. Without binding it runs regularly. This does not happen with non-framebuffer binds.
      GLFramebuffer::GLFramebuffer(FramebufferCreateInfo createInfo) { glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); textures = new GLuint[createInfo.numColorTargets]; glGenTextures(createInfo.numColorTargets, textures); GLenum *DrawBuffers = new GLenum[createInfo.numColorTargets]; for (uint32_t i = 0; i < createInfo.numColorTargets; i++) { glBindTexture(GL_TEXTURE_2D, textures[i]); GLint internalFormat; GLenum format; TranslateFormats(createInfo.colorFormats[i], format, internalFormat); // returns GL_RGBA and GL_RGBA glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, createInfo.width, createInfo.height, 0, format, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); DrawBuffers[i] = GL_COLOR_ATTACHMENT0 + i; glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, textures[i], 0); } if (createInfo.depthFormat != FORMAT_DEPTH_NONE) { GLenum depthFormat; switch (createInfo.depthFormat) { case FORMAT_DEPTH_16: depthFormat = GL_DEPTH_COMPONENT16; break; case FORMAT_DEPTH_24: depthFormat = GL_DEPTH_COMPONENT24; break; case FORMAT_DEPTH_32: depthFormat = GL_DEPTH_COMPONENT32; break; case FORMAT_DEPTH_24_STENCIL_8: depthFormat = GL_DEPTH24_STENCIL8; break; case FORMAT_DEPTH_32_STENCIL_8: depthFormat = GL_DEPTH32F_STENCIL8; break; } glGenTextures(1, &depthrenderbuffer); glBindTexture(GL_TEXTURE_2D, depthrenderbuffer); glTexImage2D(GL_TEXTURE_2D, 0, depthFormat, createInfo.width, createInfo.height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthrenderbuffer, 0); } if (createInfo.numColorTargets > 0) glDrawBuffers(createInfo.numColorTargets, DrawBuffers); else glDrawBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) std::cout << "Framebuffer Incomplete\n"; glBindFramebuffer(GL_FRAMEBUFFER, 0); width = createInfo.width; height = createInfo.height; } // ... // FBO Creation FramebufferCreateInfo gbufferCI; gbufferCI.colorFormats = gbufferCFs.data(); gbufferCI.depthFormat = FORMAT_DEPTH_32; gbufferCI.numColorTargets = gbufferCFs.size(); gbufferCI.width = engine.settings.resolutionX; gbufferCI.height = engine.settings.resolutionY; gbufferCI.renderPass = nullptr; gbuffer = graphicsWrapper->CreateFramebuffer(gbufferCI); // Bind glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); // Draw here... // Bind to textures glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textures[0]); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, textures[1]); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, textures[2]); glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, depthrenderbuffer); Here is an extract of my code. I can't think of anything else to include. I've really been butting my head into a wall trying to think of a reason but I can think of none and all my research yields nothing. Thanks in advance!
    • By Adrianensis
      Hi everyone, I've shared my 2D Game Engine source code. It's the result of 4 years working on it (and I still continue improving features ) and I want to share with the community. You can see some videos on youtube and some demo gifs on my twitter account.
      This Engine has been developed as End-of-Degree Project and it is coded in Javascript, WebGL and GLSL. The engine is written from scratch.
      This is not a professional engine but it's for learning purposes, so anyone can review the code an learn basis about graphics, physics or game engine architecture. Source code on this GitHub repository.
      I'm available for a good conversation about Game Engine / Graphics Programming
    • By C0dR
      I would like to introduce the first version of my physically based camera rendering library, written in C++, called PhysiCam.
      Physicam is an open source OpenGL C++ library, which provides physically based camera rendering and parameters. It is based on OpenGL and designed to be used as either static library or dynamic library and can be integrated in existing applications.
       
      The following features are implemented:
      Physically based sensor and focal length calculation Autoexposure Manual exposure Lense distortion Bloom (influenced by ISO, Shutter Speed, Sensor type etc.) Bokeh (influenced by Aperture, Sensor type and focal length) Tonemapping  
      You can find the repository at https://github.com/0x2A/physicam
       
      I would be happy about feedback, suggestions or contributions.

    • By altay
      Hi folks,
      Imagine we have 8 different light sources in our scene and want dynamic shadow map for each of them. The question is how do we generate shadow maps? Do we render the scene for each to get the depth data? If so, how about performance? Do we deal with the performance issues just by applying general methods (e.g. frustum culling)?
      Thanks,
       
  • Popular Now