1 | #ifndef NX_COLLISION_NXTRIANGLEMESHSHAPE
|
---|
2 | #define NX_COLLISION_NXTRIANGLEMESHSHAPE
|
---|
3 | /*----------------------------------------------------------------------------*\
|
---|
4 | |
|
---|
5 | | Public Interface to NovodeX Technology
|
---|
6 | |
|
---|
7 | | www.novodex.com
|
---|
8 | |
|
---|
9 | \*----------------------------------------------------------------------------*/
|
---|
10 | /** \addtogroup physics
|
---|
11 | @{
|
---|
12 | */
|
---|
13 |
|
---|
14 | #include "Nxp.h"
|
---|
15 | #include "NxShape.h"
|
---|
16 |
|
---|
17 | class NxTriangle;
|
---|
18 | class NxTriangleMeshShapeDesc;
|
---|
19 | class NxTriangleMesh;
|
---|
20 |
|
---|
21 |
|
---|
22 | /**
|
---|
23 | \brief This class is a shape instance of a triangle mesh object of type NxTriangleMesh.
|
---|
24 |
|
---|
25 | Each shape is owned by an actor that it is attached to.
|
---|
26 |
|
---|
27 | <h3>Creation</h3>
|
---|
28 |
|
---|
29 | An instance can be created by calling the createShape() method of the NxActor object
|
---|
30 | that should own it, with a NxTriangleMeshShapeDesc object as the parameter, or by adding the
|
---|
31 | shape descriptor into the NxActorDesc class before creating the actor.
|
---|
32 |
|
---|
33 | The shape is deleted by calling NxActor::releaseShape() on the owning actor.
|
---|
34 |
|
---|
35 | Example:
|
---|
36 |
|
---|
37 | \include NxTriangleMeshShape_Create.cpp
|
---|
38 |
|
---|
39 | <h3>Visulizations:</h3>
|
---|
40 | \li #NX_VISUALIZE_COLLISION_AABBS
|
---|
41 | \li #NX_VISUALIZE_COLLISION_SHAPES
|
---|
42 | \li #NX_VISUALIZE_COLLISION_AXES
|
---|
43 | \li #NX_VISUALIZE_COLLISION_VNORMALS
|
---|
44 | \li #NX_VISUALIZE_COLLISION_FNORMALS
|
---|
45 | \li #NX_VISUALIZE_COLLISION_EDGES
|
---|
46 | \li #NX_VISUALIZE_COLLISION_SPHERES
|
---|
47 |
|
---|
48 | @see NxTriangleMeshShapeDesc NxTriangleMesh
|
---|
49 | */
|
---|
50 |
|
---|
51 | class NxTriangleMeshShape: public NxShape
|
---|
52 | {
|
---|
53 | public:
|
---|
54 | /*
|
---|
55 | \brief Saves the state of the shape object to a descriptor.
|
---|
56 |
|
---|
57 | \param[out] desc The descriptor used to retrieve the state of the object.
|
---|
58 |
|
---|
59 | <b>Platform:</b>
|
---|
60 | \li PC SW: Yes
|
---|
61 | \li PPU : Yes
|
---|
62 | \li PS3 : Yes
|
---|
63 | \li XB360: Yes
|
---|
64 |
|
---|
65 | @see NxTriangleMeshShapeDesc
|
---|
66 | */
|
---|
67 | virtual void saveToDesc(NxTriangleMeshShapeDesc& desc) const = 0;
|
---|
68 |
|
---|
69 | /**
|
---|
70 | \brief Retrieves the triangle mesh data associated with this instance.
|
---|
71 |
|
---|
72 | \return The triangle mesh associated with this shape.
|
---|
73 |
|
---|
74 | <b>Platform:</b>
|
---|
75 | \li PC SW: Yes
|
---|
76 | \li PPU : Yes
|
---|
77 | \li PS3 : Yes
|
---|
78 | \li XB360: Yes
|
---|
79 |
|
---|
80 | @see NxTriangleMesh
|
---|
81 | */
|
---|
82 | virtual NxTriangleMesh& getTriangleMesh() = 0;
|
---|
83 | virtual const NxTriangleMesh& getTriangleMesh() const = 0;
|
---|
84 |
|
---|
85 | /**
|
---|
86 | \brief Retrieves triangle data from a triangle ID.
|
---|
87 |
|
---|
88 | This function can be used together with #overlapAABBTriangles() to retrieve triangle properties.
|
---|
89 |
|
---|
90 | \param[out] triangle triangle points in local or world space.
|
---|
91 | \param[out] edgeTri World space edge normals for triangle (NULL to not compute).
|
---|
92 | \param[out] flags Flags which show if an edge is convex. See #NxTriangleFlags
|
---|
93 | \param[in] triangleIndex The index of the triangle to retrieve.
|
---|
94 | \param[in] worldSpace true to return triangle in world space, else false for local space
|
---|
95 | \return Unused.
|
---|
96 |
|
---|
97 | <b>Platform:</b>
|
---|
98 | \li PC SW: Yes
|
---|
99 | \li PPU : Yes
|
---|
100 | \li PS3 : Yes
|
---|
101 | \li XB360: Yes
|
---|
102 |
|
---|
103 | @see NxTriangle NxTriangleFlags NxTriangleID overlapAABBTriangles()
|
---|
104 | */
|
---|
105 | virtual NxU32 getTriangle(NxTriangle& triangle, NxTriangle* edgeTri, NxU32* flags, NxTriangleID triangleIndex, bool worldSpace=true) const = 0;
|
---|
106 |
|
---|
107 | /**
|
---|
108 | \brief Finds triangles touching input bounds.
|
---|
109 |
|
---|
110 | \warning This method returns a pointer to an internal structure using the indices member. Hence the
|
---|
111 | user should use or copy the indices before calling any other API function.
|
---|
112 |
|
---|
113 | The triangle indices returned by overlapAABBTriangles() can be used with #getTriangle() to retrieve the triangle properties.
|
---|
114 |
|
---|
115 | \param[in] bounds Bounds to test against. In object or world space depending on #NxQueryFlags. <b>Range:</b> See #NxBounds3
|
---|
116 | \param[in] flags Controls if the bounds are in object or world space and if we return first contact only. See #NxQueryFlags.
|
---|
117 | \param[out] nb Retrieves the number of triangle indices touching the AABB.
|
---|
118 | \param[out] indices Returns an array of touching triangle indices.
|
---|
119 | \return True if there is an overlap.
|
---|
120 |
|
---|
121 | <b>Platform:</b>
|
---|
122 | \li PC SW: Yes
|
---|
123 | \li PPU : No
|
---|
124 | \li PS3 : Yes
|
---|
125 | \li XB360: Yes
|
---|
126 |
|
---|
127 | @see NxBounds3 NxQueryFlags NxScene.overlapAABBShapes() getTriangle()
|
---|
128 | */
|
---|
129 | virtual bool overlapAABBTriangles(const NxBounds3 bounds, NxU32 flags, NxU32& nb, const NxU32*& indices) const = 0;
|
---|
130 |
|
---|
131 |
|
---|
132 | /**
|
---|
133 | \brief Send a page to the PhysX processor.
|
---|
134 |
|
---|
135 | Ensure that a mesh instance corresponding to a mesh page is present on the PhysX processor. If the
|
---|
136 | page is not present on the processor, it is also sent. If the PhysX processor is not present, this call has
|
---|
137 | no effect and returns false. If the page instance is already on the processor, this call has no effect and
|
---|
138 | returns true.
|
---|
139 |
|
---|
140 | \param pageIndex the index of the page to map. Pages are indexed sequentially starting from zero.
|
---|
141 | \return False if there are insufficient resources available on the processor to accommodate the page or page
|
---|
142 | instance.
|
---|
143 |
|
---|
144 | <b>Platform:</b>
|
---|
145 | \li PC SW: Yes
|
---|
146 | \li PPU : Yes
|
---|
147 | \li PS3 : Yes
|
---|
148 | \li XB360: Yes
|
---|
149 | */
|
---|
150 |
|
---|
151 | virtual bool mapPageInstance(NxU32 pageIndex) = 0;
|
---|
152 |
|
---|
153 | /**
|
---|
154 | \brief Release a page instance from the PhysX processor.
|
---|
155 |
|
---|
156 | Release a page instance corresponding to a mesh page from the PhysX processor. no other page instances
|
---|
157 | reference the mesh page, the page is also released. If the PhysX card is not present, this call has no effect.
|
---|
158 |
|
---|
159 | \param pageIndex the index of the page to unmap. Pages are indexed sequentially starting from zero.
|
---|
160 |
|
---|
161 | <b>Platform:</b>
|
---|
162 | \li PC SW: Yes
|
---|
163 | \li PPU : Yes
|
---|
164 | \li PS3 : Yes
|
---|
165 | \li XB360: Yes
|
---|
166 | */
|
---|
167 |
|
---|
168 | virtual void unmapPageInstance(NxU32 pageIndex) = 0;
|
---|
169 |
|
---|
170 | /**
|
---|
171 | \brief Determine whether a page instance is present from the PhysX processor.
|
---|
172 |
|
---|
173 | \param pageIndex the index of the page being queried. Pages are indexed sequentially starting from zero.
|
---|
174 | \return False if the page is not mapped or if the PhysX processor is not present.
|
---|
175 |
|
---|
176 | <b>Platform:</b>
|
---|
177 | \li PC SW: Yes
|
---|
178 | \li PPU : Yes
|
---|
179 | \li PS3 : Yes
|
---|
180 | \li XB360: Yes
|
---|
181 | */
|
---|
182 |
|
---|
183 | virtual bool isPageInstanceMapped(NxU32 pageIndex) const = 0;
|
---|
184 |
|
---|
185 | };
|
---|
186 |
|
---|
187 | /** @} */
|
---|
188 | #endif
|
---|
189 |
|
---|
190 |
|
---|
191 | //AGCOPYRIGHTBEGIN
|
---|
192 | ///////////////////////////////////////////////////////////////////////////
|
---|
193 | // Copyright © 2005 AGEIA Technologies.
|
---|
194 | // All rights reserved. www.ageia.com
|
---|
195 | ///////////////////////////////////////////////////////////////////////////
|
---|
196 | //AGCOPYRIGHTEND
|
---|
197 |
|
---|