Torque3D Documentation / _generateds / concretePolyList.h

concretePolyList.h

Engine/source/collision/concretePolyList.h

More...

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         object = NULL;
53         material = NULL;
54      }
55   };
56
57   typedef Vector<PlaneF> PlaneList;
58   typedef Vector<Point3F> VertexList;
59   typedef Vector<Poly>   PolyList;
60   typedef Vector<U32>    IndexList;
61
62   PolyList   mPolyList;
63   VertexList mVertexList;
64   IndexList  mIndexList;
65
66   PlaneList  mPolyPlaneList;
67
68  public:
69   ConcretePolyList();
70   ~ConcretePolyList();
71   void clear();
72
73   // Virtual methods
74   U32  addPoint(const Point3F& p);
75   U32  addPlane(const PlaneF& plane);
76   void begin(BaseMatInstance* material,U32 surfaceKey);
77   void plane(U32 v1,U32 v2,U32 v3);
78   void plane(const PlaneF& p);
79   void plane(const U32 index);
80   void vertex(U32 vi);
81   void end();
82   void render();
83
84   bool isEmpty() const;
85
86   /// This breaks all polys in the polylist into triangles.
87   void triangulate();
88
89  protected:
90   const PlaneF& getIndexedPlane(const U32 index);
91};
92
93#endif  // _CONCRETEPOLYLIST_H_
94