mirror of https://github.com/axmolengine/axmol.git
newmodel
This commit is contained in:
parent
fdcec51cf4
commit
88bb1482e3
|
@ -124,6 +124,9 @@ protected:
|
||||||
std::unordered_map<std::string, AttachNode*> _attachments;
|
std::unordered_map<std::string, AttachNode*> _attachments;
|
||||||
|
|
||||||
BlendFunc _blend;
|
BlendFunc _blend;
|
||||||
|
|
||||||
|
//since 3.3
|
||||||
|
std::vector<Mesh*> _meshes;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern std::string CC_DLL s_attributeNames[];//attribute names array
|
extern std::string CC_DLL s_attributeNames[];//attribute names array
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include "3d/CCObjLoader.h"
|
#include "3d/CCObjLoader.h"
|
||||||
#include "3d/CCSprite3DMaterial.h"
|
#include "3d/CCSprite3DMaterial.h"
|
||||||
|
#include "3d/CCMesh.h"
|
||||||
|
|
||||||
#include "base/ccMacros.h"
|
#include "base/ccMacros.h"
|
||||||
#include "base/CCEventCustom.h"
|
#include "base/CCEventCustom.h"
|
||||||
|
@ -50,12 +51,14 @@ SubMesh::SubMesh()
|
||||||
, _primitiveType(PrimitiveType::TRIANGLES)
|
, _primitiveType(PrimitiveType::TRIANGLES)
|
||||||
, _indexFormat(IndexFormat::INDEX16)
|
, _indexFormat(IndexFormat::INDEX16)
|
||||||
, _indexCount(0)
|
, _indexCount(0)
|
||||||
|
, _mesh(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SubMesh::~SubMesh()
|
SubMesh::~SubMesh()
|
||||||
{
|
{
|
||||||
cleanAndFreeBuffers();
|
cleanAndFreeBuffers();
|
||||||
|
CC_SAFE_RELEASE(_mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
SubMesh* SubMesh::create(PrimitiveType primitivetype, IndexFormat indexformat, const std::vector<unsigned short>& indices)
|
SubMesh* SubMesh::create(PrimitiveType primitivetype, IndexFormat indexformat, const std::vector<unsigned short>& indices)
|
||||||
|
@ -68,6 +71,17 @@ SubMesh* SubMesh::create(PrimitiveType primitivetype, IndexFormat indexformat, c
|
||||||
return submesh;
|
return submesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SubMesh* SubMesh::create(Mesh* mesh, PrimitiveType primitivetype, IndexFormat indexformat, const std::vector<unsigned short>& indices)
|
||||||
|
{
|
||||||
|
auto submesh = new SubMesh();
|
||||||
|
submesh->_primitiveType = primitivetype;
|
||||||
|
submesh->_indexFormat = indexformat;
|
||||||
|
submesh->_mesh = mesh;
|
||||||
|
submesh->autorelease();
|
||||||
|
|
||||||
|
return submesh;
|
||||||
|
}
|
||||||
|
|
||||||
void SubMesh::cleanAndFreeBuffers()
|
void SubMesh::cleanAndFreeBuffers()
|
||||||
{
|
{
|
||||||
if(glIsBuffer(_indexBuffer))
|
if(glIsBuffer(_indexBuffer))
|
||||||
|
|
|
@ -54,6 +54,8 @@ enum class PrimitiveType
|
||||||
POINTS = GL_POINTS
|
POINTS = GL_POINTS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Mesh;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SubMesh: Defines the way the mesh's vertices how to be connected together.
|
* SubMesh: Defines the way the mesh's vertices how to be connected together.
|
||||||
*/
|
*/
|
||||||
|
@ -65,6 +67,8 @@ public:
|
||||||
/**create submesh from primitivetype indexformat and indices*/
|
/**create submesh from primitivetype indexformat and indices*/
|
||||||
static SubMesh* create(PrimitiveType primitivetype, IndexFormat indexformat, const std::vector<unsigned short>& indices);
|
static SubMesh* create(PrimitiveType primitivetype, IndexFormat indexformat, const std::vector<unsigned short>& indices);
|
||||||
|
|
||||||
|
static SubMesh* create(Mesh* mesh, PrimitiveType primitivetype, IndexFormat indexformat, const std::vector<unsigned short>& indices);
|
||||||
|
|
||||||
/** get primitive type*/
|
/** get primitive type*/
|
||||||
PrimitiveType getPrimitiveType() const { return _primitiveType; }
|
PrimitiveType getPrimitiveType() const { return _primitiveType; }
|
||||||
/**get index count*/
|
/**get index count*/
|
||||||
|
@ -74,6 +78,8 @@ public:
|
||||||
/**get index buffer*/
|
/**get index buffer*/
|
||||||
GLuint getIndexBuffer() const {return _indexBuffer; }
|
GLuint getIndexBuffer() const {return _indexBuffer; }
|
||||||
|
|
||||||
|
/** get mesh */
|
||||||
|
Mesh* getMesh() const { return _mesh; }
|
||||||
|
|
||||||
CC_CONSTRUCTOR_ACCESS:
|
CC_CONSTRUCTOR_ACCESS:
|
||||||
|
|
||||||
|
@ -91,8 +97,10 @@ protected:
|
||||||
|
|
||||||
GLuint _indexBuffer;
|
GLuint _indexBuffer;
|
||||||
ssize_t _indexCount;
|
ssize_t _indexCount;
|
||||||
|
|
||||||
|
Mesh* _mesh; //parent mesh, weak ref
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
#endif // __CCMESH_H_
|
#endif // __CCSUBMESH_H_
|
||||||
|
|
|
@ -49,6 +49,7 @@ SubMeshState::SubMeshState()
|
||||||
: _visible(true)
|
: _visible(true)
|
||||||
, _texture(nullptr)
|
, _texture(nullptr)
|
||||||
, _skin(nullptr)
|
, _skin(nullptr)
|
||||||
|
, _subMesh(nullptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,6 +57,7 @@ SubMeshState::~SubMeshState()
|
||||||
{
|
{
|
||||||
CC_SAFE_RELEASE(_texture);
|
CC_SAFE_RELEASE(_texture);
|
||||||
CC_SAFE_RELEASE(_skin);
|
CC_SAFE_RELEASE(_skin);
|
||||||
|
CC_SAFE_RELEASE(_subMesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
SubMeshState* SubMeshState::create()
|
SubMeshState* SubMeshState::create()
|
||||||
|
@ -86,4 +88,14 @@ void SubMeshState::setSkin(MeshSkin* skin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SubMeshState::setSubMesh(SubMesh* subMesh)
|
||||||
|
{
|
||||||
|
if (_subMesh != subMesh)
|
||||||
|
{
|
||||||
|
CC_SAFE_RETAIN(subMesh);
|
||||||
|
CC_SAFE_RELEASE(_subMesh);
|
||||||
|
_subMesh = subMesh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -39,6 +39,7 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
class Texture2D;
|
class Texture2D;
|
||||||
class MeshSkin;
|
class MeshSkin;
|
||||||
|
class SubMesh;
|
||||||
/**
|
/**
|
||||||
* SubMeshState: visibility and apperence of submesh
|
* SubMeshState: visibility and apperence of submesh
|
||||||
*/
|
*/
|
||||||
|
@ -61,6 +62,14 @@ public:
|
||||||
void setSkin(MeshSkin* skin);
|
void setSkin(MeshSkin* skin);
|
||||||
MeshSkin* getSkin() const { return _skin; }
|
MeshSkin* getSkin() const { return _skin; }
|
||||||
|
|
||||||
|
/**sub mesh getter and setter*/
|
||||||
|
void setSubMesh(SubMesh* subMesh);
|
||||||
|
SubMesh* getSubMesh() const { return _subMesh; }
|
||||||
|
|
||||||
|
/**name getter and setter*/
|
||||||
|
void setName(const std::string& name) { _name = name; }
|
||||||
|
const std::string& getName() const { return _name; }
|
||||||
|
|
||||||
CC_CONSTRUCTOR_ACCESS:
|
CC_CONSTRUCTOR_ACCESS:
|
||||||
|
|
||||||
SubMeshState();
|
SubMeshState();
|
||||||
|
@ -70,6 +79,10 @@ protected:
|
||||||
Texture2D* _texture; //texture that submesh is using
|
Texture2D* _texture; //texture that submesh is using
|
||||||
MeshSkin* _skin; //skin
|
MeshSkin* _skin; //skin
|
||||||
bool _visible; // is the submesh visible
|
bool _visible; // is the submesh visible
|
||||||
|
|
||||||
|
//since 3.3
|
||||||
|
std::string _name;
|
||||||
|
SubMesh* _subMesh;
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
Loading…
Reference in New Issue