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

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

Inherits Ref.

Public Member Functions

GLuint getVertexBuffer () const
 get vertex buffer More...
 
var getVertexBuffer ()
 get vertex buffer More...
 
bool hasVertexAttrib (int attrib) const
 has vertex attribute? More...
 
ssize_t getMeshVertexAttribCount () const
 get mesh vertex attribute count
 
var getMeshVertexAttribCount ()
 get mesh vertex attribute count
 
local getMeshVertexAttribCount ()
 get mesh vertex attribute count
 
const MeshVertexAttribgetMeshVertexAttribute (int idx)
 get MeshVertexAttribute by index
 
local getMeshVertexAttribute ( local idx)
 get MeshVertexAttribute by index
 
int getVertexSizeInBytes () const
 get per vertex size in bytes
 
var getVertexSizeInBytes ()
 get per vertex size in bytes
 
local getVertexSizeInBytes ()
 get per vertex size in bytes
 
void setTexture (const std::string &texPath)
 set texture (diffuse), which is responsible for the main appearance. More...
 
void setTexture (Texture2D *tex)
 set texture (diffuse), which is responsible for the main appearance. 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...
 
var setTexture ( var texPath, var usage)
 set texture More...
 
local setTexture ( local texPath, local usage)
 set texture More...
 
Texture2DgetTexture () const
 Get texture (diffuse), which is responsible for the main appearance. More...
 
Texture2DgetTexture (NTextureData::Usage usage)
 Get texture. More...
 
local getTexture ( local usage)
 Get texture. More...
 
void setVisible (bool visible)
 visible getter and setter
 
var setVisible ( var visible)
 visible getter and setter
 
local setVisible ( local visible)
 visible getter and setter
 
MeshSkingetSkin () const
 skin getter More...
 
MeshIndexDatagetMeshIndexData () const
 mesh index data getter More...
 
GLProgramStategetGLProgramState () const
 get GLProgramState More...
 
const std::string & getName () const
 name getter
 
var getName ()
 name getter
 
local getName ()
 name getter
 
GLenum getPrimitiveType () const
 get primitive type More...
 
var getPrimitiveType ()
 get primitive type More...
 
ssize_t getIndexCount () const
 get index count More...
 
var getIndexCount ()
 get index count More...
 
GLenum getIndexFormat () const
 get index format More...
 
var getIndexFormat ()
 get index format More...
 
GLuint getIndexBuffer () const
 get index buffer More...
 
var getIndexBuffer ()
 get index buffer More...
 
const AABBgetAABB () const
 get AABB
 
local getAABB ()
 get AABB
 
void setGLProgramState (GLProgramState *glProgramState)
 Sets a new GLProgramState for the Mesh A new Material will be created for it.
 
void setMaterial (Material *material)
 Sets a new Material to the Mesh.
 
var setMaterial ( var material)
 Sets a new Material to the Mesh.
 
local setMaterial ( local material)
 Sets a new Material to the Mesh.
 
MaterialgetMaterial () const
 Returns the Material being used by the Mesh.
 
var getMaterial ()
 Returns the Material being used by the Mesh.
 
local getMaterial ()
 Returns the Material being used by the Mesh.
 
MeshCommand & getMeshCommand ()
 Get the MeshCommand.
 
var getMeshCommand ()
 Get the MeshCommand.
 
local getMeshCommand ()
 Get the MeshCommand.
 
void setSkin (MeshSkin *skin)
 skin setter
 
var setSkin ( var skin)
 skin setter
 
local setSkin ( local skin)
 skin setter
 
void setMeshIndexData (MeshIndexData *indexdata)
 Mesh index data setter.
 
var setMeshIndexData ( var indexdata)
 Mesh index data setter.
 
local setMeshIndexData ( local indexdata)
 Mesh index data setter.
 
void setName (const std::string &name)
 name setter
 
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
 
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
local 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. More...
 

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, int, const std::vector< MeshVertexAttrib > &attribs, int)
 create mesh with vertex attributes
 
local create ( local vertices, local perVertexSizeInFloat, local indices, local int, local attribs, local int)
 create mesh with vertex attributes
 
static Meshcreate (const std::string &name, MeshIndexData *indexData, MeshSkin *skin=nullptr)
 create mesh 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.
 

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::string &  name,
MeshIndexData indexData,
MeshSkin skin = nullptr 
)
static

create mesh

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

create mesh

GLuint getVertexBuffer ( ) const

get vertex buffer

var getVertexBuffer ( )

get vertex buffer

bool hasVertexAttrib ( int  attrib) const

has vertex attribute?

var hasVertexAttrib ( var  attrib)

has vertex attribute?

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
var setTexture ( var  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
local setTexture ( local  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
var setTexture ( var  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
local setTexture ( local  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
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

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
var getTexture ( )

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
local getTexture ( )

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
var getTexture ( var  usage)

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)

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

var getSkin ( )
inline

skin getter

MeshIndexData* getMeshIndexData ( ) const
inline

mesh index data getter

var getMeshIndexData ( )
inline

mesh index data getter

GLProgramState* getGLProgramState ( ) const
var getGLProgramState ( )
GLenum getPrimitiveType ( ) const

get primitive type

var getPrimitiveType ( )

get primitive type

ssize_t getIndexCount ( ) const

get index count

var getIndexCount ( )

get index count

GLenum getIndexFormat ( ) const

get index format

var getIndexFormat ( )

get index format

GLuint getIndexBuffer ( ) const

get index buffer

var getIndexBuffer ( )

get index buffer

void calculateAABB ( )

calculate the AABB of the mesh

Note
the AABB is in the local space, not the world space
var calculateAABB ( )

calculate the AABB of the mesh

Note
the AABB is in the local space, not the world space
local 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: