Skip to main content
Bumped by Community user
added 3 characters in body
Source Link
Kromster
  • 10.7k
  • 4
  • 54
  • 67

I am trying to implement collision detection system in opengl and c++ and I have a few qustions about best directions. I will just explain my ideas. 

So, I have a cube and a sphere as a basic collision example. Well, maybe more basic example would be two spheres but let us ust go with this. So, main idea is to check the distance between cube faces and a sphere. Idea of checking the distance from some plain is mathematically clear to me, but in practice, I have to give my vertices to gpu and then do transformations there. So, what I could do, I could transform my vertices on cpu side also, but obviously this would be done just for the vertices, not for all the points. So I could know where my cube is and where are all the corners. So, I can check if I am above any cube side and if I am I can check if I am colliding with it. But what I can't check is what is exact point of collision since I do not have every point on cpu side tracked. If I want to have realistic collisions I would need to know this in order to calculate cube rotation and translation. So should I solve plane/line intersections or what? Should I maintain an equation for each plane of the cube and solve for intersections to know exact spot? Of course, I would do this only after being sure that I am colliding with that plane. Basicaly, what is the best way of manipulating data on cpu side to keep track of everything?

I am trying to implement collision detection system in opengl and c++ and I have a few qustions about best directions. I will just explain my ideas. So, I have a cube and a sphere as a basic collision example. Well, maybe more basic example would be two spheres but let us ust go with this. So, main idea is to check the distance between cube faces and a sphere. Idea of checking the distance from some plain is mathematically clear to me, but in practice, I have to give my vertices to gpu and then do transformations there. So, what I could do, I could transform my vertices on cpu side also, but obviously this would be done just for the vertices, not for all the points. So I could know where my cube is and where are all the corners. So, I can check if I am above any cube side and if I am I can check if I am colliding with it. But what I can't check is what is exact point of collision since I do not have every point on cpu side tracked. If I want to have realistic collisions I would need to know this in order to calculate cube rotation and translation. So should I solve plane/line intersections or what? Should I maintain an equation for each plane of the cube and solve for intersections to know exact spot? Of course, I would do this only after being sure that I am colliding with that plane. Basicaly, what is the best way of manipulating data on cpu side to keep track of everything?

I am trying to implement collision detection system in opengl and c++ and I have a few qustions about best directions. I will just explain my ideas. 

So, I have a cube and a sphere as a basic collision example. Well, maybe more basic example would be two spheres but let us ust go with this. So, main idea is to check the distance between cube faces and a sphere. Idea of checking the distance from some plain is mathematically clear to me, but in practice, I have to give my vertices to gpu and then do transformations there. So, what I could do, I could transform my vertices on cpu side also, but obviously this would be done just for the vertices, not for all the points. So I could know where my cube is and where are all the corners. So, I can check if I am above any cube side and if I am I can check if I am colliding with it. But what I can't check is what is exact point of collision since I do not have every point on cpu side tracked. If I want to have realistic collisions I would need to know this in order to calculate cube rotation and translation. So should I solve plane/line intersections or what? Should I maintain an equation for each plane of the cube and solve for intersections to know exact spot? Of course, I would do this only after being sure that I am colliding with that plane. Basicaly, what is the best way of manipulating data on cpu side to keep track of everything?

Source Link

How to implement collision detection using opengl and c++

I am trying to implement collision detection system in opengl and c++ and I have a few qustions about best directions. I will just explain my ideas. So, I have a cube and a sphere as a basic collision example. Well, maybe more basic example would be two spheres but let us ust go with this. So, main idea is to check the distance between cube faces and a sphere. Idea of checking the distance from some plain is mathematically clear to me, but in practice, I have to give my vertices to gpu and then do transformations there. So, what I could do, I could transform my vertices on cpu side also, but obviously this would be done just for the vertices, not for all the points. So I could know where my cube is and where are all the corners. So, I can check if I am above any cube side and if I am I can check if I am colliding with it. But what I can't check is what is exact point of collision since I do not have every point on cpu side tracked. If I want to have realistic collisions I would need to know this in order to calculate cube rotation and translation. So should I solve plane/line intersections or what? Should I maintain an equation for each plane of the cube and solve for intersections to know exact spot? Of course, I would do this only after being sure that I am colliding with that plane. Basicaly, what is the best way of manipulating data on cpu side to keep track of everything?