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

RoamInstance.cpp

Go to the documentation of this file.
00001 
00002 /*
00003     TSGL - Teddy Space Game Library
00004     Copyright (C) 2002 Timo Suoranta
00005     tksuoran@cc.helsinki.fi
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     $Id: RoamInstance.cpp,v 1.1 2002/01/08 20:47:05 tksuoran Exp $
00022 */
00023 
00024 
00025 #if 0
00026 
00027 
00028 #include "UniverseDevelopmentKit/CMaster.h"
00029 #include "Teddy/SpaceGame/RoamInstance.h"
00030 #include "Teddy/SpaceGame/RoamSphere.h"
00031 #include "PhysicalComponents/Projection.h"
00032 #include "UniverseDevelopmentKit/CVertex.h"
00033 #include "Scenes/Camera.h"
00034 using namespace PhysicalComponents;
00035 using namespace UniverseDevelopmentKit;
00036 using namespace Scenes;
00037 
00038 
00039 namespace Teddy     {
00040 namespace SpaceGame {
00041 
00042 
00043 float c_h;
00044 
00045 
00046 RoamInstance::RoamInstance( const char *name, Mesh *mesh ):CollisionInstance(name,mesh){
00047 }
00048 
00049 
00050 /*virtual*/ bool RoamInstance::collisionCheck( CollisionInstance *other ){
00051     RoamSphere *sphere = dynamic_cast<RoamSphere*>( this->mesh );
00052     if( sphere == NULL ){
00053         return false;
00054     }
00055 
00056     Vector other_pos = other->getPosition();
00057     float   radius    = other->getClipRadius();
00058     if( sphere->collisionCheck( other_pos - this->getPosition(), radius ) ){
00059         this->applyCollision( other );
00060         other->applyCollision( this );
00061         return true;
00062     }
00063     return false;
00064 }
00065 
00066 /*virtual*/ void RoamInstance::drawImmediate( Projection *p ){
00067     View       *view   = p->getView  ();
00068     Camera     *camera = p->getCamera();
00069     RoamSphere *sphere = dynamic_cast<RoamSphere*>( this->mesh );
00070     if( sphere == NULL || p==NULL ){
00071         return;
00072     }
00073 
00074 //  need origo camera fix
00075 //  Vector vPosition_beg = p->getCamera()->getPosition() - this->getPosition();
00076     Vector vPosition_beg =  - this->getPosition() + camera->getPosition();
00077     Vector vPosition     =  this->rotateVector( vPosition_beg );
00078 
00079     c_h = 0;
00080 
00081     if( roam_update ){
00082         sphere->update( vPosition, camera );
00083     }
00084 
00085 //  need origo camera fix
00086 //  Matrix m = getScaledModelMatrix( p->getCamera() );
00087     camera->doObjectMatrix( p, localToWorld() );
00088 
00089     CVertex::Array.EnableVertexArray();
00090     CVertex::Array.EnableNormalArray();
00091     CVertex::Array.InitRender();
00092     mesh->drawImmediate( p, this->material );
00093     CVertex::Array.FinishRender();
00094 }
00095 
00096 
00097 };  //  namespace SpaceGame
00098 };  //  namespace Teddy
00099 
00100 
00101 #endif
00102