# OpenGL Buildings in 3D game

## Recommended Posts

I've began to learn 3D game programming with OpenGL not long ago so I'm new to all this. I've done a lot of stuff in 2D so the concepts are familiar to me but I have some thoughts about how to do some things. I'm at the phase now where I got an more or less empty world up and runing and the ability to move around in it. What I'd like to o is work a little more on the world and add some objects like buildings, trees, benches, etc. What I'm wondering is how should I implement this? Should I use 3D models for the objects oronly for the smaller ones like benches and use big Texture images on a flat polygon for the buildings? The buildings aren't supposed to be interactable, just for the view. Also, I'm more into the gameplay creation so what are the recommendations for the models? I'd like to spend as little time as possible coding loaders and such. Thanx

##### Share on other sites
If you're a designer then don't do any complicated graphic work.

Ask a graphist to build you nice objects, and/or a programmer to help you intergrating one of the numerous libs to import 3ds for example.

What kind of game are you building ? As a designer, have you a concept or are you "just filling a world with benches" ?

If you have a nice game concept, you know as a designer that "filling" the world can come at the very end of the project. You can play using white boxes for houses and quads for benches if the gameplay is good !

Peous

##### Share on other sites
I wouldn't call myself a designer, it's the programming I'm interested in. I only meant that I'm into the designing programming, so to speak. I don't mind programming everything, including graphics, it's just that I'm not very familiar with different model types and to be honest I don't want to learn about how .3ds works so I can program a loader.

Also, I'm not just filling the world with objects, I was only asking what techniques are recommended for this when the time comes. The buildings and benches were simply two examples. For instance, I'm asking how can I put a building in my world with as much effective code as possible. The building won't play a central role in the game so the only restriction is that it looks somewhat decent. I myself thought of just using a box with textures on and normal mapping. But like I said, I'm still new to all this so that's why I thought I could ask what other, more experienced people think.

##### Share on other sites
hi.

i would suggest you read up about it. (the capital words are important)
for far away objects as well as sky and horizon, you should read up about SKYBOXes.
for placing objects that appear very often, you could use BILLBOARDS. (like grass, etc.)
and you will maybe create a SCENEGRAPH for your world where the objects are placed and can be culled by the renderer.
for real 3d-objects you can use MIPMAPPING and terrain algorithms like GEOMORPHING.

and maybe later on you will have some DECALS and/or PARTICLE SYSTEMS and use some advanced techniques like SKELETAL ANIMATION.

there are always libs for loading models and such, when you use directx i would recommend using *.x - files, because these are easy to implement and supported by the d3dx-functions. later on, you can change this and support more model-formats.

so make your way to your first small game world, thats more than many others are able to do. good luck.

##### Share on other sites
www.3drock.co.uk

It does exactly what you're saying - the buildings are basically quads - but you'd be surprised at how good they look. I took about 300 fotos of shops and appartments in my home town.

##### Share on other sites
Whatever you want it's your stuff, only limits are your imagination.

It's easy to create content in a 3D graphics program such as Lightwave, Maya, DelEd, Gamespace, or Milkshape, there's usually plenty of free models and textures you can use at your disposal to accomplish the simple texturing task.

Then on the coding end you'd handle the loading and rendering of the 3D content, it's good to go with a standard model format that's supported by alot of 3D graphics editing tools so you can easily import/export content too and from graphics editing environments for further editing and/or authoring.

A standard such as DirectX or OBJ/3DS is common, all geometry based file formats store data needed related to the geometry, you simply need to read this data then store it in an object like a mesh object vclass you define to store the information about the meshes geometry, then display it when the time comes, optionally you can create a tool and your own proprietary format to organize things the way you want and add further functionality not included in the normal format.

This method pay's off in the long run because once you get the basic coding of the loader, display, and other things you want added, the rest of your focus becomes on content creation and interaction programming, here's a list of file formats to help you get started: http://local.wasp.uwa.edu.au/~pbourke/dataformats

Here's an example of a simple box using the OBJ geometry file format:
# Vertices: 8
# Points: 0
# Lines: 0
# Faces: 6
# Materials: 1

o 1

# Vertex list

v -0.5 -0.5 0.5
v -0.5 -0.5 -0.5
v -0.5 0.5 -0.5
v -0.5 0.5 0.5
v 0.5 -0.5 0.5
v 0.5 -0.5 -0.5
v 0.5 0.5 -0.5
v 0.5 0.5 0.5

# Point/Line/Face list

usemtl Default
f 4 3 2 1
f 2 6 5 1
f 3 7 6 2
f 8 7 3 4
f 5 8 4 1
f 6 7 8 5

# End of file

Once you know how to already display simple geometry and just read data into your program via a simple text stream, you can even just use a windows control such as RichEditTextBox to load the file as a plain text file it's really not all that hard to do and the longterm effects are generally worth it. The only challenge comes in handling files where a specific tool modifies the original output in a way extra and unneeded data isn't require. Such as:

#This file was created by: A specific tool blah blah blahhhh. Created year: Blah blah blahhhh.

Like this:
Graphics engine loading and applying material and texture data to geometry Box.mt....
And so on...

You can also create a simple small editor for 3D geometry object placement and store object position, rotation, scale, and other settings such as special graphics engine render and display settings, as well as basic object interactivity and animation keyframe and/or other things.

The simpler the design and effort of your graphics engine, and the more flexible and re-usable the overall design architecture, even with standard software applications, the quicker things get done, less headaches in the longrun, and more you can focus on more complicated tasks such as physics detail, AI, and hardware optimizations, etc...

[Edited by - Knight Chat X on September 28, 2006 7:04:54 PM]

##### Share on other sites
Thanx Knight, that's exactly what I was looking for. Thanx for takingt he time to write =)

## 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

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627654
• Total Posts
2978447
• ### Similar Content

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
• By cebugdev
hi guys,
are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic
let me know if you guys have recommendations.
Thank you in advance!
• By dud3
How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below?
Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.

References:
Code: https://pastebin.com/Hcshj3FQ
The video shows the difference between blender and my rotation:

• By Defend
I've had a Google around for this but haven't yet found some solid advice. There is a lot of "it depends", but I'm not sure on what.
My question is what's a good rule of thumb to follow when it comes to creating/using VBOs & VAOs? As in, when should I use multiple or when should I not? My understanding so far is that if I need a new VBO, then I need a new VAO. So when it comes to rendering multiple objects I can either:
* make lots of VAO/VBO pairs and flip through them to render different objects, or
* make one big VBO and jump around its memory to render different objects.
I also understand that if I need to render objects with different vertex attributes, then a new VAO is necessary in this case.
If that "it depends" really is quite variable, what's best for a beginner with OpenGL, assuming that better approaches can be learnt later with better understanding?

• 10
• 12
• 22
• 13
• 33