concretePolyList.h
Engine/source/collision/concretePolyList.h
Classes:
class
A concrete, renderable PolyList.
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#ifndef _CONCRETEPOLYLIST_H_ 25#define _CONCRETEPOLYLIST_H_ 26 27#ifndef _ABSTRACTPOLYLIST_H_ 28#include "collision/abstractPolyList.h" 29#endif 30 31/// A concrete, renderable PolyList 32/// 33/// This class is used to store geometry from a PolyList query. 34/// 35/// It allows you to render this data, as well. 36/// 37/// @see AbstractPolyList 38class ConcretePolyList : public AbstractPolyList 39{ 40 public: 41 42 struct Poly { 43 PlaneF plane; 44 SceneObject* object; 45 BaseMatInstance* material; 46 U32 vertexStart; 47 U32 vertexCount; 48 U32 surfaceKey; 49 50 Poly() 51 { 52 vertexStart = 0; 53 vertexCount = 0; 54 surfaceKey = 0; 55 object = NULL; 56 material = NULL; 57 } 58 }; 59 60 typedef Vector<PlaneF> PlaneList; 61 typedef Vector<Point3F> VertexList; 62 typedef Vector<Poly> PolyList; 63 typedef Vector<U32> IndexList; 64 65 PolyList mPolyList; 66 VertexList mVertexList; 67 IndexList mIndexList; 68 69 PlaneList mPolyPlaneList; 70 71 public: 72 ConcretePolyList(); 73 ~ConcretePolyList(); 74 void clear(); 75 76 // Virtual methods 77 U32 addPoint(const Point3F& p); 78 U32 addPlane(const PlaneF& plane); 79 void begin(BaseMatInstance* material,U32 surfaceKey); 80 void plane(U32 v1,U32 v2,U32 v3); 81 void plane(const PlaneF& p); 82 void plane(const U32 index); 83 void vertex(U32 vi); 84 void end(); 85 void render(); 86 87 bool isEmpty() const; 88 89 /// This breaks all polys in the polylist into triangles. 90 void triangulate(); 91 92 protected: 93 const PlaneF& getIndexedPlane(const U32 index); 94}; 95 96#endif // _CONCRETEPOLYLIST_H_ 97