Main Page Namespace List Class Hierarchy Alphabetical List Data Structures File List Namespace Members Data Fields Globals

# ExCModel.cpp

Go to the documentation of this file.

    00001 /*
    00002  * ExNihilo 3D Engine
    00003  *
    00004  *  This program is free software; you can redistribute it and/or modify
    00005  *  it under the terms of the GNU General Public License as published by
    00006  *  the Free Software Foundation; either version 2 of the License, or
    00007  *  (at your option) any later version.
    00008  *
    00009  *  This program is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012  *  GNU Library General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU General Public License
    00015  *  along with this program; if not, write to the Free Software
    00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    00017  *
    00018  * Please read AUTHORS file !!!
    00019  *
    00020
    00021  *
    00022  */
    00023
    00024 #include "ExCModel.h"
    00025
    00026 ExCModel::ExCModel()
    00027 {
    00028 Guard(ExCModel::ExCModel())
    00029 UnGuard
    00030 }
    00031
    00032 ExCModel::~ExCModel()
    00033 {
    00034 Guard(ExCModel::~ExCModel())
    00035 UnGuard
    00036 }
    00037
    00038 void ExCModel::Forward(void)
    00039 {
    00040 Guard(void ExCModel::Forward(void))
    00041         m_Position=m_Position+m_Target;
    00042 UnGuard
    00043 }
    00044
    00045 void ExCModel::Draw(void)
    00046 {
    00047 Guard(void ExCModel::Draw(void))
    00048         //move objet to position
    00049         glRotatef(-90,1,0,0);//just for align with 3ds max cord
    00050         glTranslatef(m_Position.GetX(),m_Position.GetY(),m_Position.GetZ());
    00051         //rotate object
    00052         glRotatef(m_AngleX,1,0,0);
    00053         glRotatef(m_AngleY,0,1,0);
    00054         glRotatef(m_AngleZ,0,0,1);
    00055
    00056         //m_AngleX-=90;
    00057         if(m_AngleX<0){m_AngleX=360-m_AngleX;}
    00058     if(m_AngleX>359)m_AngleX=0;
    00059         if(m_AngleY<0)m_AngleY=359;
    00060         if(m_AngleY>359)m_AngleY=0;
    00061         if(m_AngleZ<0)m_AngleZ=359;
    00062         if(m_AngleZ>359)m_AngleZ=0;
    00063
    00064         float cosY,cosP,cosR;
    00065         float sinY,sinP,sinR;
    00066
    00067         cosY=cosf(DegreesToRadians(m_AngleY));
    00068         cosP=cosf(DegreesToRadians(m_AngleX));
    00069         cosR=cosf(DegreesToRadians(m_AngleZ));
    00070
    00071         sinY=sinf(DegreesToRadians(m_AngleY));
    00072         sinP=sinf(DegreesToRadians(m_AngleX));
    00073         sinR=sinf(DegreesToRadians(m_AngleZ));
    00074
    00075         ExCVec3D fwd,side,vtmp;
    00076
    00077         fwd.SetX(sinY*cosP);
    00078         fwd.SetY(sinP);
    00079         fwd.SetZ(cosP*-cosY);
    00080
    00081     m_Up.SetX((-cosY*sinR)-(sinY*sinP*cosR));
    00082         m_Up.SetY(cosP*cosR);
    00083         m_Up.SetZ((-sinY*sinR)-(sinP*cosR*-cosY));
    00084
    00085         //m_Position=m_Position+((m_Target-m_Position)*m_speed);
    00086         side=GetCrossProduct(fwd,m_Up);
    00087
    00088         /*
    00089         vtmp=side;
    00090         side=fwd;
    00091         fwd=vtmp;
    00092         */
    00093
    00094
    00095         m_Target=fwd+m_Position;
    00096         //Draw force vector
    00097         /*glDisable(GL_LIGHTING);
    00098         glLineWidth(20);
    00099         glColor3f(0,0,1);
    00100         glBegin(GL_LINES);
    00101                 glVertex3f(0,0,0);
    00102                 glVertex3f(m_Up.GetX()*5,m_Up.GetY()*5,m_Up.GetZ()*5);
    00103         glEnd();
    00104
    00105         glColor3f(0,1,0);
    00106         glBegin(GL_LINES);
    00107                 glVertex3f(0,0,0);
    00108                 glVertex3f(fwd.GetX()*5,fwd.GetY()*5,fwd.GetZ()*5);
    00109         glEnd();
    00110
    00111         glColor3f(1,0,0);
    00112         glBegin(GL_LINES);
    00113                 glVertex3f(0,0,0);
    00114                 glVertex3f(side.GetX()*5,side.GetY()*5,side.GetZ()*5);
    00115         glEnd();
    00116
    00117
    00118         glColor3f(1,1,1);
    00119         glBegin(GL_LINES);
    00120                 glVertex3f(0,0,0);
    00121                 glVertex3f(m_Target.GetX(),m_Target.GetY(),m_Target.GetZ());
    00122         glEnd();*/
    00123         /*glColor3f(0.5,0,0.5);
    00124         glBegin(GL_LINES);
    00125                 glVertex3f(0,0,0);
    00126                 glVertex3f(m_Position.GetX(),m_Position.GetY(),m_Position.GetZ());
    00127         glEnd();
    00128         glColor3f(0.0,0.5,0.5);
    00129         glBegin(GL_LINES);
    00130                 glVertex3f(m_Target.GetX(),m_Target.GetY(),m_Target.GetZ());
    00131                 glVertex3f(m_Position.GetX(),m_Position.GetY(),m_Position.GetZ());
    00132         glEnd();*/
    00133         glLineWidth(1.5);
    00134         glColor3f(1,1,1);
    00135 UnGuard
    00136 }
    00137
    00138 void ExCModel::NextFrame(void)
    00139 {
    00140 Guard(void ExCModel::NextFrame(void))
    00141         m_CurrentFrames++;
    00142         if(m_CurrentFrames>m_numFrames)m_CurrentFrames=1;
    00143 UnGuard
    00144 }
    00145
    00146 void ExCModel::PreviousFrame(void)
    00147 {
    00148 Guard(void ExCModel::PreviousFrame(void))
    00149         m_CurrentFrames--;
    00150         if(m_CurrentFrames<1)m_CurrentFrames=m_numFrames;
    00151 UnGuard
    00152 }
    00153
    00154 void ExCModel::SetCurrentFrame(int frame)
    00155 {
    00156 Guard(void ExCModel::SetCurrentFrame(int frame))
    00157   if(frame>0&&frame<m_numFrames)
    00158         m_CurrentFrames=frame;
    00159 UnGuard
    00160 }
    00161
    00162 void ExCModel::StartRun(void)
    00163 {
    00164 Guard(void ExCModel::StartRun(void))
    00165         //m_CurrentFrames=40;
    00166         //m_Transition=true;
    00167 UnGuard
    00168 }
    00169
    00170 void ExCModel::StopRun(void)
    00171 {
    00172 Guard(void ExCModel::StopRun(void))
    00173         //m_CurrentFrames=1;
    00174         //m_Transition=false;
    00175 UnGuard
    00176 }
    00177
    00178 void ExCModel::StartAction(std::string   Action)
    00179 {
    00180 Guard(void ExCModel::SStartAction(std::string    Action))
    00181 UnGuard
    00182 }
    00183
    00184 void ExCModel::StopAction(void)
    00185 {
    00186 Guard(void ExCModel::StopAction(void))
    00187 UnGuard
    00188 }