Computational Embodied Neuroscience Simulator  1.1
3D simulation library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
Public Member Functions | Private Attributes | List of all members
cens::CENSGraphicsShape Class Reference

Graphic processing of an object. More...

#include <cens_graphics_shape.h>

Public Member Functions

 CENSGraphicsShape ()
 
 CENSGraphicsShape (const CENSGraphicsShape &copy)
 
 ~CENSGraphicsShape ()
 
void buildAsPlane (const Vector3f &orig, const Vector3f &v1, const Vector3f &v2, const Vector3f &color=CENS_NULL_COLOR, CENSPixelMap pixmap=CENS_NULL_PIXMAP)
 
void buildAsBox (const Vector3f &halfExtents, const Vector3f &color=CENS_NULL_COLOR, CENSPixelMap pixmap=CENS_NULL_PIXMAP)
 
void buildAsSphere (float radius, const Vector3f &color=CENS_NULL_COLOR, CENSPixelMap pixmap=CENS_NULL_PIXMAP)
 
void buildAsConvex (const Vertices &vertices, const unsigned int *idx, int nvtxs, int nidxs, int ntrns, const TexCoords &texCoords=CENS_NULL_TEXCOORDS, const Vector3f &color=CENS_NULL_COLOR, CENSPixelMap pixmap=CENS_NULL_PIXMAP)
 
void buildAsSoft (int numTriangles, const TexCoords &texCoords=CENS_NULL_TEXCOORDS, const Vector3f &color=CENS_NULL_COLOR, CENSPixelMap pixmap=CENS_NULL_PIXMAP)
 
void draw (const Vector3f &org, const Matrix3f &rot)
 
void drawSoft ()
 
void copyimage (const GLubyte *source)
 
void setTexture ()
 
void initTexture ()
 
int getType ()
 
const Vector3f & getColor ()
 
VerticesgetVertices ()
 
Vector3f & getVertex (int vertex_index)
 
VerticesgetNormals ()
 
Vector3f & getNormal (int normal_index)
 
TexCoordsgetTexCoords ()
 
Vector2f & getTexCoord (int texCoord_index)
 
void setType (int type)
 
void setColor (const Vector3f &color)
 
void setVertices (const Vertices &vertices)
 
void addVertex (const Vector3f &vertex)
 
void setNormals (const Vertices &normals)
 
void addNormal (const Vector3f &normal)
 
void setTexCoords (const TexCoords &texCoords)
 
void addTexCoord (const Vector2f &texCoord)
 

Private Attributes

int m_gsType
 
Vector3f m_gsColor
 
Vertices m_gsVertices
 
Vertices m_gsNormals
 
TexCoords m_gsTexCoords
 
GLuint m_gsTexture
 
GLubyte * m_gsTextureImage
 
int m_gsTextureWidth
 
int m_gsTextureHeight
 

Detailed Description

Graphic processing of an object.

It manages rendering of shape, texture and color of an object.

Definition at line 50 of file cens_graphics_shape.h.

Constructor & Destructor Documentation

cens::CENSGraphicsShape::CENSGraphicsShape ( )
inline

Definition at line 55 of file cens_graphics_shape.h.

References cens::GS_NULL.

cens::CENSGraphicsShape::CENSGraphicsShape ( const CENSGraphicsShape copy)
inline
cens::CENSGraphicsShape::~CENSGraphicsShape ( )

Definition at line 74 of file cens_graphics_shape.cpp.

References m_gsTextureImage.

Member Function Documentation

void cens::CENSGraphicsShape::addNormal ( const Vector3f &  normal)

Definition at line 671 of file cens_graphics_shape.cpp.

References m_gsNormals.

void cens::CENSGraphicsShape::addTexCoord ( const Vector2f &  texCoord)

Add an UV texture coordinate

Parameters
texCoordan UV coordinate

Definition at line 685 of file cens_graphics_shape.cpp.

References m_gsTexCoords.

Referenced by buildAsBox(), and buildAsSphere().

void cens::CENSGraphicsShape::addVertex ( const Vector3f &  vertex)
Parameters
vertexan XYZ position

Definition at line 657 of file cens_graphics_shape.cpp.

References m_gsVertices.

Referenced by buildAsPlane(), and buildAsSphere().

void cens::CENSGraphicsShape::buildAsBox ( const Vector3f &  halfExtents,
const Vector3f &  color = CENS_NULL_COLOR,
CENSPixelMap  pixmap = CENS_NULL_PIXMAP 
)

Builds a box.

Parameters
halfExtentshalves of box dimentions.
colorcolor of the box.
pixmappicture for the texture.

Definition at line 102 of file cens_graphics_shape.cpp.

References addTexCoord(), copyimage(), cens::CENSPixelMap::getData(), cens::CENSPixelMap::getHeight(), cens::CENSPixelMap::getWidth(), cens::GS_BOX, m_gsColor, m_gsTextureHeight, m_gsTextureWidth, m_gsType, and setVertices().

Referenced by cens::CENSEngine::localCreateRigidBody(), and cens::CENSEngine::localImportRigidBody().

void cens::CENSGraphicsShape::buildAsConvex ( const Vertices vertices,
const unsigned int *  idx,
int  nvtxs,
int  nidxs,
int  ntrns,
const TexCoords texCoords = CENS_NULL_TEXCOORDS,
const Vector3f &  color = CENS_NULL_COLOR,
CENSPixelMap  pixmap = CENS_NULL_PIXMAP 
)

Builds a convex hull.

Parameters
verticesa vector containing all the vertices of the hull.
idxa vector containing a sequences of indexes to the vertices vector. Vertices are indexed in order to form the triangles of the mesh.
nvtxsnumber of vertices.
nidxsnumber of indices.
ntrnsnumber of triangles.
texCoordsUV cordinates for texture.
colorcolor of the hull.
pixmappicture for the texture.

Definition at line 215 of file cens_graphics_shape.cpp.

References copyimage(), cens::CENSPixelMap::getData(), cens::CENSPixelMap::getHeight(), cens::CENSPixelMap::getWidth(), cens::GS_CONVEX, m_gsColor, m_gsTexCoords, m_gsTextureHeight, m_gsTextureWidth, m_gsType, m_gsVertices, and setTexCoords().

Referenced by cens::CENSEngine::localCreateRigidBody(), and cens::CENSEngine::localImportRigidBody().

void cens::CENSGraphicsShape::buildAsPlane ( const Vector3f &  orig,
const Vector3f &  v1,
const Vector3f &  v2,
const Vector3f &  color = CENS_NULL_COLOR,
CENSPixelMap  pixmap = CENS_NULL_PIXMAP 
)

Builds a plane.

Parameters
origup versor of the plane.
v1first orthogonal versor.
v2second orthogonal versor.
colorcolor of the plane.
pixmappicture for the texture.

Definition at line 86 of file cens_graphics_shape.cpp.

References addVertex(), copyimage(), cens::CENSPixelMap::getData(), cens::CENSPixelMap::getHeight(), cens::CENSPixelMap::getWidth(), cens::GS_PLANE, m_gsColor, m_gsTextureHeight, m_gsTextureWidth, and m_gsType.

Referenced by cens::CENSEngine::localCreateRigidBody(), and cens::CENSEngine::localImportRigidBody().

void cens::CENSGraphicsShape::buildAsSoft ( int  numTriangles,
const TexCoords texCoords = CENS_NULL_TEXCOORDS,
const Vector3f &  color = CENS_NULL_COLOR,
CENSPixelMap  pixmap = CENS_NULL_PIXMAP 
)

Builds a soft body

Parameters
numTrianglesnumber of triangles.
texCoordsUV cordinates for texture.
colorcolor of the soft body.
pixmappicture for the texture.

Definition at line 284 of file cens_graphics_shape.cpp.

References copyimage(), cens::CENSPixelMap::getData(), cens::CENSPixelMap::getHeight(), cens::CENSPixelMap::getWidth(), cens::GS_SOFT, m_gsColor, m_gsNormals, m_gsTextureHeight, m_gsTextureWidth, m_gsType, m_gsVertices, and setTexCoords().

Referenced by cens::CENSEngine::localCreateSoftBody(), and cens::CENSEngine::localLinkSoftBody().

void cens::CENSGraphicsShape::buildAsSphere ( float  radius,
const Vector3f &  color = CENS_NULL_COLOR,
CENSPixelMap  pixmap = CENS_NULL_PIXMAP 
)
void cens::CENSGraphicsShape::copyimage ( const GLubyte *  source)

Copy the texture picture.

Parameters
sourcearray of unsigned bytes where the image is stored.

Definition at line 33 of file cens_graphics_shape.cpp.

References m_gsTextureHeight, m_gsTextureImage, and m_gsTextureWidth.

Referenced by buildAsBox(), buildAsConvex(), buildAsPlane(), buildAsSoft(), and buildAsSphere().

void cens::CENSGraphicsShape::draw ( const Vector3f &  org,
const Matrix3f &  rot 
)

Rendering of rigid objects.

Parameters
orgposition of the center of mass of the object.
rotrotation from inittial position of the object.

Definition at line 312 of file cens_graphics_shape.cpp.

References cens::GS_BOX, cens::GS_CONVEX, cens::GS_PLANE, cens::GS_SPHERE, cens::GS_SPHERE_LATS, cens::GS_SPHERE_LONGS, m_gsColor, m_gsTexCoords, m_gsType, m_gsVertices, and setTexture().

void cens::CENSGraphicsShape::drawSoft ( )

Rendering of soft bodies.

Definition at line 483 of file cens_graphics_shape.cpp.

References m_gsColor, m_gsNormals, m_gsTexCoords, m_gsVertices, and setTexture().

const Vector3f & cens::CENSGraphicsShape::getColor ( )
Returns
a RGB vector with 0.0 to 1.0 elements

Definition at line 584 of file cens_graphics_shape.cpp.

References m_gsColor.

Vector3f & cens::CENSGraphicsShape::getNormal ( int  normal_index)
Parameters
normal_indexindex of a normal
Returns
a normal

Definition at line 613 of file cens_graphics_shape.cpp.

References m_gsNormals.

Vertices & cens::CENSGraphicsShape::getNormals ( )
Returns
a vector of normals

Definition at line 606 of file cens_graphics_shape.cpp.

References m_gsNormals.

Vector2f & cens::CENSGraphicsShape::getTexCoord ( int  texCoord_index)

An UV texture coordinate

Parameters
texCoord_indexindex of the UV coordinate
Returns
an UV coordinate

Definition at line 627 of file cens_graphics_shape.cpp.

References m_gsTexCoords.

TexCoords & cens::CENSGraphicsShape::getTexCoords ( )

Get UV texture coordinates

Returns
a vector of UV coordinates

Definition at line 620 of file cens_graphics_shape.cpp.

References m_gsTexCoords.

int cens::CENSGraphicsShape::getType ( )
Returns
the object type: can be one of GS_NULL, GS_PLANE, GS_BOX, GS_SPHERE, GS_CONVEX or GS_SOFT;

Definition at line 577 of file cens_graphics_shape.cpp.

References m_gsType.

Vector3f & cens::CENSGraphicsShape::getVertex ( int  vertex_index)
Parameters
vertex_indexthe index of a vertex
Returns
an XYZ position

Definition at line 599 of file cens_graphics_shape.cpp.

References m_gsVertices.

Vertices & cens::CENSGraphicsShape::getVertices ( )
Returns
a vector of XYZ positions

Definition at line 592 of file cens_graphics_shape.cpp.

References m_gsVertices.

void cens::CENSGraphicsShape::initTexture ( )

Initialize texturing for the object.

Definition at line 548 of file cens_graphics_shape.cpp.

References m_gsTexture, m_gsTextureHeight, m_gsTextureImage, and m_gsTextureWidth.

void cens::CENSGraphicsShape::setColor ( const Vector3f &  color)
Parameters
colora RGB vector with 0.0 to 1.0 elements

Definition at line 643 of file cens_graphics_shape.cpp.

References m_gsColor.

void cens::CENSGraphicsShape::setNormals ( const Vertices normals)
Parameters
normalsa vector of normals

Definition at line 664 of file cens_graphics_shape.cpp.

References m_gsNormals.

void cens::CENSGraphicsShape::setTexCoords ( const TexCoords texCoords)

Set UV texture coordinates

Parameters
texCoordsa vector of UV coordinates

Definition at line 678 of file cens_graphics_shape.cpp.

References m_gsTexCoords.

Referenced by buildAsConvex(), and buildAsSoft().

void cens::CENSGraphicsShape::setTexture ( )

Set texturing for the object.

Definition at line 539 of file cens_graphics_shape.cpp.

References m_gsTexture.

Referenced by draw(), and drawSoft().

void cens::CENSGraphicsShape::setType ( int  type)

The object type

Parameters
typeone of GS_NULL, GS_PLANE, GS_BOX, GS_SPHERE, GS_CONVEX or GS_SOFT;

Definition at line 636 of file cens_graphics_shape.cpp.

References m_gsType.

void cens::CENSGraphicsShape::setVertices ( const Vertices vertices)
Parameters
verticesa vector of XYZ positions

Definition at line 650 of file cens_graphics_shape.cpp.

References m_gsVertices.

Referenced by buildAsBox().

Member Data Documentation

Vector3f cens::CENSGraphicsShape::m_gsColor
private
Vertices cens::CENSGraphicsShape::m_gsNormals
private
TexCoords cens::CENSGraphicsShape::m_gsTexCoords
private
GLuint cens::CENSGraphicsShape::m_gsTexture
private

Definition at line 263 of file cens_graphics_shape.h.

Referenced by CENSGraphicsShape(), initTexture(), and setTexture().

int cens::CENSGraphicsShape::m_gsTextureHeight
private
GLubyte* cens::CENSGraphicsShape::m_gsTextureImage
private
int cens::CENSGraphicsShape::m_gsTextureWidth
private
int cens::CENSGraphicsShape::m_gsType
private
Vertices cens::CENSGraphicsShape::m_gsVertices
private

The documentation for this class was generated from the following files: