PixelLightAPI  .
SNMPhysicsBodyMesh.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: SNMPhysicsBodyMesh.h                           *
00003  *
00004  *  Copyright (C) 2002-2011 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 __PLPHYSICS_SCENENODEMODIFIERS_BODYMESH_H__
00024 #define __PLPHYSICS_SCENENODEMODIFIERS_BODYMESH_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLPhysics/SceneNodeModifiers/SNMPhysicsBody.h"
00032 
00033 
00034 //[-------------------------------------------------------]
00035 //[ Namespace                                             ]
00036 //[-------------------------------------------------------]
00037 namespace PLPhysics {
00038 
00039 
00040 //[-------------------------------------------------------]
00041 //[ Classes                                               ]
00042 //[-------------------------------------------------------]
00043 /**
00044 *  @brief
00045 *    Physics mesh body scene node modifier
00046 *
00047 *  @remarks
00048 *    Tree collision is the preferred method for collision with polygonal meshes
00049 *    of arbitrary complexity. The mesh must be made of flat non-intersecting polygons, but they
00050 *    do not explicitly need to be triangles. Tree collision can be serialized by the application
00051 *    to/from an arbitrary storage device.\n
00052 *    If concave polygons are added to the tree collision, the variable 'Optimize' must be set to 1.
00053 *    With the optimize variable set to 1, we will optimize the collision mesh by removing non
00054 *    essential edges from adjacent flat polygons. We will not change the topology of the mesh but
00055 *    significantly reduces the number of polygons in the mesh. The reduction factor of the number of
00056 *    polygons in the mesh depends upon the irregularity of the mesh topology. A reduction factor of
00057 *    1.5 to 2 is common. If the variable optimize is set to zero, will leave the mesh geometry unaltered.
00058 *
00059 *  @note
00060 *    - When a tree collision is assigned to a body the mass of the body is ignored in all dynamics
00061 *      calculations. This makes the body behave as a static body.
00062 */
00063 class SNMPhysicsBodyMesh : public SNMPhysicsBody {
00064 
00065 
00066     //[-------------------------------------------------------]
00067     //[ RTTI interface                                        ]
00068     //[-------------------------------------------------------]
00069     pl_class(PLPHYSICS_RTTI_EXPORT, SNMPhysicsBodyMesh, "PLPhysics", PLPhysics::SNMPhysicsBody, "Physics mesh body scene node modifier")
00070         // Attributes
00071         pl_attribute(Mesh,      PLCore::String, "",     ReadWrite,  GetSet, "Collision mesh, if empty, the variable 'Mesh' (if available) of the scene node is used instead",                               "Type='Mesh'")
00072         pl_attribute(Optimize,  bool,           false,  ReadWrite,  GetSet, "Flag that indicates whether it should optimize this mesh. Set to 1 to optimize (may take some time!) the mesh, otherwise 0.",  "")
00073         // Constructors
00074         pl_constructor_1(ParameterConstructor,  PLScene::SceneNode&,    "Parameter constructor",    "")
00075     pl_class_end
00076 
00077 
00078     //[-------------------------------------------------------]
00079     //[ Public RTTI get/set functions                         ]
00080     //[-------------------------------------------------------]
00081     public:
00082         PLPHYSICS_API PLCore::String GetMesh() const;
00083         PLPHYSICS_API void SetMesh(const PLCore::String &sValue);
00084         PLPHYSICS_API bool GetOptimize() const;
00085         PLPHYSICS_API void SetOptimize(bool bValue);
00086 
00087 
00088     //[-------------------------------------------------------]
00089     //[ Public functions                                      ]
00090     //[-------------------------------------------------------]
00091     public:
00092         /**
00093         *  @brief
00094         *    Constructor
00095         *
00096         *  @param[in] cSceneNode
00097         *    Owner scene node
00098         */
00099         PLPHYSICS_API SNMPhysicsBodyMesh(PLScene::SceneNode &cSceneNode);
00100 
00101         /**
00102         *  @brief
00103         *    Destructor
00104         */
00105         PLPHYSICS_API virtual ~SNMPhysicsBodyMesh();
00106 
00107 
00108     //[-------------------------------------------------------]
00109     //[ Private data                                          ]
00110     //[-------------------------------------------------------]
00111     private:
00112         PLCore::String m_sMesh;     /**< Collision mesh, if empty, the variable 'Mesh' (if available) of the scene node is used instead */
00113         bool           m_bOptimize; /**< Flag that indicates whether it should optimize this mesh. Set to 1 to optimize (may take some time!) the mesh, otherwise 0. */
00114 
00115 
00116     //[-------------------------------------------------------]
00117     //[ Private virtual SNMPhysicsBody functions              ]
00118     //[-------------------------------------------------------]
00119     private:
00120         virtual void CreatePhysicsBody() override;
00121 
00122 
00123 };
00124 
00125 
00126 //[-------------------------------------------------------]
00127 //[ Namespace                                             ]
00128 //[-------------------------------------------------------]
00129 } // PLPhysics
00130 
00131 
00132 #endif // __PLPHYSICS_SCENENODEMODIFIERS_BODYMESH_H__


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:02
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported