THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/09/2012 at 12:50, xxxxxxxx wrote:
Here's where my ignorance is showing about the GeColliderEngine.
I've only done some very basic ray collision stuff with python. And from what I gathered it sends out a ray( or a spline used as the ray in my example) from the center of a polygon.
But what happens if the collision occurs on the corners of the objects?
The ray shooting out will not hit the other object and generate a collision.
Snippet from my python spline ray casting plugin:
rc = utils.GeRayCollider()
rc. Init(obj)
rc. Intersect(start_pos, direct, length)
intersect_cnt = rc.GetIntersectionCount ()
I'm sure I'm not thinking about it correctly. And the GeColliderEngine will probably work. But I'm just so new and lost about how that class works that I'm struggling very badly with it.
If we had access to the code inside of the collision node. I thought it might help demystify how it works.
I did figure out how to do spherical collisions today. Which is at least a step in the right direction.
Here is a python example of spherical collisions:
import c4d
def main() :
text = doc.SearchObject("Text") #A text object
player = op.GetObject() #The object with the python tag on it
playerpos = player.GetMg().off #The object's global position
pRad = player.GetRad() #The object's bounding box radius
enemy = doc.SearchObject("enemy") #The object that will collide with the player object
enemypos = enemy.GetMg().off #The object's global position
eRad = enemy.GetRad() #The object's bounding box radius
distvec = playerpos - enemypos #The vector between the two objects
length = distvec.GetLength() #The distance between the two objects
if length < pRad.x + eRad.x: #If the distance is less than the sum of the two obj radius
text[c4d.PRIM_TEXT_TEXT]="Collision" #We have a collision so change the text in the text object
else: text[c4d.PRIM_TEXT_TEXT]="None" #Otherwise...Set the text to "None"
While this is great and fairly useful.
I would really like to learn how to do AABB collisons in C4D(in C++ or python). Or whatever the xpresso collision node is doing for it's collisions.
I tried to invent Bounding Box collisions from scratch. Breaking the scene into Right,Left,Front,Back,Top, Bottom quadrants relative to the player object's global position. Then checking positions between player and the enemy objects. But it's very buggy. And I'm positive I'm doing it wrong.
Meaning...I'm sure I'm asking the wrong questions in my code.
Anyway...Whenever the subject comes up. It tends to get brushed off quickly as being too complex. Or not a question that the support staff can answer. So I was hoping that we could maybe not try to tackle the super duper accurate collisions. And instead possibly share some code with each other for simpler collisions. Like the collision node.
Matthias sometimes shares xpresso code with us. So I was just wondering if Maxon would allow us to see the code for the collision node. And maybe we could learn from it.
-ScottA