Forest/tree server collision detection
by Claude-Alain Fournier · in Torque Game Engine Advanced · 07/27/2007 (12:31 am) · 7 replies
Hi,
I am reworking ony my forest ressource, (see plan here : www.garagegames.com/blogs/34804/12469)
I am trying to solve the collision detection and I need to do that on the server.
Now I can't get around this problem and need some help or at least pointers.
What I want is that server detect a collision between a player (npc/ai/player) and a "virtual" tree in the forest, I call it virtual because there is not corresponding object in the server side. So assume I have a list of tree position in the server. My idea was to go through the list and create a "virtual collision box" of 1 by 1 to be able to detect possible collision.
My question is where does this code go ? I would just need an example, even just a hardcoded col-box into the code, show me where the code goes to detect player collision against that box.
Once I could solve that I will release the forest code as a ressource.
Thanks in advance,
CAF
I am reworking ony my forest ressource, (see plan here : www.garagegames.com/blogs/34804/12469)
I am trying to solve the collision detection and I need to do that on the server.
Now I can't get around this problem and need some help or at least pointers.
What I want is that server detect a collision between a player (npc/ai/player) and a "virtual" tree in the forest, I call it virtual because there is not corresponding object in the server side. So assume I have a list of tree position in the server. My idea was to go through the list and create a "virtual collision box" of 1 by 1 to be able to detect possible collision.
My question is where does this code go ? I would just need an example, even just a hardcoded col-box into the code, show me where the code goes to detect player collision against that box.
Once I could solve that I will release the forest code as a ressource.
Thanks in advance,
CAF
#2
07/27/2007 (6:13 am)
Actually no, it's like for any other collision, it's purely on the server side. It would be like collision detection with a .dts shape. Only that shape is virtual.
#3
:)
again... i apologize... it's early... i need some coffee...
--Mike
07/28/2007 (4:12 am)
Please don't be angry at me for interjecting this lil bit of humor... but for some reason, the ole axiom about not being able to see the forest for the trees, pops into mind...:)
again... i apologize... it's early... i need some coffee...
--Mike
#4
Look thru some of the other objects... like AtlasInstance or InteriorInstance to see some examples of how to respond to these. Also the collision tutorial resource is a very good read.
07/28/2007 (11:16 am)
@Claude - You need to implement a custom SceneObject on the server side that implements the following three functions:/// Casts a ray and obtain collision information, returns true if RayInfo is modified.
///
/// @param start Start point of ray
/// @param end End point of ray
/// @param info Collision information obtained (out)
virtual bool castRay(const Point3F &start, const Point3F &end, RayInfo* info);
/// Builds a convex hull for this object.
///
/// Think of a convex hull as a low-res mesh which covers, as tightly as
/// possible, the object mesh, and is used as a collision mesh.
/// @param box
/// @param convex Convex mesh generated (out)
virtual void buildConvex(const Box3F& box,Convex* convex);
/// Builds a list of polygons which intersect a bounding volume.
///
/// This will use either the sphere or the box, not both, the
/// SceneObject implimentation ignores sphere.
///
/// @see AbstractPolyList
/// @param polyList Poly list build (out)
/// @param box Box bounding volume
/// @param sphere Sphere bounding volume
virtual bool buildPolyList(AbstractPolyList* polyList, const Box3F &box, const SphereF &sphere);Look thru some of the other objects... like AtlasInstance or InteriorInstance to see some examples of how to respond to these. Also the collision tutorial resource is a very good read.
#5
@Tom, thanks, that's very usefull and study of the ressource already give me some good insight of the collision problem. One thing I am sure though is that I SHOULD not use the method described there, reason been that a forest of 100'000 trees is a lot of poly. But anyway the ressoure definitely point me to the right direction.
By the way Tom, what's happening with Sickhead forest pack ? Can't wait to put my hand on it.
07/29/2007 (1:13 am)
@Michael, actually that's exactly my problem ;)@Tom, thanks, that's very usefull and study of the ressource already give me some good insight of the collision problem. One thing I am sure though is that I SHOULD not use the method described there, reason been that a forest of 100'000 trees is a lot of poly. But anyway the ressoure definitely point me to the right direction.
By the way Tom, what's happening with Sickhead forest pack ? Can't wait to put my hand on it.
#6
07/29/2007 (2:35 am)
Thought: you're presumably feeding the tree's positions to each client by seeding a number through a pseudo-random algorithm so that the visuals end up the same on each client, so why not do a simple check to see if the position of the object youre testing it against is within X distance of the closest point that satisfies that algie?
#7
Claude-Alain did you ever get around a solution for that problem regarding this pack, I recall you mentioned David Dougher had a go to release it as a ressource. Was it ?
10/13/2007 (2:47 pm)
Knocking on a old tree ;)Claude-Alain did you ever get around a solution for that problem regarding this pack, I recall you mentioned David Dougher had a go to release it as a ressource. Was it ?
Torque Owner Christian S
Oak-Entertainment
No idea at all, but it would require a lot of 'talk' between the client and the server as a 'actor' enters the replicator area I guess.
Keep up the spirit ;)