opengl and collision detection

Questions regarding game mechanics and graphic programming should go here.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

opengl and collision detection

Postby WildFire » Mon Feb 07, 2005 2:24 pm

Well guys if i make a cube in opengl how can i make it so that you cant go outside the cube?
"C++ > Mircscript" -WildFire
WildFire
 
Posts: 34
Joined: Wed Jun 23, 2004 1:56 pm

Postby tomcant » Mon Feb 07, 2005 2:25 pm

How do you mean? You need to explain a little more before we can help.
If it wasn't for C, we would be using BASI, PASAL and OBOL.
User avatar
tomcant
 
Posts: 3101
Joined: Tue Sep 23, 2003 1:56 am
Location: Colchester, UK

Re: opengl and collision detection

Postby t i l e x » Mon Feb 07, 2005 5:44 pm

WildFire wrote:Well guys if i make a cube in opengl how can i make it so that you cant go outside the cube?
How did you get in ? :lol:
User avatar
t i l e x
 
Posts: 3604
Joined: Wed Dec 03, 2003 3:59 pm
Location: Québec (Canada)

Postby Invictus » Mon Feb 07, 2005 5:48 pm

if(xpos < cube.front)
xpos++
etc............

... lol
User avatar
Invictus
 
Posts: 3054
Joined: Tue Oct 21, 2003 12:59 pm

Postby schloob » Mon Feb 07, 2005 5:56 pm

Invictus, maybe he means dynamic :\
:]
User avatar
schloob
 
Posts: 1853
Joined: Mon Feb 16, 2004 10:29 am
Location: Seattle

Postby Bugdude » Mon Feb 07, 2005 6:03 pm

OpenGL has no provision for collision detection, you have to perform it yourself. I suggest you first decide upon and implement a scene database so you know where everything is.
User avatar
Bugdude
Moderator
 
Posts: 2480
Joined: Sun Aug 29, 2004 1:58 am
Location: Living in sin

Re: opengl and collision detection

Postby Darobat » Mon Feb 07, 2005 6:15 pm

t i l e x wrote:
WildFire wrote:Well guys if i make a cube in opengl how can i make it so that you cant go outside the cube?
How did you get in ? :lol:
I don't know why I laughed at that.
Code: Select all
#include <stdio.h>
struct W{char m,M[4??),w;void x(char
*W)??<w^=w;while(w[W]!=0)putchar(W[w
]^M[w++%5??));}W():m(040),w(0){char*
X="d@PLfAU\x05P)sHEMoTTPF""\31";for(
;w<5;w++[M??)=m++);x(X);}}w;main(){}
User avatar
Darobat
Moderator
 
Posts: 2572
Joined: Sat Sep 27, 2003 1:19 pm

Postby tomcant » Tue Feb 08, 2005 10:28 am

Invictus wrote:if(xpos < cube.front)
xpos++


? I believe you ment:
Code: Select all
if(xpos > cube.front)
  xpos--;


Also, I'v always achieved the same thing with:
Code: Select all
if(xpos >= max.x)
  xpos=max.x;
If it wasn't for C, we would be using BASI, PASAL and OBOL.
User avatar
tomcant
 
Posts: 3101
Joined: Tue Sep 23, 2003 1:56 am
Location: Colchester, UK

Postby BlackDeath » Fri Feb 11, 2005 11:15 am

take a look at these tuts here: http://nehe.gamedev.net/default.asp
Stat rosa pristina nomine, nomina nuda tenemus.
User avatar
BlackDeath
 
Posts: 107
Joined: Wed Feb 09, 2005 12:35 pm
Location: Under the full moon

Postby Invictus » Fri Feb 11, 2005 6:52 pm

tomcant wrote:
Invictus wrote:if(xpos < cube.front)
xpos++


? I believe you ment:
Code: Select all
if(xpos > cube.front)
  xpos--;


Also, I'v always achieved the same thing with:
Code: Select all
if(xpos >= max.x)
  xpos=max.x;


No, I was using 'front' from a first person perspective. What you demonstrates was 'back' in my observation.
User avatar
Invictus
 
Posts: 3054
Joined: Tue Oct 21, 2003 12:59 pm

Postby tomcant » Sat Feb 12, 2005 6:30 am

They both work. :)
If it wasn't for C, we would be using BASI, PASAL and OBOL.
User avatar
tomcant
 
Posts: 3101
Joined: Tue Sep 23, 2003 1:56 am
Location: Colchester, UK

Postby Invictus » Sat Feb 12, 2005 6:47 am

tomcant wrote:They both work. :)

Yes
User avatar
Invictus
 
Posts: 3054
Joined: Tue Oct 21, 2003 12:59 pm


Return to Games and Graphics

Who is online

Users browsing this forum: No registered users and 2 guests