From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/camera_8cpp-source.html | 278 +++++++++++++++++++++++++++++++ 1 file changed, 278 insertions(+) create mode 100644 docs/doxygen/nel/camera_8cpp-source.html (limited to 'docs/doxygen/nel/camera_8cpp-source.html') diff --git a/docs/doxygen/nel/camera_8cpp-source.html b/docs/doxygen/nel/camera_8cpp-source.html new file mode 100644 index 00000000..30f9a62b --- /dev/null +++ b/docs/doxygen/nel/camera_8cpp-source.html @@ -0,0 +1,278 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

camera.cpp

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2000 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NEL.
+00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #include "std3d.h"
+00027 
+00028 #include "3d/camera.h"
+00029 
+00030 
+00031 namespace       NL3D
+00032 {
+00033 
+00034 
+00035 // ***************************************************************************
+00036 void    CCamera::registerBasic()
+00037 {
+00038         CMOT::registerModel(CameraId, TransformId, CCamera::creator);
+00039 }
+00040 
+00041 
+00042 // ***************************************************************************
+00043 CCamera::CCamera()
+00044 {
+00045         setFrustum(1.0f, 1.0f, 0.01f, 1.0f);
+00046 
+00047         // IAnimatable.
+00048         IAnimatable::resize(AnimValueLast);
+00049 
+00050         _FovAnimationEnabled= false;
+00051         _TargetAnimationEnabled= false;
+00052         _FovAnimationAspectRatio= 4.0f/3.0f;
+00053 
+00054         // Default Anims.
+00055         _Fov.Value= (float)NLMISC::Pi/2;
+00056         _Target.Value= CVector::Null;
+00057         _Roll.Value= 0;
+00058 }
+00059 // ***************************************************************************
+00060 void            CCamera::setFrustum(float left, float right, float bottom, float top, float znear, float zfar, bool perspective)
+00061 {
+00062         _Frustum.init( left, right,bottom, top, znear, zfar, perspective);
+00063 }
+00064 // ***************************************************************************
+00065 void            CCamera::setFrustum(float width, float height, float znear, float zfar, bool perspective)
+00066 {
+00067         _Frustum.init(width, height, znear, zfar, perspective);
+00068 }
+00069 // ***************************************************************************
+00070 void            CCamera::setPerspective(float fov, float aspectRatio, float znear, float zfar)
+00071 {
+00072         _Frustum.initPerspective(fov, aspectRatio, znear, zfar);
+00073 }
+00074 // ***************************************************************************
+00075 void            CCamera::getFrustum(float &left, float &right, float &bottom, float &top, float &znear, float &zfar) const
+00076 {
+00077         left= _Frustum.Left;
+00078         right= _Frustum.Right;
+00079         bottom= _Frustum.Bottom;
+00080         top= _Frustum.Top;
+00081         znear= _Frustum.Near;
+00082         zfar= _Frustum.Far;
+00083 }
+00084 // ***************************************************************************
+00085 bool            CCamera::isOrtho() const
+00086 {
+00087         return !_Frustum.Perspective;
+00088 }
+00089 // ***************************************************************************
+00090 bool            CCamera::isPerspective() const
+00091 {
+00092         return _Frustum.Perspective;
+00093 }
+00094 
+00095 
+00096 // ***************************************************************************
+00097 // ***************************************************************************
+00098 // Anims.
+00099 // ***************************************************************************
+00100 // ***************************************************************************
+00101 
+00102 
+00103 
+00104 // ***************************************************************************
+00105 IAnimatedValue* CCamera::getValue (uint valueId)
+00106 {
+00107         // what value ?
+00108         switch (valueId)
+00109         {
+00110         case FovValue:                  return &_Fov;
+00111         case TargetValue:               return &_Target;
+00112         case RollValue:                 return &_Roll;
+00113         }
+00114 
+00115         return CTransform::getValue(valueId);
+00116 }
+00117 // ***************************************************************************
+00118 const char *CCamera::getValueName (uint valueId) const
+00119 {
+00120         // what value ?
+00121         switch (valueId)
+00122         {
+00123         case FovValue:                  return getFovValueName();
+00124         case TargetValue:               return getTargetValueName();
+00125         case RollValue:                 return getRollValueName();
+00126         }
+00127 
+00128         return CTransform::getValueName(valueId);
+00129 }
+00130 
+00131 // ***************************************************************************
+00132 CTrackDefaultFloat              CCamera::DefaultFov( (float)NLMISC::Pi/2 );
+00133 CTrackDefaultVector             CCamera::DefaultTarget( CVector::Null );
+00134 CTrackDefaultFloat              CCamera::DefaultRoll( 0 );
+00135 
+00136 
+00137 ITrack* CCamera::getDefaultTrack (uint valueId)
+00138 {
+00139         // what value ?
+00140         switch (valueId)
+00141         {
+00142         case FovValue:                  return &DefaultFov;
+00143         case TargetValue:               return &DefaultTarget;
+00144         case RollValue:                 return &DefaultRoll;
+00145         }
+00146 
+00147         return CTransform::getDefaultTrack(valueId);
+00148 }
+00149 // ***************************************************************************
+00150 void    CCamera::registerToChannelMixer(CChannelMixer *chanMixer, const std::string &prefix)
+00151 {
+00152         // For CCamera, channels are not detailled.
+00153         addValue(chanMixer, FovValue, OwnerBit, prefix, false);
+00154         addValue(chanMixer, TargetValue, OwnerBit, prefix, false);
+00155         addValue(chanMixer, RollValue, OwnerBit, prefix, false);
+00156 
+00157         CTransform::registerToChannelMixer(chanMixer, prefix);
+00158 }
+00159 
+00160 
+00161 
+00162 // ***************************************************************************
+00163 void    CCamera::update()
+00164 {
+00165         CTransform::update();
+00166         
+00167         // test animations
+00168         if(IAnimatable::isTouched(OwnerBit))
+00169         {
+00170                 // FOV.
+00171                 if( _FovAnimationEnabled && IAnimatable::isTouched(FovValue))
+00172                 {
+00173                         // keep the same near/far.
+00174                         setPerspective(_Fov.Value, _FovAnimationAspectRatio, _Frustum.Near, _Frustum.Far);
+00175                 }
+00176 
+00177                 // Target / Roll.
+00178                 // If target/Roll is animated, compute our own quaternion.
+00179                 if( _TargetAnimationEnabled && (IAnimatable::isTouched(TargetValue) || IAnimatable::isTouched(RollValue)) )
+00180                 {
+00181                         CQuat   q0, q1;
+00182 
+00183                         // compute rotation of target.
+00184                         CMatrix mat;
+00185                         mat.setRot(CVector::I, _Target.Value, CVector::K);
+00186                         mat.normalize(CMatrix::YZX);
+00187                         q0= mat.getRot();
+00188 
+00189                         // compute roll rotation.
+00190                         q1.setAngleAxis(CVector::J, _Roll.Value);
+00191 
+00192 
+00193                         // combine and set rotquat!!
+00194                         setRotQuat(q0*q1);
+00195                 }
+00196 
+00197 
+00198                 IAnimatable::clearFlag(FovValue);
+00199                 IAnimatable::clearFlag(TargetValue);
+00200                 IAnimatable::clearFlag(RollValue);
+00201 
+00202                 // We are OK!
+00203                 IAnimatable::clearFlag(OwnerBit);
+00204         }
+00205 }
+00206 
+00207 
+00208 }
+00209 
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1