Support Forum       G3D Web Page     
Public Member Functions | Static Public Member Functions | Static Protected Member Functions | List of all members
G3D::MeshShape Class Reference


Mesh shape is intended for debugging and for collision detection. More...

Inherits G3D::Shape.

Public Member Functions

 MeshShape (const Array< Vector3 > &vertex, const Array< int > &index)
 Copies the geometry from the arrays. More...
 
 MeshShape (const String &filename, float scale=1.0f)
 
 MeshShape (const CPUVertexArray &vertexArray, const Array< Tri > &tri)
 Copies the triangle array. More...
 
 MeshShape (const class ParseOBJ &parseOBJ)
 
virtual float area () const
 Slow the first time it is called because the BSP tree must be computed. More...
 
virtual CoordinateFrameaxes ()
 
virtual AABox boundingAABox () const
 Bounding axis aligned box of this object. More...
 
virtual Sphere boundingSphere () const
 Bounding sphere of this object. More...
 
virtual Boxbox ()
 
virtual const Boxbox () const
 
virtual const shared_ptr< TriTree > & bspTree () const
 Not computed until the first call to bspTree, area, or getRandomSurfacePoint. More...
 
virtual Capsulecapsule ()
 
virtual const Capsulecapsule () const
 
virtual Vector3 center () const
 Center of mass for this object. More...
 
virtual Cylindercylinder ()
 
virtual const Cylindercylinder () const
 
virtual void getRandomSurfacePoint (Vector3 &P, Vector3 &N=Vector3::ignore, Random &rnd=Random::common()) const
 A point selected uniformly at random with respect to the surface area of this object. More...
 
virtual void getRandomSurfacePoint (Vector3 &P, Vector3 &N, int &triangleStartIndex, Vector3 &barycentricWeights, Random &rnd=Random::common()) const
 
const Array< int > & indexArray () const
 Tri-list index array into vertexArray(). More...
 
virtual Planeplane ()
 
virtual const Planeplane () const
 
virtual Vector3point ()
 
virtual const Vector3point () const
 
virtual Vector3 randomInteriorPoint (Random &rnd=Random::common()) const
 Returns a point on the surface. More...
 
virtual Rayray ()
 
virtual const Rayray () const
 
virtual void render (RenderDevice *rd, const CoordinateFrame &cframe, Color4 solidColor=Color4(0.5f, 0.5f, 0, 0.5f), Color4 wireColor=Color3::black())
 
virtual Spheresphere ()
 
virtual const Spheresphere () const
 
virtual Triangletriangle ()
 
virtual const Triangletriangle () const
 
virtual Type type () const
 
const Array< Vector3 > & vertexArray () const
 
virtual float volume () const
 No volume; Mesh is treated as a 2D surface. More...
 

Static Public Member Functions

static String typeToString (Type t)
 

Static Protected Member Functions

template<class T , class ... ArgTypes>
static shared_ptr< T > createShared (ArgTypes &&... args)
 Like std::make_shared, but works for protected constructors. More...
 

Detailed Description


Mesh shape is intended for debugging and for collision detection.

It is not a general purpose mesh.

See also
G3D::Surface, G3D::ArticulatedModel, G3D::IFSModel, G3D::MD2Model, G3D::MeshAlg

Constructor & Destructor Documentation

◆ MeshShape() [1/4]

G3D::MeshShape::MeshShape ( const Array< Vector3 > &  vertex,
const Array< int > &  index 
)

Copies the geometry from the arrays.

The index array must describe a triangle list; you can convert other primitives using the MeshAlg methods.

◆ MeshShape() [2/4]

G3D::MeshShape::MeshShape ( const String filename,
float  scale = 1.0f 
)
explicit

◆ MeshShape() [3/4]

G3D::MeshShape::MeshShape ( const CPUVertexArray vertexArray,
const Array< Tri > &  tri 
)

Copies the triangle array.

◆ MeshShape() [4/4]

G3D::MeshShape::MeshShape ( const class ParseOBJ parseOBJ)
explicit

Member Function Documentation

◆ area()

virtual float G3D::MeshShape::area ( ) const
virtual

Slow the first time it is called because the BSP tree must be computed.

Implements G3D::Shape.

◆ axes()

virtual CoordinateFrame& G3D::Shape::axes ( )
inlinevirtualinherited

Reimplemented in G3D::AxesShape.

◆ boundingAABox()

virtual AABox G3D::MeshShape::boundingAABox ( ) const
virtual

Bounding axis aligned box of this object.

Implements G3D::Shape.

◆ boundingSphere()

virtual Sphere G3D::MeshShape::boundingSphere ( ) const
virtual

Bounding sphere of this object.

Implements G3D::Shape.

◆ box() [1/2]

virtual Box& G3D::Shape::box ( )
inlinevirtualinherited

Reimplemented in G3D::BoxShape.

◆ box() [2/2]

virtual const Box& G3D::Shape::box ( ) const
inlinevirtualinherited

Reimplemented in G3D::BoxShape.

◆ bspTree()

virtual const shared_ptr<TriTree>& G3D::MeshShape::bspTree ( ) const
inlinevirtual

Not computed until the first call to bspTree, area, or getRandomSurfacePoint.

◆ capsule() [1/2]

virtual Capsule& G3D::Shape::capsule ( )
inlinevirtualinherited

Reimplemented in G3D::CapsuleShape.

◆ capsule() [2/2]

virtual const Capsule& G3D::Shape::capsule ( ) const
inlinevirtualinherited

Reimplemented in G3D::CapsuleShape.

◆ center()

virtual Vector3 G3D::MeshShape::center ( ) const
virtual

Center of mass for this object.

Implements G3D::Shape.

◆ createShared()

template<class T , class ... ArgTypes>
static shared_ptr<T> G3D::ReferenceCountedObject::createShared ( ArgTypes &&...  args)
inlinestaticprotectedinherited

Like std::make_shared, but works for protected constructors.

Call as createShared<myclass>.

◆ cylinder() [1/2]

virtual Cylinder& G3D::Shape::cylinder ( )
inlinevirtualinherited

Reimplemented in G3D::CylinderShape.

◆ cylinder() [2/2]

virtual const Cylinder& G3D::Shape::cylinder ( ) const
inlinevirtualinherited

Reimplemented in G3D::CylinderShape.

◆ getRandomSurfacePoint() [1/2]

virtual void G3D::MeshShape::getRandomSurfacePoint ( Vector3 P,
Vector3 N = Vector3::ignore,
Random rnd = Random::common() 
) const
virtual

A point selected uniformly at random with respect to the surface area of this object.

Not available on the Plane or Ray, which have infinite extent. The normal has unit length and points out of the surface.

Implements G3D::Shape.

◆ getRandomSurfacePoint() [2/2]

virtual void G3D::MeshShape::getRandomSurfacePoint ( Vector3 P,
Vector3 N,
int &  triangleStartIndex,
Vector3 barycentricWeights,
Random rnd = Random::common() 
) const
virtual
Parameters
triangleStartIndexThe first element of the index array describing this triangle. The next two indices are the others defining the returned triangle.

◆ indexArray()

const Array<int>& G3D::MeshShape::indexArray ( ) const
inlinevirtual

Tri-list index array into vertexArray().

Reimplemented from G3D::Shape.

◆ plane() [1/2]

virtual Plane& G3D::Shape::plane ( )
inlinevirtualinherited

Reimplemented in G3D::PlaneShape.

◆ plane() [2/2]

virtual const Plane& G3D::Shape::plane ( ) const
inlinevirtualinherited

Reimplemented in G3D::PlaneShape.

◆ point() [1/2]

virtual Vector3& G3D::Shape::point ( )
inlinevirtualinherited

Reimplemented in G3D::PointShape.

◆ point() [2/2]

virtual const Vector3& G3D::Shape::point ( ) const
inlinevirtualinherited

Reimplemented in G3D::PointShape, and G3D::ArrowShape.

◆ randomInteriorPoint()

virtual Vector3 G3D::MeshShape::randomInteriorPoint ( Random rnd = Random::common()) const
virtual

Returns a point on the surface.

The process is done by random sampling and will only sample a set number of points. If none of the points sampled are found to be on the interior of the mesh than a nan value is returned. If this function consitently returns a nan value, it is probaly because the mesh shape is poorly constructed

Implements G3D::Shape.

◆ ray() [1/2]

virtual Ray& G3D::Shape::ray ( )
inlinevirtualinherited

Reimplemented in G3D::RayShape.

◆ ray() [2/2]

virtual const Ray& G3D::Shape::ray ( ) const
inlinevirtualinherited

Reimplemented in G3D::RayShape.

◆ render()

virtual void G3D::MeshShape::render ( RenderDevice rd,
const CoordinateFrame cframe,
Color4  solidColor = Color4(0.5f, 0.5f, 0, 0.5f),
Color4  wireColor = Color3::black() 
)
virtual

Implements G3D::Shape.

◆ sphere() [1/2]

virtual Sphere& G3D::Shape::sphere ( )
inlinevirtualinherited

Reimplemented in G3D::SphereShape.

◆ sphere() [2/2]

virtual const Sphere& G3D::Shape::sphere ( ) const
inlinevirtualinherited

Reimplemented in G3D::SphereShape.

◆ triangle() [1/2]

virtual Triangle& G3D::Shape::triangle ( )
inlinevirtualinherited

Reimplemented in G3D::TriangleShape.

◆ triangle() [2/2]

virtual const Triangle& G3D::Shape::triangle ( ) const
inlinevirtualinherited

Reimplemented in G3D::TriangleShape.

◆ type()

virtual Type G3D::MeshShape::type ( ) const
inlinevirtual

Implements G3D::Shape.

◆ typeToString()

static String G3D::Shape::typeToString ( Type  t)
staticinherited

◆ vertexArray()

const Array<Vector3>& G3D::MeshShape::vertexArray ( ) const
inlinevirtual

Reimplemented from G3D::Shape.

◆ volume()

virtual float G3D::MeshShape::volume ( ) const
virtual

No volume; Mesh is treated as a 2D surface.

Implements G3D::Shape.


documentation generated on Wed Nov 24 2021 08:01:58 using doxygen 1.8.15