PixelLightAPI  .
BodyMesh.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: BodyMesh.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_BODYMESH_H__
00024 #define __PLPHYSICS_BODYMESH_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLMath/Vector3.h>
00032 #include "PLPhysics/Body.h"
00033 
00034 
00035 //[-------------------------------------------------------]
00036 //[ Namespace                                             ]
00037 //[-------------------------------------------------------]
00038 namespace PLPhysics {
00039 
00040 
00041 //[-------------------------------------------------------]
00042 //[ Classes                                               ]
00043 //[-------------------------------------------------------]
00044 /**
00045 *  @brief
00046 *    Abstract PL physics mesh body
00047 *
00048 *  @remarks
00049 *    Tree collision is the preferred method for collision with polygonal meshes
00050 *    of arbitrary complexity. The mesh must be made of flat non-intersecting polygons, but they
00051 *    do not explicitly need to be triangles. Tree collision can be serialized by the application
00052 *    to/from an arbitrary storage device.\n
00053 *    If concave polygons are added to the tree collision, the variable 'Optimize' must be set to 1.
00054 *    With the optimize variable set to 1, we will optimize the collision mesh by removing non
00055 *    essential edges from adjacent flat polygons. We will not change the topology of the mesh but
00056 *    significantly reduces the number of polygons in the mesh. The reduction factor of the number of
00057 *    polygons in the mesh depends upon the irregularity of the mesh topology. A reduction factor of
00058 *    1.5 to 2 is common. If the variable optimize is set to zero, will leave the mesh geometry unaltered.
00059 *
00060 *  @note
00061 *    - When a mesh is assigned to a body the mass of the body is ignored in all dynamics
00062 *      calculations. This makes the body behave as a static body.
00063 *    - The "TwoSided" material parameter should be supported
00064 */
00065 class BodyMesh : public Body {
00066 
00067 
00068     //[-------------------------------------------------------]
00069     //[ Public functions                                      ]
00070     //[-------------------------------------------------------]
00071     public:
00072         /**
00073         *  @brief
00074         *    Destructor
00075         */
00076         PLPHYSICS_API virtual ~BodyMesh();
00077 
00078         /**
00079         *  @brief
00080         *    Returns the collision mesh
00081         *
00082         *  @return
00083         *    The collision mesh
00084         */
00085         PLPHYSICS_API PLCore::String GetMesh() const;
00086 
00087         /**
00088         *  @brief
00089         *    Returns the mesh scale
00090         *
00091         *  @return
00092         *    The mesh scale
00093         */
00094         PLPHYSICS_API const PLMath::Vector3 &GetMeshScale() const;
00095 
00096         /**
00097         *  @brief
00098         *    Returns whether the physics API is allowed to optimize the mesh or not (if supported)
00099         *
00100         *  @return
00101         *    'true' if the physics API is allowed to optimize the mesh, else 'false'
00102         */
00103         PLPHYSICS_API bool GetOptimize() const;
00104 
00105 
00106     //[-------------------------------------------------------]
00107     //[ Protected functions                                   ]
00108     //[-------------------------------------------------------]
00109     protected:
00110         /**
00111         *  @brief
00112         *    Constructor
00113         *
00114         *  @param[in] cWorld
00115         *    World this body is in
00116         *  @param[in] cBodyImpl
00117         *    Reference to the physics API specific body implementation
00118         *  @param[in] sMesh
00119         *    Collision mesh
00120         *  @param[in] vMeshScale
00121         *    Mesh scale
00122         *  @param[in] bOptimize
00123         *    Allow the physics API to optimize the mesh? (if supported)
00124         */
00125         PLPHYSICS_API BodyMesh(World &cWorld, BodyImpl &cBodyImpl, const PLCore::String &sMesh, const PLMath::Vector3 &vMeshScale, bool bOptimize);
00126 
00127 
00128     //[-------------------------------------------------------]
00129     //[ Protected data                                        ]
00130     //[-------------------------------------------------------]
00131     protected:
00132         PLCore::String  m_sMesh;        /**< Collision mesh */
00133         PLMath::Vector3 m_vMeshScale;   /**< Mesh scale */
00134         bool            m_bOptimize;    /**< Allow the physics API to optimize the mesh? (if supported) */
00135 
00136 
00137 };
00138 
00139 
00140 //[-------------------------------------------------------]
00141 //[ Namespace                                             ]
00142 //[-------------------------------------------------------]
00143 } // PLPhysics
00144 
00145 
00146 #endif // __PLPHYSICS_BODYMESH_H__


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