Cocos2d-x  v3.11
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups
Mesh Class Reference

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

Inherits Ref.

Public Types

typedef std::vector< unsigned
short > 
IndexArray
 The indices array.
 

Public Member Functions

GLuint getVertexBuffer () const
 Get the vertex buffer. More...
 
bool hasVertexAttrib (int attrib) const
 Check if the mesh have specified vertex attribute or not The attribute type ID. More...
 
var hasVertexAttrib ( var attrib)
 Check if the mesh have specified vertex attribute or not The attribute type ID. More...
 
ssize_t getMeshVertexAttribCount () const
 Get the mesh vertex attribute count. More...
 
local getMeshVertexAttribCount ()
 Get the mesh vertex attribute count. More...
 
const MeshVertexAttribgetMeshVertexAttribute (int idx)
 Get MeshVertexAttribute by index The index. More...
 
var getMeshVertexAttribute ( var idx)
 Get MeshVertexAttribute by index The index. More...
 
local getMeshVertexAttribute ( local idx)
 Get MeshVertexAttribute by index The index. More...
 
int getVertexSizeInBytes () const
 Get per vertex size in bytes. More...
 
var getVertexSizeInBytes ()
 Get per vertex size in bytes. More...
 
local getVertexSizeInBytes ()
 Get per vertex size in bytes. More...
 
void setTexture (const std::string &texPath)
 Texture setter. More...
 
var setTexture ( var texPath)
 Texture setter. More...
 
local setTexture ( local texPath)
 Texture setter. More...
 
void setTexture (Texture2D *tex)
 Texture setter. More...
 
var setTexture ( var tex)
 Texture setter. More...
 
local setTexture ( local tex)
 Texture setter. More...
 
void setTexture (Texture2D *tex, NTextureData::Usage usage, bool cacheFileName=true)
 set texture More...
 
var setTexture ( var tex, var usage, var true)
 set texture More...
 
local setTexture ( local tex, local usage, local true)
 set texture More...
 
void setTexture (const std::string &texPath, NTextureData::Usage usage)
 set texture More...
 
Texture2DgetTexture () const
 Texture getter. More...
 
Texture2DgetTexture (NTextureData::Usage usage)
 Visible setter The visiblity. More...
 
bool isVisible () const
 Visible getter.
 
var isVisible ()
 Visible getter.
 
local isVisible ()
 Visible getter.
 
MeshSkingetSkin () const
 The skin getter. More...
 
MeshIndexDatagetMeshIndexData () const
 Mesh index data getter. More...
 
GLProgramStategetGLProgramState () const
 Get GLProgramState. More...
 
const std::string & getName () const
 Get the mesh's name. More...
 
void setBlendFunc (const BlendFunc &blendFunc)
 Set the blending function. More...
 
var setBlendFunc ( var blendFunc)
 Set the blending function. More...
 
local setBlendFunc ( local blendFunc)
 Set the blending function. More...
 
const BlendFuncgetBlendFunc () const
 Get the mesh's blending function.
 
local getBlendFunc ()
 Get the mesh's blending function.
 
GLenum getPrimitiveType () const
 Get primitive type. More...
 
var getPrimitiveType ()
 Get primitive type. More...
 
ssize_t getIndexCount () const
 Get index count The index count of the mesh.
 
var getIndexCount ()
 Get index count The index count of the mesh.
 
GLenum getIndexFormat () const
 Get the mesh's index data format. More...
 
var getIndexFormat ()
 Get the mesh's index data format. More...
 
GLuint getIndexBuffer () const
 Get the mesh's index buffer object(IBO) handle. More...
 
var getIndexBuffer ()
 Get the mesh's index buffer object(IBO) handle. More...
 
const AABBgetAABB () const
 Get the mesh's AABB in local space. More...
 
local getAABB ()
 Get the mesh's AABB in local space. More...
 
void setGLProgramState (GLProgramState *glProgramState)
 Sets a new GLProgramState for the Mesh The new GLProgramState object. More...
 
void setMaterial (Material *material)
 Sets a new Material to the Mesh The new Material object.
 
MaterialgetMaterial () const
 Get the Material which being used by the Mesh The material object.
 
MeshCommandgetMeshCommand ()
 Get the MeshCommand. More...
 
void setSkin (MeshSkin *skin)
 Set a specified skin to mesh. More...
 
var setSkin ( var skin)
 Set a specified skin to mesh. More...
 
local setSkin ( local skin)
 Set a specified skin to mesh. More...
 
void setMeshIndexData (MeshIndexData *indexdata)
 Set the mesh index data. More...
 
var setMeshIndexData ( var indexdata)
 Set the mesh index data. More...
 
local setMeshIndexData ( local indexdata)
 Set the mesh index data. More...
 
void setName (const std::string &name)
 Set the mesh's name. More...
 
var setName ( var name)
 Set the mesh's name. More...
 
local setName ( local name)
 Set the mesh's name. More...
 
void calculateAABB ()
 Calculate the AABB of the mesh. More...
 
var calculateAABB ()
 Calculate the AABB of the mesh. More...
 
local calculateAABB ()
 Calculate the AABB of the mesh. More...
 
void setForce2DQueue (bool force2D)
 force set this Sprite3D to 2D render queue
 
var setForce2DQueue ( var force2D)
 force set this Sprite3D to 2D render queue
 
local setForce2DQueue ( local force2D)
 force set this Sprite3D to 2D render queue
 
std::string getTextureFileName ()
 Return texture file name.
 
var getTextureFileName ()
 Return texture file name.
 
local getTextureFileName ()
 Return texture file name.
 
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
local 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...
 
local getReferenceCount ()
 Returns the Ref's current reference count. More...
 
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 The positions list. More...
 
local create ( local positions, local normals, local texs, local indices)
 Create mesh from positions, normals, and so on, single SubMesh The positions list. More...
 
static Meshcreate (const std::vector< float > &vertices, int perVertexSizeInFloat, const IndexArray &indices, int numIndex, const std::vector< MeshVertexAttrib > &attribs, int attribCount)
 create mesh with vertex attributes
 
var create ( var vertices, var perVertexSizeInFloat, var indices, var numIndex, var attribs, var attribCount)
 create mesh with vertex attributes
 
local create ( local vertices, local perVertexSizeInFloat, local indices, local numIndex, local attribs, local attribCount)
 create mesh with vertex attributes
 
static Meshcreate (const std::vector< float > &vertices, int perVertexSizeInFloat, const IndexArray &indices, const std::vector< MeshVertexAttrib > &attribs)
 Create mesh from vertices, indices and attribs the vertices list. More...
 
static Meshcreate (const std::string &name, MeshIndexData *indexData, MeshSkin *skin=nullptr)
 Create mesh from name, mesh index data and skin The name. More...
 

Additional Inherited Members

- Public Attributes inherited from Ref
unsigned int _ID
 object id, ScriptSupport need public _ID
 
local _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 
local _luaID
 Lua reference id.
 
void * _scriptObject
 scriptObject, support for swift
 
local _scriptObject
 scriptObject, support for swift
 
bool _rooted
 When true, it means that the object was already rooted.
 
local _rooted
 When true, it means that the object was already rooted.
 
bool _scriptOwned
 The life of the object is scrolled by the scripting engine. More...
 
local _scriptOwned
 The life of the object is scrolled by the scripting engine. More...
 

Detailed Description

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

Member Function Documentation

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

Create mesh from positions, normals, and so on, single SubMesh The positions list.

The normals list. The texture UV corodinates list. The indices list The Mesh object.

var create ( var  positions,
var  normals,
var  texs,
var  indices 
)
static

Create mesh from positions, normals, and so on, single SubMesh The positions list.

The normals list. The texture UV corodinates list. The indices list The Mesh object.

local create ( local  positions,
local  normals,
local  texs,
local  indices 
)
static

Create mesh from positions, normals, and so on, single SubMesh The positions list.

The normals list. The texture UV corodinates list. The indices list The Mesh object.

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

Create mesh from vertices, indices and attribs the vertices list.

Each vertex element's size. The indices list. The mesh vertices attributes list. The Mesh object.

var create ( var  vertices,
var  perVertexSizeInFloat,
var  indices,
var  attribs 
)
static

Create mesh from vertices, indices and attribs the vertices list.

Each vertex element's size. The indices list. The mesh vertices attributes list. The Mesh object.

static Mesh* create ( const std::string &  name,
MeshIndexData indexData,
MeshSkin skin = nullptr 
)
static

Create mesh from name, mesh index data and skin The name.

The indexData list. The MeshSkin object. The Mesh object.

var create ( var  name,
var  indexData,
var  skin = nullptr 
)
static

Create mesh from name, mesh index data and skin The name.

The indexData list. The MeshSkin object. The Mesh object.

GLuint getVertexBuffer ( ) const

Get the vertex buffer.

The VBO ID.

var getVertexBuffer ( )

Get the vertex buffer.

The VBO ID.

bool hasVertexAttrib ( int  attrib) const

Check if the mesh have specified vertex attribute or not The attribute type ID.

Return true if the mesh have specified attribute, otherwise return false.

var hasVertexAttrib ( var  attrib)

Check if the mesh have specified vertex attribute or not The attribute type ID.

Return true if the mesh have specified attribute, otherwise return false.

ssize_t getMeshVertexAttribCount ( ) const

Get the mesh vertex attribute count.

The vertex attribute count.

var getMeshVertexAttribCount ( )

Get the mesh vertex attribute count.

The vertex attribute count.

local getMeshVertexAttribCount ( )

Get the mesh vertex attribute count.

The vertex attribute count.

const MeshVertexAttrib&
getMeshVertexAttribute
( int  idx)

Get MeshVertexAttribute by index The index.

The MeshVertexAttribute object.

var getMeshVertexAttribute ( var  idx)

Get MeshVertexAttribute by index The index.

The MeshVertexAttribute object.

local getMeshVertexAttribute ( local  idx)

Get MeshVertexAttribute by index The index.

The MeshVertexAttribute object.

int getVertexSizeInBytes ( ) const

Get per vertex size in bytes.

The per vertex size in bytes.

var getVertexSizeInBytes ( )

Get per vertex size in bytes.

The per vertex size in bytes.

local getVertexSizeInBytes ( )

Get per vertex size in bytes.

The per vertex size in bytes.

void setTexture ( const std::string &  texPath)

Texture setter.

The texture file path.

var setTexture ( var  texPath)

Texture setter.

The texture file path.

local setTexture ( local  texPath)

Texture setter.

The texture file path.

void setTexture ( Texture2D tex)

Texture setter.

The Texture2D object.

var setTexture ( var  tex)

Texture setter.

The Texture2D object.

local setTexture ( local  tex)

Texture setter.

The Texture2D object.

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
var setTexture ( var  tex,
var  usage,
var  cacheFileName = true 
)

set texture

Parameters
textexture to be set
usageUsage of this texture
whetherrefresh the cache file name
local setTexture ( local  tex,
local  usage,
local  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
var setTexture ( var  texPath,
var  usage 
)

set texture

Parameters
texPathtexture path
usageUsage of this texture
local setTexture ( local  texPath,
local  usage 
)

set texture

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

Texture getter.

The Texture2D object.

var getTexture ( )

Texture getter.

The Texture2D object.

local getTexture ( )

Texture getter.

The Texture2D object.

Texture2D* getTexture ( NTextureData::Usage  usage)

Visible setter The visiblity.

Get texture

Parameters
usageUsage of returned texture
Returns
The texture of this usage, return the texture of first mesh if multiple meshes exist
var getTexture ( var  usage)

Visible setter The visiblity.

Get texture

Parameters
usageUsage of returned texture
Returns
The texture of this usage, return the texture of first mesh if multiple meshes exist
local getTexture ( local  usage)

Visible setter The visiblity.

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

The skin getter.

The MeshSkin Object.

var getSkin ( )
inline

The skin getter.

The MeshSkin Object.

MeshIndexData* getMeshIndexData ( ) const
inline

Mesh index data getter.

The MeshIndexData object.

var getMeshIndexData ( )
inline

Mesh index data getter.

The MeshIndexData object.

GLProgramState* getGLProgramState ( ) const

Get GLProgramState.

The GLProgramState object.

var getGLProgramState ( )

Get GLProgramState.

The GLProgramState object.

const std::string& getName ( ) const
inline

Get the mesh's name.

The mesh's name.

var getName ( )
inline

Get the mesh's name.

The mesh's name.

local getName ( )
inline

Get the mesh's name.

The mesh's name.

void setBlendFunc ( const BlendFunc blendFunc)

Set the blending function.

The specified blending function.

var setBlendFunc ( var  blendFunc)

Set the blending function.

The specified blending function.

local setBlendFunc ( local  blendFunc)

Set the blending function.

The specified blending function.

GLenum getPrimitiveType ( ) const

Get primitive type.

The primitive type.

var getPrimitiveType ( )

Get primitive type.

The primitive type.

GLenum getIndexFormat ( ) const

Get the mesh's index data format.

The index data format, should be GL_UNSIGNED_SHORT.

var getIndexFormat ( )

Get the mesh's index data format.

The index data format, should be GL_UNSIGNED_SHORT.

GLuint getIndexBuffer ( ) const

Get the mesh's index buffer object(IBO) handle.

The IBO handle.

var getIndexBuffer ( )

Get the mesh's index buffer object(IBO) handle.

The IBO handle.

const AABB& getAABB ( ) const
inline

Get the mesh's AABB in local space.

The AABB object.

var getAABB ( )
inline

Get the mesh's AABB in local space.

The AABB object.

local getAABB ( )
inline

Get the mesh's AABB in local space.

The AABB object.

void setGLProgramState ( GLProgramState glProgramState)

Sets a new GLProgramState for the Mesh The new GLProgramState object.

A new Material will be created for it

var setGLProgramState ( var  glProgramState)

Sets a new GLProgramState for the Mesh The new GLProgramState object.

A new Material will be created for it

local setGLProgramState ( local  glProgramState)

Sets a new GLProgramState for the Mesh The new GLProgramState object.

A new Material will be created for it

MeshCommand& getMeshCommand ( )
inline

Get the MeshCommand.

The MeshCommand object

var getMeshCommand ( )
inline

Get the MeshCommand.

The MeshCommand object

local getMeshCommand ( )
inline

Get the MeshCommand.

The MeshCommand object

void setSkin ( MeshSkin skin)

Set a specified skin to mesh.

The specified skin object.

var setSkin ( var  skin)

Set a specified skin to mesh.

The specified skin object.

local setSkin ( local  skin)

Set a specified skin to mesh.

The specified skin object.

void setMeshIndexData ( MeshIndexData indexdata)

Set the mesh index data.

The specified MeshIndexData.

var setMeshIndexData ( var  indexdata)

Set the mesh index data.

The specified MeshIndexData.

local setMeshIndexData ( local  indexdata)

Set the mesh index data.

The specified MeshIndexData.

void setName ( const std::string &  name)
inline

Set the mesh's name.

The mesh's new name.

var setName ( var  name)
inline

Set the mesh's name.

The mesh's new name.

local setName ( local  name)
inline

Set the mesh's name.

The mesh's new name.

void calculateAABB ( )

Calculate the AABB of the mesh.

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

var calculateAABB ( )

Calculate the AABB of the mesh.

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

local calculateAABB ( )

Calculate the AABB of the mesh.

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


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