Tushar
28-01-2010 12:36:11
Hi friends
I am using MOGRE1.6.5 (i am new in MOGRE)
I hosting the Ogre on the window forms.
I put the different cube on the window
then i put the robot
the i create the two knot. (say source knot and destination knot)
in source knot the robot is standing
now i move the robot from source to destination.
but in between the cube are coming. so I need a Collision detection
How the robot detect the cube and then find the right path to reach the destination.
Give me good tutorial on Collision detection in C# .net
or sample project application with source code (link or blog)
please Help me
Have nice Time
Advance Thanks
TaylorMouse
11-02-2010 12:53:56
Isn't there one in the examples ?
Cause Soon i was gonna do this too ?
T.
Kohedlo
30-05-2010 21:51:57
Beauty
04-06-2010 11:53:07
For my application I use the
Newton physics library. It also contains collision detection.
Here I created a wiki page with useful information about:
http://www.ogre3d.org/wiki/index.php/Co ... ith_Newton
Here are some useful basics about Newton:
http://www.ogre3d.org/wiki/index.php/Ne ... a_Nutshell
At the end of the page is a link to a Mogre snippet.
Also I created little
demo applications to show the 2 (or 3?) ways of collision detection by Newton. I'm not shure, if it is in the current SDK. It contains a very old Mogre library and an early release of the MogreNewt wrapper. But in general with the current libraries it should work similar. In future I want to update my samples for the current Mogre and Newton version.
Here you can download it:
http://www.beauty-of-darkness.de/pub/Co ... _types.rar
An advantage of Newton is that it contains good debugging possebilities (e.g. display of the real collision hulls).
I hope I could help.
Feel free to give us a feedback.
If you updated my test applications successfully to the current libraries, I would be happy when you give it back to the community.
Kohedlo
04-06-2010 14:36:56
Thanks.
I collide with one moment.
In case when need create simple body collision - phys shapes is really good.
But when mesh contain hight-leavel geometry - how to create phys body7. For example we make mesh with 100 leavels houses - is contain holes,curves and other. In this case - assign to the position this mesh -invisible phys body without holes -is no good. I dont know -is posible for newton do this -but MOC demo on C++ release this idea.
I true use Mogre Minimla Colliion. But no know how to use this members.
I succesfully assign to entitys - Querry Flags.
But problem to write function for framelistener.
// if (collisionTools.CollidesWithEntity(oldPos, mCamera.ParentSceneNode.Position, 2.5f, 0.0f, (uint)QueryFlags.ENTITY_MASK))
// {
// mCamera.ParentSceneNode.SetPosition(oldPos.x,oldPos.y,oldPos.z);
// mCamera.ParentSceneNode.SetOrientation(oldOrientation.w,oldOrientation.x,oldOrientation.y,oldOrientation.z);
// }
Beauty
04-06-2010 16:11:36
Yes, holes are a problem.
I suppose there is something like "collision tree" in newton which can "collect" all entities of an object. But I don't know much about.
In my application I use convex collision hulls for several parts of a vehicle (several mesh files).
A problem is, when all subparts of an object are together in one mesh.
Has MMC a solution for such complex objects?
Or maybe there is an other solution for Newton, too?
Kohedlo
05-06-2010 15:03:24
I hope create tool for detecting collision -simple character controller - without phys bodies.
xerios
05-06-2010 21:28:57
Good luck, cause that'll be really slow. =/
Beauty
06-06-2010 19:40:26
Collision detection would not be so slow when using only a few rays.
But
collision detection by RAY is NOT RECOMMEND.
In an scientific conference paper I wrote about the problems with it.
Lock to page 159 + 160. There are also images for easy understanding.
http://www.ssi.tu-harburg.de/doc/websei ... it2009.pdf (aware: the pdf file has 50MB)
Note: when you use rays in Ogre, you just can detect the bounding box of objects. This would be much more worst than a convex hull.
Maybe it works with an improved code called
Raycasting to the polygon level.
http://www.ogre3d.org/wiki/index.php/Ra ... 28Mogre%29
(If this link isn't available after switch to tiki wiki, just search for it)
The Newton library can also cast rays. But I don't know details.
Kohedlo
07-06-2010 21:41:37
Whwn i use Dark Physics for Dark Basic Professional - his contained metod -create mesh. Created physics model identical with 3d model file, even model has holes. I think - it is are mesh or convex in Newton or PhysX. Only need write good method for create such idenical model. If raycasting not recommend -this alternative is best.
Back to the raycasting:
mRaySceneQuery = mSceneMgr.CreateRayQuery(new Ray());
mRaySceneQuery.Ray = new Ray(new Vector3(camPosOld.x, camPosOld.y, camPosOld.z), Vector3.NEGATIVE_UNIT_Y);
rQR = mRaySceneQuery.Execute();
rQRI = rQR.Begin();
foreach (RaySceneQueryResultEntry entry in rQR)
{
if (entry.movable != null)
{
if (entry.distance != 0)
{
if (entry.distance <= 15)
{
mCamera.SetPosition(.mCamera.Position.x,
mCamera.Position.y + 0.5F,
mCamera.Position.z);
}
}
}
}
This sample show how to shot to -Y ray and control distance to entity model on -y direction and stop camera when distance is near.
Beauty
08-06-2010 12:11:27
I nerver heard about Dark Basic. Can it be combinated with Mogre?
If someone is interested - here is its wikipedia with some infos and further links. Also on youtube are videos.
http://en.wikipedia.org/wiki/DarkBASIC
Kohedlo
11-06-2010 20:24:05
No. Dark Basic - is language with compiler in complect. Hi independent based on DX language.
zarfius
22-06-2010 00:36:41
I use the .NET wrapper for PhysX called PhysX™ Candy Wrapper
http://eyecm-physx.sourceforge.net/
It has a binding for Mogre and seems to work really well. The main issue is documentation, but if you read the PhysX documentation you can figure most stuff out. I had some difficulty working out how to do triangle meshes, but got it working in the end.
Beauty
23-06-2010 08:12:50
I created a wiki page for the PhysX wrapper:
http://www.ogre3d.org/tikiwiki/PhysX+Candy+Wrapper
Does it also work with AMD cards or Nvidia cards without CUDA?
Great would be when you (zarifus) add some useful information to the wiki (links, etc.). Great would be a tutorial how to use.
Beauty
23-06-2010 08:24:37
This sample show how to shot to -Y ray and control distance to entity model on -y direction and stop camera when distance is near.
You should also sort the query results. (I'm not shure if it's done by default.)
mRaySceneQuery = mSceneMgr.CreateRayQuery(new Ray());
mRaySceneQuery.SetSortByDistance(true);
...
koirat
23-06-2010 10:38:30
I'm thinking about moving to PhysX also.
I just can't stand Newton anymore, and I hope PhysX will be more useful.
I just have to sign in for PhysX sdk download eyecandy and plug it in into my application. Is this correct ?
zarfius
23-06-2010 12:58:52
Great would be when you (zarifus) add some useful information to the wiki (links, etc.). Great would be a tutorial how to use.
Not a problem, I'll see if I can find some time tommorrow during work
Beauty
23-06-2010 17:24:22
I just can't stand Newton anymore
I would be interested in more detailed reasons.
What are your main problems with Newton? (It's not critism - I just want to know.)
The functionality, documentation, errors, updates, stability, ...?
Do you use it only for collision detection or also for physics?
Will PhysX work without Nvidia card?
i use Dark Physics for Dark Basic Professional
Maybe this is also an interesting Newton alternative for Mogre users.
Is there a free version available?
Is there some information about using together with Mogre? Maybe examples? Or a guide how it works?
If not, it would be great if you add some information here or to the wiki.
koirat
23-06-2010 19:19:36
I'm using it for Physics and collision. I will point out few things that left some bad impression.
PhysX as I know is not bind to nvidia hardware. But It will use of this resource if present.
When i was starting to play with newton it was in it's 1.53 version. I made a level in blender and add it as a trecollision to the newton world. Inside my game I have spawned some boxes on a higher platform of my level. When I was dropping them on the lower level they were sometimes behaving very chaotic, like bouncing with high rotation just when they were about to stop moving. I messed around with some settings but still could not make it stable. (I think that default settings should be good enought to use in such a simple case). I skipped this error since my level changed drastically and I could not afford invest more time into it.
When it comes to using only collision tools:
For example:
NewtonCollisionCollide
this is a part of documentation for this function
Applications using Newton as a collision system only, are responsible for implementing their own broad phase collision determination, based on any high level tree structure. Also the application should implement their own trivial aabb test, before calling this function .
So I just can't use internal Newton space structure to efficiently determine with what my collision shape is colliding with.
I guess I'm left with a brute force, or trace all the objects by my own and do some Swap and Prune, or whatever is used for physics this days. [No thanks]
The last thing I wanted to point out was that my smaller bodies (ConvexHulls) with high tesselation was very often penetrating my level treecollision with bigger triangles. Also during my use of this engine I have found some increased probability of sinking in place when the treecollision triangles were sharing edges.
Lately I was trying to change my collision shapes driven by my skeleton into a ragdol [damn].
All this can be my fault, if I'm wrong please correct me, but I just could not tame this engine. Maybe I will finish my project with this engine but I will have to skip some features like ragdoll.
Also with PhysX since it is more well known and checked engine I'm more likely to get some help with my issues.
Beauty
23-06-2010 19:43:21
I can understand you. I also had a strange problem in the first time (Newton 1.x). Then I used Newton 2 beta and it works well. Ok, I just used collision detection and no physics.
On different problems I got help directly in the newton forum.
I had an improvement idea for special collision cases and the Newton developer added the functionality in just a few days!
Also I found a bug (in an early beta release) which caused a dead lock. Then I wrote a simple demo application to reproduce the problem, send it to the developer. He debugged it and quickly published a bugfixed version. This are my experiences.
My main reason for Newton was that I found no documented alternative for Mogre (2 years ago). So I used for Newton.
One more alternative could be OgreODE of the ODE physics engine. Today there is some information about in the wiki. More I don't know about this.
When you still have problems with your Newton using application - ask in the Newton forum. (You could make a copy of your last post.) The people there have a good knowledge.
http://www.newtondynamics.com/forum
Applications using Newton as a collision system only, are responsible for implementing their own broad phase collision determination, based on any high level tree structure. Also the application should implement their own trivial aabb test, before calling this function .
I don't know this function. Maybe the documentation is outdated. Newton 2 has many improvements. If you worry about something - ask in the Newton forum.
This shouldn't be advertisement - I just want to tell you the right place for Newton questions
Did you introduce your Mogre project in the Ogre showcase?
I'm interested to see what you (and others) do. Also screenshots would be nice. (not in this thread - use the showcase section of Ogre forum.) Or maybe you have a website about?
koirat
23-06-2010 22:11:41
I can understand you. I also had a strange problem in the first time (Newton 1.x). Then I used Newton 2 beta and it works well. Ok, I just used collision detection and no physics.
On different problems I got help directly in the newton forum.
I'm also a member of this forum. I have asked some questions don't remember if it were answered. But probably not.
I had an improvement idea for special collision cases and the Newton developer added the functionality in just a few days!
Also I found a bug (in an early beta release) which caused a dead lock. Then I wrote a simple demo application to reproduce the problem, send it to the developer. He debugged it and quickly published a bugfixed version. This are my experiences.
My main reason for Newton was that I found no documented alternative for Mogre (2 years ago). So I used for Newton.
One more alternative could be OgreODE of the ODE physics engine. Today there is some information about in the wiki. More I don't know about this.
When you still have problems with your Newton using application - ask in the Newton forum. (You could make a copy of your last post.) The people there have a good knowledge. http://www.newtondynamics.com/forum
My main reason for using Newton was also easy integration with Mogre and I have started using it the same time as u did
![Smile :)]({SMILIES_PATH}/icon_smile.gif)
.
If there were some useful wrappers for PhysX I would use it instead that time. After investing a lot of time in Newton I was trying to justify my choice by sniffing around internet for posts how equal or better Newton is to other engines. But maybe it's time to wake up
![Laughing :lol:]({SMILIES_PATH}/icon_lol.gif)
.
What is cool about newton compared to PhysX is that you don't have to install some additional drivers to your system. And dll is lightweight compared to PhysX. Thay say that Newton is more realistic, but realy I can care less, I will have to cheat on my players anyway
![Smile :)]({SMILIES_PATH}/icon_smile.gif)
.
I don't know this function. Maybe the documentation is outdated. Newton 2 has many improvements. If you worry about something - ask in the Newton forum.
This shouldn't be advertisement - I just want to tell you the right place for Newton questions ![Wink :wink:]({SMILIES_PATH}/icon_wink.gif)
It's a function inside MogreNewt.CollisionTools namespace
I thought that you were using collision detection with this low level functions.
Are you doing it by gethering collision during newton CollisionCollback and just ignoring this collisions for physics ?
Some of the functionality of Newton 2.0 is not a part of MogreNewt so it can be a also at it's relative disadvantage..
Did you introduce your Mogre project in the Ogre showcase?
I'm interested to see what you (and others) do. Also screenshots would be nice. (not in this thread - use the showcase section of Ogre forum.) Or maybe you have a website about?
No not yet. You know, I feels like a painter who just can't show it's unfinished "children".
![Embarassed :oops:]({SMILIES_PATH}/icon_redface.gif)
It's a pixel shader 2.0 model based game so it is far from Crysis.
Also it's a programmer's graphics. (Do I have to comment more on this one)
But recent Gantz post about his resignation from his position, mobilize me a little in posting what I have managed to achieve with Mogre.
People got to know how useful this wrapper is and that it's not abandoned by it's users.
Beauty
23-06-2010 23:43:43
It's a function inside MogreNewt.CollisionTools namespace
I thought that you were using collision detection with this low level functions.
Are you doing it by gethering collision during newton CollisionCollback and just ignoring this collisions for physics ?
Some of the functionality of Newton 2.0 is not a part of MogreNewt so it can be a also at it's relative disadvantage.
No, I didn't use the collision tools. I think I didn't know how to handle them, because there was no example.
I figured out how to do collision detection by the wrapped Newton methods (callback functions).
Also the author of newton added for me a method how to check for collisions by iteration - without callback.
So I can check a specific body for collision detection instead of checking all bodies of the world again and again.
Also I told the developer to add the method
myWorld.CollisionUpdate().
This was needed, because I used only collision detection without physics. The bodies I moved "manually" by
.SetPositionOrientation().
Here is the alternative OgreODE:
http://www.ogre3d.org/tikiwiki/OgreOde+ ... n+Handling
In the thread about the
Alimer Game Engine the user boyamer used 2 other physics engines for his C# engine.
I'm using PhysX for 3D physics simulation with whole support,implementation is based on (http://physxdotnet.codeplex.com/) and Farseer (http://farseerphysics.codeplex.com/) for 2D physics simulation ( As Alimer Engine has whole 2D support,when i say whole i mean really whole,even deferred shading system is integrated into 2D rendering with light support and shadows)
Maybe it's interesting for your lookaround. Feel free to post experiences
zarfius
24-06-2010 05:15:29
Great would be when you (zarifus) add some useful information to the wiki (links, etc.). Great would be a tutorial how to use.
Not a problem, I'll see if I can find some time tommorrow during work ![Wink ;)]({SMILIES_PATH}/icon_wink.gif)
I just have to sign in for PhysX sdk download eyecandy and plug it in into my application. Is this correct ?
Hey guys, as promised, I've started putting together the wiki page on using the PhysX candy wrapper. It's only got the basics so far but it should be enough to get started. Feel free to add more to the wiki page as you see fit.
http://www.ogre3d.org/tikiwiki/tiki-ind ... %20Wrapper
Next I'll put in the code for setting up actors and collision shapes including generating triangle and convex meshes from Ogre entities.
Beauty
24-06-2010 09:30:09
Wow, you did a great job. The article is excellent! Many thanks!
I made some tiny corrections - see history.
Also I have a few questions. (Maybe you'll add a feature list? Or link to a feature list?)
* Can collision detection be used without using physics?
* Is there a possibility to create collision hull for complex bodies?
In Newton the convexHull is nice, but it's a problem when a body has dents or holes. Great would be a parser where you just add a sceneNode and everything at this sceneNode will be encapsulated by the hull.
* Can objects be encapsulated, which are no mesh? (e.g. ManualObject)
* Is there a support for Ogre terrain? If yes, which SceneManager is supported / not supported? (I use the plain old Terrain Scene Manager)
koirat
24-06-2010 10:43:21
how to check for collisions by iteration - without callback.
Could you tell me how you do this ?
Great addition to the wiki zarfius.
zarfius
24-06-2010 11:45:00
I made some tiny corrections - see history.
Thanks Beauty, although I did notice that one of the changes is slightly wrong. In the original version I wrote that the wrapper is designed to be used with the math library of your choice and you changed it to the graphic library of your choice. I can see how this was confusing because it seems that I'm refering to Mogre as a math library.
You see, the wrapper doesn't care about any of the rendering capabilities of Mogre but it does need to know about the math library used by Mogre, which due to the way Ogre is designed happens to be built in. I'll explain this better on the wiki next time I make an update.
Also I have a few questions. (Maybe you'll add a feature list? Or link to a feature list?)
Good idea. There is already a feature list on the wrappers website, but it couldn't hurt to have it handy on the wiki also.
Can collision detection be used without using physics?
I believe I've read somewhere that it can but I've never tried it.
Is there a possibility to create collision hull for complex bodies? In Newton the convexHull is nice, but it's a problem when a body has dents or holes.
Yep. Convex hulls are one of the most powerful part of any physics engine. It's important to realise that due to the complex calculations involved in detecting collisions they put a limitation on the shape of moving objects (that's why you can't have dents or holes). You won't find a real-time physics engine without this limitation. However, there is a way around it by combining several shapes into one. I'll explain that more on the wiki also.
Great would be a parser where you just add a sceneNode and everything at this sceneNode will be encapsulated by the hull.
That's kind of how it will work. You won't pass in the scene node, but you will be able to pass in the Entity that is attached to the scene node. Of course, it wouldn't be hard to adapt it to your liking.
Can objects be encapsulated, which are no mesh? (e.g. ManualObject)
The way it works is that you pass in a list of vertices and triangles that make up the mesh. So there's no reason why you couldn't do the same with a ManualObject, after all they are just a list of vertices and triangles too. All I've done is written a class that has the job of extracting the vertices and triangles out of a mesh, then I give that to the physics engine.
Is there a support for Ogre terrain? If yes, which SceneManager is supported / not supported? (I use the plain old Terrain Scene Manager)
PhysX has a special optimised shape for simple heightfield terrians, or you can do it just like any other triangle mesh. The SceneManager doesn't make any difference as long as there is a way to extract the vertices and triangles that makeup the terrain.
If nobody beats me too it
![Wink ;)]({SMILIES_PATH}/icon_wink.gif)
I'll put all this info up on the wiki so that it's not lost in the forums.
Beauty
24-06-2010 15:35:44
how to check for collisions by iteration - without callback.
Could you tell me how you do this ?
Here I added a demo with 2 or 3 collision examples.
One is using iteration.
http://www.beauty-of-darkness.de/pub/Co ... _types.rar
(aware: the libraries are outdated - the demo just show how to do)
The basics are the same (creating world, bodies, etc.).
The main difference: You don't apply a callback function.
Here is an easy example:
void CheckForCollision(Body body)
{
Boolean contact = false;
// check if this body collides with other ones
foreach (ContactJoint joint in body.ContactJoints)
{
contact = true; // a contact happens to the body
// do something (for each contact)
}
if (contact)
{
// do something (only once, independent of amount of contacts)
}
else
{
// do something else
}
}
Of couse you can make more checks, like
void CheckForCollision(Body body)
{
// check if this body collides with other ones
Body otherBody;
Boolean contact = false;
foreach (ContactJoint joint in body.ContactJoints)
{
if (joint.Body0 == body)
otherBody = joint.Body1;
else
otherBody = joint.Body0;
string f = null;
foreach (ContactMaterial mat in joint.ContactMaterials)
{
Vector3 pos, normal;
mat.GetContactPositionAndNormal(out pos, out normal);
Console.WriteLine("Contact at position: " + pos.ToString());
// and get access to body and otherBody
// e.g. body.UserData
}
}
}
In my main application I use the
userData property to store e.g. the name of the related SceneNode or some references.
The you just need a short snippet in the foreach() loop to get the information.
// print name of the colliding SceneNodes
Console.WriteLine(String.Format(
"Colliding SceneNodes: {0} <--> {1} ",
((DataType.NewtBodyProperty)body.UserData).Name, ((DataType.NewtBodyProperty)otherBody.UserData).Name)));
koirat
24-06-2010 16:27:32
Thanks beauty.
It's just recently that I was thinking what is Body.ContactJoints for.
Beauty
24-06-2010 16:43:19
There you can also get forces and other values.
When somebody uses Newton without physics (only collision detection) and you move bodies by
body.SetPositionOrientation() then it's important to call
world.CollisionUpdate() to update the internal state. Without physics you don't need to call
world.Update().
And it's important to give all collidable bodies has a mass > 0.
This and other information I wrote to the wiki page
Collision detection with Newton. Interesting could also be the link list at the page bottom.
koirat
24-06-2010 19:57:55
But it still would be perfect to just:
Body[] bodies = World.GetIntersectingBodies(Vector3 pos,Quaternion orient,Collision col);
unfortunately such a function does not exists.
Also you cannot check what bodies are at some point. Even with a brute force you have to create a very small sphere since there is no such a thing as a point.
One of those things that newton lacks are such a helpers. I just cant believe that Julio is not using such a math internally, he should make it usable to the users.
zarfius
25-06-2010 07:44:36
I've added more info to the PhysX candy wrapper wiki page:
http://www.ogre3d.org/tikiwiki/PhysX+Candy+Wrapper
The code was pulled out of my current project and stripped down to the basics for the wiki, unfortunately I'm at work so I am unable to test it. If you find any issues please feel free to update the wiki. There's still a fair bit I want to add, and maybe a little demo project to download.
I'm no expert on tiki wiki yet, so there may be some formatting that can be done too. Like splitting it up into several pages.
Beauty
25-06-2010 15:07:13
Thanks again. Don't worry about the layout. Most important is the information - the rest can be done later by others.
Yes, a tiny demo would be nice
koirat
01-07-2010 17:53:26
Julio pointed me to this one
World.BodyInAABB.Go(AAB aabb)
Besically it will get all the objects inside AABB from the world.
Looks like I will give Newton the second chance
zarfius
02-07-2010 00:49:57
I added some more info on using the PhysX Candy Wrapper to the wiki.
This time around it's building shapes from triangle meshes.