Echo Mesh
Posted: Mon Jun 04, 2007 7:08 pm
Hey folks!
I'm currently working on some code to simulate the throwing of a ball when the left mouse is clicked. At the moment, when the left mouse button is clicked a sphere mesh is loaded, and attached to a node positioned at the camera position. It then moves off in the direction the camera is pointing as required. However, a second sphere mesh is also being created and remains stationary at the point the sphere was fired. My code dealing with this is as follows:
..and then each frame the following function is called:
Any idea what could be causing this? Any help is very much appreciated!
I'm currently working on some code to simulate the throwing of a ball when the left mouse is clicked. At the moment, when the left mouse button is clicked a sphere mesh is loaded, and attached to a node positioned at the camera position. It then moves off in the direction the camera is pointing as required. However, a second sphere mesh is also being created and remains stationary at the point the sphere was fired. My code dealing with this is as follows:
Code: Select all
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if(event.EventType == irr::EET_MOUSE_INPUT_EVENT)
{
if(event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
{
IAnimatedMesh* sphereMesh = smgr->getMesh("sphere.3ds");
sphereNode = smgr->addAnimatedMeshSceneNode(sphereMesh);
sphereNode->setPosition(m_cam->getPosition());
sphereNode->setMaterialFlag(EMF_LIGHTING, false);
disp = m_cam->getTarget() - m_cam->getPosition();
}
}
return false;
}
};
Code: Select all
void updatePos()
{
disp.setLength(initVel/driver->getFPS());
spherePos = spherePos + disp;
sphereNode->setPosition(spherePos);
}