Aware, in some (many?) cases you need the WorldPosition and WorldOrientation of a SceneNode.

I work with collision detection by Newton and when I update the objects in Newton world, I have to set the world parameters.In my application the Newton objects follow the Ogre SceneNodes. So Ogre determines where the collision objects should be set. (In oposite of the case with use of physically calculation, where the Ogre SceneNodes will be moved by Newton.)

With MOC I suppose it can be the same.If the SceneNode is attached to the RootSceneNode, then the world parameters are the same, but if there is an other parent SceneNode, that can be totally different.

Help to add information to the wiki. Also tiny edits will let it grow ... Add your country to your profile ... it's interesting to know from where of the world you are.

I checkt while debugging and the program runs through CollidesWithEntity() and when there's no collision it returns false like it should so the program returns to capturing mouse and keyboard input, does another collidesWithEntity() but this time it doesn't do anything anymore after it returns false, and the capture() method of my inputhandler isn't called anymore which normally happens every frame. It just seems to get stuck at RayCastFromPoint. (also the second time my distToDest variable is 0,0,0)

Hey there. I am very new to Ogre and thus new to MOC. I am currently using Code::Blocks as my IDE but I am having a hard time building and running the demo that was with the download. I am unsure if I am doing something wrong. I have tried the various different versions available opening up the .sln file each time and hitting build and run but I get 15 or so errors.

Is there a light weight tutorial to follow to allow me to understand how to get things going with the collision in MOC?

It should work out of the box with Ogre, but there are problems with the sample code and C::B / MinGW it seems, we are looking into it right now. If you don't need cross platform support and want to run it on windows only, I suggest using VC++ Express, free and works.

About the usage, if you open the SampleApp.cpp and look at the Startup() and Update() methods you can pretty much see the usage for collision and if you check the mousePressed() method you will see there is a pickEntity() method called, this should pretty much explain everything. Very simple to use really, if you have detail questions, please don't hesitate to ask again and more

Hey there I have had a fair bit or trouble trying to get MOC working with my basic interior geometry. I have included both the CollisionTools Header and Source files to my app and have finally been able to get the whole thing to build without an error. When I run the application from the release folder there is no Collision detection present. I am seriously in need of help from somebody. Please find the code below for the 4 files in my app. Sorry about the length, but I really need help.If someone could point out where I am going wrongand make suggestions this would really really help, as I am a novice programmer.

// raycast from a point in to the scene.// returns success or failure.// on success the point is returned in the result.bool CollisionTools::raycastFromPoint(const Vector3 &point, const Vector3 &normal, Vector3 &result,ulong &target,float &closest_distance, const uint32 queryMask){ // create the ray to test static Ogre::Ray ray; ray.setOrigin(point); ray.setDirection(normal);

// at this point we have raycast to a series of different objects bounding boxes. // we need to test these different objects to see which is the first polygon hit. // there are some minor optimizations (distance based) that mean we wont have to // check all of the objects most of the time, but the worst case scenario is that // we need to test every triangle of every object. //Ogre::Real closest_distance = -1.0f; closest_distance = -1.0f; Ogre::Vector3 closest_result; Ogre::RaySceneQueryResult &query_result = mRaySceneQuery->getLastResults(); for (size_t qr_idx = 0; qr_idx < query_result.size(); qr_idx++) { // stop checking if we have found a raycast hit that is closer // than all remaining entities if ((closest_distance >= 0.0f) && (closest_distance < query_result[qr_idx].distance)) { break; }

// only check this result if its a hit against an entity if ((query_result[qr_idx].movable != NULL) && (query_result[qr_idx].movable->getMovableType().compare("Entity") == 0)) { // get the entity to check Ogre::Entity *pentity = static_cast<Ogre::Entity*>(query_result[qr_idx].movable);

// if it was a hit check if its the closest if (hit.first) { if ((closest_distance < 0.0f) || (hit.second < closest_distance)) { // this is the closest so far, save it off closest_distance = hit.second; new_closest_found = true; } } }

// if we found a new closest raycast for this object, update the // closest_result before moving on to the next object. if (new_closest_found) { target = (ulong)pentity; closest_result = ray.getPoint(closest_distance); } } }

// There is _no_ baseVertexPointerToElement() which takes an Ogre::Real or a double // as second argument. So make it float, to avoid trouble when Ogre::Real will // be comiled/typedefed as double: // Ogre::Real* pReal; float* pReal;

// check if a collision would happen with an entity if (mCollisionTools->collidesWithEntity(oldPos, mCamNode->getPosition(),ENTITY_MASK)) {

// if there was a collision discard the movement reset the camera to old position mCamNode->setPosition(oldPos);

} }

or in an update method if you work without framelistener, as I said, if you look at the example app that comes with MOC it should be clear how to call it and where. In doubt I strongly recommend to work the basic ogre wiki tutorials -> http://www.ogre3d.org/wiki/index.php/Ogre_Tutorials <- to understand how a framelistener works or how you setup a basic ogre app without framelistener. No offense but seeing your code you won't get much further without that.

Additionally you need to flag all your Entities with setQueryMask(ENTITY_MASK).

You may use this sample code for anything you like, it is not covered by theLGPL like the rest of the engine.-----------------------------------------------------------------------------*/

/** \file Grass.cpp \brief Specialisation of OGRE's framework application to show the use of the StaticGeometry class to create 'baked' instances of many meshes, to create effects like grass efficiently.**/

// check if we are colliding with anything with a collision radius of 2.5 ogre units and we // set the ray origin -1.0 lower towards the ground to get smaller obstacles too if (mCollisionTools->collidesWithEntity(oldPos, mCamera->getPosition(), 2.5f, -1.0f, GROUND_MASK)) { // undo move mCamera->setPosition(oldPos); }

StaticGeometry* s = mSceneMgr->createStaticGeometry("bing"); s->setRegionDimensions(Vector3(1000,1000,1000)); // Set the region origin so the centre is at 0 world s->setOrigin(Vector3(-500, 500, -500));

I'm using Code::Blocks, MinGW, Vista 64-Bit. I copied the CollisionTools.h and CollisionTools.cpp to the include and src dirs to be more easily accessible, but even if I don't I still get these errors. Help would be appreciated.

I just took your Grass.cpp and copied it into my MOC C::B test project and it compiled just fine, 3 warnings, no errors. I created that project with the Codeblocks Ogre wizard, so there is likely something wrong with your setup, because the code works like this. Mind you I haven't tested any functionality, I only did compile it.

Hey mickey, brogaard just informed me that he is still working on it, but had to pause for a more urgent matter. I have very little time right now being busy with Artifex mainly, so if you need it fast you would have to implement it yourself, I have posted a theoretical approach that should work and not be all that hard to put into code: http://www.artifexterra3d.com/forum/moc ... -collsion/

@mickeyren: Sorry I totally missed that, yes it should, since it calculates the intersection point with the ray and the polygon hit.

@ludollu: Out of the box, I have no idea why that could be the case, but you could try and create an identical mesh in blender or whatever modeler, then apply your transformations and try the picking again on the test object to compare the difference to your manual object, might give you a better clue where things go wrong.