ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am currently writing a simple 3D game in OpenGL, while learning OpenGL. I was wondering if there was any easy way I could use a software tool (Such as Blender) to create a 3D map which OpenGL could then load , instead of me having to individually enter every location. Also, is there a easy way to do collision detection in OpenGL. Nothing major, but I want to make sure that the player cannot move through the walls.
If anyone can help me with this, please do. The collision detection is probably more important, but the map would make it so much easier. If there is no way to do the map, is there a way to place a cube in an exact position? I have the positions and items drawn out on a map, but I have only found out about rotations and transformations, not precise locations.
Last edited by anon02; 01-15-2012 at 08:22 AM.
Reason: Adding more information.
I was wondering if there was any easy way I could use a software tool (Such as Blender) to create a 3D map which OpenGL could then load , instead of me having to individually enter every location.
Well you can create some geometry in Blender or so and save (or export) it in a file. Then you'll have to parse the file in your C program (some formats are easier to parse -- *.obj, *.ase,..) to get the data you need. It is not as difficult as it would seem. As far as I know, OpenGL does not provide any functions to load such files, but if you search the internet, perhaps you will be able to find some C libraries for loading the respective formats.
Quote:
Originally Posted by ThatPerson
Also, is there a easy way to do collision detection in OpenGL. Nothing major, but I want to make sure that the player cannot move through the walls.
I have only worked with OpenGL 2.0, so I don't know if that applies for newer version as well, but AFAIK, OpenGL only does graphics. Collision detection (and collision response) is a very complex problem that you'll have to implement yourself. Unless your game is supposed to be *very* realistic (flight simulator, car driving) with a very accurate collision detection, you don't need to use the game geometry you use in openGL for collision detection as well. It will probably suffice to approximate each object with a "box" or "sphere" or a small set off boxes to reduce the complexity. Collision detection for boxes is then a relatively trivial problem.
Again, if you search the internet, you might find some libraries that provide such functionality. I believe there is something called PhysX which should be able to do collision detection, but I have never seen it myself.
Quote:
Originally Posted by ThatPerson
If there is no way to do the map, is there a way to place a cube in an exact position? I have the positions and items drawn out on a map, but I have only found out about rotations and transformations, not precise locations.
You position objects in your scene using modelview transformations (glTranslate*()). It is the same as moving the camera, but in the oposite direction.
Well you can create some geometry in Blender or so and save (or export) it in a file. Then you'll have to parse the file in your C program (some formats are easier to parse -- *.obj, *.ase,..) to get the data you need. It is not as difficult as it would seem. As far as I know, OpenGL does not provide any functions to load such files, but if you search the internet, perhaps you will be able to find some C libraries for loading the respective formats.
I have only worked with OpenGL 2.0, so I don't know if that applies for newer version as well, but AFAIK, OpenGL only does graphics. Collision detection (and collision response) is a very complex problem that you'll have to implement yourself. Unless your game is supposed to be *very* realistic (flight simulator, car driving) with a very accurate collision detection, you don't need to use the game geometry you use in openGL for collision detection as well. It will probably suffice to approximate each object with a "box" or "sphere" or a small set off boxes to reduce the complexity. Collision detection for boxes is then a relatively trivial problem.
Again, if you search the internet, you might find some libraries that provide such functionality. I believe there is something called PhysX which should be able to do collision detection, but I have never seen it myself.
You position objects in your scene using modelview transformations (glTranslate*()). It is the same as moving the camera, but in the oposite direction.
Perfect. I am going to have a look into PhysX, and for the map I am going to write a API type thing for it so it is easier.
Hey, how did you get started programming OpenGL for Linux? How exactly do you set it up so that you can write OpenGL stuff in your C code? What exactly do you have to download?
Hey, how did you get started programming OpenGL for Linux? How exactly do you set it up so that you can write OpenGL stuff in your C code? What exactly do you have to download?
Well, as I had OpenGL already installed, I just added:
-L adds a directory to the library search path, passing a file name doesn't help anything. Since /usr/lib is already searched by default, you don't need -L at all.
Are you sure that OpenGL is not already installed on your system?
Btw, you have been asking the same question a lot lately, in several OpenGL related threads. As you have been already told, you should use your favourite search engine to find the answer since the question has been asked and answered many times around the internet. If you have a specific problem, please create a thread and tell us what distro you have, what you have tried so far, what errors you are getting, etc.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.