Tano_ITA
07-06-2008 19:07:24
Hi, i need help! I'm trying to put a message when something collide with a mesh.. I tried to read all example, but i can't solve.
This is my class:
And this is the code for my Robot Mesh:
When i try to lunch a object on my robot nothing happen.. Anyone can help me to fix this problem?
thanks a lot!
This is my class:
#pragma once
#include <OgreNewt.h>
class RobotDieCallBacks : public OgreNewt::ContactCallback
{
public:
RobotDieCallBacks(int robotID);
~RobotDieCallBacks(void);
int userProcess();
private:
int m_robotID;
};
#include "RobotDieCallBacks.h"
#include <OgreCEGUIRenderer.h>
#include <CEGUI/CEGUISystem.h>
#include <CEGUI/CEGUISchemeManager.h>
#include <CEGUI/CEGUI.h>
RobotDieCallBacks::RobotDieCallBacks(int robotID ) : OgreNewt::ContactCallback()
{
m_robotID = robotID;
}
RobotDieCallBacks::~RobotDieCallBacks(void)
{
}
int RobotDieCallBacks::userProcess()
{
if (m_body0->getType() == m_robotID || (m_body1->getType() == m_robotID))
{
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
CEGUI::Window* myRoot = wmgr.createWindow( "DefaultWindow", "root" );
CEGUI::System::getSingleton().setGUISheet( myRoot );
CEGUI::FrameWindow*fWnd = (CEGUI::FrameWindow*)wmgr.createWindow( "TaharezLook/StaticText", "testWindow" );
myRoot->addChildWindow( fWnd );
// position a quarter of the way in from the top-left of parent.
fWnd->setPosition( CEGUI::UVector2( CEGUI::UDim( 0.27f, 0 ), CEGUI::UDim( 0.27f, 0 ) ) );
// set size to be half the size of the parent
fWnd->setSize( CEGUI::UVector2( CEGUI::UDim( 0.45f, 0 ), CEGUI::UDim( 0.45f, 0 ) ) );
fWnd->setText( "Benvenuto in T");
}
return 1;
}
And this is the code for my Robot Mesh:
void OgreNewtonApplication::MakeRobot()
{
// base mass on the size of the object.
Ogre::Real massPlayer = 2.5;
// calculate the inertia based on box formula and mass
Ogre::Vector3 inertiaPlayer = OgreNewt::MomentOfInertia::CalcBoxSolid( massPlayer, Vector3(3.0,3.0,3.0) );
entRobot = mSceneMgr->createEntity("robot","Robot.mesh");
RobotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("robot");
entRobot->setNormaliseNormals(true);
entRobot->setMaterialName("Simple/BeachStones");
RobotNode->attachObject(entRobot);
RobotNode->setScale(0.16,0.16,0.16);
OgreNewt::Collision* colRobot = new OgreNewt::CollisionPrimitives::TreeCollision(m_World, RobotNode, true);
RobotBody = new OgreNewt::Body(m_World, colRobot);
RobotBody->attachToNode(RobotNode);
RobotBody->setMassMatrix(massPlayer, inertiaPlayer);
RobotBody->setStandardForceCallback();
delete colRobot;
RobotBody->attachToNode(RobotNode);
RobotBody->setPositionOrientation(Ogre::Vector3(-33,1.0,23),Ogre::Quaternion::IDENTITY);
RobotID = new OgreNewt::MaterialID(m_World);
RobotBody->setMaterialGroupID(RobotID);
RobotBody->setUserData(this);
mRobotDefault = m_World->getDefaultMaterialID();
mRobotCall = new OgreNewt::MaterialID( m_World );
mRobotPairDefault = new OgreNewt::MaterialPair( m_World, mRobotDefault, mRobotCall );
mRobotCallBack = new RobotDieCallBacks(1);
mRobotPairDefault->setContactCallback( mRobotCallBack );
mRobotPairDefault->setDefaultFriction( 1.5, 1.4 );
}
When i try to lunch a object on my robot nothing happen.. Anyone can help me to fix this problem?
thanks a lot!