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);
Nauk: if you like it, you can add the changes to your next verson of MOC.