FineKernelToolKit
2.8.10
|
00001 /**************************************************************************** 00002 * 00003 * Copyright (c) 1999-2011, Fine Kernel Project, All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, 00006 * with or without modification, are permitted provided that the 00007 * following conditions are met: 00008 * 00009 * - Redistributions of source code must retain the above 00010 * copyright notice, this list of conditions and the 00011 * following disclaimer. 00012 * 00013 * - Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the 00015 * following disclaimer in the documentation and/or 00016 * other materials provided with the distribution. 00017 * 00018 * - Neither the name of the copyright holders nor the names 00019 * of its contributors may be used to endorse or promote 00020 * products derived from this software without specific 00021 * prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00026 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00027 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00029 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00031 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 00032 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00033 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00034 * POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 ****************************************************************************/ 00037 /**************************************************************************** 00038 * 00039 * Copyright (c) 1999-2011, Fine Kernel Project, All rights reserved. 00040 * 00041 * 本ソフトウェアおよびソースコードのライセンスは、基本的に 00042 * 「修正 BSD ライセンス」に従います。以下にその詳細を記します。 00043 * 00044 * ソースコード形式かバイナリ形式か、変更するかしないかを問わず、 00045 * 以下の条件を満たす場合に限り、再頒布および使用が許可されます。 00046 * 00047 * - ソースコードを再頒布する場合、上記の著作権表示、本条件一覧、 00048 * および下記免責条項を含めること。 00049 * 00050 * - バイナリ形式で再頒布する場合、頒布物に付属のドキュメント等の 00051 * 資料に、上記の著作権表示、本条件一覧、および下記免責条項を 00052 * 含めること。 00053 * 00054 * - 書面による特別の許可なしに、本ソフトウェアから派生した製品の 00055 * 宣伝または販売促進に、本ソフトウェアの著作権者の名前または 00056 * コントリビューターの名前を使用してはならない。 00057 * 00058 * 本ソフトウェアは、著作権者およびコントリビューターによって「現 00059 * 状のまま」提供されており、明示黙示を問わず、商業的な使用可能性、 00060 * および特定の目的に対する適合性に関す暗黙の保証も含め、またそれ 00061 * に限定されない、いかなる保証もないものとします。著作権者もコン 00062 * トリビューターも、事由のいかんを問わず、損害発生の原因いかんを 00063 * 問わず、かつ責任の根拠が契約であるか厳格責任であるか(過失その 00064 * 他の)不法行為であるかを問わず、仮にそのような損害が発生する可 00065 * 能性を知らされていたとしても、本ソフトウェアの使用によって発生 00066 * した(代替品または代用サービスの調達、使用の喪失、データの喪失、 00067 * 利益の喪失、業務の中断も含め、またそれに限定されない)直接損害、 00068 * 間接損害、偶発的な損害、特別損害、懲罰的損害、または結果損害に 00069 * ついて、一切責任を負わないものとします。 00070 * 00071 ****************************************************************************/ 00072 #ifndef __FK_MATADMIN_HEADER__ 00073 #define __FK_MATADMIN_HEADER__ 00074 00075 #include <FK/Base.h> 00076 #include <FK/Matrix.h> 00077 #include <FK/Angle.h> 00078 00080 00121 class fk_MatrixAdmin : public fk_BaseObject { 00122 00123 protected: 00124 00125 #ifndef FK_DOXYGEN_USER_PROCESS 00126 00127 fk_OrthoMatrix OrthoMatrix; // Model Base Matrix 00128 fk_HVector Position; // Model Position 00129 fk_HVector Vec, UpVec; // Model Vector & Up Vector 00130 fk_Angle Angle; // Model Angle (Heading Pitch Bank) 00131 double Scale; // Model Scale 00132 double xScale, yScale, zScale; // Axis Scale 00133 bool ScaleMode; 00134 00135 void RotateLtoG(fk_Vector *, const fk_Vector *, 00136 const fk_Angle *) const; 00137 void VectorToHeadPitch(fk_Angle *, const fk_Vector *) const; 00138 void VectorToAngle(fk_Angle *, const fk_Vector *, 00139 const fk_Vector *) const; 00140 void AngleToVector(fk_Vector *, fk_Vector *, 00141 const fk_Angle *) const; 00142 void AddAngle(fk_Angle *, const fk_Angle *) const; 00143 00144 void AdjustAngleToVec(void); 00145 void AdjustVecToAngle(void); 00146 00147 void UpdateMatrix(bool = true); 00148 00149 fk_OrthoMatrix OrthonormalMatrix(const fk_Vector &, const fk_Vector &, 00150 const double) const; 00151 void SetScaleMode(void); 00152 00153 void GlRotate_(const fk_Vector &, const fk_Vector &, 00154 const double); 00155 void LoRotate_(const fk_Vector &, const fk_Vector &, 00156 const double); 00157 00158 void GlRotateWithVec_(const fk_Vector &, 00159 const fk_Vector &, 00160 double); 00161 00162 void LoRotateWithVec_(const fk_Vector &, 00163 const fk_Vector &, 00164 double); 00165 00166 #endif 00167 00168 public: 00169 00171 fk_MatrixAdmin(fk_ObjectType = FK_MATRIXADMIN); 00172 00174 virtual ~fk_MatrixAdmin(); 00175 00177 //@( 00178 00180 00191 fk_Vector getPosition(void) const; 00192 00194 00205 fk_Vector getVec(void) const; 00206 00208 00219 fk_Vector getUpvec(void) const; 00220 00221 #ifndef FK_DOXYGEN_USER_PROCESS 00222 fk_Vector getUpVec(void) const; 00223 #endif 00224 00226 00238 fk_Angle getAngle(void) const; 00239 00241 00252 fk_Matrix getMatrix(void) const; 00253 00255 00267 fk_Matrix getInvMatrix(void) const; 00268 00270 00282 fk_OrthoMatrix getBaseMatrix(void) const; 00283 00285 00297 fk_OrthoMatrix getInvBaseMatrix(void) const; 00298 00299 //@) 00300 00302 //@( 00303 00305 00317 bool setScale(const double scale); 00318 00320 00333 bool setScale(const double scale, fk_Axis axis); 00334 00336 00350 bool setScale(const double x, const double y, const double z); 00351 00353 00365 bool prdScale(const double scale); 00366 00368 00381 bool prdScale(const double scale, fk_Axis axis); 00382 00384 00398 bool prdScale(const double x, const double y, const double z); 00399 00401 00406 double getScale(void) const; 00407 00409 00416 double getScale(fk_Axis axis) const; 00417 00419 00438 bool getScaleMode(void) const; 00439 00440 //@) 00441 00443 //@( 00444 00446 00465 bool glRotate(fk_Vector origin, fk_Axis axis, double theta); 00466 00468 00489 bool glRotate(double orgX, double orgY, double orgZ, 00490 fk_Axis axis, double theta); 00491 00493 00513 bool glRotate(fk_Vector A, fk_Vector B, double theta); 00514 00516 00540 bool glRotate(double Ax, double Ay, double Az, 00541 double Bx, double By, double Bz, double theta); 00542 00544 00564 bool loRotate(fk_Vector origin, fk_Axis axis, double theta); 00565 00567 00589 bool loRotate(double orgX, double orgY, double orgZ, 00590 fk_Axis axis, double theta); 00591 00592 00594 00616 bool loRotate(fk_Vector A, fk_Vector B, double theta); 00617 00619 00650 bool loRotate(double Ax, double Ay, double Az, 00651 double Bx, double By, double Bz, double theta); 00652 00654 00674 bool glRotateWithVec(fk_Vector origin, 00675 fk_Axis axis, double theta); 00676 00678 00700 bool glRotateWithVec(double orgX, double orgY, double orgZ, 00701 fk_Axis axis, double theta); 00702 00704 00725 bool glRotateWithVec(fk_Vector A, fk_Vector B, double theta); 00726 00728 00753 bool glRotateWithVec(double Ax, double Ay, double Az, 00754 double Bx, double By, double Bz, 00755 double theta); 00756 00758 00779 bool loRotateWithVec(fk_Vector origin, 00780 fk_Axis axis, double theta); 00781 00783 00806 bool loRotateWithVec(double orgX, double orgY, double orgZ, 00807 fk_Axis axis, double theta); 00808 00809 00811 00834 bool loRotateWithVec(fk_Vector A, fk_Vector B, 00835 double theta); 00836 00837 00839 00871 bool loRotateWithVec(double Ax, double Ay, double Az, 00872 double Bx, double By, double Bz, 00873 double theta); 00874 00875 //@) 00876 00878 //@( 00879 00881 00894 bool glTranslate(fk_Vector v); 00895 00897 00912 bool glTranslate(double x, double y, double z); 00913 00915 00928 bool loTranslate(fk_Vector v); 00929 00931 00946 bool loTranslate(double x, double y, double z); 00947 00949 00965 bool glMoveTo(fk_Vector p); 00966 00968 00986 bool glMoveTo(double x, double y, double z); 00987 00988 //@) 00989 00991 //@( 00992 00994 01013 bool glFocus(fk_Vector p); 01014 01016 01037 bool glFocus(double x, double y, double z); 01038 01040 01059 bool loFocus(fk_Vector p); 01060 01062 01083 bool loFocus(double x, double y, double z); 01084 01086 01109 bool glVec(fk_Vector v); 01110 01112 01137 bool glVec(double x, double y, double z); 01138 01140 01155 bool glUpvec(fk_Vector v); 01156 01158 01175 bool glUpvec(double x, double y, double z); 01176 01178 01196 bool loUpvec(fk_Vector v); 01197 01199 01219 bool loUpvec(double x, double y, double z); 01220 01222 01234 bool glAngle(fk_Angle angle); 01235 01237 01251 bool glAngle(double h, double p, double b); 01252 01254 01264 bool loAngle(fk_Angle angle); 01265 01267 01279 bool loAngle(double h, double p, double b); 01280 01281 //@) 01282 01283 #ifndef FK_DOXYGEN_USER_PROCESS 01284 01285 void snapShot(void); 01286 void restore(void); 01287 void restore(double t); 01288 01289 #endif 01290 01291 }; 01292 01293 #endif // !__FK_MATADMIN_HEADER__