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

OgreRefAppBox.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-2003 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 "OgreRefAppBox.h"
00026 #include "OgreRefAppWorld.h"
00027 
00028 namespace OgreRefApp
00029 {
00030 
00031     //-------------------------------------------------------------------------
00032     Box::Box(const String& name, Real width, Real height, Real depth) : ApplicationObject(name)
00033     {
00034         mDimensions.x = width;
00035         mDimensions.y = height;
00036         mDimensions.z = depth;
00037         setUp(name);
00038     }
00039     //-------------------------------------------------------------------------
00040     Box::~Box()
00041     {
00042 
00043     }
00044     //-------------------------------------------------------------------------
00045     void Box::setUp(const String& name)
00046     {
00047         // Create visual presence
00048         SceneManager* sm = World::getSingleton().getSceneManager();
00049         mEntity = sm->createEntity(name, "cube.mesh");
00050         mSceneNode = sm->getRootSceneNode()->createChildSceneNode(name);
00051         // Scale down, default size is 100x100x100
00052         mSceneNode->scale(mDimensions.x / 100.f, 
00053             mDimensions.y / 100.f, mDimensions.z / 100.f);
00054 
00055         mSceneNode->attachObject(mEntity);
00056         // Add reverse reference
00057         mEntity->setUserObject(this);
00058 
00059         // Create mass body
00060         mOdeBody = new dBody(World::getSingleton().getOdeWorld()->id());
00061         // Set reverse reference
00062         mOdeBody->setData(this);
00063         // Set mass 
00064         setMassBox(0.05, mDimensions);
00065 
00066         this->setBounceParameters(0.0, 0.0);
00067         this->setSoftness(0.0f);
00068         this->setFriction(Math::POS_INFINITY);
00069 
00070         // Create collision proxy
00071         dBox* odeBox = new dBox(0, mDimensions.x, mDimensions.y, mDimensions.z);
00072         mCollisionProxies.push_back(odeBox);
00073         updateCollisionProxies();
00074 
00075 
00076     }
00077 
00078 
00079 }

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