Sign in to follow this  
djdduty

OpenGL placing alot of objects

Recommended Posts

djdduty    109
What is the method of reading each pixel of an image and using it to place objects in a 3D world called?

does anyone know?

Thank you in advance

Share this post


Link to post
Share on other sites
lauris71    841
[quote name='djdduty' timestamp='1312967309' post='4847086']
Hello, I've learning openGL latly and I find it a real pain to have to call a gl mult matrix, declare textures, etc if I have alot of objects in the scene. For example I want to render a bunch of different trees sitting right on top of the terrain. Instead of going through 30 different trees and declaring the position of all of them, or if I have a bunch of the same object with a different texture. So what I'm asking is if there is anyway to load from like a text file the location and texture of objects without a complcated scripting system or world editor and importer like so:
position.x,position.y,position.z,name of model, texture
if there is a way, which I know there is but I havnt gotten into loading from a file yet, What is it called so I can google it, Or does anyone have any links to basic description or tutorial of how to do it?
[/quote]
OpenGL is low-level rendering API, so no, there is no such functionality.

If you want to use higher-level methods (like loading object definitions from files), use some engine, like Ogre, Irrlicht (free graphic engines) or Unreal (commercial game engine, but free for non-commercial use I think). There are many more - search in these forums for links.

Share this post


Link to post
Share on other sites
speciesUnknown    527
[quote name='djdduty' timestamp='1312967309' post='4847086']
Hello, I've learning openGL latly and I find it a real pain to have to call a gl mult matrix, declare textures, etc if I have alot of objects in the scene. For example I want to render a bunch of different trees sitting right on top of the terrain. Instead of going through 30 different trees and declaring the position of all of them, or if I have a bunch of the same object with a different texture. So what I'm asking is if there is anyway to load from like a text file the location and texture of objects without a complcated scripting system or world editor and importer like so:
position.x,position.y,position.z,name of model, texture
if there is a way, which I know there is but I havnt gotten into loading from a file yet, What is it called so I can google it, Or does anyone have any links to basic description or tutorial of how to do it?

Thank you in advance, Sorry for my bad english and confusion...
[/quote]

You can build simple levels using a text file - the text file contains a grid, and each section of the grid corresponds to a different "thing" in that location. A more sophisticated solution is to use an image, and put a green dot for a tree, a blue dot for a collectable item, a red dot for an enemy, etc.

You would build the tree in a seperate application, a modelling application, and then just "instance" it in your game.


For more advanced stuff you need a world editor. These editors are dedicated to building the world, not building the meshes and models / textures. Sadly there isn't much in the way of free level editors around, so you have to probably do one yourself.

Share this post


Link to post
Share on other sites
djdduty    109
[quote name='speciesUnknown' timestamp='1312984571' post='4847156']
[quote name='djdduty' timestamp='1312967309' post='4847086']
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)]What is the method of reading each pixel of an image and using it to place objects in a 3D world called?[/background][/left][/size][/font][/color]

[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)]does anyone know?[/background][/left][/size][/font][/color]

[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)]Thank you in advance [/background][/left][/size][/font][/color]
[/quote]

You can build simple levels using a text file - the text file contains a grid, and each section of the grid corresponds to a different "thing" in that location. A more sophisticated solution is to use an image, and put a green dot for a tree, a blue dot for a collectable item, a red dot for an enemy, etc.

You would build the tree in a seperate application, a modelling application, and then just "instance" it in your game.


For more advanced stuff you need a world editor. These editors are dedicated to building the world, not building the meshes and models / textures. Sadly there isn't much in the way of free level editors around, so you have to probably do one yourself.
[/quote]


The imaged based way of doing it with dots sounds very very useful because I also need to cover the ground in grass and that would really take forever even with a text document, I do plan on making a level editor in the future, but I have to start with the basics first, and this would be the basics. Do you happen to know what the method using an image is called because I cant find anything pertaining to this on google, and I'm not all to great enough to do something like this without a little tutorial or something... I actually suppose the text document way would be easy to do and I could probably do that. but it will still take forever.
anyways, Thank you for the response and the help

Share this post


Link to post
Share on other sites
speciesUnknown    527
[quote name='djdduty' timestamp='1313040986' post='4847508']
[quote name='speciesUnknown' timestamp='1312984571' post='4847156']
[quote name='djdduty' timestamp='1312967309' post='4847086']
Hello, I've learning openGL latly and I find it a real pain to have to call a gl mult matrix, declare textures, etc if I have alot of objects in the scene. For example I want to render a bunch of different trees sitting right on top of the terrain. Instead of going through 30 different trees and declaring the position of all of them, or if I have a bunch of the same object with a different texture. So what I'm asking is if there is anyway to load from like a text file the location and texture of objects without a complcated scripting system or world editor and importer like so:
position.x,position.y,position.z,name of model, texture
if there is a way, which I know there is but I havnt gotten into loading from a file yet, What is it called so I can google it, Or does anyone have any links to basic description or tutorial of how to do it?

Thank you in advance, Sorry for my bad english and confusion...
[/quote]

You can build simple levels using a text file - the text file contains a grid, and each section of the grid corresponds to a different "thing" in that location. A more sophisticated solution is to use an image, and put a green dot for a tree, a blue dot for a collectable item, a red dot for an enemy, etc.

You would build the tree in a seperate application, a modelling application, and then just "instance" it in your game.


For more advanced stuff you need a world editor. These editors are dedicated to building the world, not building the meshes and models / textures. Sadly there isn't much in the way of free level editors around, so you have to probably do one yourself.
[/quote]


The imaged based way of doing it with dots sounds very very useful because I also need to cover the ground in grass and that would really take forever even with a text document, I do plan on making a level editor in the future, but I have to start with the basics first, and this would be the basics. Do you happen to know what the method using an image is called because I cant find anything pertaining to this on google, and I'm not all to great enough to do something like this without a little tutorial or something... I actually suppose the text document way would be easy to do and I could probably do that. but it will still take forever.
anyways, Thank you for the response and the help
[/quote]

You need to be able to load images from file. There are a few libraries which can do this, when I was doing opengl and c++ dev I used SOIL. You simply need to open the image, get the raw data, then iterate over it; wherever you get a green pixel, instance a new tree there, and so on.

For the ground (It sounds like you want terrain) you should use a height map texture - this is a monochrome texture (usually) where white is the highest point and black the lowest. This technique is well documented online, search for terms such as heightmap and terrain heightmapping.

Share this post


Link to post
Share on other sites
djdduty    109
[quote name='speciesUnknown' timestamp='1313044515' post='4847517']
[quote name='djdduty' timestamp='1313040986' post='4847508']
[quote name='speciesUnknown' timestamp='1312984571' post='4847156']
[quote name='djdduty' timestamp='1312967309' post='4847086']
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)]What is the method of reading each pixel of an image and using it to place objects in a 3D world called?[/background][/left][/size][/font][/color]

[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)]does anyone know?[/background][/left][/size][/font][/color]

[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)]Thank you in advance [/background][/left][/size][/font][/color]
[/quote]

You can build simple levels using a text file - the text file contains a grid, and each section of the grid corresponds to a different "thing" in that location. A more sophisticated solution is to use an image, and put a green dot for a tree, a blue dot for a collectable item, a red dot for an enemy, etc.

You would build the tree in a seperate application, a modelling application, and then just "instance" it in your game.


For more advanced stuff you need a world editor. These editors are dedicated to building the world, not building the meshes and models / textures. Sadly there isn't much in the way of free level editors around, so you have to probably do one yourself.
[/quote]


The imaged based way of doing it with dots sounds very very useful because I also need to cover the ground in grass and that would really take forever even with a text document, I do plan on making a level editor in the future, but I have to start with the basics first, and this would be the basics. Do you happen to know what the method using an image is called because I cant find anything pertaining to this on google, and I'm not all to great enough to do something like this without a little tutorial or something... I actually suppose the text document way would be easy to do and I could probably do that. but it will still take forever.
anyways, Thank you for the response and the help
[/quote]

You need to be able to load images from file. There are a few libraries which can do this, when I was doing opengl and c++ dev I used SOIL. You simply need to open the image, get the raw data, then iterate over it; wherever you get a green pixel, instance a new tree there, and so on.

For the ground (It sounds like you want terrain) you should use a height map texture - this is a monochrome texture (usually) where white is the highest point and black the lowest. This technique is well documented online, search for terms such as heightmap and terrain heightmapping.
[/quote]


Thank you for the response again. I have used heightmaps before and have a heightmap terrain. I can also load an image but I dont fully understand the code required to determine where a certain colored pixel is, and then make it decide where the pixel is in a multmatrix format to put it in the same spot even if i do 1 pixel = 1 float point unit and if I have a 512x512 image thats completly green(for all grass) with some blue dots(for trees)? I have been googling intensly the last couple of hours to try to find an example of this and have come up empty handed. But I was able to create a program that reads from a text file and it works well, but now i have to place all the grass... I have over like 400 quads of grass and it is very hard. I'm thinking of making a world editor as I found a nice documentation for a mdi and it could be easily built upon and make export, and I may just do this, but the image way of doing it sounds much simpler for larger foresty levels. would it work with buildings? like, a square a certain size is a type of building but a bigger size is a bigger type of building?

Share this post


Link to post
Share on other sites
speciesUnknown    527
[quote name='djdduty' timestamp='1313045679' post='4847521']
[quote name='speciesUnknown' timestamp='1313044515' post='4847517']
[quote name='djdduty' timestamp='1313040986' post='4847508']
[quote name='speciesUnknown' timestamp='1312984571' post='4847156']
[quote name='djdduty' timestamp='1312967309' post='4847086']
Hello, I've learning openGL latly and I find it a real pain to have to call a gl mult matrix, declare textures, etc if I have alot of objects in the scene. For example I want to render a bunch of different trees sitting right on top of the terrain. Instead of going through 30 different trees and declaring the position of all of them, or if I have a bunch of the same object with a different texture. So what I'm asking is if there is anyway to load from like a text file the location and texture of objects without a complcated scripting system or world editor and importer like so:
position.x,position.y,position.z,name of model, texture
if there is a way, which I know there is but I havnt gotten into loading from a file yet, What is it called so I can google it, Or does anyone have any links to basic description or tutorial of how to do it?

Thank you in advance, Sorry for my bad english and confusion...
[/quote]

You can build simple levels using a text file - the text file contains a grid, and each section of the grid corresponds to a different "thing" in that location. A more sophisticated solution is to use an image, and put a green dot for a tree, a blue dot for a collectable item, a red dot for an enemy, etc.

You would build the tree in a seperate application, a modelling application, and then just "instance" it in your game.


For more advanced stuff you need a world editor. These editors are dedicated to building the world, not building the meshes and models / textures. Sadly there isn't much in the way of free level editors around, so you have to probably do one yourself.
[/quote]


The imaged based way of doing it with dots sounds very very useful because I also need to cover the ground in grass and that would really take forever even with a text document, I do plan on making a level editor in the future, but I have to start with the basics first, and this would be the basics. Do you happen to know what the method using an image is called because I cant find anything pertaining to this on google, and I'm not all to great enough to do something like this without a little tutorial or something... I actually suppose the text document way would be easy to do and I could probably do that. but it will still take forever.
anyways, Thank you for the response and the help
[/quote]

You need to be able to load images from file. There are a few libraries which can do this, when I was doing opengl and c++ dev I used SOIL. You simply need to open the image, get the raw data, then iterate over it; wherever you get a green pixel, instance a new tree there, and so on.

For the ground (It sounds like you want terrain) you should use a height map texture - this is a monochrome texture (usually) where white is the highest point and black the lowest. This technique is well documented online, search for terms such as heightmap and terrain heightmapping.
[/quote]


Thank you for the response again. I have used heightmaps before and have a heightmap terrain. I can also load an image but I dont fully understand the code required to determine where a certain colored pixel is, and then make it decide where the pixel is in a multmatrix format to put it in the same spot even if i do 1 pixel = 1 float point unit and if I have a 512x512 image thats completly green(for all grass) with some blue dots(for trees)? I have been googling intensly the last couple of hours to try to find an example of this and have come up empty handed. But I was able to create a program that reads from a text file and it works well, but now i have to place all the grass... I have over like 400 quads of grass and it is very hard. I'm thinking of making a world editor as I found a nice documentation for a mdi and it could be easily built upon and make export, and I may just do this, but the image way of doing it sounds much simpler for larger foresty levels. would it work with buildings? like, a square a certain size is a type of building but a bigger size is a bigger type of building?
[/quote]


I strongly recommend an image, because with that you can paint areas on using various tools such as flood fill, smoothing, and polygon drawing which you cannot do using a text file.


WRT Buildings i would recommend a seperate layer, again with spots on; this time, each colour corresponds to a different building type, and one corner of the building is drawn there. It's more likely that you will have a finite list of different models of a building, and there may not be a 1:1 relationship between their footprint size and the building type. Create a pallette image with a splodge of one colour for each building type.

I must point out that once you start placing buildings and the such, you reach the limits of what complexity you can achieve using layers of image, and need a full blown world editor.

Share this post


Link to post
Share on other sites
djdduty    109
Ok, So do you have any Idea of what the code or psuedo code would look like for locating a pixel and determening the type of object to go there? I actually found a demo called wald, it comes with source and uses this exact method I think wald is world in german [url="http://3d.benjamin-thaut.de/?p=7"]http://3d.benjamin-thaut.de/?p=7[/url] but I cant build the source as I use visual studio and there is no project files and when i tried to make a project out of them tutned out there was no header files? But this demo is almost exactly what I want to acheive

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