MOC: my small update to Minimal Ogre Collision

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
mondeva2008
Gnoblar
Posts: 2
Joined: Tue Dec 22, 2009 12:10 pm

MOC: my small update to Minimal Ogre Collision

Post by mondeva2008 »

Hi

I found very useful and easy to use the MOC engine created by Nauk. However, I missed a couple of functionalities that I needed for my project, so I made some changes to the code. That is:

-Add the possibility of excluding an entity from the ray casting. I added an optional parameter "excludeEntity" to the ray casting functions. It is a string with the name of the entity to exclude.

-Add new functions for casting a single object, ignoring the rest of the scene objects. These are the prototypes:

Code: Select all

bool raycastObjectFromCamera(Ogre::RenderWindow* rw, Ogre::Camera* camera,
                                               const Ogre::Vector2 &mousecoords, Ogre::Vector3 &result,
                                               Ogre::Entity* target,float &closest_distance
                                               );
bool raycastObjectFromCamera(Ogre::RenderWindow* rw, Ogre::Camera* camera,
                                               const Ogre::Vector2 &mousecoords, Ogre::Vector3 &result,
                                               Ogre::MovableObject* target,float &closest_distance
                                               );
bool raycastObjectFromPoint(const Ogre::Vector3 &point,
                                                const Ogre::Vector3 &normal,
                                                Ogre::Vector3 &result,Ogre::Entity* target,
                                                float &closest_distance);
bool raycastObjectFromPoint(const Ogre::Vector3 &point,
                                                const Ogre::Vector3 &normal,
                                                Ogre::Vector3 &result,Ogre::MovableObject* target,
                                                float &closest_distance);
In this case, you should pass the object to cast in "target" and, obviously, no target is returned. I send the modified code attached. I hope you find it useful.
Nauk: if you like it, you can add the changes to your next verson of MOC.
You do not have the required permissions to view the files attached to this post.