Torque3D Documentation / _generateds / AbstractPolyList

AbstractPolyList

Engine/source/collision/abstractPolyList.h

A polygon filtering interface.

More...

Common Interface

Sets the transform applying to the current stream of vertices.

getTransform(MatrixF * mat, Point3F * scale)

Gets the transform applying to the current stream of vertices.

This is called by the object which is currently feeding us vertices, to tell us who it is.

addBox(const Box3F & box, BaseMatInstance * material)

Add a box via the query interface (below).

Query Interface

It is through this interface that geometry data is fed to the PolyList.

The order of calls are:

// Example code that adds data to a PolyList.
// See AbstractPolyList::addBox() for the function this was taken from.

// First, we add points... (note that we use base to track the start of adding.)
U32 base = addPoint(pos);
pos.y += dy; addPoint(pos);
pos.x += dx; addPoint(pos);
pos.y -= dy; addPoint(pos);
pos.z += dz; addPoint(pos);
pos.x -= dx; addPoint(pos);
pos.y += dy; addPoint(pos);
pos.x += dx; addPoint(pos);

// Now we add our surfaces. (there are six, as we are adding a cube here)
for (S32 i = 0; i < 6; i++) {
   // Begin a surface
   begin(0,i);

   // Calculate the vertex ids; we have a lookup table to tell us offset from base.
   // In your own code, you might use a different method.
   S32 v1 = base + PolyFace[i][0];
   S32 v2 = base + PolyFace[i][1];
   S32 v3 = base + PolyFace[i][2];
   S32 v4 = base + PolyFace[i][3];

   // Reference the four vertices that make up this surface.
   vertex(v1);
   vertex(v2);
   vertex(v3);
   vertex(v4);

   // Indicate the plane of this surface.
   plane(v1,v2,v3);

   // End the surface.
   end();
}

bool

Are we empty of data?

Adds a point to the poly list, and returns an ID number for that point.

Adds a point and normal to the poly list, and returns an ID number for them.

Adds a plane to the poly list, and returns an ID number for that point.

begin(BaseMatInstance * material, U32 surfaceKey)

Start a surface.

plane(U32 v1, U32 v2, U32 v3)

Indicate the plane of the surface.

Indicate the plane of the surface.

plane(const U32 index)

Indicate the plane of the surface.

vertex(U32 vi)

Reference a vertex which is in this surface.

end()

Mark the end of a surface.

bool

Return list transform and bounds in list space.

Interest

This is a mechanism to let you specify interest in a specific normal.

If you set a normal you're interested in, then any planes facing "away" from that normal are culled from the results.

This is handy if you're using this to do a physics check, as you're not interested in polygons facing away from you (since you don't collide with the backsides/insides of things).

Public Functions

Protected Functions

A helper function to convert a plane index to a PlaneF structure.

Detailed Description

A polygon filtering interface.

The various AbstractPolyList subclasses are used in Torque as an interface to handle spatial queries. SceneObject::buildPolyList() takes an implementor of AbstractPolyList (such as ConcretePolyList, ClippedPolyList, etc.) and a bounding volume. The function runs geometry data from all the objects in the bounding volume through the passed PolyList.

This interface only provides a method to get data INTO your implementation. Different subclasses provide different interfaces to get data back out, depending on their specific quirks.

The physics engine now uses convex hulls for collision detection.

see:

Common Interface

setBaseTransform(const MatrixF & mat)

setTransform(const MatrixF * mat, const Point3F & scale)

Sets the transform applying to the current stream of vertices.

Parameters:

mat

Transformation of the object. (in)

scale

Scaling of the object. (in)

getTransform(MatrixF * mat, Point3F * scale)

Gets the transform applying to the current stream of vertices.

Parameters:

mat

Transformation of the object. (out)

scale

Scaling of the object. (out)

setObject(SceneObject * )

This is called by the object which is currently feeding us vertices, to tell us who it is.

addBox(const Box3F & box, BaseMatInstance * material)

Add a box via the query interface (below).

This wraps some calls to addPoint and addPlane.

doConstruct()

Query Interface

It is through this interface that geometry data is fed to the PolyList.

The order of calls are:

// Example code that adds data to a PolyList.
// See AbstractPolyList::addBox() for the function this was taken from.

// First, we add points... (note that we use base to track the start of adding.)
U32 base = addPoint(pos);
pos.y += dy; addPoint(pos);
pos.x += dx; addPoint(pos);
pos.y -= dy; addPoint(pos);
pos.z += dz; addPoint(pos);
pos.x -= dx; addPoint(pos);
pos.y += dy; addPoint(pos);
pos.x += dx; addPoint(pos);

// Now we add our surfaces. (there are six, as we are adding a cube here)
for (S32 i = 0; i < 6; i++) {
   // Begin a surface
   begin(0,i);

   // Calculate the vertex ids; we have a lookup table to tell us offset from base.
   // In your own code, you might use a different method.
   S32 v1 = base + PolyFace[i][0];
   S32 v2 = base + PolyFace[i][1];
   S32 v3 = base + PolyFace[i][2];
   S32 v4 = base + PolyFace[i][3];

   // Reference the four vertices that make up this surface.
   vertex(v1);
   vertex(v2);
   vertex(v3);
   vertex(v4);

   // Indicate the plane of this surface.
   plane(v1,v2,v3);

   // End the surface.
   end();
}

isEmpty()

Are we empty of data?

Reimplemented by: ClippedPolyList, ConcretePolyList, EarlyOutPolyList, ExtrudedPolyList, OptimizedPolyList, PlaneExtractorPolyList, VertexPolyList, RecastPolyList

addPoint(const Point3F & p)

Adds a point to the poly list, and returns an ID number for that point.

Reimplemented by: ClippedPolyList, ConcretePolyList, EarlyOutPolyList, ExtrudedPolyList, OptimizedPolyList, PlaneExtractorPolyList, VertexPolyList, RecastPolyList

addPointAndNormal(const Point3F & p, const Point3F & normal)

Adds a point and normal to the poly list, and returns an ID number for them.

Normals are ignored for polylists that do not support them.

Reimplemented by: ClippedPolyList

addPlane(const PlaneF & plane)

Adds a plane to the poly list, and returns an ID number for that point.

Reimplemented by: ClippedPolyList, ConcretePolyList, EarlyOutPolyList, ExtrudedPolyList, OptimizedPolyList, PlaneExtractorPolyList, VertexPolyList, RecastPolyList

begin(BaseMatInstance * material, U32 surfaceKey)

Start a surface.

Parameters:

material

A material ID for this surface.

surfaceKey

A key value to associate with this surface.

Reimplemented by: ClippedPolyList, ConcretePolyList, EarlyOutPolyList, ExtrudedPolyList, OptimizedPolyList, PlaneExtractorPolyList, VertexPolyList, RecastPolyList

plane(U32 v1, U32 v2, U32 v3)

Indicate the plane of the surface.

Reimplemented by: ClippedPolyList, ConcretePolyList, EarlyOutPolyList, ExtrudedPolyList, OptimizedPolyList, PlaneExtractorPolyList, VertexPolyList, RecastPolyList

plane(const PlaneF & p)

Indicate the plane of the surface.

Reimplemented by: ClippedPolyList, ConcretePolyList, EarlyOutPolyList, ExtrudedPolyList, OptimizedPolyList, PlaneExtractorPolyList, VertexPolyList, RecastPolyList

plane(const U32 index)

Indicate the plane of the surface.

Reimplemented by: ClippedPolyList, ConcretePolyList, EarlyOutPolyList, ExtrudedPolyList, OptimizedPolyList, PlaneExtractorPolyList, VertexPolyList, RecastPolyList

vertex(U32 vi)

Reference a vertex which is in this surface.

Reimplemented by: ClippedPolyList, ConcretePolyList, EarlyOutPolyList, ExtrudedPolyList, OptimizedPolyList, PlaneExtractorPolyList, VertexPolyList, RecastPolyList

end()

Mark the end of a surface.

Reimplemented by: ClippedPolyList, ConcretePolyList, DepthSortList, EarlyOutPolyList, ExtrudedPolyList, OptimizedPolyList, PlaneExtractorPolyList, VertexPolyList, RecastPolyList

getMapping(MatrixF * , Box3F * )

Return list transform and bounds in list space.

return:

False if no data is available.

Reimplemented by: DepthSortList

Interest

This is a mechanism to let you specify interest in a specific normal.

If you set a normal you're interested in, then any planes facing "away" from that normal are culled from the results.

This is handy if you're using this to do a physics check, as you're not interested in polygons facing away from you (since you don't collide with the backsides/insides of things).

setInterestNormal(const Point3F & normal)

clearInterestNormal()

isInterestedInPlane(const PlaneF & plane)

isInterestedInPlane(const U32 index)

Protected Attributes

MatrixF mBaseMatrix 
SceneObject * mCurrObject 
Point3F mInterestNormal 
bool mInterestNormalRegistered 
MatrixF mMatrix 
PlaneTransformer mPlaneTransformer 
Point3F mScale 
MatrixF mTransformMatrix 

Public Functions

AbstractPolyList()

~AbstractPolyList()

Protected Functions

getIndexedPlane(const U32 index)

A helper function to convert a plane index to a PlaneF structure.

Reimplemented by: ClippedPolyList, ConcretePolyList, EarlyOutPolyList, ExtrudedPolyList, OptimizedPolyList, PlaneExtractorPolyList, VertexPolyList, RecastPolyList