PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: MeshCreatorBezierPatch.h * 00003 * 00004 * Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/) 00005 * 00006 * This file is part of PixelLight. 00007 * 00008 * PixelLight is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published by 00010 * the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * PixelLight is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with PixelLight. If not, see <http://www.gnu.org/licenses/>. 00020 \*********************************************************/ 00021 00022 00023 #ifndef __PLMESH_MESHCREATOR_BEZIERPATCH_H__ 00024 #define __PLMESH_MESHCREATOR_BEZIERPATCH_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLMath/Vector3.h> 00032 #include "PLMesh/Creator/MeshCreator.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Namespace ] 00037 //[-------------------------------------------------------] 00038 namespace PLMesh { 00039 00040 00041 //[-------------------------------------------------------] 00042 //[ Classes ] 00043 //[-------------------------------------------------------] 00044 /** 00045 * @brief 00046 * Bezier batch mesh creator class 00047 */ 00048 class MeshCreatorBezierPatch : public MeshCreator { 00049 00050 00051 //[-------------------------------------------------------] 00052 //[ RTTI interface ] 00053 //[-------------------------------------------------------] 00054 pl_class(PLMESH_RTTI_EXPORT, MeshCreatorBezierPatch, "PLMesh", PLMesh::MeshCreator, "Bezier batch mesh creator class") 00055 // Attributes 00056 pl_attribute(Offset, PLMath::Vector3, PLMath::Vector3::Zero, ReadWrite, DirectValue, "Offset to center", "") 00057 pl_attribute(Divisions, PLCore::uint32, 10, ReadWrite, DirectValue, "Number of divisions", "") 00058 00059 /* 00060 // [TODO] New RTTI usage 00061 // Control points row 0 00062 DEFINE_VAR (PL_VAR_CLASS, m_vV[0][0], "V[0][0]", "0.0 0.0 0.0", "Control point 0/0", "", "") 00063 DEFINE_VAR (PL_VAR_CLASS, m_vV[1][0], "V[1][0]", "0.25 1.0 0.0", "Control point 1/0", "", "") 00064 DEFINE_VAR (PL_VAR_CLASS, m_vV[2][0], "V[2][0]", "0.5 0.0 0.0", "Control point 2/0", "", "") 00065 DEFINE_VAR (PL_VAR_CLASS, m_vV[3][0], "V[3][0]", "1.0 0.5 0.0", "Control point 3/0", "", "") 00066 // Control points row 1 00067 DEFINE_VAR (PL_VAR_CLASS, m_vV[0][1], "V[0][1]", "0.0 0.3 0.25", "Control point 0/1", "", "") 00068 DEFINE_VAR (PL_VAR_CLASS, m_vV[1][1], "V[1][1]", "0.25 0.0 0.25","Control point 1/1", "", "") 00069 DEFINE_VAR (PL_VAR_CLASS, m_vV[2][1], "V[2][1]", "0.5 0.1 0.25", "Control point 2/1", "", "") 00070 DEFINE_VAR (PL_VAR_CLASS, m_vV[3][1], "V[3][1]", "1.0 0.0 0.25", "Control point 3/1", "", "") 00071 // Control points row 2 00072 DEFINE_VAR (PL_VAR_CLASS, m_vV[0][2], "V[0][2]", "0.0 0.1 0.5", "Control point 0/2", "", "") 00073 DEFINE_VAR (PL_VAR_CLASS, m_vV[1][2], "V[1][2]", "0.25 0.2 0.5", "Control point 1/2", "", "") 00074 DEFINE_VAR (PL_VAR_CLASS, m_vV[2][2], "V[2][2]", "0.5 0.3 0.5", "Control point 2/2", "", "") 00075 DEFINE_VAR (PL_VAR_CLASS, m_vV[3][2], "V[3][2]", "1.0 0.4 0.5", "Control point 3/2", "", "") 00076 // Control points row 3 00077 DEFINE_VAR (PL_VAR_CLASS, m_vV[0][3], "V[0][3]", "0.0 0.0 1.0", "Control point 0/3", "", "") 00078 DEFINE_VAR (PL_VAR_CLASS, m_vV[1][3], "V[1][3]", "0.25 0.0 1.0", "Control point 1/3", "", "") 00079 DEFINE_VAR (PL_VAR_CLASS, m_vV[2][3], "V[2][3]", "0.5 1.0 1.0", "Control point 2/3", "", "") 00080 DEFINE_VAR (PL_VAR_CLASS, m_vV[3][3], "V[3][3]", "1.0 0.7 1.0", "Control point 3/3", "", "") 00081 */ 00082 00083 // Constructors 00084 pl_constructor_0(DefaultConstructor, "Default constructor", "") 00085 pl_class_end 00086 00087 00088 //[-------------------------------------------------------] 00089 //[ Public functions ] 00090 //[-------------------------------------------------------] 00091 public: 00092 /** 00093 * @brief 00094 * Default constructor 00095 */ 00096 PLMESH_API MeshCreatorBezierPatch(); 00097 00098 /** 00099 * @brief 00100 * Destructor 00101 */ 00102 PLMESH_API virtual ~MeshCreatorBezierPatch(); 00103 00104 00105 //[-------------------------------------------------------] 00106 //[ Private functions ] 00107 //[-------------------------------------------------------] 00108 private: 00109 /** 00110 * @brief 00111 * Calculates 3rd degree polynomial based on array of 4 points 00112 * and a single variable (u) which is generally between 0 and 1 00113 * 00114 * @param fU 00115 * Variable 00116 * @param pvV 00117 * Array of 4 points 00118 * 00119 * @return 00120 * Resulting vector 00121 */ 00122 PLMath::Vector3 Bernstein(float fU, const PLMath::Vector3 *pvV) const; 00123 00124 00125 //[-------------------------------------------------------] 00126 //[ Private data ] 00127 //[-------------------------------------------------------] 00128 private: 00129 // [TODO] New RTTI usage 00130 // Exported variables 00131 PLMath::Vector3 m_vV[4][4]; 00132 00133 00134 //[-------------------------------------------------------] 00135 //[ Private virtual MeshCreator functions ] 00136 //[-------------------------------------------------------] 00137 private: 00138 virtual Mesh *Create(Mesh &cMesh, PLCore::uint32 nLODLevel = 0, bool bStatic = true) const override; 00139 00140 00141 }; 00142 00143 00144 //[-------------------------------------------------------] 00145 //[ Namespace ] 00146 //[-------------------------------------------------------] 00147 } // PLMesh 00148 00149 00150 #endif // __PLMESH_MESHCREATOR_BEZIERPATCH_H__
|