00001 /**************************************************************************** 00002 * 00003 * Copyright (c) 1999-2009, 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-2009, 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_MODEL_HEADER__ 00073 #define __FK_MODEL_HEADER__ 00074 00075 #include <FK/MatAdmin.h> 00076 #include <FK/Palette.h> 00077 #include <FK/Angle.h> 00078 00079 class fk_Material; 00080 class fk_Shape; 00081 class fk_TreeData; 00082 00083 typedef unsigned int fk_DrawMode; 00084 00085 const fk_DrawMode FK_NONEMODE = 0x0000; 00086 const fk_DrawMode FK_POINTMODE = 0x0001; 00087 const fk_DrawMode FK_LINEMODE = 0x0002; 00088 const fk_DrawMode FK_POLYMODE = 0x0004; 00089 const fk_DrawMode FK_BACK_POLYMODE = (0x0008 | FK_POLYMODE); 00090 const fk_DrawMode FK_FRONTBACK_POLYMODE = (0x0010 | FK_POLYMODE); 00091 00092 #ifndef FK_DOXYGEN_USER_PROCESS 00093 00094 enum fk_BoundaryMode { 00095 FK_SPHERE_B, 00096 FK_BOX_B, 00097 FK_CAPSULE_B 00098 }; 00099 00100 #endif 00101 00103 00134 class fk_Model : public fk_MatrixAdmin { 00135 00136 private: 00137 fk_Material *material; 00138 fk_Color *pointColor; 00139 fk_Color *lineColor; 00140 fk_Shape *shape; 00141 fk_Model *parent; 00142 bool materialFlag; 00143 fk_DrawMode drawMode; 00144 fk_MaterialMode materialMode; 00145 double drawSize; 00146 double drawWidth; 00147 bool pickFlag; 00148 bool smoothFlag; 00149 bool reverseFlag; 00150 bool treeFlag; 00151 unsigned int _modelID; 00152 00153 fk_BoundaryMode boundaryMode; 00154 00155 fk_HVector snapPos; 00156 fk_HVector snapInhPos; 00157 fk_Angle snapAngle; 00158 bool snapFlag; 00159 00160 double sbRadius; 00161 00162 void EntryTree(void); 00163 void DeleteTree(void); 00164 fk_TreeData * GetTreeData(fk_Model *); 00165 00166 public: 00167 00169 00175 fk_Model(fk_Shape *shape = (fk_Shape *)NULL); 00176 00178 virtual ~fk_Model(); 00179 00180 00182 00189 unsigned int getID(void) const; 00190 00192 //@( 00193 00195 00206 void setShape(fk_Shape *shape); 00207 00209 00215 fk_Shape * getShape(void) const; 00216 00217 //@) 00218 00220 //@( 00222 00239 void setMaterial(const fk_Material &mat); 00240 00242 00250 void setPointColor(fk_Color *col); 00251 00253 00263 void setPointColor(float r, float g, float b); 00264 00266 00274 void setLineColor(fk_Color *col); 00275 00277 00287 void setLineColor(float r, float g, float b); 00288 00290 00295 void deleteMaterial(void); 00296 00298 00303 void deletePointColor(void); 00304 00306 00311 void deleteLineColor(void); 00312 //@) 00313 00315 //@( 00317 00325 fk_Material * getMaterial(void); 00326 00328 00337 fk_Material * getInhMaterial(void); 00338 00340 00348 fk_Color * getPointColor(void); 00349 00351 00360 fk_Color * getInhPointColor(void); 00361 00363 00371 fk_Color * getLineColor(void); 00372 00374 00383 fk_Color * getInhLineColor(void); 00384 //@) 00385 00387 //@( 00388 00390 00396 void setSize(const double size); 00397 00399 00405 void setWidth(const double width); 00406 00408 00413 double getSize(void) const; 00414 00416 00421 double getWidth(void) const; 00422 //@) 00423 00425 //@( 00426 00428 00451 void setDrawMode(const fk_DrawMode mode); 00452 00454 00461 fk_DrawMode getDrawMode(void) const; 00462 00464 00490 void setMaterialMode(const fk_MaterialMode mode); 00491 00493 00500 fk_MaterialMode getMaterialMode(void) const; 00501 00503 00515 void setPickMode(const bool mode); 00516 00518 00525 bool getPickMode(void) const; 00526 00528 00537 void setSmoothMode(const bool mode); 00538 00540 00547 bool getSmoothMode(void) const; 00548 00550 00558 void setReverseDrawMode(const bool mode); 00559 00561 00568 bool getReverseDrawMode(void) const; 00569 //@) 00570 00572 //@( 00573 00575 00588 fk_Matrix getInhMatrix(void) const; 00589 00591 00605 fk_Matrix getInhInvMatrix(void) const; 00606 00608 00623 fk_OrthoMatrix getInhBaseMatrix(void) const; 00624 00626 00641 fk_OrthoMatrix getInhInvBaseMatrix(void) const; 00642 00644 00652 fk_Vector getInhPosition(void) const; 00653 00655 00663 fk_Vector getInhVec(void) const; 00664 00666 00674 fk_Vector getInhUpvec(void) const; 00675 00676 #ifndef FK_DOXYGEN_USER_PROCESS 00677 fk_Vector getInhUpVec(void) const; 00678 #endif 00679 00681 00690 fk_Angle getInhAngle(void) const; 00691 //@) 00692 00694 //@( 00695 00697 00715 bool setParent(fk_Model *model, bool setMode = false); 00716 00718 00730 void deleteParent(bool setMode = false); 00731 00733 00741 fk_Model * getParent(void) const; 00742 00744 00762 bool entryChild(fk_Model *model, bool setMode = false); 00763 00765 00782 bool deleteChild(fk_Model *model, bool setMode = false); 00783 00785 00797 void deleteChildren(bool setMode = false); 00798 00800 00829 fk_Model * foreachChild(fk_Model *model); 00830 00831 //@) 00832 00834 //@( 00835 00837 00843 void snapShot(void); 00844 00846 00851 bool restore(void); 00852 00854 00866 bool restore(double t); 00867 00868 //@) 00869 00871 //@( 00872 00874 00887 virtual void preShader(void) {}; 00888 00890 00903 virtual void postShader(void) {}; 00904 //@) 00905 00906 #ifndef FK_DOXYGEN_USER_PROCESS 00907 00908 void setBoundaryMode(fk_BoundaryMode); 00909 fk_BoundaryMode getBoundaryMode(void); 00910 void setSBRadius(double); 00911 double getSBRadius(void); 00912 bool isInterference(fk_Model *); 00913 bool isCollision(fk_Model *); 00914 double getCollisionTime(fk_Model *); 00915 00916 00917 // rita_ext: カスタムテクスチャ描画用エントリポイント 00918 virtual void connectShader(unsigned int) {}; 00919 00920 void TreePrint(void); 00921 #endif 00922 }; 00923 00924 #endif // !__FK_MODEL_HEADER__