🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

[Adding 3D image to OpenGL scene]

Started by
2 comments, last by Warp9 2 years ago

Hello guys, I hope you're all doing well.

So I've been wondering if there is a way to add a 3D object to OpenGL scene without actually constructing it.

I mean for example if I want to add w house to my scene; Instead of constructing the house using vertex data then adding the texture for each part of the house, I upload a 3D picture of the house and add it to the scene directly ?

I made a quick research and appearently I can load an OBJ file.

Does the extension have to be .OBJ ? or are there other 3D image extension that can be loaded in OpenGL ?

Thank you all for your help.

Advertisement

OBJ is a common file format for 3D models in mesh form. It also has a .mtl file defining materials, and the material can refer to a texture which is projected on the surface mesh using UV coordinate per vertex.

There are many different file format standards around, e.g. Autodesk fbx, Khronos glTF, Collada, etc. They often have support for more advanced stuff, e.g. to include a character bones hierarchy, skinning info per vertex, and animation.
There are also free libraries to import all those formats, e.g. AssImp, to make your life easier.

ogldev1 said:
I mean for example if I want to add w house to my scene; Instead of constructing the house using vertex data then adding the texture for each part of the house, I upload a 3D picture of the house and add it to the scene directly ?

Phrasing it this way, i would assume you do not want to render a complex 3D model at all, but instead an image showing this model, so the final render looks like showing the complex model, but in deed only displays a simple textured quad.

This technique is called ‘Impostors’, and is often used to get better performance from complex scenes, e.g. distant trees could be rendered using images if trees.

@ogldev1 Based on your quote here :

I mean for example if I want to add w house to my scene; Instead of constructing the house using vertex data then adding the texture for each part of the house, I upload a 3D picture of the house and add it to the scene directly ?

I made a quick research and appearently I can load an OBJ file.

I'm guessing that there might be some confusion about how 3D files (such as OBJ files work). With a format like OBJ, it is all about the vertex data. You can create the vertex data yourself, or you can load the vertex data in from a file. OpenGL doesn't care how you got the data.

I should add that there are 3D textures, which is a whole different thing than what you are talking about with a 3D file format like OBJ. . . 3D textures would just be image files. These take up a lot of memory space compared to similar resolution 2D textures. And you still need some geometry to display them on. I can't say too much about 3D textures. However, from what I understand, that would be a bunch of quads, each quad taking up a particular slice of the texture (you can do some research on that, if you want to, but, as I said above that has nothing to do with OBJ files). My only use of 3D textures in OpenGL so far has been to map out ambient lighting for my scenes (and those were some low res 3D textures), and in my case, you don't see the textures directly, just how I use that data to light up objects in the scene.

This topic is closed to new replies.

Advertisement