Cocos2d-x  4.0.0
Public Member Functions | Static Public Member Functions | List of all members
Mesh Class Reference

Mesh: contains ref to index buffer, GLProgramState, texture, skin, blend function, aabb and so on. More...

Inherits Ref.

Public Member Functions

backend::BuffergetVertexBuffer () const
 get vertex buffer
 
bool hasVertexAttrib (shaderinfos::VertexKey attrib) const
 has vertex attribute?
 
ssize_t getMeshVertexAttribCount () const
 get mesh vertex attribute count
 
const MeshVertexAttribgetMeshVertexAttribute (int idx)
 get MeshVertexAttribute by index
 
int getVertexSizeInBytes () const
 get per vertex size in bytes
 
void setTexture (const std::string &texPath)
 set texture (diffuse), which is responsible for the main appearance.
 
void setTexture (Texture2D *tex)
 set texture (diffuse), which is responsible for the main appearance.
 
void setTexture (Texture2D *tex, NTextureData::Usage usage, bool cacheFileName=true)
 set texture
 
void setTexture (const std::string &texPath, NTextureData::Usage usage)
 set texture
 
Texture2DgetTexture () const
 Get texture (diffuse), which is responsible for the main appearance.
 
Texture2DgetTexture (NTextureData::Usage usage)
 Get texture.
 
void setVisible (bool visible)
 visible getter and setter
 
MeshSkingetSkin () const
 skin getter
 
MeshIndexDatagetMeshIndexData () const
 mesh index data getter
 
backend::ProgramState * getProgramState () const
 get ProgramState
 
const std::string & getName () const
 name getter
 
CustomCommand::PrimitiveType getPrimitiveType () const
 get primitive type
 
ssize_t getIndexCount () const
 get index count
 
CustomCommand::IndexFormat getIndexFormat () const
 get index format
 
backend::BuffergetIndexBuffer () const
 get index buffer
 
const AABBgetAABB () const
 get AABB
 
void setProgramState (backend::ProgramState *programState)
 Sets a new ProgramState for the Mesh A new Material will be created for it.
 
void setMaterial (Material *material)
 Sets a new Material to the Mesh.
 
MaterialgetMaterial () const
 Returns the Material being used by the Mesh.
 
void setSkin (MeshSkin *skin)
 skin setter
 
void setMeshIndexData (MeshIndexData *indexdata)
 Mesh index data setter.
 
void setName (const std::string &name)
 name setter
 
void calculateAABB ()
 calculate the AABB of the mesh
 
void setForce2DQueue (bool force2D)
 force set this Sprite3D to 2D render queue
 
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership.
 
void release ()
 Releases the ownership immediately.
 
Refautorelease ()
 Releases the ownership sometime soon automatically.
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count.
 
virtual ~Ref ()
 Destructor.
 

Static Public Member Functions

static Meshcreate (const std::vector< float > &positions, const std::vector< float > &normals, const std::vector< float > &texs, const IndexArray &indices)
 create mesh from positions, normals, and so on, single SubMesh
 
static Meshcreate (const std::vector< float > &vertices, int perVertexSizeInFloat, const IndexArray &indices, const std::vector< MeshVertexAttrib > &attribs)
 NA
 
static Meshcreate (const std::string &name, MeshIndexData *indexData, MeshSkin *skin=nullptr)
 create mesh NA
 

Additional Inherited Members

- Public Attributes inherited from Ref
unsigned int _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 
void * _scriptObject
 scriptObject, support for swift
 
bool _rooted
 When true, it means that the object was already rooted.
 

Detailed Description

Mesh: contains ref to index buffer, GLProgramState, texture, skin, blend function, aabb and so on.

Member Function Documentation

backend::Buffer* getVertexBuffer ( ) const

get vertex buffer

NA

bool hasVertexAttrib ( shaderinfos::VertexKey  attrib) const

has vertex attribute?

NA

void setTexture ( const std::string &  texPath)

set texture (diffuse), which is responsible for the main appearance.

It is also means main texture, you can also call setTexture(texPath, NTextureData::Usage::Diffuse)

Parameters
texPathtexture path
void setTexture ( Texture2D tex)

set texture (diffuse), which is responsible for the main appearance.

It is also means main texture, you can also call setTexture(texPath, NTextureData::Usage::Diffuse)

Parameters
textexture to be set
void setTexture ( Texture2D tex,
NTextureData::Usage  usage,
bool  cacheFileName = true 
)

set texture

Parameters
textexture to be set
usageUsage of this texture
whetherrefresh the cache file name
void setTexture ( const std::string &  texPath,
NTextureData::Usage  usage 
)

set texture

Parameters
texPathtexture path
usageUsage of this texture
Texture2D* getTexture ( ) const

Get texture (diffuse), which is responsible for the main appearance.

It is also means main texture, you can also call getTexture(NTextureData::Usage::Diffuse)

Returns
Texture used, return the texture of first mesh if multiple meshes exist
Texture2D* getTexture ( NTextureData::Usage  usage)

Get texture.

Parameters
usageUsage of returned texture
Returns
The texture of this usage, return the texture of first mesh if multiple meshes exist
MeshSkin* getSkin ( ) const
inline

skin getter

NA

MeshIndexData* getMeshIndexData ( ) const
inline

mesh index data getter

NA

backend::ProgramState* getProgramState ( ) const

get ProgramState

NA

CustomCommand::PrimitiveType getPrimitiveType ( ) const

get primitive type

NA

ssize_t getIndexCount ( ) const

get index count

NA

CustomCommand::IndexFormat getIndexFormat ( ) const

get index format

NA

backend::Buffer* getIndexBuffer ( ) const

get index buffer

NA

void calculateAABB ( )

calculate the AABB of the mesh

Note
the AABB is in the local space, not the world space

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