Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreRefAppBall.cpp

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of the OGRE Reference Application, a layer built
00004 on top of OGRE(Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright © 2000-2002 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #include "OgreRefAppBall.h"
00026 #include "OgreRefAppWorld.h"
00027 
00028 namespace OgreRefApp
00029 {
00030 
00031     //-------------------------------------------------------------------------
00032     Ball::Ball(const String& name, Real radius) : ApplicationObject(name)
00033     {
00034         mRadius = radius;
00035         setUp(name);
00036     }
00037     //-------------------------------------------------------------------------
00038     Ball::~Ball()
00039     {
00040 
00041     }
00042     //-------------------------------------------------------------------------
00043     void Ball::setUp(const String& name)
00044     {
00045         // Create visual presence
00046         SceneManager* sm = World::getSingleton().getSceneManager();
00047         mEntity = sm->createEntity(name, "sphere.mesh");
00048         mSceneNode = sm->getRootSceneNode()->createChildSceneNode(name);
00049         // Scale down, default size is 100
00050         Real scale = mRadius / 100.0f;
00051         mSceneNode->scale(scale, scale, scale);
00052 
00053         mSceneNode->attachObject(mEntity);
00054         // Add reverse reference
00055         mEntity->setUserObject(this);
00056 
00057         // Create mass body
00058         mOdeBody = new dBody(World::getSingleton().getOdeWorld()->id());
00059         // Set reverse reference
00060         mOdeBody->setData(this);
00061         // Set mass 
00062         setMassSphere(0.1, mRadius); // TODO change to more realistic values
00063 
00064         this->setBounceParameters(0.7, 0.1);
00065         this->setSoftness(0.0f);
00066         this->setFriction(Math::POS_INFINITY);
00067 
00068         // Create collision proxy
00069         dSphere* odeSphere = new dSphere(0, mRadius);
00070         mCollisionProxies.push_back(odeSphere);
00071         updateCollisionProxies();
00072 
00073 
00074     }
00075 
00076 
00077 }

Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:22:38 2004