mirror of https://github.com/axmolengine/axmol.git
merge, obj not work now
This commit is contained in:
commit
cd4da73beb
|
@ -288,6 +288,8 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas, MaterialDatas& materialdatas, NodeD
|
|||
NTextureData tex;
|
||||
tex.filename = dir + it.material.diffuse_texname;
|
||||
tex.type = NTextureData::Usage::Diffuse;
|
||||
tex.wrapS = GL_CLAMP;
|
||||
tex.wrapT = GL_CLAMP;
|
||||
|
||||
sprintf(str, "%d", i++);
|
||||
materialdata.textures.push_back(tex);
|
||||
|
|
|
@ -271,46 +271,95 @@ void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& m
|
|||
ModelNodeData* modelNodeData=nodedata->asModelNodeData();
|
||||
if(modelNodeData)
|
||||
{
|
||||
auto subMeshState = SubMeshState::create(modelNodeData->id);
|
||||
if(subMeshState)
|
||||
if(modelNodeData->bones.size() > 0)
|
||||
{
|
||||
_subMeshStates.pushBack(subMeshState);
|
||||
subMeshState->setSubMesh(getSubMesh(modelNodeData->subMeshId));
|
||||
if (_skeleton && modelNodeData->bones.size())
|
||||
auto subMeshState = SubMeshState::create(modelNodeData->id);
|
||||
if(subMeshState)
|
||||
{
|
||||
auto skin = MeshSkin::create(_skeleton, modelNodeData->bones, modelNodeData->invBindPose);
|
||||
subMeshState->setSkin(skin);
|
||||
}
|
||||
|
||||
if (modelNodeData->matrialId == "" && matrialdatas.materials.size())
|
||||
{
|
||||
const NTextureData* textureData = matrialdatas.materials[0].getTextureData(NTextureData::Usage::Diffuse);
|
||||
subMeshState->setTexture(textureData->filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
const NMaterialData* materialData=matrialdatas.getMaterialData(modelNodeData->matrialId);
|
||||
if(materialData)
|
||||
_subMeshStates.pushBack(subMeshState);
|
||||
subMeshState->setSubMesh(getSubMesh(modelNodeData->subMeshId));
|
||||
if (_skeleton && modelNodeData->bones.size())
|
||||
{
|
||||
const NTextureData* textureData = materialData->getTextureData(NTextureData::Usage::Diffuse);
|
||||
if(textureData)
|
||||
auto skin = MeshSkin::create(_skeleton, modelNodeData->bones, modelNodeData->invBindPose);
|
||||
subMeshState->setSkin(skin);
|
||||
}
|
||||
|
||||
if (modelNodeData->matrialId == "" && matrialdatas.materials.size())
|
||||
{
|
||||
const NTextureData* textureData = matrialdatas.materials[0].getTextureData(NTextureData::Usage::Diffuse);
|
||||
subMeshState->setTexture(textureData->filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
const NMaterialData* materialData=matrialdatas.getMaterialData(modelNodeData->matrialId);
|
||||
if(materialData)
|
||||
{
|
||||
auto tex = Director::getInstance()->getTextureCache()->addImage(textureData->filename);
|
||||
if(tex)
|
||||
const NTextureData* textureData = materialData->getTextureData(NTextureData::Usage::Diffuse);
|
||||
if(textureData)
|
||||
{
|
||||
Texture2D::TexParams texParams;
|
||||
texParams.minFilter = GL_LINEAR;
|
||||
texParams.magFilter = GL_LINEAR;
|
||||
texParams.wrapS = textureData->wrapS;
|
||||
texParams.wrapT = textureData->wrapT;
|
||||
tex->setTexParameters(texParams);
|
||||
subMeshState->setTexture(tex);
|
||||
auto tex = Director::getInstance()->getTextureCache()->addImage(textureData->filename);
|
||||
if(tex)
|
||||
{
|
||||
Texture2D::TexParams texParams;
|
||||
texParams.minFilter = GL_LINEAR;
|
||||
texParams.magFilter = GL_LINEAR;
|
||||
texParams.wrapS = textureData->wrapS;
|
||||
texParams.wrapT = textureData->wrapT;
|
||||
tex->setTexParameters(texParams);
|
||||
subMeshState->setTexture(tex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto sprite = new Sprite3D();
|
||||
if (sprite)
|
||||
{
|
||||
auto subMeshState = SubMeshState::create(modelNodeData->id);
|
||||
subMeshState->setSubMesh(getSubMesh(modelNodeData->subMeshId));
|
||||
if (modelNodeData->matrialId == "" && matrialdatas.materials.size())
|
||||
{
|
||||
const NTextureData* textureData = matrialdatas.materials[0].getTextureData(NTextureData::Usage::Diffuse);
|
||||
subMeshState->setTexture(textureData->filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
const NMaterialData* materialData=matrialdatas.getMaterialData(modelNodeData->matrialId);
|
||||
if(materialData)
|
||||
{
|
||||
const NTextureData* textureData = materialData->getTextureData(NTextureData::Usage::Diffuse);
|
||||
if(textureData)
|
||||
{
|
||||
auto tex = Director::getInstance()->getTextureCache()->addImage(textureData->filename);
|
||||
if(tex)
|
||||
{
|
||||
Texture2D::TexParams texParams;
|
||||
texParams.minFilter = GL_LINEAR;
|
||||
texParams.magFilter = GL_LINEAR;
|
||||
texParams.wrapS = textureData->wrapS;
|
||||
texParams.wrapT = textureData->wrapT;
|
||||
tex->setTexParameters(texParams);
|
||||
subMeshState->setTexture(tex);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
sprite->setAdditionalTransform(&nodedata->transform);
|
||||
sprite->addSubMeshState(subMeshState);
|
||||
sprite->autorelease();
|
||||
sprite->genGLProgramState();
|
||||
if(root)
|
||||
{
|
||||
root->addChild(sprite);
|
||||
}
|
||||
}
|
||||
node=sprite;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -344,6 +393,12 @@ SubMesh* Sprite3D::getSubMesh(const std::string& subMeshId) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void Sprite3D::addSubMeshState(SubMeshState* subMeshState)
|
||||
{
|
||||
_meshes.pushBack(subMeshState->getSubMesh()->getMesh());
|
||||
_subMeshStates.pushBack(subMeshState);
|
||||
}
|
||||
|
||||
void Sprite3D::setTexture(const std::string& texFile)
|
||||
{
|
||||
auto tex = Director::getInstance()->getTextureCache()->addImage(texFile);
|
||||
|
|
|
@ -135,7 +135,7 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
void createNode(NodeData* nodedata, Node* root, const MaterialDatas& matrialdatas);
|
||||
/**get SubMesh by Id*/
|
||||
SubMesh* getSubMesh(const std::string& subMeshId) const;
|
||||
|
||||
void addSubMeshState(SubMeshState* subMeshState);
|
||||
protected:
|
||||
|
||||
Skeleton3D* _skeleton; //skeleton
|
||||
|
|
Loading…
Reference in New Issue