29#ifndef PX_RENDER_OUTPUT_H
30#define PX_RENDER_OUTPUT_H
32#include "foundation/PxMat44.h"
33#include "foundation/PxBasicTemplates.h"
34#include "PxRenderBuffer.h"
43#pragma warning( disable : 4251 )
68 mTransform(PxIdentity),
106 : minimum(-extents), maximum(extents), wireframe(wireframe_) {}
109 : minimum(pos - extents), maximum(pos + extents), wireframe(wireframe_) {}
112 : minimum(bounds.minimum), maximum(bounds.maximum), wireframe(wireframe_) {}
121 out << PxRenderOutput::LINESTRIP;
122 out <<
PxVec3(box.minimum.x, box.minimum.y, box.minimum.z);
123 out <<
PxVec3(box.maximum.x, box.minimum.y, box.minimum.z);
124 out <<
PxVec3(box.maximum.x, box.maximum.y, box.minimum.z);
125 out <<
PxVec3(box.minimum.x, box.maximum.y, box.minimum.z);
126 out <<
PxVec3(box.minimum.x, box.minimum.y, box.minimum.z);
127 out <<
PxVec3(box.minimum.x, box.minimum.y, box.maximum.z);
128 out <<
PxVec3(box.maximum.x, box.minimum.y, box.maximum.z);
129 out <<
PxVec3(box.maximum.x, box.maximum.y, box.maximum.z);
130 out <<
PxVec3(box.minimum.x, box.maximum.y, box.maximum.z);
131 out <<
PxVec3(box.minimum.x, box.minimum.y, box.maximum.z);
132 out << PxRenderOutput::LINES;
133 out <<
PxVec3(box.maximum.x, box.minimum.y, box.minimum.z);
134 out <<
PxVec3(box.maximum.x, box.minimum.y, box.maximum.z);
135 out <<
PxVec3(box.maximum.x, box.maximum.y, box.minimum.z);
136 out <<
PxVec3(box.maximum.x, box.maximum.y, box.maximum.z);
137 out <<
PxVec3(box.minimum.x, box.maximum.y, box.minimum.z);
138 out <<
PxVec3(box.minimum.x, box.maximum.y, box.maximum.z);
142 out << PxRenderOutput::TRIANGLESTRIP;
143 out << PxVec3(box.minimum.x, box.minimum.y, box.minimum.z);
144 out << PxVec3(box.minimum.x, box.maximum.y, box.minimum.z);
145 out << PxVec3(box.maximum.x, box.minimum.y, box.minimum.z);
146 out << PxVec3(box.maximum.x, box.maximum.y, box.minimum.z);
147 out << PxVec3(box.maximum.x, box.maximum.y, box.maximum.z);
148 out << PxVec3(box.minimum.x, box.maximum.y, box.minimum.z);
149 out << PxVec3(box.minimum.x, box.maximum.y, box.maximum.z);
150 out << PxVec3(box.minimum.x, box.minimum.y, box.minimum.z);
151 out << PxVec3(box.minimum.x, box.minimum.y, box.maximum.z);
152 out << PxVec3(box.maximum.x, box.minimum.y, box.minimum.z);
153 out << PxVec3(box.maximum.x, box.minimum.y, box.maximum.z);
154 out << PxVec3(box.maximum.x, box.maximum.y, box.maximum.z);
155 out << PxVec3(box.minimum.x, box.minimum.y, box.maximum.z);
156 out << PxVec3(box.minimum.x, box.maximum.y, box.maximum.z);
164 : base(pos), tip(pos + vec), headLength(vec.
magnitude()*0.15f) {}
167 : base(pos), tip(pos + vec), headLength(headLength_) {}
174 tangent0 =
PxAbs(normal.x) < 0.70710678f ?
PxVec3(0, -normal.z, normal.y) :
PxVec3(-normal.y, normal.x, 0);
176 tangent1 = normal.
cross(tangent0);
178 PX_FORCE_INLINE PxRenderOutput& operator<<(PxRenderOutput& out,
const PxDebugArrow& arrow)
180 PxVec3 t0 = arrow.tip - arrow.base, t1, t2;
183 normalToTangents(t0, t1, t2);
185 const PxReal tipAngle = 0.25f;
186 t1 *= arrow.headLength * tipAngle;
187 t2 *= arrow.headLength * tipAngle *
PxSqrt(3.0f);
188 PxVec3 headBase = arrow.tip - t0 * arrow.headLength;
190 out << PxRenderOutput::LINES;
191 out << arrow.base << arrow.tip;
193 out << PxRenderOutput::TRIANGLESTRIP;
195 out << headBase + t1 + t1;
196 out << headBase - t1 - t2;
197 out << headBase - t1 + t2;
199 out << headBase + t1 + t1;
206 PxU32 cY = PxU32(PxDebugColor::eARGB_GREEN), PxU32 cZ = PxU32(PxDebugColor::eARGB_BLUE))
207 : extends(ext), colorX(cX), colorY(cY), colorZ(cZ) {}
209 PxU32 colorX, colorY, colorZ;
213 const PxReal headLength = basis.extends.
magnitude() * 0.15f;
223 : nSegments(s), radius(r) {}
229 const PxF32 step = PxTwoPi / circle.nSegments;
231 out << PxRenderOutput::LINESTRIP;
232 for (PxU32 i = 0; i < circle.nSegments; i++, angle += step)
233 out <<
PxVec3(circle.radius *
PxSin(angle), circle.radius *
PxCos(angle), 0);
234 out <<
PxVec3(0, circle.radius, 0);
240 PxDebugArc(PxU32 s, PxReal r, PxReal minAng, PxReal maxAng)
241 : nSegments(s), radius(r), minAngle(minAng), maxAngle(maxAng) {}
244 PxReal minAngle, maxAngle;
248 const PxF32 step = (arc.maxAngle - arc.minAngle) / arc.nSegments;
249 PxF32 angle = arc.minAngle;
250 out << PxRenderOutput::LINESTRIP;
251 for (PxU32 i = 0; i < arc.nSegments; i++, angle += step)
253 out <<
PxVec3(arc.radius *
PxSin(arc.maxAngle), arc.radius *
PxCos(arc.maxAngle), 0);
257 PX_INLINE PxRenderOutput& PxRenderOutput::operator<<(Primitive prim)
264 PX_INLINE PxRenderOutput& PxRenderOutput::operator<<(PxU32 color)
270 PX_INLINE PxRenderOutput& PxRenderOutput::operator<<(
const PxMat44& transform)
276 PX_INLINE PxRenderOutput& PxRenderOutput::operator<<(
const PxTransform& t)
278 mTransform = PxMat44(t);
282 PX_INLINE PxRenderOutput& PxRenderOutput::operator<<(
const PxVec3& vertexIn)
285 const PxVec3 vertex = mTransform.
transform(vertexIn);
292 mBuffer.addPoint(PxDebugPoint(vertex, mColor));
break;
294 if (mVertexCount == 2)
296 mBuffer.addLine(PxDebugLine(mVertex0, vertex, mColor));
301 if (mVertexCount >= 2)
302 mBuffer.addLine(PxDebugLine(mVertex0, vertex, mColor));
305 if (mVertexCount == 3)
307 mBuffer.addTriangle(PxDebugTriangle(mVertex1, mVertex0, vertex, mColor));
312 if (mVertexCount >= 3)
313 mBuffer.addTriangle(PxDebugTriangle(
314 (mVertexCount & 0x1) ? mVertex0 : mVertex1,
315 (mVertexCount & 0x1) ? mVertex1 : mVertex0, vertex, mColor));
320 if (1 < mVertexCount)
332 PX_INLINE PxDebugLine* PxRenderOutput::reserveSegments(PxU32 nbSegments)
334 return mBuffer.reserveLines(nbSegments);
337 PX_INLINE PxDebugPoint* PxRenderOutput::reservePoints(PxU32 nbPoints)
339 return mBuffer.reservePoints(nbPoints);
343 PX_INLINE void PxRenderOutput::outputSegment(
const PxVec3& v0,
const PxVec3& v1)
345 PxDebugLine* segment = mBuffer.reserveLines(1);
348 segment->color0 = segment->color1 = mColor;
351 PX_INLINE PxRenderOutput& PxRenderOutput::outputCapsule(PxF32 radius, PxF32 halfHeight,
const PxMat44& absPose)
353 PxRenderOutput& out = *
this;
355 const PxVec3 vleft2(-halfHeight, 0.0f, 0.0f);
356 PxMat44 left2 = absPose;
357 left2.column3 += PxVec4(left2.rotate(vleft2), 0.0f);
358 out << left2 << PxDebugArc(100, radius, PxPi, PxTwoPi);
360 PxMat44 rotPose = left2;
361 PxSwap(rotPose.column1, rotPose.column2);
362 rotPose.column1 = -rotPose.column1;
363 out << rotPose << PxDebugArc(100, radius, PxPi, PxTwoPi);
365 PxSwap(rotPose.column0, rotPose.column2);
366 rotPose.column0 = -rotPose.column0;
367 out << rotPose << PxDebugCircle(100, radius);
369 const PxVec3 vright2(halfHeight, 0.0f, 0.0f);
370 PxMat44 right2 = absPose;
371 right2.column3 += PxVec4(right2.rotate(vright2), 0.0f);
372 out << right2 << PxDebugArc(100, radius, 0.0f, PxPi);
375 PxSwap(rotPose.column1, rotPose.column2);
376 rotPose.column1 = -rotPose.column1;
377 out << rotPose << PxDebugArc(100, radius, 0.0f, PxPi);
379 PxSwap(rotPose.column0, rotPose.column2);
380 rotPose.column0 = -rotPose.column0;
381 out << rotPose << PxDebugCircle(100, radius);
384 out.outputSegment(absPose.transform(PxVec3(-halfHeight, radius, 0)),
385 absPose.transform(PxVec3(halfHeight, radius, 0)));
386 out.outputSegment(absPose.transform(PxVec3(-halfHeight, -radius, 0)),
387 absPose.transform(PxVec3(halfHeight, -radius, 0)));
388 out.outputSegment(absPose.transform(PxVec3(-halfHeight, 0, radius)),
389 absPose.transform(PxVec3(halfHeight, 0, radius)));
390 out.outputSegment(absPose.transform(PxVec3(-halfHeight, 0, -radius)),
391 absPose.transform(PxVec3(halfHeight, 0, -radius)));
Class representing 3D range or axis aligned bounding box.
Definition PxBounds3.h:58
4x4 matrix class
Definition PxMat44.h:55
PX_CUDA_CALLABLE PX_INLINE const PxVec4 transform(const PxVec4 &other) const
Transform vector by matrix, equal to v' = M*v.
Definition PxMat44.h:279
Interface for points, lines, triangles, and text buffer.
Definition PxRenderBuffer.h:136
Definition PxRenderOutput.h:50
PX_CUDA_CALLABLE PX_FORCE_INLINE Type normalize()
normalizes the vector in place
Definition PxVec3.h:297
3 Element vector class.
Definition PxVec3.h:50
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 cross(const PxVec3 &v) const
cross product
Definition PxVec3.h:284
PX_CUDA_CALLABLE PX_FORCE_INLINE float normalize()
normalizes the vector in place
Definition PxVec3.h:300
PX_CUDA_CALLABLE PX_FORCE_INLINE float magnitude() const
returns the magnitude
Definition PxVec3.h:183
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_INLINE
Definition PxPreprocessor.h:320
transform(pattern)
Definition docopt.py:72
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_CUDA_CALLABLE PX_FORCE_INLINE float PxCos(float a)
Cosine of an angle (Unit: Radians)
Definition PxMath.h:190
PX_CUDA_CALLABLE PX_FORCE_INLINE float PxAbs(float a)
abs returns the absolute value of its argument.
Definition PxMath.h:109
PX_CUDA_CALLABLE PX_FORCE_INLINE float PxSqrt(float a)
Square root.
Definition PxMath.h:146
PX_CUDA_CALLABLE PX_FORCE_INLINE float PxSin(float a)
trigonometry – all angles are in radians.
Definition PxMath.h:178
Definition PxRenderOutput.h:239
Definition PxRenderOutput.h:162
Definition PxRenderOutput.h:204
Definition PxRenderOutput.h:104
Definition PxRenderOutput.h:221
Used to store a single line and colour for debug rendering.
Definition PxRenderBuffer.h:85
Used to store a single point and colour for debug rendering.
Definition PxRenderBuffer.h:73