View Full Version : How can I do impenetrable walls with OpenGL?
04-26-2001, 02:03 AM
I want to model by OpenGL a world that is surrounded by a fence. The user lives in this world and he/she need to explore it, but I don't know how to do impenetrable walls (so that the user can't go through the fence). Could you give me a clue or trick, please?. Any suggestions and help will be welcome. Thank
This has nothing to do with OpenGL. It's a math-in-general question. If your world is, say 100x100 units large, starting at (0,0) and ending at (100,100), just make sure the users coordinate is inside the range [0, 100] in both directions. If the user is outside this range of valid coordinates, then push the user back inside this range, or whatever you like.
04-26-2001, 11:43 PM
O.K. Bob (and thanks). Now, let's suppose there is an open door separating in/out of the world. We can go through it at the peripheral field (surrounding the fence). How can I distinguish between penetrable and impenetrable surfaces. I agree with you it is a general programming question, but I think it has posed frequently a lot of problems to the programmers (specially in games). Could you (or somebody) tell me how they solve it (with the new door)?.
Well, somewhere you must sture your world data. Lets say you store each surface in a structure. How this structure looks like internally is irrelevant. Now, to determing in runtime wether a surface is penetrable or not, you can just add a flag to the surface structure, indicating it's status. Or if you are using indoors environment only, build a BSP tree and do colission detection, which I believe is not too hard in a BSP tree. If it's a outdoor enviromnent, you can do a bounding box collision detection with the surface. There are quite a few ways to do it, and it's nearly impossible to answer the question in a general case like this. It's up to you as a "leveldesigner" to mark surfaces as penetratable or not, and up to you as programmer to use this information in a way that works best for you.
So, to "solve" your problem, we must know more about what you need. Which type of environment, and how advanced do you want it, for example.
04-28-2001, 12:31 AM
What you need is something called collision detection. You could do very primitive collision detection by preventing the user from going beyond a certain x value or z value or y value, but this is very primitive method. There are some artciles on collision detection, just do a searcb.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.