cocos2d-x  3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Mesh Class Reference

Mesh: Geometry with a collection of vertex. More...

#include <CCMesh.h>

Inheritance diagram for Mesh:
Ref

Public Types

enum  IndexFormat { INDEX8 = GL_UNSIGNED_BYTE, INDEX16 = GL_UNSIGNED_SHORT }
 Defines supported index formats. More...
 
enum  PrimitiveType {
  TRIANGLES = GL_TRIANGLES, TRIANGLE_STRIP = GL_TRIANGLE_STRIP, LINES = GL_LINES, LINE_STRIP = GL_LINE_STRIP,
  POINTS = GL_POINTS
}
 Defines supported primitive types. More...
 

Public Member Functions

GLuint getVertexBuffer () const
 get vertex buffer More...
 
ssize_t getMeshVertexAttribCount () const
 get mesh vertex attribute count More...
 
const MeshVertexAttribgetMeshVertexAttribute (int idx) const
 get MeshVertexAttribute by index More...
 
bool hasVertexAttrib (int attrib)
 has vertex attribute? More...
 
int getVertexSizeInBytes () const
 get per vertex size in bytes More...
 
PrimitiveType getPrimitiveType () const
 get primitive type More...
 
ssize_t getIndexCount () const
 get index count More...
 
IndexFormat getIndexFormat () const
 get index format More...
 
GLuint getIndexBuffer () const
 get index buffer More...
 
void restore ()
 build vertex buffer from renderdata More...
 
virtual ~Mesh ()
bool init (const std::vector< float > &positions, const std::vector< float > &normals, const std::vector< float > &texs, const std::vector< unsigned short > &indices)
 init mesh More...
 
bool init (const std::vector< float > &vertices, int vertexSizeInFloat, const std::vector< unsigned short > &indices, const std::vector< MeshVertexAttrib > &attribs)
 init mesh More...
 
void buildBuffer ()
 build buffer More...
 
void cleanAndFreeBuffers ()
 free buffer More...
 
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()

Static Public Member Functions

static Meshcreate (const std::vector< float > &positions, const std::vector< float > &normals, const std::vector< float > &texs, const std::vector< unsigned short > &indices)
 create mesh from positions, normals, and so on More...
 
static Meshcreate (const std::vector< float > &vertices, int vertexSizeInFloat, const std::vector< unsigned short > &indices, int numIndex, const std::vector< MeshVertexAttrib > &attribs, int attribCount)
 create mesh with vertex attributes More...
 
static Meshcreate (const std::vector< float > &vertices, int vertexSizeInFloat, const std::vector< unsigned short > &indices, const std::vector< MeshVertexAttrib > &attribs)
 create mesh with vertex attributes More...
 

Public Attributes

CC_CONSTRUCTOR_ACCESS __pad0__: Mesh()

Protected Attributes

PrimitiveType _primitiveType
IndexFormat _indexFormat
GLuint _vertexBuffer
GLuint _indexBuffer
ssize_t _indexCount
RenderMeshData _renderdata
- Protected Attributes inherited from Ref
unsigned int _referenceCount
 count of references More...
 

Additional Inherited Members

- Protected Member Functions inherited from Ref
 Ref ()
 Constructor. More...
 

Detailed Description

Mesh: Geometry with a collection of vertex.

Supporting various vertex formats.

Member Enumeration Documentation

enum IndexFormat
strong

Defines supported index formats.

Enumerator
INDEX8 
INDEX16 
enum PrimitiveType
strong

Defines supported primitive types.

Enumerator
TRIANGLES 
TRIANGLE_STRIP 
LINES 
LINE_STRIP 
POINTS 

Constructor & Destructor Documentation

virtual ~Mesh ( )
virtual

Member Function Documentation

void buildBuffer ( )

build buffer

void cleanAndFreeBuffers ( )

free buffer

static Mesh* create ( const std::vector< float > &  positions,
const std::vector< float > &  normals,
const std::vector< float > &  texs,
const std::vector< unsigned short > &  indices 
)
static

create mesh from positions, normals, and so on

static Mesh* create ( const std::vector< float > &  vertices,
int  vertexSizeInFloat,
const std::vector< unsigned short > &  indices,
int  numIndex,
const std::vector< MeshVertexAttrib > &  attribs,
int  attribCount 
)
inlinestatic

create mesh with vertex attributes

static Mesh* create ( const std::vector< float > &  vertices,
int  vertexSizeInFloat,
const std::vector< unsigned short > &  indices,
const std::vector< MeshVertexAttrib > &  attribs 
)
static

create mesh with vertex attributes

GLuint getIndexBuffer ( ) const
inline

get index buffer

ssize_t getIndexCount ( ) const
inline

get index count

IndexFormat getIndexFormat ( ) const
inline

get index format

ssize_t getMeshVertexAttribCount ( ) const
inline

get mesh vertex attribute count

const MeshVertexAttrib&
getMeshVertexAttribute
( int  idx) const
inline

get MeshVertexAttribute by index

PrimitiveType getPrimitiveType ( ) const
inline

get primitive type

GLuint getVertexBuffer ( ) const
inline

get vertex buffer

int getVertexSizeInBytes ( ) const
inline

get per vertex size in bytes

bool hasVertexAttrib ( int  attrib)
inline

has vertex attribute?

bool init ( const std::vector< float > &  positions,
const std::vector< float > &  normals,
const std::vector< float > &  texs,
const std::vector< unsigned short > &  indices 
)

init mesh

bool init ( const std::vector< float > &  vertices,
int  vertexSizeInFloat,
const std::vector< unsigned short > &  indices,
const std::vector< MeshVertexAttrib > &  attribs 
)

init mesh

void restore ( )

build vertex buffer from renderdata

Member Data Documentation

GLuint _indexBuffer
protected
ssize_t _indexCount
protected
IndexFormat _indexFormat
protected
PrimitiveType _primitiveType
protected
RenderMeshData _renderdata
protected
GLuint _vertexBuffer
protected

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