From 656babac78d99bffc744c71f1e2b4d51b9a0cf36 Mon Sep 17 00:00:00 2001 From: Turky Mohammed <45469625+DelinWorks@users.noreply.github.com> Date: Tue, 5 Jul 2022 09:48:46 +0300 Subject: [PATCH] [IMPROVMENT] Change class name `Sprite3D` to `MeshRenderer` (#705) * First draft [skip ci] * Improve comments [skip ci] * Rename MeshRendererMaterial to MeshMaterial [skip ci] * Update dependent classes. * Replace occurrences of Sprite3D with MeshRenderer. * Update cpp-tests and extensions. * Fix compilation. * Try fixing lua-bindings * Try fixing lua-bindings * Update lua_cocos2dx_3d_manual.cpp [skip ci] * Create RENAMED_TYPES.md --- RENAMED_TYPES.md | 8 + core/3d/CCAnimate3D.cpp | 8 +- core/3d/CCAnimate3D.h | 6 +- core/3d/CCAttachNode.h | 6 +- core/3d/CCBundle3DData.h | 2 +- core/3d/CCMesh.h | 4 +- ...prite3DMaterial.cpp => CCMeshMaterial.cpp} | 151 ++- ...{CCSprite3DMaterial.h => CCMeshMaterial.h} | 90 +- .../3d/{CCSprite3D.cpp => CCMeshRenderer.cpp} | 333 +++-- core/3d/{CCSprite3D.h => CCMeshRenderer.h} | 195 ++- core/3d/CCMeshVertexIndexData.cpp | 2 +- core/3d/CCMeshVertexIndexData.h | 4 +- core/3d/CCOBB.h | 6 +- core/3d/CMakeLists.txt | 8 +- core/adxe.h | 4 +- core/base/CCConfiguration.h | 18 +- core/physics3d/CCPhysics3D.h | 2 +- ...Sprite3D.cpp => CCPhysicsMeshRenderer.cpp} | 20 +- ...sicsSprite3D.h => CCPhysicsMeshRenderer.h} | 24 +- core/physics3d/CMakeLists.txt | 4 +- extensions/Particle3D/CCParticle3DRender.cpp | 36 +- extensions/Particle3D/CCParticle3DRender.h | 8 +- extensions/Particle3D/PU/CCPUBeamRender.cpp | 2 +- .../Particle3D/PU/CCPUBillboardChain.cpp | 2 +- extensions/Particle3D/PU/CCPURender.cpp | 46 +- extensions/Particle3D/PU/CCPURender.h | 6 +- extensions/Particle3D/PU/CCPURibbonTrail.cpp | 2 +- .../Particle3D/PU/CCPURibbonTrailRender.cpp | 2 +- .../cocostudio/ActionTimeline/CSLoader.cpp | 4 +- extensions/cocostudio/CocoStudio.cpp | 4 +- .../MeshReader.cpp} | 54 +- .../MeshReader.h} | 8 +- .../auto/lua_cocos2dx_3d_auto.cpp | 708 +++++------ .../auto/lua_cocos2dx_physics3d_auto.cpp | 110 +- .../manual/3d/lua_cocos2dx_3d_manual.cpp | 60 +- .../lua_cocos2dx_physics3d_manual.cpp | 50 +- tests/cpp-tests/CMakeLists.txt | 8 +- tests/cpp-tests/Classes/AppDelegate.cpp | 5 + .../Classes/BillBoardTest/BillBoardTest.cpp | 14 +- .../cpp-tests/Classes/BugsTest/Bug-15594.cpp | 8 +- .../Classes/Camera3DTest/Camera3DTest.cpp | 186 +-- .../Classes/Camera3DTest/Camera3DTest.h | 22 +- .../cpp-tests/Classes/LightTest/LightTest.cpp | 36 +- .../MaterialSystemTest/MaterialSystemTest.cpp | 180 +-- .../MaterialSystemTest/MaterialSystemTest.h | 10 +- .../DrawNode3D.cpp | 0 .../DrawNode3D.h | 0 .../MeshRendererTest.cpp} | 1092 ++++++++--------- .../MeshRendererTest.h} | 244 ++-- .../Classes/NavMeshTest/NavMeshTest.cpp | 14 +- .../Classes/Particle3DTest/Particle3DTest.cpp | 14 +- .../Classes/Particle3DTest/Particle3DTest.h | 8 +- .../Classes/Physics3DTest/Physics3DTest.cpp | 248 ++-- .../RenderTextureTest/RenderTextureTest.cpp | 92 -- .../RenderTextureTest/RenderTextureTest.h | 21 - .../Classes/TerrainTest/TerrainTest.cpp | 28 +- .../Classes/TerrainTest/TerrainTest.h | 12 +- tests/cpp-tests/Classes/controller.cpp | 2 +- tests/cpp-tests/Classes/tests.h | 2 +- 59 files changed, 2066 insertions(+), 2177 deletions(-) create mode 100644 RENAMED_TYPES.md rename core/3d/{CCSprite3DMaterial.cpp => CCMeshMaterial.cpp} (63%) rename core/3d/{CCSprite3DMaterial.h => CCMeshMaterial.h} (62%) rename core/3d/{CCSprite3D.cpp => CCMeshRenderer.cpp} (72%) rename core/3d/{CCSprite3D.h => CCMeshRenderer.h} (53%) rename core/physics3d/{CCPhysicsSprite3D.cpp => CCPhysicsMeshRenderer.cpp} (84%) rename core/physics3d/{CCPhysicsSprite3D.h => CCPhysicsMeshRenderer.h} (82%) rename extensions/cocostudio/WidgetReader/{Sprite3DReader/Sprite3DReader.cpp => MeshReader/MeshReader.cpp} (83%) rename extensions/cocostudio/WidgetReader/{Sprite3DReader/Sprite3DReader.h => MeshReader/MeshReader.h} (93%) rename tests/cpp-tests/Classes/{Sprite3DTest => MeshRendererTest}/DrawNode3D.cpp (100%) rename tests/cpp-tests/Classes/{Sprite3DTest => MeshRendererTest}/DrawNode3D.h (100%) rename tests/cpp-tests/Classes/{Sprite3DTest/Sprite3DTest.cpp => MeshRendererTest/MeshRendererTest.cpp} (66%) rename tests/cpp-tests/Classes/{Sprite3DTest/Sprite3DTest.h => MeshRendererTest/MeshRendererTest.h} (69%) diff --git a/RENAMED_TYPES.md b/RENAMED_TYPES.md new file mode 100644 index 0000000000..9eab809106 --- /dev/null +++ b/RENAMED_TYPES.md @@ -0,0 +1,8 @@ +adxe-1.0 ?? + +### Classes & Types +* ```Sprite3D``` => ```MeshRenderer``` + +### Functions & Methods +* ```Director::isDisplayStats()``` => ```Director::isStatsDisplay()``` + diff --git a/core/3d/CCAnimate3D.cpp b/core/3d/CCAnimate3D.cpp index c29ee96850..6c54c29e8a 100644 --- a/core/3d/CCAnimate3D.cpp +++ b/core/3d/CCAnimate3D.cpp @@ -24,7 +24,7 @@ ****************************************************************************/ #include "3d/CCAnimate3D.h" -#include "3d/CCSprite3D.h" +#include "3d/CCMeshRenderer.h" #include "3d/CCSkeleton3D.h" #include "platform/CCFileUtils.h" #include "base/CCConfiguration.h" @@ -156,9 +156,9 @@ void Animate3D::startWithTarget(Node* target) _nodeCurves.clear(); bool hasCurve = false; - Sprite3D* sprite = dynamic_cast(target); + MeshRenderer* mesh = dynamic_cast(target); - if (sprite) + if (mesh) { if (_animation) { @@ -166,7 +166,7 @@ void Animate3D::startWithTarget(Node* target) for (const auto& iter : boneCurves) { std::string_view boneName = iter.first; - auto skin = sprite->getSkeleton(); + auto skin = mesh->getSkeleton(); if (skin) { auto bone = skin->getBoneByName(boneName); diff --git a/core/3d/CCAnimate3D.h b/core/3d/CCAnimate3D.h index 58eff3563b..67a0aa64a0 100644 --- a/core/3d/CCAnimate3D.h +++ b/core/3d/CCAnimate3D.h @@ -37,7 +37,7 @@ NS_CC_BEGIN class Bone3D; -class Sprite3D; +class MeshRenderer; class EventCustom; enum class Animate3DQuality @@ -54,7 +54,7 @@ enum class Animate3DQuality */ /** - * @brief Animate3D, Animates a Sprite3D given with an Animation3D + * @brief Animate3D, Animates a MeshRenderer given with an Animation3D */ class CC_DLL Animate3D : public ActionInterval { @@ -174,7 +174,7 @@ protected: std::unordered_map _keyFrameEvent; std::unordered_map _displayedEventInfo; - // sprite animates + // mesh animations static std::unordered_map s_fadeInAnimates; static std::unordered_map s_fadeOutAnimates; static std::unordered_map s_runningAnimates; diff --git a/core/3d/CCAttachNode.h b/core/3d/CCAttachNode.h index efd5b4ee66..7bc06fadd0 100644 --- a/core/3d/CCAttachNode.h +++ b/core/3d/CCAttachNode.h @@ -38,9 +38,9 @@ class Bone3D; /** * @brief attach a node to a bone - * usage: auto sprite = Sprite3D::create("girl.c3b"); - * auto weapon = Sprite3D::create("weapon.c3b"); - * auto attachNode = sprite->getAttachNode("left hand"); + * usage: auto mesh = MeshRenderer::create("girl.c3b"); + * auto weapon = MeshRenderer::create("weapon.c3b"); + * auto attachNode = mesh->getAttachNode("left hand"); * attachNode->addChild(weapon); */ class CC_DLL AttachNode : public Node diff --git a/core/3d/CCBundle3DData.h b/core/3d/CCBundle3DData.h index e877814287..8bbf5cc784 100644 --- a/core/3d/CCBundle3DData.h +++ b/core/3d/CCBundle3DData.h @@ -109,7 +109,7 @@ struct NodeData struct NodeDatas { std::vector skeleton; // skeleton - std::vector nodes; // nodes, CCNode, Sprite3D or part of Sprite3D + std::vector nodes; // nodes, CCNode, MeshRenderer or parts of MeshRenderer virtual ~NodeDatas() { resetData(); } diff --git a/core/3d/CCMesh.h b/core/3d/CCMesh.h index 0ecac8a450..cb03a40b4c 100644 --- a/core/3d/CCMesh.h +++ b/core/3d/CCMesh.h @@ -61,7 +61,7 @@ class Buffer; */ class CC_DLL Mesh : public Ref { - friend class Sprite3D; + friend class MeshRenderer; public: typedef std::vector IndexArray; @@ -234,7 +234,7 @@ public: void calculateAABB(); /** - * force set this Sprite3D to 2D render queue + * force set this Mesh renderer to 2D render queue */ void setForce2DQueue(bool force2D) { _force2DQueue = force2D; } diff --git a/core/3d/CCSprite3DMaterial.cpp b/core/3d/CCMeshMaterial.cpp similarity index 63% rename from core/3d/CCSprite3DMaterial.cpp rename to core/3d/CCMeshMaterial.cpp index 068cdcbb17..4e7909cf47 100644 --- a/core/3d/CCSprite3DMaterial.cpp +++ b/core/3d/CCMeshMaterial.cpp @@ -23,7 +23,7 @@ THE SOFTWARE. ****************************************************************************/ -#include "3d/CCSprite3DMaterial.h" +#include "3d/CCMeshMaterial.h" #include "3d/CCMesh.h" #include "platform/CCFileUtils.h" #include "renderer/CCTexture2D.h" @@ -36,102 +36,102 @@ NS_CC_BEGIN -Sprite3DMaterialCache* Sprite3DMaterialCache::_cacheInstance = nullptr; +MeshMaterialCache* MeshMaterialCache::_cacheInstance = nullptr; -std::unordered_map Sprite3DMaterial::_materials; -Sprite3DMaterial* Sprite3DMaterial::_unLitMaterial = nullptr; -Sprite3DMaterial* Sprite3DMaterial::_unLitNoTexMaterial = nullptr; -Sprite3DMaterial* Sprite3DMaterial::_vertexLitMaterial = nullptr; -Sprite3DMaterial* Sprite3DMaterial::_diffuseMaterial = nullptr; -Sprite3DMaterial* Sprite3DMaterial::_diffuseNoTexMaterial = nullptr; -Sprite3DMaterial* Sprite3DMaterial::_bumpedDiffuseMaterial = nullptr; +std::unordered_map MeshMaterial::_materials; +MeshMaterial* MeshMaterial::_unLitMaterial = nullptr; +MeshMaterial* MeshMaterial::_unLitNoTexMaterial = nullptr; +MeshMaterial* MeshMaterial::_vertexLitMaterial = nullptr; +MeshMaterial* MeshMaterial::_diffuseMaterial = nullptr; +MeshMaterial* MeshMaterial::_diffuseNoTexMaterial = nullptr; +MeshMaterial* MeshMaterial::_bumpedDiffuseMaterial = nullptr; -Sprite3DMaterial* Sprite3DMaterial::_unLitMaterialSkin = nullptr; -Sprite3DMaterial* Sprite3DMaterial::_vertexLitMaterialSkin = nullptr; -Sprite3DMaterial* Sprite3DMaterial::_diffuseMaterialSkin = nullptr; -Sprite3DMaterial* Sprite3DMaterial::_bumpedDiffuseMaterialSkin = nullptr; +MeshMaterial* MeshMaterial::_unLitMaterialSkin = nullptr; +MeshMaterial* MeshMaterial::_vertexLitMaterialSkin = nullptr; +MeshMaterial* MeshMaterial::_diffuseMaterialSkin = nullptr; +MeshMaterial* MeshMaterial::_bumpedDiffuseMaterialSkin = nullptr; -backend::ProgramState* Sprite3DMaterial::_unLitMaterialProgState = nullptr; -backend::ProgramState* Sprite3DMaterial::_unLitNoTexMaterialProgState = nullptr; -backend::ProgramState* Sprite3DMaterial::_vertexLitMaterialProgState = nullptr; -backend::ProgramState* Sprite3DMaterial::_diffuseMaterialProgState = nullptr; -backend::ProgramState* Sprite3DMaterial::_diffuseNoTexMaterialProgState = nullptr; -backend::ProgramState* Sprite3DMaterial::_bumpedDiffuseMaterialProgState = nullptr; +backend::ProgramState* MeshMaterial::_unLitMaterialProgState = nullptr; +backend::ProgramState* MeshMaterial::_unLitNoTexMaterialProgState = nullptr; +backend::ProgramState* MeshMaterial::_vertexLitMaterialProgState = nullptr; +backend::ProgramState* MeshMaterial::_diffuseMaterialProgState = nullptr; +backend::ProgramState* MeshMaterial::_diffuseNoTexMaterialProgState = nullptr; +backend::ProgramState* MeshMaterial::_bumpedDiffuseMaterialProgState = nullptr; -backend::ProgramState* Sprite3DMaterial::_unLitMaterialSkinProgState = nullptr; -backend::ProgramState* Sprite3DMaterial::_vertexLitMaterialSkinProgState = nullptr; -backend::ProgramState* Sprite3DMaterial::_diffuseMaterialSkinProgState = nullptr; -backend::ProgramState* Sprite3DMaterial::_bumpedDiffuseMaterialSkinProgState = nullptr; +backend::ProgramState* MeshMaterial::_unLitMaterialSkinProgState = nullptr; +backend::ProgramState* MeshMaterial::_vertexLitMaterialSkinProgState = nullptr; +backend::ProgramState* MeshMaterial::_diffuseMaterialSkinProgState = nullptr; +backend::ProgramState* MeshMaterial::_bumpedDiffuseMaterialSkinProgState = nullptr; -void Sprite3DMaterial::createBuiltInMaterial() +void MeshMaterial::createBuiltInMaterial() { auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::SKINPOSITION_TEXTURE_3D); _unLitMaterialSkinProgState = new backend::ProgramState(program); - _unLitMaterialSkin = new Sprite3DMaterial(); + _unLitMaterialSkin = new MeshMaterial(); if (_unLitMaterialSkin && _unLitMaterialSkin->initWithProgramState(_unLitMaterialSkinProgState)) { - _unLitMaterialSkin->_type = Sprite3DMaterial::MaterialType::UNLIT; + _unLitMaterialSkin->_type = MeshMaterial::MaterialType::UNLIT; } program = backend::Program::getBuiltinProgram(backend::ProgramType::SKINPOSITION_NORMAL_TEXTURE_3D); _diffuseMaterialSkinProgState = new backend::ProgramState(program); - _diffuseMaterialSkin = new Sprite3DMaterial(); + _diffuseMaterialSkin = new MeshMaterial(); if (_diffuseMaterialSkin && _diffuseMaterialSkin->initWithProgramState(_diffuseMaterialSkinProgState)) { - _diffuseMaterialSkin->_type = Sprite3DMaterial::MaterialType::DIFFUSE; + _diffuseMaterialSkin->_type = MeshMaterial::MaterialType::DIFFUSE; } program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_NORMAL_TEXTURE_3D); _diffuseMaterialProgState = new backend::ProgramState(program); - _diffuseMaterial = new Sprite3DMaterial(); + _diffuseMaterial = new MeshMaterial(); if (_diffuseMaterial && _diffuseMaterial->initWithProgramState(_diffuseMaterialProgState)) { - _diffuseMaterial->_type = Sprite3DMaterial::MaterialType::DIFFUSE; + _diffuseMaterial->_type = MeshMaterial::MaterialType::DIFFUSE; } program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_3D); _unLitMaterialProgState = new backend::ProgramState(program); - _unLitMaterial = new Sprite3DMaterial(); + _unLitMaterial = new MeshMaterial(); if (_unLitMaterial && _unLitMaterial->initWithProgramState(_unLitMaterialProgState)) { - _unLitMaterial->_type = Sprite3DMaterial::MaterialType::UNLIT; + _unLitMaterial->_type = MeshMaterial::MaterialType::UNLIT; } program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_3D); _unLitNoTexMaterialProgState = new backend::ProgramState(program); - _unLitNoTexMaterial = new Sprite3DMaterial(); + _unLitNoTexMaterial = new MeshMaterial(); if (_unLitNoTexMaterial && _unLitNoTexMaterial->initWithProgramState(_unLitNoTexMaterialProgState)) { - _unLitNoTexMaterial->_type = Sprite3DMaterial::MaterialType::UNLIT_NOTEX; + _unLitNoTexMaterial->_type = MeshMaterial::MaterialType::UNLIT_NOTEX; } program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_NORMAL_3D); _diffuseNoTexMaterialProgState = new backend::ProgramState(program); - _diffuseNoTexMaterial = new Sprite3DMaterial(); + _diffuseNoTexMaterial = new MeshMaterial(); if (_diffuseNoTexMaterial && _diffuseNoTexMaterial->initWithProgramState(_diffuseNoTexMaterialProgState)) { - _diffuseNoTexMaterial->_type = Sprite3DMaterial::MaterialType::DIFFUSE_NOTEX; + _diffuseNoTexMaterial->_type = MeshMaterial::MaterialType::DIFFUSE_NOTEX; } program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_BUMPEDNORMAL_TEXTURE_3D); _bumpedDiffuseMaterialProgState = new backend::ProgramState(program); - _bumpedDiffuseMaterial = new Sprite3DMaterial(); + _bumpedDiffuseMaterial = new MeshMaterial(); if (_bumpedDiffuseMaterial && _bumpedDiffuseMaterial->initWithProgramState(_bumpedDiffuseMaterialProgState)) { - _bumpedDiffuseMaterial->_type = Sprite3DMaterial::MaterialType::BUMPED_DIFFUSE; + _bumpedDiffuseMaterial->_type = MeshMaterial::MaterialType::BUMPED_DIFFUSE; } program = backend::Program::getBuiltinProgram(backend::ProgramType::SKINPOSITION_BUMPEDNORMAL_TEXTURE_3D); _bumpedDiffuseMaterialSkinProgState = new backend::ProgramState(program); - _bumpedDiffuseMaterialSkin = new Sprite3DMaterial(); + _bumpedDiffuseMaterialSkin = new MeshMaterial(); if (_bumpedDiffuseMaterialSkin && _bumpedDiffuseMaterialSkin->initWithProgramState(_bumpedDiffuseMaterialSkinProgState)) { - _bumpedDiffuseMaterialSkin->_type = Sprite3DMaterial::MaterialType::BUMPED_DIFFUSE; + _bumpedDiffuseMaterialSkin->_type = MeshMaterial::MaterialType::BUMPED_DIFFUSE; } } -void Sprite3DMaterial::releaseBuiltInMaterial() +void MeshMaterial::releaseBuiltInMaterial() { CC_SAFE_RELEASE_NULL(_unLitMaterial); CC_SAFE_RELEASE_NULL(_unLitMaterialSkin); @@ -159,7 +159,7 @@ void Sprite3DMaterial::releaseBuiltInMaterial() CC_SAFE_RELEASE_NULL(_bumpedDiffuseMaterialSkinProgState); } -void Sprite3DMaterial::releaseCachedMaterial() +void MeshMaterial::releaseCachedMaterial() { for (auto& it : _materials) { @@ -169,11 +169,10 @@ void Sprite3DMaterial::releaseCachedMaterial() _materials.clear(); } -Material* Sprite3DMaterial::clone() const +Material* MeshMaterial::clone() const { - auto material = new Sprite3DMaterial(); + auto material = new MeshMaterial(); - // RenderState::cloneInto(material); material->_renderState = _renderState; for (const auto& technique : _techniques) @@ -196,36 +195,36 @@ Material* Sprite3DMaterial::clone() const return material; } -Sprite3DMaterial* Sprite3DMaterial::createBuiltInMaterial(MaterialType type, bool skinned) +MeshMaterial* MeshMaterial::createBuiltInMaterial(MaterialType type, bool skinned) { ///// if (_diffuseMaterial == nullptr) createBuiltInMaterial(); - Sprite3DMaterial* material = nullptr; + MeshMaterial* material = nullptr; switch (type) { - case Sprite3DMaterial::MaterialType::UNLIT: + case MeshMaterial::MaterialType::UNLIT: material = skinned ? _unLitMaterialSkin : _unLitMaterial; break; - case Sprite3DMaterial::MaterialType::UNLIT_NOTEX: + case MeshMaterial::MaterialType::UNLIT_NOTEX: material = _unLitNoTexMaterial; break; - case Sprite3DMaterial::MaterialType::VERTEX_LIT: - CCASSERT(0, "not implement"); + case MeshMaterial::MaterialType::VERTEX_LIT: + CCASSERT(0, "not implemented."); break; - case Sprite3DMaterial::MaterialType::DIFFUSE: + case MeshMaterial::MaterialType::DIFFUSE: material = skinned ? _diffuseMaterialSkin : _diffuseMaterial; break; - case Sprite3DMaterial::MaterialType::DIFFUSE_NOTEX: + case MeshMaterial::MaterialType::DIFFUSE_NOTEX: material = _diffuseNoTexMaterial; break; - case Sprite3DMaterial::MaterialType::BUMPED_DIFFUSE: + case MeshMaterial::MaterialType::BUMPED_DIFFUSE: material = skinned ? _bumpedDiffuseMaterialSkin : _bumpedDiffuseMaterial; break; @@ -233,41 +232,41 @@ Sprite3DMaterial* Sprite3DMaterial::createBuiltInMaterial(MaterialType type, boo break; } if (material) - return (Sprite3DMaterial*)material->clone(); + return (MeshMaterial*)material->clone(); return nullptr; } -Sprite3DMaterial* Sprite3DMaterial::createWithFilename(std::string_view path) +MeshMaterial* MeshMaterial::createWithFilename(std::string_view path) { auto validfilename = FileUtils::getInstance()->fullPathForFilename(path); if (!validfilename.empty()) { auto it = _materials.find(validfilename); if (it != _materials.end()) - return (Sprite3DMaterial*)it->second->clone(); + return (MeshMaterial*)it->second->clone(); - auto material = new Sprite3DMaterial(); + auto material = new MeshMaterial(); if (material->initWithFile(path)) { - material->_type = Sprite3DMaterial::MaterialType::CUSTOM; + material->_type = MeshMaterial::MaterialType::CUSTOM; _materials[validfilename] = material; - return (Sprite3DMaterial*)material->clone(); + return (MeshMaterial*)material->clone(); } CC_SAFE_DELETE(material); } return nullptr; } -Sprite3DMaterial* Sprite3DMaterial::createWithProgramState(backend::ProgramState* programState) +MeshMaterial* MeshMaterial::createWithProgramState(backend::ProgramState* programState) { - CCASSERT(programState, "Invalid GL Program State"); + CCASSERT(programState, "Invalid program state."); - auto mat = new Sprite3DMaterial(); + auto mat = new MeshMaterial(); if (mat->initWithProgramState(programState)) { - mat->_type = Sprite3DMaterial::MaterialType::CUSTOM; + mat->_type = MeshMaterial::MaterialType::CUSTOM; mat->autorelease(); return mat; } @@ -275,7 +274,7 @@ Sprite3DMaterial* Sprite3DMaterial::createWithProgramState(backend::ProgramState return nullptr; } -void Sprite3DMaterial::setTexture(Texture2D* tex, NTextureData::Usage usage) +void MeshMaterial::setTexture(Texture2D* tex, NTextureData::Usage usage) { const auto& passes = getTechnique()->getPasses(); for (auto& pass : passes) @@ -286,24 +285,24 @@ void Sprite3DMaterial::setTexture(Texture2D* tex, NTextureData::Usage usage) ////////////////////////////////////////////////////////////////////////////////////////////////////// -Sprite3DMaterialCache::Sprite3DMaterialCache() {} +MeshMaterialCache::MeshMaterialCache() {} -Sprite3DMaterialCache::~Sprite3DMaterialCache() +MeshMaterialCache::~MeshMaterialCache() { - removeAllSprite3DMaterial(); + removeAllMeshMaterial(); } -Sprite3DMaterialCache* Sprite3DMaterialCache::getInstance() +MeshMaterialCache* MeshMaterialCache::getInstance() { if (!_cacheInstance) { - _cacheInstance = new Sprite3DMaterialCache(); + _cacheInstance = new MeshMaterialCache(); } return _cacheInstance; } -void Sprite3DMaterialCache::destroyInstance() +void MeshMaterialCache::destroyInstance() { if (_cacheInstance) { @@ -311,7 +310,7 @@ void Sprite3DMaterialCache::destroyInstance() } } -bool Sprite3DMaterialCache::addSprite3DMaterial(std::string_view key, Texture2D* texture) +bool MeshMaterialCache::addMeshMaterial(std::string_view key, Texture2D* texture) { auto itr = _materials.find(key); if (itr == _materials.end()) @@ -323,7 +322,7 @@ bool Sprite3DMaterialCache::addSprite3DMaterial(std::string_view key, Texture2D* return false; } -Texture2D* Sprite3DMaterialCache::getSprite3DMaterial(std::string_view key) +Texture2D* MeshMaterialCache::getMeshMaterial(std::string_view key) { auto itr = _materials.find(key); if (itr != _materials.end()) @@ -333,7 +332,7 @@ Texture2D* Sprite3DMaterialCache::getSprite3DMaterial(std::string_view key) return nullptr; } -void Sprite3DMaterialCache::removeAllSprite3DMaterial() +void MeshMaterialCache::removeAllMeshMaterial() { for (auto& itr : _materials) { @@ -341,14 +340,14 @@ void Sprite3DMaterialCache::removeAllSprite3DMaterial() } _materials.clear(); } -void Sprite3DMaterialCache::removeUnusedSprite3DMaterial() +void MeshMaterialCache::removeUnusedMeshMaterial() { for (auto it = _materials.cbegin(), itCend = _materials.cend(); it != itCend; /* nothing */) { auto value = it->second; if (value->getReferenceCount() == 1) { - CCLOG("cocos2d: Sprite3DMaterialCache: removing unused Sprite3DMaterial"); + CCLOG("cocos2d: MeshMaterialCache: removing unused mesh renderer materials."); value->release(); it = _materials.erase(it); diff --git a/core/3d/CCSprite3DMaterial.h b/core/3d/CCMeshMaterial.h similarity index 62% rename from core/3d/CCSprite3DMaterial.h rename to core/3d/CCMeshMaterial.h index 8d6473b486..45c7a4fe59 100644 --- a/core/3d/CCSprite3DMaterial.h +++ b/core/3d/CCMeshMaterial.h @@ -46,26 +46,26 @@ class ProgramState; } /** - * @brief Sprite3DMaterial: Material for Sprite3D. + * @brief MeshMaterial: a mesh material for MeshRenderers. */ -class CC_DLL Sprite3DMaterial : public Material +class CC_DLL MeshMaterial : public Material { public: /** - * Material type, there are mainly two types of materials. Built in materials and Custom material + * Material types, there are mainly two types of materials. Built-in materials and Custom materials. */ enum class MaterialType { - // Built in material + // Built in materials UNLIT, // unlit material - UNLIT_NOTEX, // unlit material without texture + UNLIT_NOTEX, // unlit material (without texture) VERTEX_LIT, // vertex lit DIFFUSE, // diffuse (pixel lighting) DIFFUSE_NOTEX, // diffuse (without texture) BUMPED_DIFFUSE, // bumped diffuse // Custom material - CUSTOM, // Create from material file + CUSTOM, // Create from a material file }; /** @@ -77,35 +77,34 @@ public: /** * Create built in material from material type * @param type Material type - * @param skinned Has skin? - * @return Created material + * @param skinned Has hardware skinning? + * @return An autorelease material object */ - static Sprite3DMaterial* createBuiltInMaterial(MaterialType type, bool skinned); + static MeshMaterial* createBuiltInMaterial(MaterialType type, bool skinned); /** * Create material with file name, it creates material from cache if it is previously loaded * @param path Path of material file - * @return Created material + * @return An autorelease material object */ - static Sprite3DMaterial* createWithFilename(std::string_view path); + static MeshMaterial* createWithFilename(std::string_view path); /** - * Create material with GLProgramState + * Create material with a ProgramState * @param programState GLProgramState instance - * @return Created material + * @return An autorelease material object */ - // static Sprite3DMaterial* createWithGLStateProgram(GLProgramState* programState); - static Sprite3DMaterial* createWithProgramState(backend::ProgramState* programState); + static MeshMaterial* createWithProgramState(backend::ProgramState* programState); void setTexture(Texture2D* tex, NTextureData::Usage usage); /** - * Create all build in materials + * Create all built-in materials */ static void createBuiltInMaterial(); /** - * Release all built in materials + * Release all built-in materials */ static void releaseBuiltInMaterial(); @@ -115,24 +114,24 @@ public: static void releaseCachedMaterial(); /** - * Clone material + * Clone this material. */ virtual Material* clone() const override; protected: MaterialType _type; - static std::unordered_map _materials; // cached material - static Sprite3DMaterial* _unLitMaterial; - static Sprite3DMaterial* _unLitNoTexMaterial; - static Sprite3DMaterial* _vertexLitMaterial; - static Sprite3DMaterial* _diffuseMaterial; - static Sprite3DMaterial* _diffuseNoTexMaterial; - static Sprite3DMaterial* _bumpedDiffuseMaterial; + static std::unordered_map _materials; // cached material + static MeshMaterial* _unLitMaterial; + static MeshMaterial* _unLitNoTexMaterial; + static MeshMaterial* _vertexLitMaterial; + static MeshMaterial* _diffuseMaterial; + static MeshMaterial* _diffuseNoTexMaterial; + static MeshMaterial* _bumpedDiffuseMaterial; - static Sprite3DMaterial* _unLitMaterialSkin; - static Sprite3DMaterial* _vertexLitMaterialSkin; - static Sprite3DMaterial* _diffuseMaterialSkin; - static Sprite3DMaterial* _bumpedDiffuseMaterialSkin; + static MeshMaterial* _unLitMaterialSkin; + static MeshMaterial* _vertexLitMaterialSkin; + static MeshMaterial* _diffuseMaterialSkin; + static MeshMaterial* _bumpedDiffuseMaterialSkin; static backend::ProgramState* _unLitMaterialProgState; static backend::ProgramState* _unLitNoTexMaterialProgState; @@ -148,36 +147,33 @@ protected: }; /** - * @brief the sprite3D material is only texture for now + * @brief MeshMaterialCache: the MeshRenderer material cache, it can only cache textures for now. * @js NA * @lua NA */ -class Sprite3DMaterialCache +class MeshMaterialCache { public: - /**get & destroy cache*/ - static Sprite3DMaterialCache* getInstance(); - - /**destroy the instance*/ + static MeshMaterialCache* getInstance(); static void destroyInstance(); - /**add to cache*/ - bool addSprite3DMaterial(std::string_view key, Texture2D* tex); + /** add a material to cache */ + bool addMeshMaterial(std::string_view key, Texture2D* tex); - /**get material from cache*/ - Texture2D* getSprite3DMaterial(std::string_view key); + /** get material from cache */ + Texture2D* getMeshMaterial(std::string_view key); - /**remove all spritematerial*/ - void removeAllSprite3DMaterial(); - /**remove unused spritematerial*/ - void removeUnusedSprite3DMaterial(); + /** remove all cached materials */ + void removeAllMeshMaterial(); + /** remove unused cached materials */ + void removeUnusedMeshMaterial(); - Sprite3DMaterialCache(); - ~Sprite3DMaterialCache(); + MeshMaterialCache(); + ~MeshMaterialCache(); protected: - static Sprite3DMaterialCache* _cacheInstance; // instance - hlookup::string_map _materials; // cached material + static MeshMaterialCache* _cacheInstance; // cache instance + hlookup::string_map _materials; // cached materials }; // end of 3d group diff --git a/core/3d/CCSprite3D.cpp b/core/3d/CCMeshRenderer.cpp similarity index 72% rename from core/3d/CCSprite3D.cpp rename to core/3d/CCMeshRenderer.cpp index 14f47e10a1..d3efbb3f34 100644 --- a/core/3d/CCSprite3D.cpp +++ b/core/3d/CCMeshRenderer.cpp @@ -23,11 +23,11 @@ THE SOFTWARE. ****************************************************************************/ -#include "3d/CCSprite3D.h" +#include "3d/CCMeshRenderer.h" #include "3d/CCObjLoader.h" #include "3d/CCMeshSkin.h" #include "3d/CCBundle3D.h" -#include "3d/CCSprite3DMaterial.h" +#include "3d/CCMeshMaterial.h" #include "3d/CCAttachNode.h" #include "3d/CCMesh.h" @@ -48,87 +48,87 @@ NS_CC_BEGIN -static Sprite3DMaterial* getSprite3DMaterialForAttribs(MeshVertexData* meshVertexData, bool usesLight); +static MeshMaterial* getMeshRendererMaterialForAttribs(MeshVertexData* meshVertexData, bool usesLight); -Sprite3D* Sprite3D::create() +MeshRenderer* MeshRenderer::create() { - auto sprite = new Sprite3D(); - if (sprite->init()) + auto mesh = new MeshRenderer(); + if (mesh->init()) { - sprite->autorelease(); - return sprite; + mesh->autorelease(); + return mesh; } - CC_SAFE_DELETE(sprite); + CC_SAFE_DELETE(mesh); return nullptr; } -Sprite3D* Sprite3D::create(std::string_view modelPath) +MeshRenderer* MeshRenderer::create(std::string_view modelPath) { - CCASSERT(modelPath.length() >= 4, "invalid filename for Sprite3D"); + CCASSERT(modelPath.length() >= 4, "Invalid filename."); - auto sprite = new Sprite3D(); - if (sprite->initWithFile(modelPath)) + auto mesh = new MeshRenderer(); + if (mesh->initWithFile(modelPath)) { - sprite->_contentSize = sprite->getBoundingBox().size; - sprite->autorelease(); - return sprite; + mesh->_contentSize = mesh->getBoundingBox().size; + mesh->autorelease(); + return mesh; } - CC_SAFE_DELETE(sprite); + CC_SAFE_DELETE(mesh); return nullptr; } -Sprite3D* Sprite3D::create(std::string_view modelPath, std::string_view texturePath) +MeshRenderer* MeshRenderer::create(std::string_view modelPath, std::string_view texturePath) { - auto sprite = create(modelPath); - if (sprite) + auto mesh = create(modelPath); + if (mesh) { - sprite->setTexture(texturePath); + mesh->setTexture(texturePath); } - return sprite; + return mesh; } -void Sprite3D::createAsync(std::string_view modelPath, - const std::function& callback, +void MeshRenderer::createAsync(std::string_view modelPath, + const std::function& callback, void* callbackparam) { createAsync(modelPath, "", callback, callbackparam); } -void Sprite3D::createAsync(std::string_view modelPath, +void MeshRenderer::createAsync(std::string_view modelPath, std::string_view texturePath, - const std::function& callback, + const std::function& callback, void* callbackparam) { - Sprite3D* sprite = new Sprite3D(); - if (sprite->loadFromCache(modelPath)) + MeshRenderer* mesh = new MeshRenderer(); + if (mesh->loadFromCache(modelPath)) { - sprite->autorelease(); + mesh->autorelease(); if (!texturePath.empty()) - sprite->setTexture(texturePath); - callback(sprite, callbackparam); + mesh->setTexture(texturePath); + callback(mesh, callbackparam); return; } - sprite->_asyncLoadParam.afterLoadCallback = callback; - sprite->_asyncLoadParam.texPath = texturePath; - sprite->_asyncLoadParam.modelPath = modelPath; - sprite->_asyncLoadParam.modelFullPath = FileUtils::getInstance()->fullPathForFilename(modelPath); - sprite->_asyncLoadParam.callbackParam = callbackparam; - sprite->_asyncLoadParam.materialdatas = new MaterialDatas(); - sprite->_asyncLoadParam.meshdatas = new MeshDatas(); - sprite->_asyncLoadParam.nodeDatas = new NodeDatas(); + mesh->_asyncLoadParam.afterLoadCallback = callback; + mesh->_asyncLoadParam.texPath = texturePath; + mesh->_asyncLoadParam.modelPath = modelPath; + mesh->_asyncLoadParam.modelFullPath = FileUtils::getInstance()->fullPathForFilename(modelPath); + mesh->_asyncLoadParam.callbackParam = callbackparam; + mesh->_asyncLoadParam.materialdatas = new MaterialDatas(); + mesh->_asyncLoadParam.meshdatas = new MeshDatas(); + mesh->_asyncLoadParam.nodeDatas = new NodeDatas(); AsyncTaskPool::getInstance()->enqueue( - AsyncTaskPool::TaskType::TASK_IO, CC_CALLBACK_1(Sprite3D::afterAsyncLoad, sprite), - (void*)(&sprite->_asyncLoadParam), [sprite]() { - sprite->_asyncLoadParam.result = - sprite->loadFromFile(sprite->_asyncLoadParam.modelFullPath, sprite->_asyncLoadParam.nodeDatas, - sprite->_asyncLoadParam.meshdatas, sprite->_asyncLoadParam.materialdatas); + AsyncTaskPool::TaskType::TASK_IO, CC_CALLBACK_1(MeshRenderer::afterAsyncLoad, mesh), + (void*)(&mesh->_asyncLoadParam), [mesh]() { + mesh->_asyncLoadParam.result = + mesh->loadFromFile(mesh->_asyncLoadParam.modelFullPath, mesh->_asyncLoadParam.nodeDatas, + mesh->_asyncLoadParam.meshdatas, mesh->_asyncLoadParam.materialdatas); }); } -void Sprite3D::afterAsyncLoad(void* param) +void MeshRenderer::afterAsyncLoad(void* param) { - Sprite3D::AsyncLoadParam* asyncParam = (Sprite3D::AsyncLoadParam*)param; + MeshRenderer::AsyncLoadParam* asyncParam = (MeshRenderer::AsyncLoadParam*)param; autorelease(); if (asyncParam) { @@ -145,11 +145,11 @@ void Sprite3D::afterAsyncLoad(void* param) auto& nodeDatas = asyncParam->nodeDatas; if (initFrom(*nodeDatas, *meshdatas, *materialdatas)) { - auto spritedata = Sprite3DCache::getInstance()->getSpriteData(asyncParam->modelPath); - if (spritedata == nullptr) + auto meshdata = MeshRendererCache::getInstance()->getMeshData(asyncParam->modelPath); + if (meshdata == nullptr) { // add to cache - auto data = new Sprite3DCache::Sprite3DData(); + auto data = new MeshRendererCache::MeshRendererData(); data->materialdatas = materialdatas; data->nodedatas = nodeDatas; data->meshVertexDatas = _meshVertexDatas; @@ -158,7 +158,7 @@ void Sprite3D::afterAsyncLoad(void* param) data->programStates.pushBack(mesh->getProgramState()); } - Sprite3DCache::getInstance()->addSprite3DData(asyncParam->modelPath, data); + MeshRendererCache::getInstance()->addMeshRendererData(asyncParam->modelPath, data); CC_SAFE_DELETE(meshdatas); materialdatas = nullptr; @@ -176,13 +176,13 @@ void Sprite3D::afterAsyncLoad(void* param) } else { - CCLOG("file load failed: %s ", asyncParam->modelPath.c_str()); + CCLOG("file load failed: %s\n", asyncParam->modelPath.c_str()); } asyncParam->afterLoadCallback(this, asyncParam->callbackParam); } } -AABB Sprite3D::getAABBRecursivelyImp(Node* node) +AABB MeshRenderer::getAABBRecursivelyImp(Node* node) { AABB aabb; for (auto iter : node->getChildren()) @@ -190,46 +190,46 @@ AABB Sprite3D::getAABBRecursivelyImp(Node* node) aabb.merge(getAABBRecursivelyImp(iter)); } - Sprite3D* sprite3d = dynamic_cast(node); - if (sprite3d) - aabb.merge(sprite3d->getAABB()); + MeshRenderer* meshRenderer = dynamic_cast(node); + if (meshRenderer) + aabb.merge(meshRenderer->getAABB()); return aabb; } -bool Sprite3D::loadFromCache(std::string_view path) +bool MeshRenderer::loadFromCache(std::string_view path) { - auto spritedata = Sprite3DCache::getInstance()->getSpriteData(path); - if (spritedata) + auto meshdata = MeshRendererCache::getInstance()->getMeshData(path); + if (meshdata) { - for (auto it : spritedata->meshVertexDatas) + for (auto it : meshdata->meshVertexDatas) { _meshVertexDatas.pushBack(it); } - _skeleton = Skeleton3D::create(spritedata->nodedatas->skeleton); + _skeleton = Skeleton3D::create(meshdata->nodedatas->skeleton); CC_SAFE_RETAIN(_skeleton); - const bool singleSprite = (spritedata->nodedatas->nodes.size() == 1); - for (const auto& it : spritedata->nodedatas->nodes) + const bool singleMesh = (meshdata->nodedatas->nodes.size() == 1); + for (const auto& it : meshdata->nodedatas->nodes) { if (it) { - createNode(it, this, *(spritedata->materialdatas), singleSprite); + createNode(it, this, *(meshdata->materialdatas), singleMesh); } } - for (const auto& it : spritedata->nodedatas->skeleton) + for (const auto& it : meshdata->nodedatas->skeleton) { if (it) { - createAttachSprite3DNode(it, *(spritedata->materialdatas)); + createAttachMeshRendererNode(it, *(meshdata->materialdatas)); } } for (ssize_t i = 0, size = _meshes.size(); i < size; ++i) { - // cloning is needed in order to have one state per sprite - auto glstate = spritedata->programStates.at(i); + // cloning is needed in order to have one state per mesh + auto glstate = meshdata->programStates.at(i); _meshes.at(i)->setProgramState(glstate->clone()); } return true; @@ -238,7 +238,7 @@ bool Sprite3D::loadFromCache(std::string_view path) return false; } -bool Sprite3D::loadFromFile(std::string_view path, +bool MeshRenderer::loadFromFile(std::string_view path, NodeDatas* nodedatas, MeshDatas* meshdatas, MaterialDatas* materialdatas) @@ -269,7 +269,7 @@ bool Sprite3D::loadFromFile(std::string_view path, return false; } -Sprite3D::Sprite3D() +MeshRenderer::MeshRenderer() : _skeleton(nullptr) , _blend(BlendFunc::ALPHA_NON_PREMULTIPLIED) , _aabbDirty(true) @@ -279,7 +279,7 @@ Sprite3D::Sprite3D() , _usingAutogeneratedGLProgram(true) {} -Sprite3D::~Sprite3D() +MeshRenderer::~MeshRenderer() { _meshes.clear(); _meshVertexDatas.clear(); @@ -287,7 +287,7 @@ Sprite3D::~Sprite3D() removeAllAttachNode(); } -bool Sprite3D::init() +bool MeshRenderer::init() { if (Node::init()) { @@ -296,7 +296,7 @@ bool Sprite3D::init() return false; } -bool Sprite3D::initWithFile(std::string_view path) +bool MeshRenderer::initWithFile(std::string_view path) { _aabbDirty = true; _meshes.clear(); @@ -315,7 +315,7 @@ bool Sprite3D::initWithFile(std::string_view path) if (initFrom(*nodeDatas, *meshdatas, *materialdatas)) { // add to cache - auto data = new Sprite3DCache::Sprite3DData(); + auto data = new MeshRendererCache::MeshRendererData(); data->materialdatas = materialdatas; data->nodedatas = nodeDatas; data->meshVertexDatas = _meshVertexDatas; @@ -324,7 +324,7 @@ bool Sprite3D::initWithFile(std::string_view path) data->programStates.pushBack(mesh->getProgramState()); } - Sprite3DCache::getInstance()->addSprite3DData(path, data); + MeshRendererCache::getInstance()->addMeshRendererData(path, data); CC_SAFE_DELETE(meshdatas); _contentSize = getBoundingBox().size; return true; @@ -337,7 +337,7 @@ bool Sprite3D::initWithFile(std::string_view path) return false; } -bool Sprite3D::initFrom(const NodeDatas& nodeDatas, const MeshDatas& meshdatas, const MaterialDatas& materialdatas) +bool MeshRenderer::initFrom(const NodeDatas& nodeDatas, const MeshDatas& meshdatas, const MaterialDatas& materialdatas) { for (const auto& it : meshdatas.meshDatas) { @@ -364,7 +364,7 @@ bool Sprite3D::initFrom(const NodeDatas& nodeDatas, const MeshDatas& meshdatas, { if (it) { - createAttachSprite3DNode(it, materialdatas); + createAttachMeshRendererNode(it, materialdatas); } } genMaterial(); @@ -372,11 +372,11 @@ bool Sprite3D::initFrom(const NodeDatas& nodeDatas, const MeshDatas& meshdatas, return true; } -Sprite3D* Sprite3D::createSprite3DNode(NodeData* nodedata, ModelData* modeldata, const MaterialDatas& materialdatas) +MeshRenderer* MeshRenderer::createMeshRendererNode(NodeData* nodedata, ModelData* modeldata, const MaterialDatas& materialdatas) { - auto sprite = new Sprite3D(); + auto meshRenderer = new MeshRenderer(); - sprite->setName(nodedata->id); + meshRenderer->setName(nodedata->id); auto mesh = Mesh::create(nodedata->id, getMeshIndexData(modeldata->subMeshId)); if (_skeleton && modeldata->bones.size()) @@ -434,46 +434,46 @@ Sprite3D* Sprite3D::createSprite3DNode(NodeData* nodedata, ModelData* modeldata, Quaternion qua; Vec3 scale; nodedata->transform.decompose(&scale, &qua, &pos); - sprite->setPosition3D(pos); - sprite->setRotationQuat(qua); - sprite->setScaleX(scale.x); - sprite->setScaleY(scale.y); - sprite->setScaleZ(scale.z); + meshRenderer->setPosition3D(pos); + meshRenderer->setRotationQuat(qua); + meshRenderer->setScaleX(scale.x); + meshRenderer->setScaleY(scale.y); + meshRenderer->setScaleZ(scale.z); - sprite->addMesh(mesh); - sprite->autorelease(); - sprite->genMaterial(); + meshRenderer->addMesh(mesh); + meshRenderer->autorelease(); + meshRenderer->genMaterial(); - return sprite; + return meshRenderer; } -void Sprite3D::createAttachSprite3DNode(NodeData* nodedata, const MaterialDatas& materialdatas) +void MeshRenderer::createAttachMeshRendererNode(NodeData* nodedata, const MaterialDatas& materialdatas) { for (const auto& it : nodedata->modelNodeDatas) { if (it && getAttachNode(nodedata->id)) { - auto sprite = createSprite3DNode(nodedata, it, materialdatas); - if (sprite) + auto mesh = createMeshRendererNode(nodedata, it, materialdatas); + if (mesh) { - getAttachNode(nodedata->id)->addChild(sprite); + getAttachNode(nodedata->id)->addChild(mesh); } } } for (const auto& it : nodedata->children) { - createAttachSprite3DNode(it, materialdatas); + createAttachMeshRendererNode(it, materialdatas); } } -void Sprite3D::setMaterial(Material* material) +void MeshRenderer::setMaterial(Material* material) { setMaterial(material, -1); } -void Sprite3D::setMaterial(Material* material, int meshIndex) +void MeshRenderer::setMaterial(Material* material, int meshIndex) { CCASSERT(material, "Invalid Material"); - CCASSERT(meshIndex == -1 || (meshIndex >= 0 && meshIndex < _meshes.size()), "Invalid meshIndex"); + CCASSERT(meshIndex == -1 || (meshIndex >= 0 && meshIndex < _meshes.size()), "Invalid meshIndex."); if (meshIndex == -1) { @@ -491,21 +491,21 @@ void Sprite3D::setMaterial(Material* material, int meshIndex) _usingAutogeneratedGLProgram = false; } -Material* Sprite3D::getMaterial(int meshIndex) const +Material* MeshRenderer::getMaterial(int meshIndex) const { - CCASSERT(meshIndex >= 0 && meshIndex < _meshes.size(), "Invalid meshIndex"); + CCASSERT(meshIndex >= 0 && meshIndex < _meshes.size(), "Invalid meshIndex."); return _meshes.at(meshIndex)->getMaterial(); } -void Sprite3D::genMaterial(bool useLight) +void MeshRenderer::genMaterial(bool useLight) { _shaderUsingLight = useLight; - std::unordered_map materials; + std::unordered_map materials; for (auto meshVertexData : _meshVertexDatas) { - auto material = getSprite3DMaterialForAttribs(meshVertexData, useLight); - CCASSERT(material, "material should not be null"); + auto material = getMeshRendererMaterialForAttribs(meshVertexData, useLight); + CCASSERT(material, "material should cannot be null."); materials[meshVertexData] = material; } @@ -526,16 +526,16 @@ void Sprite3D::genMaterial(bool useLight) } } -void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& materialdatas, bool singleSprite) +void MeshRenderer::createNode(NodeData* nodedata, Node* root, const MaterialDatas& materialdatas, bool singleMesh) { Node* node = nullptr; for (const auto& it : nodedata->modelNodeDatas) { if (it) { - if (!it->bones.empty() || singleSprite) + if (!it->bones.empty() || singleMesh) { - if (singleSprite && root != nullptr) + if (singleMesh && root != nullptr) root->setName(nodedata->id); auto mesh = Mesh::create(nodedata->id, getMeshIndexData(it->subMeshId)); if (mesh) @@ -546,7 +546,7 @@ void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& m auto skin = MeshSkin::create(_skeleton, it->bones, it->invBindPose); mesh->setSkin(skin); } - mesh->_visibleChanged = std::bind(&Sprite3D::onAABBDirty, this); + mesh->_visibleChanged = std::bind(&MeshRenderer::onAABBDirty, this); if (it->materialId == "" && materialdatas.materials.size()) { @@ -610,15 +610,15 @@ void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& m } else { - auto sprite = createSprite3DNode(nodedata, it, materialdatas); - if (sprite) + auto mesh = createMeshRendererNode(nodedata, it, materialdatas); + if (mesh) { if (root) { - root->addChild(sprite); + root->addChild(mesh); } } - node = sprite; + node = mesh; } } } @@ -654,7 +654,7 @@ void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& m } } -MeshIndexData* Sprite3D::getMeshIndexData(std::string_view indexId) const +MeshIndexData* MeshRenderer::getMeshIndexData(std::string_view indexId) const { for (auto it : _meshVertexDatas) { @@ -665,27 +665,27 @@ MeshIndexData* Sprite3D::getMeshIndexData(std::string_view indexId) const return nullptr; } -void Sprite3D::addMesh(Mesh* mesh) +void MeshRenderer::addMesh(Mesh* mesh) { auto meshVertex = mesh->getMeshIndexData()->_vertexData; _meshVertexDatas.pushBack(meshVertex); _meshes.pushBack(mesh); } -void Sprite3D::setTexture(std::string_view texFile) +void MeshRenderer::setTexture(std::string_view texFile) { auto tex = _director->getTextureCache()->addImage(texFile); setTexture(tex); } -void Sprite3D::setTexture(Texture2D* texture) +void MeshRenderer::setTexture(Texture2D* texture) { for (auto mesh : _meshes) { mesh->setTexture(texture); } } -AttachNode* Sprite3D::getAttachNode(std::string_view boneName) +AttachNode* MeshRenderer::getAttachNode(std::string_view boneName) { auto it = _attachments.find(boneName); if (it != _attachments.end()) @@ -706,7 +706,7 @@ AttachNode* Sprite3D::getAttachNode(std::string_view boneName) return nullptr; } -void Sprite3D::removeAttachNode(std::string_view boneName) +void MeshRenderer::removeAttachNode(std::string_view boneName) { auto it = _attachments.find(boneName); if (it != _attachments.end()) @@ -716,7 +716,7 @@ void Sprite3D::removeAttachNode(std::string_view boneName) } } -void Sprite3D::removeAllAttachNode() +void MeshRenderer::removeAllAttachNode() { for (auto& it : _attachments) { @@ -725,7 +725,7 @@ void Sprite3D::removeAllAttachNode() _attachments.clear(); } -void Sprite3D::visit(cocos2d::Renderer* renderer, const cocos2d::Mat4& parentTransform, uint32_t parentFlags) +void MeshRenderer::visit(cocos2d::Renderer* renderer, const cocos2d::Mat4& parentTransform, uint32_t parentFlags) { // quick return if not visible. children won't be drawn. if (!_visible) @@ -772,7 +772,7 @@ void Sprite3D::visit(cocos2d::Renderer* renderer, const cocos2d::Mat4& parentTra _director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); } -void Sprite3D::draw(Renderer* renderer, const Mat4& transform, uint32_t flags) +void MeshRenderer::draw(Renderer* renderer, const Mat4& transform, uint32_t flags) { #if CC_USE_CULLING // TODO new-renderer: interface isVisibleInFrustum removal @@ -815,7 +815,7 @@ void Sprite3D::draw(Renderer* renderer, const Mat4& transform, uint32_t flags) } } -bool Sprite3D::setProgramState(backend::ProgramState* programState, bool needsRetain) +bool MeshRenderer::setProgramState(backend::ProgramState* programState, bool needsRetain) { if (Node::setProgramState(programState, needsRetain)) { @@ -828,7 +828,7 @@ bool Sprite3D::setProgramState(backend::ProgramState* programState, bool needsRe return false; } -void Sprite3D::setBlendFunc(const BlendFunc& blendFunc) +void MeshRenderer::setBlendFunc(const BlendFunc& blendFunc) { if (_blend.src != blendFunc.src || _blend.dst != blendFunc.dst) { @@ -840,17 +840,17 @@ void Sprite3D::setBlendFunc(const BlendFunc& blendFunc) } } -const BlendFunc& Sprite3D::getBlendFunc() const +const BlendFunc& MeshRenderer::getBlendFunc() const { return _blend; } -AABB Sprite3D::getAABBRecursively() +AABB MeshRenderer::getAABBRecursively() { return getAABBRecursivelyImp(this); } -const AABB& Sprite3D::getAABB() const +const AABB& MeshRenderer::getAABB() const { Mat4 nodeToWorldTransform(getNodeToWorldTransform()); @@ -880,45 +880,43 @@ const AABB& Sprite3D::getAABB() const return _aabb; } -Action* Sprite3D::runAction(Action* action) +Action* MeshRenderer::runAction(Action* action) { setForceDepthWrite(true); return Node::runAction(action); } -Rect Sprite3D::getBoundingBox() const +Rect MeshRenderer::getBoundingBox() const { AABB aabb = getAABB(); Rect ret(aabb._min.x, aabb._min.y, (aabb._max.x - aabb._min.x), (aabb._max.y - aabb._min.y)); return ret; } -void Sprite3D::setCullFace(CullFaceSide side) +void MeshRenderer::setCullFace(CullFaceSide side) { for (auto& it : _meshes) { it->getMaterial()->getStateBlock().setCullFaceSide(side); - // it->getMeshCommand().setCullFace(cullFace); } } -void Sprite3D::setCullFaceEnabled(bool enable) +void MeshRenderer::setCullFaceEnabled(bool enable) { for (auto& it : _meshes) { it->getMaterial()->getStateBlock().setCullFace(enable); - // it->getMeshCommand().setCullFaceEnabled(enable); } } -Mesh* Sprite3D::getMeshByIndex(int index) const +Mesh* MeshRenderer::getMeshByIndex(int index) const { - CCASSERT(index < _meshes.size(), "invalid index"); + CCASSERT(index < _meshes.size(), "Invalid index."); return _meshes.at(index); } /**get Mesh by Name */ -Mesh* Sprite3D::getMeshByName(std::string_view name) const +Mesh* MeshRenderer::getMeshByName(std::string_view name) const { for (const auto& it : _meshes) { @@ -928,7 +926,7 @@ Mesh* Sprite3D::getMeshByName(std::string_view name) const return nullptr; } -std::vector Sprite3D::getMeshArrayByName(std::string_view name) const +std::vector MeshRenderer::getMeshArrayByName(std::string_view name) const { std::vector meshes; for (const auto& it : _meshes) @@ -939,7 +937,7 @@ std::vector Sprite3D::getMeshArrayByName(std::string_view name) const return meshes; } -Mesh* Sprite3D::getMesh() const +Mesh* MeshRenderer::getMesh() const { if (_meshes.empty()) { @@ -948,7 +946,7 @@ Mesh* Sprite3D::getMesh() const return _meshes.at(0); } -void Sprite3D::setForce2DQueue(bool force2D) +void MeshRenderer::setForce2DQueue(bool force2D) { for (const auto& mesh : _meshes) { @@ -957,14 +955,14 @@ void Sprite3D::setForce2DQueue(bool force2D) } /////////////////////////////////////////////////////////////////////////////////// -Sprite3DCache* Sprite3DCache::_cacheInstance = nullptr; -Sprite3DCache* Sprite3DCache::getInstance() +MeshRendererCache* MeshRendererCache::_cacheInstance = nullptr; +MeshRendererCache* MeshRendererCache::getInstance() { if (_cacheInstance == nullptr) - _cacheInstance = new Sprite3DCache(); + _cacheInstance = new MeshRendererCache(); return _cacheInstance; } -void Sprite3DCache::destroyInstance() +void MeshRendererCache::destroyInstance() { if (_cacheInstance) { @@ -973,54 +971,51 @@ void Sprite3DCache::destroyInstance() } } -Sprite3DCache::Sprite3DData* Sprite3DCache::getSpriteData(std::string_view key) const +MeshRendererCache::MeshRendererData* MeshRendererCache::getMeshData(std::string_view key) const { - auto it = _spriteDatas.find(key); - if (it != _spriteDatas.end()) + auto it = _meshDatas.find(key); + if (it != _meshDatas.end()) return it->second; return nullptr; } -bool Sprite3DCache::addSprite3DData(std::string_view key, Sprite3DCache::Sprite3DData* spritedata) +bool MeshRendererCache::addMeshRendererData(std::string_view key, MeshRendererCache::MeshRendererData* meshdata) { - auto it = _spriteDatas.find(key); - if (it == _spriteDatas.end()) + auto it = _meshDatas.find(key); + if (it == _meshDatas.end()) { - _spriteDatas.emplace(key, spritedata); // _spriteDatas[key] = spritedata; + _meshDatas.emplace(key, meshdata); return true; } return false; } -void Sprite3DCache::removeSprite3DData(std::string_view key) +void MeshRendererCache::removeMeshRendererData(std::string_view key) { - auto it = _spriteDatas.find(key); - if (it != _spriteDatas.end()) + auto it = _meshDatas.find(key); + if (it != _meshDatas.end()) { delete it->second; - _spriteDatas.erase(it); + _meshDatas.erase(it); } } -void Sprite3DCache::removeAllSprite3DData() +void MeshRendererCache::removeAllMeshRendererData() { - for (auto& it : _spriteDatas) + for (auto& it : _meshDatas) { delete it.second; } - _spriteDatas.clear(); + _meshDatas.clear(); } -Sprite3DCache::Sprite3DCache() {} -Sprite3DCache::~Sprite3DCache() +MeshRendererCache::MeshRendererCache() {} +MeshRendererCache::~MeshRendererCache() { - removeAllSprite3DData(); + removeAllMeshRendererData(); } -// -// MARK: Helpers -// -static Sprite3DMaterial* getSprite3DMaterialForAttribs(MeshVertexData* meshVertexData, bool usesLight) +static MeshMaterial* getMeshRendererMaterialForAttribs(MeshVertexData* meshVertexData, bool usesLight) { bool textured = meshVertexData->hasVertexAttrib(shaderinfos::VertexKey::VERTEX_ATTRIB_TEX_COORD); bool hasSkin = meshVertexData->hasVertexAttrib(shaderinfos::VertexKey::VERTEX_ATTRIB_BLEND_INDEX) && @@ -1028,27 +1023,27 @@ static Sprite3DMaterial* getSprite3DMaterialForAttribs(MeshVertexData* meshVerte bool hasNormal = meshVertexData->hasVertexAttrib(shaderinfos::VertexKey::VERTEX_ATTRIB_NORMAL); bool hasTangentSpace = meshVertexData->hasVertexAttrib(shaderinfos::VertexKey::VERTEX_ATTRIB_TANGENT) && meshVertexData->hasVertexAttrib(shaderinfos::VertexKey::VERTEX_ATTRIB_BINORMAL); - Sprite3DMaterial::MaterialType type; + MeshMaterial::MaterialType type; if (textured) { if (hasTangentSpace) { - type = hasNormal && usesLight ? Sprite3DMaterial::MaterialType::BUMPED_DIFFUSE - : Sprite3DMaterial::MaterialType::UNLIT; + type = hasNormal && usesLight ? MeshMaterial::MaterialType::BUMPED_DIFFUSE + : MeshMaterial::MaterialType::UNLIT; } else { - type = hasNormal && usesLight ? Sprite3DMaterial::MaterialType::DIFFUSE - : Sprite3DMaterial::MaterialType::UNLIT; + type = hasNormal && usesLight ? MeshMaterial::MaterialType::DIFFUSE + : MeshMaterial::MaterialType::UNLIT; } } else { - type = hasNormal && usesLight ? Sprite3DMaterial::MaterialType::DIFFUSE_NOTEX - : Sprite3DMaterial::MaterialType::UNLIT_NOTEX; + type = hasNormal && usesLight ? MeshMaterial::MaterialType::DIFFUSE_NOTEX + : MeshMaterial::MaterialType::UNLIT_NOTEX; } - return Sprite3DMaterial::createBuiltInMaterial(type, hasSkin); + return MeshMaterial::createBuiltInMaterial(type, hasSkin); } NS_CC_END diff --git a/core/3d/CCSprite3D.h b/core/3d/CCMeshRenderer.h similarity index 53% rename from core/3d/CCSprite3D.h rename to core/3d/CCMeshRenderer.h index 39f8c170a7..e37e47e3fc 100644 --- a/core/3d/CCSprite3D.h +++ b/core/3d/CCMeshRenderer.h @@ -23,8 +23,8 @@ THE SOFTWARE. ****************************************************************************/ -#ifndef __CCSPRITE3D_H__ -#define __CCSPRITE3D_H__ +#ifndef __CC_MESH_RENDERER_H__ +#define __CC_MESH_RENDERER_H__ #include @@ -33,7 +33,7 @@ #include "base/CCProtocols.h" #include "2d/CCNode.h" #include "renderer/CCMeshCommand.h" -#include "3d/CCSkeleton3D.h" // need to include for lua-binding +#include "3d/CCSkeleton3D.h" // needs to be included for lua-bindings #include "3d/CCAABB.h" #include "3d/CCBundle3DData.h" #include "3d/CCMeshVertexIndexData.h" @@ -50,49 +50,52 @@ class Texture2D; class MeshSkin; class AttachNode; struct NodeData; -/** @brief Sprite3D: A sprite can be loaded from 3D model files, .obj, .c3t, .c3b, then can be drawn as sprite */ -class CC_DLL Sprite3D : public Node, public BlendProtocol +/** @brief MeshRenderer: A mesh can be loaded from model files, .obj, .c3t, .c3b + *and a mesh renderer renders a list of these loaded meshes with specified materials + */ +class CC_DLL MeshRenderer : public Node, public BlendProtocol { public: /** - * Creates an empty sprite3D without 3D model and texture. + * Creates an empty MeshRenderer without a mesh or a texture. + * Can be used to create procedural meshes on runtime. * - * @return An autoreleased sprite3D object. + * @return An autoreleased MeshRenderer object. */ - static Sprite3D* create(); + static MeshRenderer* create(); - /** creates a Sprite3D*/ - static Sprite3D* create(std::string_view modelPath); + /** creates a MeshRenderer with a specified path */ + static MeshRenderer* create(std::string_view modelPath); - // creates a Sprite3D. It only supports one texture, and overrides the internal texture with 'texturePath' - static Sprite3D* create(std::string_view modelPath, std::string_view texturePath); + /** creates a MeshRenderer. A mesh can only have one texture, the default texture can be overridden with 'texturePath' */ + static MeshRenderer* create(std::string_view modelPath, std::string_view texturePath); - /** create 3d sprite asynchronously - * If the 3d model was previously loaded, it will create a new 3d sprite and the callback will be called at once. - * Otherwise it will load the model file in a new thread, and when the 3d sprite is loaded, the callback will be - * called with the created Sprite3D and a user-defined parameter. The callback will be called from the main thread, - * so it is safe to create any cocos2d object from the callback. + /** create 3d mesh asynchronously + * If the 3d model was previously loaded, it will create a new 3d mesh and the callback will be called once. + * Otherwise it will load the model file in a new thread, and when the 3d mesh is loaded, the callback will be + * called with the created MeshRenderer and a user-defined parameter. The callback will be called from the main thread, + * so it is safe to create any object from the callback. * @param modelPath model to be loaded - * @param callback callback after loading - * @param callbackparam user defined parameter for the callback + * @param callback callback when loading is finished + * @param callbackparam user-defined parameter for the callback */ static void createAsync(std::string_view modelPath, - const std::function& callback, + const std::function& callback, void* callbackparam); static void createAsync(std::string_view modelPath, std::string_view texturePath, - const std::function& callback, + const std::function& callback, void* callbackparam); - /**set diffuse texture, set the first if multiple textures exist*/ + /** set diffuse texture, set the first mesh's texture if multiple textures exist */ void setTexture(std::string_view texFile); void setTexture(Texture2D* texture); - /**get Mesh by index*/ + /** get Mesh by index */ Mesh* getMeshByIndex(int index) const; - /**get Mesh by Name, it returns the first one if there are more than one mesh with the same name */ + /** get Mesh by Name, returns the first one if there are more than one mesh with the same name */ Mesh* getMeshByName(std::string_view name) const; /** @@ -102,7 +105,7 @@ public: */ std::vector getMeshArrayByName(std::string_view name) const; - /**get mesh*/ + /** get mesh at index 0 which is the default mesh */ Mesh* getMesh() const; /** get mesh count */ @@ -110,13 +113,13 @@ public: Skeleton3D* getSkeleton() const { return _skeleton; } - /**get AttachNode by bone name, return nullptr if not exist*/ + /** return an AttachNode by bone name. Otherwise, return nullptr if it doesn't exist */ AttachNode* getAttachNode(std::string_view boneName); - /**remove attach node*/ + /** remove an attached node */ void removeAttachNode(std::string_view boneName); - /**remove all attach nodes*/ + /** remove all attached nodes */ void removeAllAttachNode(); // overrides @@ -124,91 +127,88 @@ public: virtual const BlendFunc& getBlendFunc() const override; // overrides - /** Sets ProgramState, you should bind attributes by yourself */ + /** Sets ProgramState, attributes should be bound by the user */ bool setProgramState(backend::ProgramState* programState, bool needsRetain = true) override; /* * Get AABB - * If the sprite has animation, it can't be calculated accurately, - * because bone can drive the vertices, we just use the origin vertices + * If the mesh has animations, it can't be calculated accurately, + * because a bone can transform the vertices, and the untransformed vertices are used * to calculate the AABB. */ const AABB& getAABB() const; /* * Get AABB Recursively - * Because some times we may have an empty Sprite3D Node as parent, but - * the Sprite3D don't contain any meshes, so getAABB() - * will return a wrong value at that time. + * Because sometimes we may have an empty MeshRenderer Node as parent, If + * the MeshRenderer doesn't contain any meshes, then we use getAABB() */ AABB getAABBRecursively(); /** - * Executes an action, and returns the action that is executed. For Sprite3D special logic are needed to take care - * of Fading. + * Executes an action, and returns the action that is executed. For the MeshRenderer special logic is needed to take + * care of Fading. * * This node becomes the action's target. Refer to Action::getTarget() * @warning Actions don't retain their target. * - * @return An Action pointer + * @return a pointer to Action */ virtual Action* runAction(Action* action) override; /** - * Force to write to depth buffer, this is useful if you want to achieve effects like fading. + * Force depth buffer writing, this is useful if you want to achieve effects like fading. */ void setForceDepthWrite(bool value) { _forceDepthWrite = value; } bool isForceDepthWrite() const { return _forceDepthWrite; }; /** - * Returns 2d bounding-box - * Note: the bounding-box is just get from the AABB which as Z=0, so that is not very accurate. + * Returns a 2d bounding-box + * Note: the bounding-box is taken from the mesh's AABB with Z-axis ignored. */ virtual Rect getBoundingBox() const override; - // set which face is going to cull, CullFaceSide::BACK, CullFaceSide::FRONT and CullFaceSide::NONE. + // set face culling side, CullFaceSide::BACK, CullFaceSide::FRONT and CullFaceSide::NONE. virtual void setCullFace(CullFaceSide side); - // set cull face enable or not + // set face culling enabled. void setCullFaceEnabled(bool enable); - /** light mask getter & setter, light works only when _lightmask & light's flag is true, default value of _lightmask - * is 0xffff */ + /** light mask getter & setter, lighting only works when _lightmask & light's flag are set to true, the default + value of _lightmask is 0xffff */ void setLightMask(unsigned int mask) { _lightMask = mask; } unsigned int getLightMask() const { return _lightMask; } - /**draw*/ + /** render all meshes within this mesh renderer */ virtual void draw(Renderer* renderer, const Mat4& transform, uint32_t flags) override; - /** Adds a new material to the sprite. - The Material will be applied to all the meshes that belong to the sprite. - Internally it will call `setMaterial(material,-1)` + /** Adds a new material to this mesh renderer. + The Material will be applied to all the meshes that belong to the mesh renderer. + It will internally call `setMaterial(material,-1)` */ void setMaterial(Material* material); - /** Adds a new material to a particular mesh of the sprite. - meshIndex is the mesh that will be applied to. - if meshIndex == -1, then it will be applied to all the meshes that belong to the sprite. + /** Adds a new material to a particular mesh in this mesh renderer. + * if meshIndex == -1, then it will be applied to all the meshes that belong to this mesh renderer. + * + * @param meshIndex Index of the mesh to apply the material to. */ void setMaterial(Material* material, int meshIndex); - /** Adds a new material to a particular mesh of the sprite. - meshIndex is the mesh that will be applied to. - if meshIndex == -1, then it will be applied to all the meshes that belong to the sprite. + /** Adds a new material to a particular mesh in this mesh renderer. + * if meshIndex == -1, then it will be applied to all the meshes that belong to this mesh renderer. + * + * @param meshIndex Index of the mesh to apply the material to. */ Material* getMaterial(int meshIndex) const; - /** - * force set this Sprite3D to 2D render queue - */ + /** force render this mesh renderer in 2D queue. */ void setForce2DQueue(bool force2D); - /** - * Get meshes used in sprite 3d - */ + /** Get list of meshes used in this mesh renderer. */ const Vector& getMeshes() const { return _meshes; } - Sprite3D(); - virtual ~Sprite3D(); + MeshRenderer(); + virtual ~MeshRenderer(); virtual bool init() override; @@ -216,27 +216,28 @@ public: bool initFrom(const NodeDatas& nodedatas, const MeshDatas& meshdatas, const MaterialDatas& materialdatas); - /**load sprite3d from cache, return true if succeed, false otherwise*/ + /** load a mesh renderer from cache, returns true if succeeded, false otherwise. */ bool loadFromCache(std::string_view path); - /** load file and set it to meshedatas, nodedatas and materialdatas, obj file .mtl file should be at the same - * directory if exist */ + /** load a file and feed it's content into meshedatas, nodedatas and materialdatas, obj file and .mtl file + should be in the same directory. */ bool loadFromFile(std::string_view path, NodeDatas* nodedatas, MeshDatas* meshdatas, MaterialDatas* materialdatas); /** - * Visits this Sprite3D's children and draw them recursively. - * Note: all its children will rendered as 3D objects + * Visits this MeshRenderer's children and draws them recursively. + * Note: all children will be rendered in 3D space with depth, this behaviour can be changed using + * setForce2DQueue() */ virtual void visit(Renderer* renderer, const Mat4& parentTransform, uint32_t parentFlags) override; - /**generate default material*/ + /** generate default material. */ void genMaterial(bool useLight = false); - void createNode(NodeData* nodedata, Node* root, const MaterialDatas& materialdatas, bool singleSprite); - void createAttachSprite3DNode(NodeData* nodedata, const MaterialDatas& materialdatas); - Sprite3D* createSprite3DNode(NodeData* nodedata, ModelData* modeldata, const MaterialDatas& materialdatas); + void createNode(NodeData* nodedata, Node* root, const MaterialDatas& materialdatas, bool singleMesh); + void createAttachMeshRendererNode(NodeData* nodedata, const MaterialDatas& materialdatas); + MeshRenderer* createMeshRendererNode(NodeData* nodedata, ModelData* modeldata, const MaterialDatas& materialdatas); - /**get MeshIndexData by Id*/ + /** get MeshIndexData by Id */ MeshIndexData* getMeshIndexData(std::string_view indexId) const; void addMesh(Mesh* mesh); @@ -248,7 +249,7 @@ public: static AABB getAABBRecursivelyImp(Node* node); protected: - Skeleton3D* _skeleton; // skeleton + Skeleton3D* _skeleton; Vector _meshVertexDatas; @@ -259,21 +260,21 @@ protected: Vector _meshes; mutable AABB _aabb; // cache current aabb - mutable Mat4 _nodeToWorldTransform; // cache the matrix + mutable Mat4 _nodeToWorldTransform; // cache current matrix mutable bool _aabbDirty; unsigned int _lightMask; - bool _shaderUsingLight; // is current shader using light ? + bool _shaderUsingLight; // Is the current shader using lighting? bool _forceDepthWrite; // Always write to depth buffer bool _usingAutogeneratedGLProgram; struct AsyncLoadParam { - std::function afterLoadCallback; // callback after load + std::function afterLoadCallback; // callback after loading is finished void* callbackParam; - bool result; // sprite load result + bool result; // mesh renderer loading result std::string modelPath; std::string modelFullPath; - std::string texPath; // + std::string texPath; MeshDatas* meshdatas; MaterialDatas* materialdatas; NodeDatas* nodeDatas; @@ -283,19 +284,18 @@ protected: /////////////////////////////////////////////////////// /** - * Sprite3DCache - * @brief the cache data of Sprite3D, use to speed up Sprite3D::create + * @brief MeshRendererCache: the cache data of MeshRenderer, used to speed up the creation process of MeshRenderer */ -class CC_DLL Sprite3DCache +class CC_DLL MeshRendererCache { public: - struct Sprite3DData + struct MeshRendererData { Vector meshVertexDatas; Vector programStates; NodeDatas* nodedatas; MaterialDatas* materialdatas; - ~Sprite3DData() + ~MeshRendererData() { if (nodedatas) delete nodedatas; @@ -306,40 +306,39 @@ public: } }; - /**get & destroy*/ - static Sprite3DCache* getInstance(); + static MeshRendererCache* getInstance(); static void destroyInstance(); /** - * get the SpriteData struct + * get a MeshData object by key * * @lua NA */ - Sprite3DData* getSpriteData(std::string_view key) const; + MeshRendererData* getMeshData(std::string_view key) const; /** - * add the SpriteData into Sprite3D by given the specified key + * add a MeshData object into the MeshRenderer with a specified key * * @lua NA */ - bool addSprite3DData(std::string_view key, Sprite3DData* spritedata); + bool addMeshRendererData(std::string_view key, MeshRendererData* meshdata); - /**remove the SpriteData from Sprite3D by given the specified key*/ - void removeSprite3DData(std::string_view key); + /** remove a MeshData from the MeshRenderer with a specified key */ + void removeMeshRendererData(std::string_view key); - /**remove all the SpriteData from Sprite3D*/ - void removeAllSprite3DData(); + /** remove all the MeshData objects from the MeshRenderer */ + void removeAllMeshRendererData(); - Sprite3DCache(); - ~Sprite3DCache(); + MeshRendererCache(); + ~MeshRendererCache(); protected: - static Sprite3DCache* _cacheInstance; - hlookup::string_map _spriteDatas; // cached sprite data + static MeshRendererCache* _cacheInstance; + hlookup::string_map _meshDatas; // cached mesh data }; // end of 3d group /// @} NS_CC_END -#endif // __SPRITE3D_H_ +#endif // __CC_MESH_RENDERER_H__ diff --git a/core/3d/CCMeshVertexIndexData.cpp b/core/3d/CCMeshVertexIndexData.cpp index 497357a57c..688b055aa5 100644 --- a/core/3d/CCMeshVertexIndexData.cpp +++ b/core/3d/CCMeshVertexIndexData.cpp @@ -30,7 +30,7 @@ #include "3d/CCMeshVertexIndexData.h" #include "3d/CCObjLoader.h" -#include "3d/CCSprite3DMaterial.h" +#include "3d/CCMeshMaterial.h" #include "3d/CCMesh.h" #include "3d/CCBundle3D.h" diff --git a/core/3d/CCMeshVertexIndexData.h b/core/3d/CCMeshVertexIndexData.h index 889eded961..bcf51e620a 100644 --- a/core/3d/CCMeshVertexIndexData.h +++ b/core/3d/CCMeshVertexIndexData.h @@ -95,7 +95,7 @@ protected: MeshData::IndexArray _indexData; friend class MeshVertexData; - friend class Sprite3D; + friend class MeshRenderer; #if CC_ENABLE_CACHE_TEXTURE_DATA EventListenerCustom* _backToForegroundListener = nullptr; #endif @@ -107,7 +107,7 @@ protected: */ class CC_DLL MeshVertexData : public Ref { - friend class Sprite3D; + friend class MeshRenderer; friend class Mesh; public: diff --git a/core/3d/CCOBB.h b/core/3d/CCOBB.h index e92e98824f..5ba29166bf 100644 --- a/core/3d/CCOBB.h +++ b/core/3d/CCOBB.h @@ -36,9 +36,9 @@ NS_CC_BEGIN */ /** - * Oriented Bounding Box(OBB) - * @brief the OBB is similar to the AABB but the bounding box has the same direction as Sprite3D. so it's collision - * detection more precise than AABB + * + * @brief Oriented Bounding Box(OBB): OBB is similar to AABB except the bounding box has the same direction as the + * MeshRenderer. so collision detection is more precise than AABB. * @js NA */ class CC_DLL OBB diff --git a/core/3d/CMakeLists.txt b/core/3d/CMakeLists.txt index 4bd43c0612..6ab996e539 100644 --- a/core/3d/CMakeLists.txt +++ b/core/3d/CMakeLists.txt @@ -2,7 +2,6 @@ set(COCOS_3D_HEADER 3d/CCBillBoard.h 3d/CCFrustum.h - 3d/CCSprite3DMaterial.h 3d/CCMeshVertexIndexData.h 3d/CCPlane.h 3d/CCRay.h @@ -10,7 +9,8 @@ set(COCOS_3D_HEADER 3d/CCAnimate3D.h 3d/CCTerrain.h 3d/CCAnimationCurve.h - 3d/CCSprite3D.h + 3d/CCMeshRenderer.h + 3d/CCMeshMaterial.h 3d/CCOBB.h 3d/CCAnimation3D.h 3d/CCMotionStreak3D.h @@ -49,8 +49,8 @@ set(COCOS_3D_SRC 3d/CCRay.cpp 3d/CCSkeleton3D.cpp 3d/CCSkybox.cpp - 3d/CCSprite3D.cpp - 3d/CCSprite3DMaterial.cpp + 3d/CCMeshRenderer.cpp + 3d/CCMeshMaterial.cpp 3d/CCTerrain.cpp 3d/CCVertexAttribBinding.cpp 3d/CC3DProgramInfo.cpp diff --git a/core/adxe.h b/core/adxe.h index 07abe026f3..f9039b2c5f 100644 --- a/core/adxe.h +++ b/core/adxe.h @@ -265,8 +265,8 @@ THE SOFTWARE. #include "3d/CCRay.h" #include "3d/CCSkeleton3D.h" #include "3d/CCSkybox.h" -#include "3d/CCSprite3D.h" -#include "3d/CCSprite3DMaterial.h" +#include "3d/CCMeshRenderer.h" +#include "3d/CCMeshMaterial.h" #include "3d/CCTerrain.h" #include "3d/CCVertexAttribBinding.h" diff --git a/core/base/CCConfiguration.h b/core/base/CCConfiguration.h index ca4f6ece93..765caf9d29 100644 --- a/core/base/CCConfiguration.h +++ b/core/base/CCConfiguration.h @@ -176,34 +176,34 @@ public: */ bool supportsMapBuffer() const; - /** Max support directional light in shader, for Sprite3D. + /** Max supported directional lights in a shader, for MeshRenderer. * - * @return Maximum supports directional light in shader. + * @return Maximum supported directional lights in a shader. * @since v3.3 */ int getMaxSupportDirLightInShader() const; - /** Max support point light in shader, for Sprite3D. + /** Max supported point lights in a shader, for MeshRenderer. * - * @return Maximum supports point light in shader. + * @return Maximum supported point lights in a shader. * @since v3.3 */ int getMaxSupportPointLightInShader() const; - /** Max support spot light in shader, for Sprite3D. + /** Max supported spot lights in a shader, for MeshRenderer. * - * @return Maximum supports spot light in shader. + * @return Maximum supported spot lights in a shader. * @since v3.3 */ int getMaxSupportSpotLightInShader() const; - /** get 3d animate quality*/ + /** get 3d animate quality */ Animate3DQuality getAnimate3DQuality() const; - /** Returns whether or not an OpenGL is supported. + /** Returns whether or not an OpenGL extension is supported. * * @param searchName A given search name. - * @return Is true if an OpenGL is supported. + * @return Is true if an OpenGL extension is supported. */ bool checkForGLExtension(std::string_view searchName) const; diff --git a/core/physics3d/CCPhysics3D.h b/core/physics3d/CCPhysics3D.h index e73926c63b..c89b25c81e 100644 --- a/core/physics3d/CCPhysics3D.h +++ b/core/physics3d/CCPhysics3D.h @@ -32,7 +32,7 @@ #if CC_USE_3D_PHYSICS # include "physics3d/CCPhysics3DShape.h" -# include "physics3d/CCPhysicsSprite3D.h" +# include "physics3d/CCPhysicsMeshRenderer.h" # include "physics3d/CCPhysics3DWorld.h" # include "physics3d/CCPhysics3DDebugDrawer.h" # include "physics3d/CCPhysics3DObject.h" diff --git a/core/physics3d/CCPhysicsSprite3D.cpp b/core/physics3d/CCPhysicsMeshRenderer.cpp similarity index 84% rename from core/physics3d/CCPhysicsSprite3D.cpp rename to core/physics3d/CCPhysicsMeshRenderer.cpp index ebe25de73d..1d851797d7 100644 --- a/core/physics3d/CCPhysicsSprite3D.cpp +++ b/core/physics3d/CCPhysicsMeshRenderer.cpp @@ -31,12 +31,12 @@ NS_CC_BEGIN -PhysicsSprite3D* PhysicsSprite3D::create(std::string_view modelPath, +PhysicsMeshRenderer* PhysicsMeshRenderer::create(std::string_view modelPath, Physics3DRigidBodyDes* rigidDes, const cocos2d::Vec3& translateInPhysics, const cocos2d::Quaternion& rotInPhsyics) { - auto ret = new PhysicsSprite3D(); + auto ret = new PhysicsMeshRenderer(); if (ret->initWithFile(modelPath)) { auto obj = Physics3DRigidBody::create(rigidDes); @@ -50,12 +50,12 @@ PhysicsSprite3D* PhysicsSprite3D::create(std::string_view modelPath, return ret; } -PhysicsSprite3D* PhysicsSprite3D::createWithCollider(std::string_view modelPath, +PhysicsMeshRenderer* PhysicsMeshRenderer::createWithCollider(std::string_view modelPath, Physics3DColliderDes* colliderDes, const cocos2d::Vec3& translateInPhysics, const cocos2d::Quaternion& rotInPhsyics) { - auto ret = new PhysicsSprite3D(); + auto ret = new PhysicsMeshRenderer(); if (ret->initWithFile(modelPath)) { auto obj = Physics3DCollider::create(colliderDes); @@ -69,31 +69,31 @@ PhysicsSprite3D* PhysicsSprite3D::createWithCollider(std::string_view modelPath, return ret; } -Physics3DObject* PhysicsSprite3D::getPhysicsObj() const +Physics3DObject* PhysicsMeshRenderer::getPhysicsObj() const { return _physicsComponent->getPhysics3DObject(); } -void PhysicsSprite3D::setSyncFlag(Physics3DComponent::PhysicsSyncFlag syncFlag) +void PhysicsMeshRenderer::setSyncFlag(Physics3DComponent::PhysicsSyncFlag syncFlag) { if (_physicsComponent) _physicsComponent->setSyncFlag(syncFlag); } -void PhysicsSprite3D::syncNodeToPhysics() +void PhysicsMeshRenderer::syncNodeToPhysics() { if (_physicsComponent) _physicsComponent->syncNodeToPhysics(); } -void PhysicsSprite3D::syncPhysicsToNode() +void PhysicsMeshRenderer::syncPhysicsToNode() { if (_physicsComponent) _physicsComponent->syncPhysicsToNode(); } -PhysicsSprite3D::PhysicsSprite3D() : _physicsComponent(nullptr) {} -PhysicsSprite3D::~PhysicsSprite3D() {} +PhysicsMeshRenderer::PhysicsMeshRenderer() : _physicsComponent(nullptr) {} +PhysicsMeshRenderer::~PhysicsMeshRenderer() {} NS_CC_END diff --git a/core/physics3d/CCPhysicsSprite3D.h b/core/physics3d/CCPhysicsMeshRenderer.h similarity index 82% rename from core/physics3d/CCPhysicsSprite3D.h rename to core/physics3d/CCPhysicsMeshRenderer.h index 07ed353dbc..06f9f09665 100644 --- a/core/physics3d/CCPhysicsSprite3D.h +++ b/core/physics3d/CCPhysicsMeshRenderer.h @@ -23,11 +23,11 @@ THE SOFTWARE. ****************************************************************************/ -#ifndef __PHYSICS_SPRITE_3D_H__ -#define __PHYSICS_SPRITE_3D_H__ +#ifndef __PHYSICS_MESH_RENDERER_H__ +#define __PHYSICS_MESH_RENDERER_H__ #include "base/ccConfig.h" -#include "3d/CCSprite3D.h" +#include "3d/CCMeshRenderer.h" #include "physics3d/CCPhysics3DObject.h" #include "physics3d/CCPhysics3DComponent.h" @@ -42,19 +42,19 @@ NS_CC_BEGIN */ /** - * @brief Convenient class to create a rigid body with Sprite3D + * @brief Convenient class to create a rigid body with a MeshRenderer */ -class CC_DLL PhysicsSprite3D : public cocos2d::Sprite3D +class CC_DLL PhysicsMeshRenderer : public cocos2d::MeshRenderer { public: - /** creates a PhysicsSprite3D*/ - static PhysicsSprite3D* create(std::string_view modelPath, + /** creates a PhysicsMeshRenderer */ + static PhysicsMeshRenderer* create(std::string_view modelPath, Physics3DRigidBodyDes* rigidDes, const cocos2d::Vec3& translateInPhysics = cocos2d::Vec3::ZERO, const cocos2d::Quaternion& rotInPhsyics = cocos2d::Quaternion::ZERO); - /** creates a PhysicsSprite3D as a collider*/ - static PhysicsSprite3D* createWithCollider(std::string_view modelPath, + /** creates a PhysicsMeshRenderer with a collider */ + static PhysicsMeshRenderer* createWithCollider(std::string_view modelPath, Physics3DColliderDes* colliderDes, const cocos2d::Vec3& translateInPhysics = cocos2d::Vec3::ZERO, const cocos2d::Quaternion& rotInPhsyics = cocos2d::Quaternion::ZERO); @@ -71,8 +71,8 @@ public: /** synchronize physics transformation to node. */ void syncPhysicsToNode(); - PhysicsSprite3D(); - virtual ~PhysicsSprite3D(); + PhysicsMeshRenderer(); + virtual ~PhysicsMeshRenderer(); protected: Physics3DComponent* _physicsComponent; @@ -86,4 +86,4 @@ NS_CC_END #endif // CC_USE_3D_PHYSICS -#endif // __PHYSICS_SPRITE_3D_H__ +#endif // __PHYSICS_MESH_RENDERER_H__ diff --git a/core/physics3d/CMakeLists.txt b/core/physics3d/CMakeLists.txt index 1e3b40651a..1da92f71ed 100644 --- a/core/physics3d/CMakeLists.txt +++ b/core/physics3d/CMakeLists.txt @@ -3,7 +3,7 @@ set(COCOS_PHYSICS3D_HEADER physics3d/CCPhysics3DShape.h physics3d/CCPhysics3D.h physics3d/CCPhysics3DWorld.h - physics3d/CCPhysicsSprite3D.h + physics3d/CCPhysicsMeshRenderer.h physics3d/CCPhysics3DObject.h physics3d/CCPhysics3DComponent.h physics3d/CCPhysics3DDebugDrawer.h @@ -17,5 +17,5 @@ set(COCOS_PHYSICS3D_SRC physics3d/CCPhysics3DObject.cpp physics3d/CCPhysics3DShape.cpp physics3d/CCPhysics3DWorld.cpp - physics3d/CCPhysicsSprite3D.cpp + physics3d/CCPhysicsMeshRenderer.cpp ) diff --git a/extensions/Particle3D/CCParticle3DRender.cpp b/extensions/Particle3D/CCParticle3DRender.cpp index 9b7ba76d8f..961c0ef83a 100644 --- a/extensions/Particle3D/CCParticle3DRender.cpp +++ b/extensions/Particle3D/CCParticle3DRender.cpp @@ -34,7 +34,7 @@ #include "renderer/backend/Device.h" #include "renderer/ccShaders.h" #include "base/CCDirector.h" -#include "3d/CCSprite3D.h" +#include "3d/CCMeshRenderer.h" #include "2d/CCCamera.h" NS_CC_BEGIN @@ -280,10 +280,10 @@ void Particle3DQuadRender::reset() } ////////////////////////////////////////////////////////////////////////////// -Particle3DModelRender::Particle3DModelRender() : _spriteSize(Vec3::ONE) {} +Particle3DModelRender::Particle3DModelRender() : _meshSize(Vec3::ONE) {} Particle3DModelRender::~Particle3DModelRender() { - for (auto iter : _spriteList) + for (auto iter : _meshList) { iter->release(); } @@ -302,26 +302,26 @@ void Particle3DModelRender::render(Renderer* renderer, const Mat4& transform, Pa if (!_isVisible) return; - if (_spriteList.empty()) + if (_meshList.empty()) { for (unsigned int i = 0; i < particleSystem->getParticleQuota(); ++i) { - Sprite3D* sprite = Sprite3D::create(_modelFile); - if (sprite == nullptr) + MeshRenderer* mesh = MeshRenderer::create(_modelFile); + if (mesh == nullptr) { CCLOG("failed to load file %s", _modelFile.c_str()); continue; } - sprite->setTexture(_texFile); - sprite->retain(); - _spriteList.push_back(sprite); + mesh->setTexture(_texFile); + mesh->retain(); + _meshList.push_back(mesh); } - if (!_spriteList.empty()) + if (!_meshList.empty()) { - const AABB& aabb = _spriteList[0]->getAABB(); + const AABB& aabb = _meshList[0]->getAABB(); Vec3 corners[8]; aabb.getCorners(corners); - _spriteSize = corners[3] - corners[6]; + _meshSize = corners[3] - corners[6]; } } @@ -337,24 +337,24 @@ void Particle3DModelRender::render(Renderer* renderer, const Mat4& transform, Pa { auto particle = iter; Mat4::createRotation(q * particle->orientation, &rotMat); - sclMat.m[0] = particle->width / _spriteSize.x; - sclMat.m[5] = particle->height / _spriteSize.y; - sclMat.m[10] = particle->depth / _spriteSize.z; + sclMat.m[0] = particle->width / _meshSize.x; + sclMat.m[5] = particle->height / _meshSize.y; + sclMat.m[10] = particle->depth / _meshSize.z; mat = rotMat * sclMat; mat.m[12] = particle->position.x; mat.m[13] = particle->position.y; mat.m[14] = particle->position.z; - _spriteList[index++]->draw(renderer, mat, 0); + _meshList[index++]->draw(renderer, mat, 0); } } void Particle3DModelRender::reset() { - for (auto iter : _spriteList) + for (auto iter : _meshList) { iter->release(); } - _spriteList.clear(); + _meshList.clear(); } // MARK: Particle3DRender diff --git a/extensions/Particle3D/CCParticle3DRender.h b/extensions/Particle3D/CCParticle3DRender.h index 4bf247d234..d5a00c9929 100644 --- a/extensions/Particle3D/CCParticle3DRender.h +++ b/extensions/Particle3D/CCParticle3DRender.h @@ -41,7 +41,7 @@ NS_CC_BEGIN class ParticleSystem3D; class Renderer; class MeshCommand; -class Sprite3D; +class MeshRenderer; class GLProgramState; class IndexBuffer; class VertexBuffer; @@ -141,7 +141,7 @@ protected: bool _rendererDepthWrite = false; }; -// particle render for Sprite3D +// particle renderer using MeshRenderer class CC_EX_DLL Particle3DModelRender : public Particle3DRender { public: @@ -154,10 +154,10 @@ public: virtual ~Particle3DModelRender(); protected: - std::vector _spriteList; + std::vector _meshList; std::string _modelFile; std::string _texFile; - Vec3 _spriteSize; + Vec3 _meshSize; }; NS_CC_END diff --git a/extensions/Particle3D/PU/CCPUBeamRender.cpp b/extensions/Particle3D/PU/CCPUBeamRender.cpp index 17b17314a1..281735f8ff 100644 --- a/extensions/Particle3D/PU/CCPUBeamRender.cpp +++ b/extensions/Particle3D/PU/CCPUBeamRender.cpp @@ -34,7 +34,7 @@ #include "renderer/CCTextureCache.h" #include "renderer/backend/ProgramState.h" #include "base/CCDirector.h" -#include "3d/CCSprite3D.h" +#include "3d/CCMeshRenderer.h" #include "3d/CCMesh.h" #include "2d/CCCamera.h" #include diff --git a/extensions/Particle3D/PU/CCPUBillboardChain.cpp b/extensions/Particle3D/PU/CCPUBillboardChain.cpp index ac25fcb07f..644bc30a70 100644 --- a/extensions/Particle3D/PU/CCPUBillboardChain.cpp +++ b/extensions/Particle3D/PU/CCPUBillboardChain.cpp @@ -36,7 +36,7 @@ #include "renderer/backend/Buffer.h" #include "renderer/backend/Device.h" #include "2d/CCCamera.h" -#include "3d/CCSprite3D.h" +#include "3d/CCMeshRenderer.h" NS_CC_BEGIN diff --git a/extensions/Particle3D/PU/CCPURender.cpp b/extensions/Particle3D/PU/CCPURender.cpp index ad1891503d..92e48f37e9 100644 --- a/extensions/Particle3D/PU/CCPURender.cpp +++ b/extensions/Particle3D/PU/CCPURender.cpp @@ -36,7 +36,7 @@ #include "renderer/backend/Device.h" #include "renderer/backend/Buffer.h" #include "base/CCDirector.h" -#include "3d/CCSprite3D.h" +#include "3d/CCMeshRenderer.h" #include "3d/CCMesh.h" #include "2d/CCCamera.h" @@ -501,28 +501,28 @@ void PUParticle3DModelRender::render(Renderer* renderer, const Mat4& transform, if (!_isVisible) return; - if (_spriteList.empty()) + if (_meshList.empty()) { for (unsigned int i = 0; i < particleSystem->getParticleQuota(); ++i) { - Sprite3D* sprite = Sprite3D::create(_modelFile); - if (sprite == nullptr) + MeshRenderer* mesh = MeshRenderer::create(_modelFile); + if (mesh == nullptr) { CCLOG("failed to load file %s", _modelFile.c_str()); continue; } - sprite->setTexture(_texFile); - sprite->setBlendFunc(particleSystem->getBlendFunc()); - sprite->setCullFaceEnabled(false); - sprite->retain(); - _spriteList.push_back(sprite); + mesh->setTexture(_texFile); + mesh->setBlendFunc(particleSystem->getBlendFunc()); + mesh->setCullFaceEnabled(false); + mesh->retain(); + _meshList.push_back(mesh); } - if (!_spriteList.empty()) + if (!_meshList.empty()) { - const AABB& aabb = _spriteList[0]->getAABB(); + const AABB& aabb = _meshList[0]->getAABB(); Vec3 corners[8]; aabb.getCorners(corners); - _spriteSize = corners[3] - corners[6]; + _meshSize = corners[3] - corners[6]; } else { @@ -543,19 +543,19 @@ void PUParticle3DModelRender::render(Renderer* renderer, const Mat4& transform, { auto particle = static_cast(iter); Mat4::createRotation(q * particle->orientation, &rotMat); - sclMat.m[0] = particle->width / _spriteSize.x; - sclMat.m[5] = particle->height / _spriteSize.y; - sclMat.m[10] = particle->depth / _spriteSize.z; + sclMat.m[0] = particle->width / _meshSize.x; + sclMat.m[5] = particle->height / _meshSize.y; + sclMat.m[10] = particle->depth / _meshSize.z; mat = rotMat * sclMat; mat.m[12] = particle->position.x; mat.m[13] = particle->position.y; mat.m[14] = particle->position.z; - if (_spriteList[index]->getCameraMask() != particleSystem->getCameraMask()) - _spriteList[index]->setCameraMask(particleSystem->getCameraMask()); - _spriteList[index]->setColor( + if (_meshList[index]->getCameraMask() != particleSystem->getCameraMask()) + _meshList[index]->setCameraMask(particleSystem->getCameraMask()); + _meshList[index]->setColor( Color3B(particle->color.x * 255, particle->color.y * 255, particle->color.z * 255)); - _spriteList[index]->setOpacity(particle->color.w * 255); - _spriteList[index]->visit(renderer, mat, Node::FLAGS_DIRTY_MASK); + _meshList[index]->setOpacity(particle->color.w * 255); + _meshList[index]->visit(renderer, mat, Node::FLAGS_DIRTY_MASK); ++index; } } @@ -567,7 +567,7 @@ PUParticle3DModelRender::PUParticle3DModelRender() PUParticle3DModelRender::~PUParticle3DModelRender() { - for (auto iter : _spriteList) + for (auto iter : _meshList) { iter->release(); } @@ -587,11 +587,11 @@ PUParticle3DModelRender* PUParticle3DModelRender::clone() void PUParticle3DModelRender::reset() { - for (auto iter : _spriteList) + for (auto iter : _meshList) { iter->release(); } - _spriteList.clear(); + _meshList.clear(); } PUParticle3DEntityRender::PUParticle3DEntityRender() diff --git a/extensions/Particle3D/PU/CCPURender.h b/extensions/Particle3D/PU/CCPURender.h index 2902d6fc33..30e4eabb69 100644 --- a/extensions/Particle3D/PU/CCPURender.h +++ b/extensions/Particle3D/PU/CCPURender.h @@ -55,7 +55,7 @@ public: public: bool autoRotate; // Means that the objects to render automatically rotate if the node to which the particle system - // is attached, rotates. + // is attached to rotates. protected: std::string _renderType; @@ -203,10 +203,10 @@ public: virtual ~PUParticle3DModelRender(); protected: - std::vector _spriteList; + std::vector _meshList; std::string _modelFile; std::string _texFile; - Vec3 _spriteSize; + Vec3 _meshSize; }; class CC_EX_DLL PUParticle3DBoxRender : public PUParticle3DEntityRender diff --git a/extensions/Particle3D/PU/CCPURibbonTrail.cpp b/extensions/Particle3D/PU/CCPURibbonTrail.cpp index e9c05b10c7..f41dee99c8 100644 --- a/extensions/Particle3D/PU/CCPURibbonTrail.cpp +++ b/extensions/Particle3D/PU/CCPURibbonTrail.cpp @@ -32,7 +32,7 @@ #include "renderer/CCTextureCache.h" #include "renderer/backend/ProgramState.h" #include "2d/CCCamera.h" -#include "3d/CCSprite3D.h" +#include "3d/CCMeshRenderer.h" NS_CC_BEGIN diff --git a/extensions/Particle3D/PU/CCPURibbonTrailRender.cpp b/extensions/Particle3D/PU/CCPURibbonTrailRender.cpp index 61c214ba46..b343c97dc0 100644 --- a/extensions/Particle3D/PU/CCPURibbonTrailRender.cpp +++ b/extensions/Particle3D/PU/CCPURibbonTrailRender.cpp @@ -32,7 +32,7 @@ #include "renderer/CCRenderer.h" #include "renderer/CCTextureCache.h" #include "base/CCDirector.h" -#include "3d/CCSprite3D.h" +#include "3d/CCMeshRenderer.h" #include "3d/CCMesh.h" #include "2d/CCCamera.h" #include diff --git a/extensions/cocostudio/ActionTimeline/CSLoader.cpp b/extensions/cocostudio/ActionTimeline/CSLoader.cpp index ec41dedd40..d54545991a 100644 --- a/extensions/cocostudio/ActionTimeline/CSLoader.cpp +++ b/extensions/cocostudio/ActionTimeline/CSLoader.cpp @@ -69,7 +69,7 @@ #include "WidgetReader/ListViewReader/ListViewReader.h" #include "WidgetReader/ArmatureNodeReader/ArmatureNodeReader.h" #include "WidgetReader/Node3DReader/Node3DReader.h" -#include "WidgetReader/Sprite3DReader/Sprite3DReader.h" +#include "WidgetReader/MeshReader/MeshReader.h" #include "WidgetReader/UserCameraReader/UserCameraReader.h" #include "WidgetReader/Particle3DReader/Particle3DReader.h" #include "WidgetReader/GameNode3DReader/GameNode3DReader.h" @@ -226,7 +226,7 @@ CSLoader::CSLoader() CREATE_CLASS_NODE_READER_INFO(ArmatureNodeReader); CREATE_CLASS_NODE_READER_INFO(Node3DReader); - CREATE_CLASS_NODE_READER_INFO(Sprite3DReader); + CREATE_CLASS_NODE_READER_INFO(MeshReader); CREATE_CLASS_NODE_READER_INFO(UserCameraReader); CREATE_CLASS_NODE_READER_INFO(Particle3DReader); CREATE_CLASS_NODE_READER_INFO(GameNode3DReader); diff --git a/extensions/cocostudio/CocoStudio.cpp b/extensions/cocostudio/CocoStudio.cpp index 9b196ff8d4..f893f5cee6 100644 --- a/extensions/cocostudio/CocoStudio.cpp +++ b/extensions/cocostudio/CocoStudio.cpp @@ -24,7 +24,7 @@ #include "WidgetReader/ListViewReader/ListViewReader.h" #include "WidgetReader/ArmatureNodeReader/ArmatureNodeReader.h" #include "WidgetReader/Node3DReader/Node3DReader.h" -#include "WidgetReader/Sprite3DReader/Sprite3DReader.h" +#include "WidgetReader/MeshReader/MeshReader.h" #include "WidgetReader/UserCameraReader/UserCameraReader.h" #include "WidgetReader/Particle3DReader/Particle3DReader.h" @@ -57,7 +57,7 @@ void destroyCocosStudio() ArmatureNodeReader::destroyInstance(); Node3DReader::destroyInstance(); - Sprite3DReader::destroyInstance(); + MeshReader::destroyInstance(); UserCameraReader::destroyInstance(); Particle3DReader::destroyInstance(); diff --git a/extensions/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.cpp b/extensions/cocostudio/WidgetReader/MeshReader/MeshReader.cpp similarity index 83% rename from extensions/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.cpp rename to extensions/cocostudio/WidgetReader/MeshReader/MeshReader.cpp index efc103f335..ea1b43c90d 100644 --- a/extensions/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.cpp +++ b/extensions/cocostudio/WidgetReader/MeshReader/MeshReader.cpp @@ -24,11 +24,11 @@ ****************************************************************************/ #include "2d/CCLight.h" -#include "3d/CCSprite3D.h" +#include "3d/CCMeshRenderer.h" #include "3d/CCAnimate3D.h" #include "3d/CCAnimation3D.h" #include "platform/CCFileUtils.h" -#include "WidgetReader/Sprite3DReader/Sprite3DReader.h" +#include "WidgetReader/MeshReader/MeshReader.h" #include "CSParseBinary_generated.h" #include "CSParse3DBinary_generated.h" @@ -43,35 +43,35 @@ using namespace flatbuffers; namespace cocostudio { -IMPLEMENT_CLASS_NODE_READER_INFO(Sprite3DReader) +IMPLEMENT_CLASS_NODE_READER_INFO(MeshReader) -Sprite3DReader::Sprite3DReader() {} +MeshReader::MeshReader() {} -Sprite3DReader::~Sprite3DReader() {} +MeshReader::~MeshReader() {} -static Sprite3DReader* _instanceSprite3DReader = nullptr; +static MeshReader* _instanceMeshReader = nullptr; -Sprite3DReader* Sprite3DReader::getInstance() +MeshReader* MeshReader::getInstance() { - if (!_instanceSprite3DReader) + if (!_instanceMeshReader) { - _instanceSprite3DReader = new Sprite3DReader(); + _instanceMeshReader = new MeshReader(); } - return _instanceSprite3DReader; + return _instanceMeshReader; } -void Sprite3DReader::purge() +void MeshReader::purge() { - CC_SAFE_DELETE(_instanceSprite3DReader); + CC_SAFE_DELETE(_instanceMeshReader); } -void Sprite3DReader::destroyInstance() +void MeshReader::destroyInstance() { - CC_SAFE_DELETE(_instanceSprite3DReader); + CC_SAFE_DELETE(_instanceMeshReader); } -Vec2 Sprite3DReader::getVec2Attribute(pugi::xml_attribute attribute) const +Vec2 MeshReader::getVec2Attribute(pugi::xml_attribute attribute) const { if (!attribute) return Vec2::ZERO; @@ -99,7 +99,7 @@ Vec2 Sprite3DReader::getVec2Attribute(pugi::xml_attribute attribute) const return ret; } -Offset Sprite3DReader::createOptionsWithFlatBuffers(pugi::xml_node objectData, +Offset
MeshReader::createOptionsWithFlatBuffers(pugi::xml_node objectData, flatbuffers::FlatBufferBuilder* builder) { auto temp = Node3DReader::getInstance()->createOptionsWithFlatBuffers(objectData, builder); @@ -205,9 +205,9 @@ Offset
Sprite3DReader::createOptionsWithFlatBuffers(pugi::xml_node object return *(Offset
*)(&options); } -void Sprite3DReader::setPropsWithFlatBuffers(cocos2d::Node* node, const flatbuffers::Table* sprite3DOptions) +void MeshReader::setPropsWithFlatBuffers(cocos2d::Node* node, const flatbuffers::Table* sprite3DOptions) { - Sprite3D* sprite3D = static_cast(node); + MeshRenderer* mesh = static_cast(node); auto options = (Sprite3DOptions*)sprite3DOptions; @@ -224,7 +224,7 @@ void Sprite3DReader::setPropsWithFlatBuffers(cocos2d::Node* node, const flatbuff { Animate3D* animate = Animate3D::create(animation); Action* action = RepeatForever::create(animate); - sprite3D->runAction(action); + mesh->runAction(action); } } @@ -237,36 +237,36 @@ void Sprite3DReader::setPropsWithFlatBuffers(cocos2d::Node* node, const flatbuff if (alpha != 255) { - sprite3D->setOpacity(alpha); + mesh->setOpacity(alpha); } if (red != 255 || green != 255 || blue != 255) { - sprite3D->setColor(Color3B(red, green, blue)); + mesh->setColor(Color3B(red, green, blue)); } if (isFlipped) { - sprite3D->setCullFaceEnabled(true); - sprite3D->setCullFace(CullFaceSide::FRONT); + mesh->setCullFaceEnabled(true); + mesh->setCullFace(CullFaceSide::FRONT); } if (lightFlag <= 0) { lightFlag = 1; } - sprite3D->setLightMask(lightFlag); + mesh->setLightMask(lightFlag); auto node3DReader = Node3DReader::getInstance(); - node3DReader->setPropsWithFlatBuffers(sprite3D, (Table*)(options->node3DOption())); + node3DReader->setPropsWithFlatBuffers(mesh, (Table*)(options->node3DOption())); } -Node* Sprite3DReader::createNodeWithFlatBuffers(const flatbuffers::Table* sprite3DOptions) +Node* MeshReader::createNodeWithFlatBuffers(const flatbuffers::Table* sprite3DOptions) { auto options = (Sprite3DOptions*)sprite3DOptions; auto fileData = options->fileData(); std::string path = fileData->path()->c_str(); - Sprite3D* ret = Sprite3D::create(); + MeshRenderer* ret = MeshRenderer::create(); if (FileUtils::getInstance()->isFileExist(path)) { ret->initWithFile(path); diff --git a/extensions/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.h b/extensions/cocostudio/WidgetReader/MeshReader/MeshReader.h similarity index 93% rename from extensions/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.h rename to extensions/cocostudio/WidgetReader/MeshReader/MeshReader.h index 0cd0bf60c6..68a1ef0a0c 100644 --- a/extensions/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.h +++ b/extensions/cocostudio/WidgetReader/MeshReader/MeshReader.h @@ -32,15 +32,15 @@ namespace cocostudio { -class CCS_DLL Sprite3DReader : public cocos2d::Ref, public NodeReaderProtocol +class CCS_DLL MeshReader : public cocos2d::Ref, public NodeReaderProtocol { DECLARE_CLASS_NODE_READER_INFO public: - Sprite3DReader(); - ~Sprite3DReader(); + MeshReader(); + ~MeshReader(); - static Sprite3DReader* getInstance(); + static MeshReader* getInstance(); /** @deprecated Use method destroyInstance() instead */ CC_DEPRECATED_ATTRIBUTE static void purge(); static void destroyInstance(); diff --git a/extensions/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp b/extensions/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp index 6a9652abdc..49ff596c46 100644 --- a/extensions/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp +++ b/extensions/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp @@ -3600,10 +3600,10 @@ int lua_register_cocos2dx_3d_Skybox(lua_State* tolua_S) return 1; } -int lua_cocos2dx_3d_Sprite3D_setCullFaceEnabled(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_setCullFaceEnabled(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -3612,15 +3612,15 @@ int lua_cocos2dx_3d_Sprite3D_setCullFaceEnabled(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_setCullFaceEnabled'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_setCullFaceEnabled'", nullptr); return 0; } #endif @@ -3630,43 +3630,43 @@ int lua_cocos2dx_3d_Sprite3D_setCullFaceEnabled(lua_State* tolua_S) { bool arg0; - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.Sprite3D:setCullFaceEnabled"); + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.MeshRenderer:setCullFaceEnabled"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_setCullFaceEnabled'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_setCullFaceEnabled'", nullptr); return 0; } cobj->setCullFaceEnabled(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:setCullFaceEnabled",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:setCullFaceEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_setCullFaceEnabled'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_setCullFaceEnabled'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_setTexture(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_setTexture(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_setTexture'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_setTexture'", nullptr); return 0; } #endif @@ -3674,7 +3674,7 @@ int lua_cocos2dx_3d_Sprite3D_setTexture(lua_State* tolua_S) do{ if (argc == 1) { cocos2d::Texture2D* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.Texture2D",&arg0, "cc.Sprite3D:setTexture"); + ok &= luaval_to_object(tolua_S, 2, "cc.Texture2D",&arg0, "cc.MeshRenderer:setTexture"); if (!ok) { break; } cobj->setTexture(arg0); @@ -3686,7 +3686,7 @@ int lua_cocos2dx_3d_Sprite3D_setTexture(lua_State* tolua_S) do{ if (argc == 1) { std::string_view arg0; - ok &= luaval_to_std_string_view(tolua_S, 2,&arg0, "cc.Sprite3D:setTexture"); + ok &= luaval_to_std_string_view(tolua_S, 2,&arg0, "cc.MeshRenderer:setTexture"); if (!ok) { break; } cobj->setTexture(arg0); @@ -3695,20 +3695,20 @@ int lua_cocos2dx_3d_Sprite3D_setTexture(lua_State* tolua_S) } }while(0); ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:setTexture",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:setTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_setTexture'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_setTexture'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_getLightMask(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_getLightMask(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -3717,15 +3717,15 @@ int lua_cocos2dx_3d_Sprite3D_getLightMask(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_getLightMask'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_getLightMask'", nullptr); return 0; } #endif @@ -3735,27 +3735,27 @@ int lua_cocos2dx_3d_Sprite3D_getLightMask(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_getLightMask'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_getLightMask'", nullptr); return 0; } unsigned int ret = cobj->getLightMask(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:getLightMask",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:getLightMask",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_getLightMask'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_getLightMask'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_getMaterial(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_getMaterial(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -3764,15 +3764,15 @@ int lua_cocos2dx_3d_Sprite3D_getMaterial(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_getMaterial'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_getMaterial'", nullptr); return 0; } #endif @@ -3782,30 +3782,30 @@ int lua_cocos2dx_3d_Sprite3D_getMaterial(lua_State* tolua_S) { int arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Sprite3D:getMaterial"); + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.MeshRenderer:getMaterial"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_getMaterial'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_getMaterial'", nullptr); return 0; } cocos2d::Material* ret = cobj->getMaterial(arg0); object_to_luaval(tolua_S, "cc.Material",(cocos2d::Material*)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:getMaterial",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:getMaterial",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_getMaterial'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_getMaterial'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_setCullFace(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_setCullFace(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -3814,15 +3814,15 @@ int lua_cocos2dx_3d_Sprite3D_setCullFace(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_setCullFace'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_setCullFace'", nullptr); return 0; } #endif @@ -3832,30 +3832,30 @@ int lua_cocos2dx_3d_Sprite3D_setCullFace(lua_State* tolua_S) { cocos2d::backend::CullMode arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Sprite3D:setCullFace"); + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.MeshRenderer:setCullFace"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_setCullFace'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_setCullFace'", nullptr); return 0; } cobj->setCullFace(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:setCullFace",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:setCullFace",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_setCullFace'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_setCullFace'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_getMeshes(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_getMeshes(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -3864,15 +3864,15 @@ int lua_cocos2dx_3d_Sprite3D_getMeshes(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_getMeshes'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_getMeshes'", nullptr); return 0; } #endif @@ -3882,27 +3882,27 @@ int lua_cocos2dx_3d_Sprite3D_getMeshes(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_getMeshes'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_getMeshes'", nullptr); return 0; } const cocos2d::Vector& ret = cobj->getMeshes(); ccvector_to_luaval(tolua_S, ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:getMeshes",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:getMeshes",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_getMeshes'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_getMeshes'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_removeAllAttachNode(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_removeAllAttachNode(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -3911,15 +3911,15 @@ int lua_cocos2dx_3d_Sprite3D_removeAllAttachNode(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_removeAllAttachNode'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_removeAllAttachNode'", nullptr); return 0; } #endif @@ -3929,40 +3929,40 @@ int lua_cocos2dx_3d_Sprite3D_removeAllAttachNode(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_removeAllAttachNode'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_removeAllAttachNode'", nullptr); return 0; } cobj->removeAllAttachNode(); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:removeAllAttachNode",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:removeAllAttachNode",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_removeAllAttachNode'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_removeAllAttachNode'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_setMaterial(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_setMaterial(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_setMaterial'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_setMaterial'", nullptr); return 0; } #endif @@ -3970,11 +3970,11 @@ int lua_cocos2dx_3d_Sprite3D_setMaterial(lua_State* tolua_S) do{ if (argc == 2) { cocos2d::Material* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.Material",&arg0, "cc.Sprite3D:setMaterial"); + ok &= luaval_to_object(tolua_S, 2, "cc.Material",&arg0, "cc.MeshRenderer:setMaterial"); if (!ok) { break; } int arg1; - ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "cc.Sprite3D:setMaterial"); + ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "cc.MeshRenderer:setMaterial"); if (!ok) { break; } cobj->setMaterial(arg0, arg1); @@ -3986,7 +3986,7 @@ int lua_cocos2dx_3d_Sprite3D_setMaterial(lua_State* tolua_S) do{ if (argc == 1) { cocos2d::Material* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.Material",&arg0, "cc.Sprite3D:setMaterial"); + ok &= luaval_to_object(tolua_S, 2, "cc.Material",&arg0, "cc.MeshRenderer:setMaterial"); if (!ok) { break; } cobj->setMaterial(arg0); @@ -3995,20 +3995,20 @@ int lua_cocos2dx_3d_Sprite3D_setMaterial(lua_State* tolua_S) } }while(0); ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:setMaterial",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:setMaterial",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_setMaterial'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_setMaterial'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_getMesh(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_getMesh(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4017,15 +4017,15 @@ int lua_cocos2dx_3d_Sprite3D_getMesh(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_getMesh'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_getMesh'", nullptr); return 0; } #endif @@ -4035,27 +4035,27 @@ int lua_cocos2dx_3d_Sprite3D_getMesh(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_getMesh'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_getMesh'", nullptr); return 0; } cocos2d::Mesh* ret = cobj->getMesh(); object_to_luaval(tolua_S, "cc.Mesh",(cocos2d::Mesh*)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:getMesh",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:getMesh",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_getMesh'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_getMesh'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_getMeshCount(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_getMeshCount(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4064,15 +4064,15 @@ int lua_cocos2dx_3d_Sprite3D_getMeshCount(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_getMeshCount'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_getMeshCount'", nullptr); return 0; } #endif @@ -4082,27 +4082,27 @@ int lua_cocos2dx_3d_Sprite3D_getMeshCount(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_getMeshCount'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_getMeshCount'", nullptr); return 0; } ssize_t ret = cobj->getMeshCount(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:getMeshCount",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:getMeshCount",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_getMeshCount'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_getMeshCount'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_getMeshByIndex(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_getMeshByIndex(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4111,15 +4111,15 @@ int lua_cocos2dx_3d_Sprite3D_getMeshByIndex(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_getMeshByIndex'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_getMeshByIndex'", nullptr); return 0; } #endif @@ -4129,30 +4129,30 @@ int lua_cocos2dx_3d_Sprite3D_getMeshByIndex(lua_State* tolua_S) { int arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Sprite3D:getMeshByIndex"); + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.MeshRenderer:getMeshByIndex"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_getMeshByIndex'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_getMeshByIndex'", nullptr); return 0; } cocos2d::Mesh* ret = cobj->getMeshByIndex(arg0); object_to_luaval(tolua_S, "cc.Mesh",(cocos2d::Mesh*)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:getMeshByIndex",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:getMeshByIndex",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_getMeshByIndex'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_getMeshByIndex'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_isForceDepthWrite(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_isForceDepthWrite(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4161,15 +4161,15 @@ int lua_cocos2dx_3d_Sprite3D_isForceDepthWrite(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_isForceDepthWrite'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_isForceDepthWrite'", nullptr); return 0; } #endif @@ -4179,27 +4179,27 @@ int lua_cocos2dx_3d_Sprite3D_isForceDepthWrite(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_isForceDepthWrite'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_isForceDepthWrite'", nullptr); return 0; } bool ret = cobj->isForceDepthWrite(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:isForceDepthWrite",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:isForceDepthWrite",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_isForceDepthWrite'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_isForceDepthWrite'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_getBlendFunc(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_getBlendFunc(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4208,15 +4208,15 @@ int lua_cocos2dx_3d_Sprite3D_getBlendFunc(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_getBlendFunc'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_getBlendFunc'", nullptr); return 0; } #endif @@ -4226,27 +4226,27 @@ int lua_cocos2dx_3d_Sprite3D_getBlendFunc(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_getBlendFunc'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_getBlendFunc'", nullptr); return 0; } const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); blendfunc_to_luaval(tolua_S, ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:getBlendFunc",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:getBlendFunc",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_getBlendFunc'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_getBlendFunc'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_setLightMask(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_setLightMask(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4255,15 +4255,15 @@ int lua_cocos2dx_3d_Sprite3D_setLightMask(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_setLightMask'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_setLightMask'", nullptr); return 0; } #endif @@ -4273,30 +4273,30 @@ int lua_cocos2dx_3d_Sprite3D_setLightMask(lua_State* tolua_S) { unsigned int arg0; - ok &= luaval_to_uint32(tolua_S, 2,&arg0, "cc.Sprite3D:setLightMask"); + ok &= luaval_to_uint32(tolua_S, 2,&arg0, "cc.MeshRenderer:setLightMask"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_setLightMask'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_setLightMask'", nullptr); return 0; } cobj->setLightMask(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:setLightMask",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:setLightMask",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_setLightMask'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_setLightMask'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_getAttachNode(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_getAttachNode(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4305,15 +4305,15 @@ int lua_cocos2dx_3d_Sprite3D_getAttachNode(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_getAttachNode'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_getAttachNode'", nullptr); return 0; } #endif @@ -4323,30 +4323,30 @@ int lua_cocos2dx_3d_Sprite3D_getAttachNode(lua_State* tolua_S) { std::string_view arg0; - ok &= luaval_to_std_string_view(tolua_S, 2,&arg0, "cc.Sprite3D:getAttachNode"); + ok &= luaval_to_std_string_view(tolua_S, 2,&arg0, "cc.MeshRenderer:getAttachNode"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_getAttachNode'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_getAttachNode'", nullptr); return 0; } cocos2d::AttachNode* ret = cobj->getAttachNode(arg0); object_to_luaval(tolua_S, "cc.AttachNode",(cocos2d::AttachNode*)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:getAttachNode",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:getAttachNode",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_getAttachNode'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_getAttachNode'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_setBlendFunc(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_setBlendFunc(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4355,15 +4355,15 @@ int lua_cocos2dx_3d_Sprite3D_setBlendFunc(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_setBlendFunc'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_setBlendFunc'", nullptr); return 0; } #endif @@ -4373,30 +4373,30 @@ int lua_cocos2dx_3d_Sprite3D_setBlendFunc(lua_State* tolua_S) { cocos2d::BlendFunc arg0; - ok &= luaval_to_blendfunc(tolua_S, 2, &arg0, "cc.Sprite3D:setBlendFunc"); + ok &= luaval_to_blendfunc(tolua_S, 2, &arg0, "cc.MeshRenderer:setBlendFunc"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_setBlendFunc'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_setBlendFunc'", nullptr); return 0; } cobj->setBlendFunc(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:setBlendFunc",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:setBlendFunc",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_setBlendFunc'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_setBlendFunc'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_setForce2DQueue(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_setForce2DQueue(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4405,15 +4405,15 @@ int lua_cocos2dx_3d_Sprite3D_setForce2DQueue(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_setForce2DQueue'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_setForce2DQueue'", nullptr); return 0; } #endif @@ -4423,30 +4423,30 @@ int lua_cocos2dx_3d_Sprite3D_setForce2DQueue(lua_State* tolua_S) { bool arg0; - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.Sprite3D:setForce2DQueue"); + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.MeshRenderer:setForce2DQueue"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_setForce2DQueue'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_setForce2DQueue'", nullptr); return 0; } cobj->setForce2DQueue(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:setForce2DQueue",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:setForce2DQueue",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_setForce2DQueue'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_setForce2DQueue'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_genMaterial(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_genMaterial(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4455,15 +4455,15 @@ int lua_cocos2dx_3d_Sprite3D_genMaterial(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_genMaterial'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_genMaterial'", nullptr); return 0; } #endif @@ -4473,7 +4473,7 @@ int lua_cocos2dx_3d_Sprite3D_genMaterial(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_genMaterial'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_genMaterial'", nullptr); return 0; } cobj->genMaterial(); @@ -4484,30 +4484,30 @@ int lua_cocos2dx_3d_Sprite3D_genMaterial(lua_State* tolua_S) { bool arg0; - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.Sprite3D:genMaterial"); + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.MeshRenderer:genMaterial"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_genMaterial'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_genMaterial'", nullptr); return 0; } cobj->genMaterial(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:genMaterial",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:genMaterial",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_genMaterial'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_genMaterial'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_removeAttachNode(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_removeAttachNode(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4516,15 +4516,15 @@ int lua_cocos2dx_3d_Sprite3D_removeAttachNode(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_removeAttachNode'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_removeAttachNode'", nullptr); return 0; } #endif @@ -4534,30 +4534,30 @@ int lua_cocos2dx_3d_Sprite3D_removeAttachNode(lua_State* tolua_S) { std::string_view arg0; - ok &= luaval_to_std_string_view(tolua_S, 2,&arg0, "cc.Sprite3D:removeAttachNode"); + ok &= luaval_to_std_string_view(tolua_S, 2,&arg0, "cc.MeshRenderer:removeAttachNode"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_removeAttachNode'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_removeAttachNode'", nullptr); return 0; } cobj->removeAttachNode(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:removeAttachNode",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:removeAttachNode",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_removeAttachNode'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_removeAttachNode'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_getSkeleton(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_getSkeleton(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4566,15 +4566,15 @@ int lua_cocos2dx_3d_Sprite3D_getSkeleton(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_getSkeleton'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_getSkeleton'", nullptr); return 0; } #endif @@ -4584,27 +4584,27 @@ int lua_cocos2dx_3d_Sprite3D_getSkeleton(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_getSkeleton'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_getSkeleton'", nullptr); return 0; } cocos2d::Skeleton3D* ret = cobj->getSkeleton(); object_to_luaval(tolua_S, "cc.Skeleton3D",(cocos2d::Skeleton3D*)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:getSkeleton",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:getSkeleton",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_getSkeleton'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_getSkeleton'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_setForceDepthWrite(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_setForceDepthWrite(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4613,15 +4613,15 @@ int lua_cocos2dx_3d_Sprite3D_setForceDepthWrite(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_setForceDepthWrite'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_setForceDepthWrite'", nullptr); return 0; } #endif @@ -4631,30 +4631,30 @@ int lua_cocos2dx_3d_Sprite3D_setForceDepthWrite(lua_State* tolua_S) { bool arg0; - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.Sprite3D:setForceDepthWrite"); + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.MeshRenderer:setForceDepthWrite"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_setForceDepthWrite'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_setForceDepthWrite'", nullptr); return 0; } cobj->setForceDepthWrite(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:setForceDepthWrite",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:setForceDepthWrite",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_setForceDepthWrite'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_setForceDepthWrite'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_getMeshByName(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_getMeshByName(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4663,15 +4663,15 @@ int lua_cocos2dx_3d_Sprite3D_getMeshByName(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_getMeshByName'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_getMeshByName'", nullptr); return 0; } #endif @@ -4681,27 +4681,27 @@ int lua_cocos2dx_3d_Sprite3D_getMeshByName(lua_State* tolua_S) { std::string_view arg0; - ok &= luaval_to_std_string_view(tolua_S, 2,&arg0, "cc.Sprite3D:getMeshByName"); + ok &= luaval_to_std_string_view(tolua_S, 2,&arg0, "cc.MeshRenderer:getMeshByName"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3D_getMeshByName'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRenderer_getMeshByName'", nullptr); return 0; } cocos2d::Mesh* ret = cobj->getMeshByName(arg0); object_to_luaval(tolua_S, "cc.Mesh",(cocos2d::Mesh*)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:getMeshByName",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:getMeshByName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_getMeshByName'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_getMeshByName'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_create(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRenderer_create(lua_State* tolua_S) { int argc = 0; bool ok = true; @@ -4710,7 +4710,7 @@ int lua_cocos2dx_3d_Sprite3D_create(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.MeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; @@ -4720,10 +4720,10 @@ int lua_cocos2dx_3d_Sprite3D_create(lua_State* tolua_S) if (argc == 1) { std::string_view arg0; - ok &= luaval_to_std_string_view(tolua_S, 2,&arg0, "cc.Sprite3D:create"); + ok &= luaval_to_std_string_view(tolua_S, 2,&arg0, "cc.MeshRenderer:create"); if (!ok) { break; } - cocos2d::Sprite3D* ret = cocos2d::Sprite3D::create(arg0); - object_to_luaval(tolua_S, "cc.Sprite3D",(cocos2d::Sprite3D*)ret); + cocos2d::MeshRenderer* ret = cocos2d::MeshRenderer::create(arg0); + object_to_luaval(tolua_S, "cc.MeshRenderer",(cocos2d::MeshRenderer*)ret); return 1; } } while (0); @@ -4732,8 +4732,8 @@ int lua_cocos2dx_3d_Sprite3D_create(lua_State* tolua_S) { if (argc == 0) { - cocos2d::Sprite3D* ret = cocos2d::Sprite3D::create(); - object_to_luaval(tolua_S, "cc.Sprite3D",(cocos2d::Sprite3D*)ret); + cocos2d::MeshRenderer* ret = cocos2d::MeshRenderer::create(); + object_to_luaval(tolua_S, "cc.MeshRenderer",(cocos2d::MeshRenderer*)ret); return 1; } } while (0); @@ -4743,71 +4743,71 @@ int lua_cocos2dx_3d_Sprite3D_create(lua_State* tolua_S) if (argc == 2) { std::string_view arg0; - ok &= luaval_to_std_string_view(tolua_S, 2,&arg0, "cc.Sprite3D:create"); + ok &= luaval_to_std_string_view(tolua_S, 2,&arg0, "cc.MeshRenderer:create"); if (!ok) { break; } std::string_view arg1; - ok &= luaval_to_std_string_view(tolua_S, 3,&arg1, "cc.Sprite3D:create"); + ok &= luaval_to_std_string_view(tolua_S, 3,&arg1, "cc.MeshRenderer:create"); if (!ok) { break; } - cocos2d::Sprite3D* ret = cocos2d::Sprite3D::create(arg0, arg1); - object_to_luaval(tolua_S, "cc.Sprite3D",(cocos2d::Sprite3D*)ret); + cocos2d::MeshRenderer* ret = cocos2d::MeshRenderer::create(arg0, arg1); + object_to_luaval(tolua_S, "cc.MeshRenderer",(cocos2d::MeshRenderer*)ret); return 1; } } while (0); ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.Sprite3D:create",argc, 2); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.MeshRenderer:create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_create'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRenderer_create'.",&tolua_err); #endif return 0; } -static int lua_cocos2dx_3d_Sprite3D_finalize(lua_State* tolua_S) +static int lua_cocos2dx_3d_MeshRenderer_finalize(lua_State* tolua_S) { - printf("luabindings: finalizing LUA object (Sprite3D)"); + printf("luabindings: finalizing LUA object (MeshRenderer)"); return 0; } -int lua_register_cocos2dx_3d_Sprite3D(lua_State* tolua_S) +int lua_register_cocos2dx_3d_MeshRenderer(lua_State* tolua_S) { - tolua_usertype(tolua_S,"cc.Sprite3D"); - tolua_cclass(tolua_S,"Sprite3D","cc.Sprite3D","cc.Node",nullptr); + tolua_usertype(tolua_S,"cc.MeshRenderer"); + tolua_cclass(tolua_S,"MeshRenderer","cc.MeshRenderer","cc.Node",nullptr); - tolua_beginmodule(tolua_S,"Sprite3D"); - tolua_function(tolua_S,"setCullFaceEnabled",lua_cocos2dx_3d_Sprite3D_setCullFaceEnabled); - tolua_function(tolua_S,"setTexture",lua_cocos2dx_3d_Sprite3D_setTexture); - tolua_function(tolua_S,"getLightMask",lua_cocos2dx_3d_Sprite3D_getLightMask); - tolua_function(tolua_S,"getMaterial",lua_cocos2dx_3d_Sprite3D_getMaterial); - tolua_function(tolua_S,"setCullFace",lua_cocos2dx_3d_Sprite3D_setCullFace); - tolua_function(tolua_S,"getMeshes",lua_cocos2dx_3d_Sprite3D_getMeshes); - tolua_function(tolua_S,"removeAllAttachNode",lua_cocos2dx_3d_Sprite3D_removeAllAttachNode); - tolua_function(tolua_S,"setMaterial",lua_cocos2dx_3d_Sprite3D_setMaterial); - tolua_function(tolua_S,"getMesh",lua_cocos2dx_3d_Sprite3D_getMesh); - tolua_function(tolua_S,"getMeshCount",lua_cocos2dx_3d_Sprite3D_getMeshCount); - tolua_function(tolua_S,"getMeshByIndex",lua_cocos2dx_3d_Sprite3D_getMeshByIndex); - tolua_function(tolua_S,"isForceDepthWrite",lua_cocos2dx_3d_Sprite3D_isForceDepthWrite); - tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_3d_Sprite3D_getBlendFunc); - tolua_function(tolua_S,"setLightMask",lua_cocos2dx_3d_Sprite3D_setLightMask); - tolua_function(tolua_S,"getAttachNode",lua_cocos2dx_3d_Sprite3D_getAttachNode); - tolua_function(tolua_S,"setBlendFunc",lua_cocos2dx_3d_Sprite3D_setBlendFunc); - tolua_function(tolua_S,"setForce2DQueue",lua_cocos2dx_3d_Sprite3D_setForce2DQueue); - tolua_function(tolua_S,"genMaterial",lua_cocos2dx_3d_Sprite3D_genMaterial); - tolua_function(tolua_S,"removeAttachNode",lua_cocos2dx_3d_Sprite3D_removeAttachNode); - tolua_function(tolua_S,"getSkeleton",lua_cocos2dx_3d_Sprite3D_getSkeleton); - tolua_function(tolua_S,"setForceDepthWrite",lua_cocos2dx_3d_Sprite3D_setForceDepthWrite); - tolua_function(tolua_S,"getMeshByName",lua_cocos2dx_3d_Sprite3D_getMeshByName); - tolua_function(tolua_S,"create", lua_cocos2dx_3d_Sprite3D_create); + tolua_beginmodule(tolua_S,"MeshRenderer"); + tolua_function(tolua_S,"setCullFaceEnabled",lua_cocos2dx_3d_MeshRenderer_setCullFaceEnabled); + tolua_function(tolua_S,"setTexture",lua_cocos2dx_3d_MeshRenderer_setTexture); + tolua_function(tolua_S,"getLightMask",lua_cocos2dx_3d_MeshRenderer_getLightMask); + tolua_function(tolua_S,"getMaterial",lua_cocos2dx_3d_MeshRenderer_getMaterial); + tolua_function(tolua_S,"setCullFace",lua_cocos2dx_3d_MeshRenderer_setCullFace); + tolua_function(tolua_S,"getMeshes",lua_cocos2dx_3d_MeshRenderer_getMeshes); + tolua_function(tolua_S,"removeAllAttachNode",lua_cocos2dx_3d_MeshRenderer_removeAllAttachNode); + tolua_function(tolua_S,"setMaterial",lua_cocos2dx_3d_MeshRenderer_setMaterial); + tolua_function(tolua_S,"getMesh",lua_cocos2dx_3d_MeshRenderer_getMesh); + tolua_function(tolua_S,"getMeshCount",lua_cocos2dx_3d_MeshRenderer_getMeshCount); + tolua_function(tolua_S,"getMeshByIndex",lua_cocos2dx_3d_MeshRenderer_getMeshByIndex); + tolua_function(tolua_S,"isForceDepthWrite",lua_cocos2dx_3d_MeshRenderer_isForceDepthWrite); + tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_3d_MeshRenderer_getBlendFunc); + tolua_function(tolua_S,"setLightMask",lua_cocos2dx_3d_MeshRenderer_setLightMask); + tolua_function(tolua_S,"getAttachNode",lua_cocos2dx_3d_MeshRenderer_getAttachNode); + tolua_function(tolua_S,"setBlendFunc",lua_cocos2dx_3d_MeshRenderer_setBlendFunc); + tolua_function(tolua_S,"setForce2DQueue",lua_cocos2dx_3d_MeshRenderer_setForce2DQueue); + tolua_function(tolua_S,"genMaterial",lua_cocos2dx_3d_MeshRenderer_genMaterial); + tolua_function(tolua_S,"removeAttachNode",lua_cocos2dx_3d_MeshRenderer_removeAttachNode); + tolua_function(tolua_S,"getSkeleton",lua_cocos2dx_3d_MeshRenderer_getSkeleton); + tolua_function(tolua_S,"setForceDepthWrite",lua_cocos2dx_3d_MeshRenderer_setForceDepthWrite); + tolua_function(tolua_S,"getMeshByName",lua_cocos2dx_3d_MeshRenderer_getMeshByName); + tolua_function(tolua_S,"create", lua_cocos2dx_3d_MeshRenderer_create); tolua_endmodule(tolua_S); - auto typeName = typeid(cocos2d::Sprite3D).name(); // rtti is literal storage - g_luaType[reinterpret_cast(typeName)] = "cc.Sprite3D"; - g_typeCast[typeName] = "cc.Sprite3D"; + auto typeName = typeid(cocos2d::MeshRenderer).name(); // rtti is literal storage + g_luaType[reinterpret_cast(typeName)] = "cc.MeshRenderer"; + g_typeCast[typeName] = "cc.MeshRenderer"; return 1; } -int lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRendererCache_removeMeshRendererData(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3DCache* cobj = nullptr; + cocos2d::MeshRendererCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4816,15 +4816,15 @@ int lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3DCache",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRendererCache",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3DCache*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRendererCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRendererCache_removeMeshRendererData'", nullptr); return 0; } #endif @@ -4834,30 +4834,30 @@ int lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData(lua_State* tolua_S) { std::string_view arg0; - ok &= luaval_to_std_string_view(tolua_S, 2,&arg0, "cc.Sprite3DCache:removeSprite3DData"); + ok &= luaval_to_std_string_view(tolua_S, 2,&arg0, "cc.MeshRendererCache:removeMeshRendererData"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRendererCache_removeMeshRendererData'", nullptr); return 0; } - cobj->removeSprite3DData(arg0); + cobj->removeMeshRendererData(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3DCache:removeSprite3DData",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRendererCache:removeMeshRendererData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRendererCache_removeMeshRendererData'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRendererCache_removeAllMeshRendererData(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3DCache* cobj = nullptr; + cocos2d::MeshRendererCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4866,15 +4866,15 @@ int lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3DCache",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshRendererCache",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3DCache*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshRendererCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRendererCache_removeAllMeshRendererData'", nullptr); return 0; } #endif @@ -4884,24 +4884,24 @@ int lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRendererCache_removeAllMeshRendererData'", nullptr); return 0; } - cobj->removeAllSprite3DData(); + cobj->removeAllMeshRendererData(); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3DCache:removeAllSprite3DData",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRendererCache:removeAllMeshRendererData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRendererCache_removeAllMeshRendererData'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3DCache_destroyInstance(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRendererCache_destroyInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; @@ -4911,7 +4911,7 @@ int lua_cocos2dx_3d_Sprite3DCache_destroyInstance(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Sprite3DCache",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.MeshRendererCache",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -4920,22 +4920,22 @@ int lua_cocos2dx_3d_Sprite3DCache_destroyInstance(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DCache_destroyInstance'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRendererCache_destroyInstance'", nullptr); return 0; } - cocos2d::Sprite3DCache::destroyInstance(); + cocos2d::MeshRendererCache::destroyInstance(); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Sprite3DCache:destroyInstance",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.MeshRendererCache:destroyInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DCache_destroyInstance'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRendererCache_destroyInstance'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3DCache_getInstance(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRendererCache_getInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; @@ -4945,7 +4945,7 @@ int lua_cocos2dx_3d_Sprite3DCache_getInstance(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Sprite3DCache",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.MeshRendererCache",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -4954,25 +4954,25 @@ int lua_cocos2dx_3d_Sprite3DCache_getInstance(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DCache_getInstance'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRendererCache_getInstance'", nullptr); return 0; } - cocos2d::Sprite3DCache* ret = cocos2d::Sprite3DCache::getInstance(); - object_to_luaval(tolua_S, "cc.Sprite3DCache",(cocos2d::Sprite3DCache*)ret); + cocos2d::MeshRendererCache* ret = cocos2d::MeshRendererCache::getInstance(); + object_to_luaval(tolua_S, "cc.MeshRendererCache",(cocos2d::MeshRendererCache*)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Sprite3DCache:getInstance",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.MeshRendererCache:getInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DCache_getInstance'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRendererCache_getInstance'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3DCache_constructor(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshRendererCache_constructor(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3DCache* cobj = nullptr; + cocos2d::MeshRendererCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4986,52 +4986,52 @@ int lua_cocos2dx_3d_Sprite3DCache_constructor(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DCache_constructor'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshRendererCache_constructor'", nullptr); return 0; } - cobj = new cocos2d::Sprite3DCache(); - tolua_pushusertype(tolua_S,(void*)cobj,"cc.Sprite3DCache"); + cobj = new cocos2d::MeshRendererCache(); + tolua_pushusertype(tolua_S,(void*)cobj,"cc.MeshRendererCache"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3DCache:Sprite3DCache",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRendererCache:MeshRendererCache",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DCache_constructor'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshRendererCache_constructor'.",&tolua_err); #endif return 0; } -static int lua_cocos2dx_3d_Sprite3DCache_finalize(lua_State* tolua_S) +static int lua_cocos2dx_3d_MeshRendererCache_finalize(lua_State* tolua_S) { - printf("luabindings: finalizing LUA object (Sprite3DCache)"); + printf("luabindings: finalizing LUA object (MeshRendererCache)"); return 0; } -int lua_register_cocos2dx_3d_Sprite3DCache(lua_State* tolua_S) +int lua_register_cocos2dx_3d_MeshRendererCache(lua_State* tolua_S) { - tolua_usertype(tolua_S,"cc.Sprite3DCache"); - tolua_cclass(tolua_S,"Sprite3DCache","cc.Sprite3DCache","",nullptr); + tolua_usertype(tolua_S,"cc.MeshRendererCache"); + tolua_cclass(tolua_S,"MeshRendererCache","cc.MeshRendererCache","",nullptr); - tolua_beginmodule(tolua_S,"Sprite3DCache"); - tolua_function(tolua_S,"new",lua_cocos2dx_3d_Sprite3DCache_constructor); - tolua_function(tolua_S,"removeSprite3DData",lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData); - tolua_function(tolua_S,"removeAllSprite3DData",lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData); - tolua_function(tolua_S,"destroyInstance", lua_cocos2dx_3d_Sprite3DCache_destroyInstance); - tolua_function(tolua_S,"getInstance", lua_cocos2dx_3d_Sprite3DCache_getInstance); + tolua_beginmodule(tolua_S,"MeshRendererCache"); + tolua_function(tolua_S,"new",lua_cocos2dx_3d_MeshRendererCache_constructor); + tolua_function(tolua_S,"removeMeshRendererData",lua_cocos2dx_3d_MeshRendererCache_removeMeshRendererData); + tolua_function(tolua_S,"removeAllMeshRendererData",lua_cocos2dx_3d_MeshRendererCache_removeAllMeshRendererData); + tolua_function(tolua_S,"destroyInstance", lua_cocos2dx_3d_MeshRendererCache_destroyInstance); + tolua_function(tolua_S,"getInstance", lua_cocos2dx_3d_MeshRendererCache_getInstance); tolua_endmodule(tolua_S); - auto typeName = typeid(cocos2d::Sprite3DCache).name(); // rtti is literal storage - g_luaType[reinterpret_cast(typeName)] = "cc.Sprite3DCache"; - g_typeCast[typeName] = "cc.Sprite3DCache"; + auto typeName = typeid(cocos2d::MeshRendererCache).name(); // rtti is literal storage + g_luaType[reinterpret_cast(typeName)] = "cc.MeshRendererCache"; + g_typeCast[typeName] = "cc.MeshRendererCache"; return 1; } -int lua_cocos2dx_3d_Sprite3DMaterial_getMaterialType(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshMaterial_getMaterialType(lua_State* tolua_S) { int argc = 0; - cocos2d::Sprite3DMaterial* cobj = nullptr; + cocos2d::MeshMaterial* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -5040,15 +5040,15 @@ int lua_cocos2dx_3d_Sprite3DMaterial_getMaterialType(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Sprite3DMaterial",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.MeshMaterial",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3DMaterial*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::MeshMaterial*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3DMaterial_getMaterialType'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_MeshMaterial_getMaterialType'", nullptr); return 0; } #endif @@ -5058,24 +5058,24 @@ int lua_cocos2dx_3d_Sprite3DMaterial_getMaterialType(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DMaterial_getMaterialType'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshMaterial_getMaterialType'", nullptr); return 0; } int ret = (int)cobj->getMaterialType(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3DMaterial:getMaterialType",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshMaterial:getMaterialType",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DMaterial_getMaterialType'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshMaterial_getMaterialType'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3DMaterial_createWithFilename(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshMaterial_createWithFilename(lua_State* tolua_S) { int argc = 0; bool ok = true; @@ -5085,7 +5085,7 @@ int lua_cocos2dx_3d_Sprite3DMaterial_createWithFilename(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Sprite3DMaterial",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.MeshMaterial",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -5093,25 +5093,25 @@ int lua_cocos2dx_3d_Sprite3DMaterial_createWithFilename(lua_State* tolua_S) if (argc == 1) { std::string_view arg0; - ok &= luaval_to_std_string_view(tolua_S, 2,&arg0, "cc.Sprite3DMaterial:createWithFilename"); + ok &= luaval_to_std_string_view(tolua_S, 2,&arg0, "cc.MeshMaterial:createWithFilename"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DMaterial_createWithFilename'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshMaterial_createWithFilename'", nullptr); return 0; } - cocos2d::Sprite3DMaterial* ret = cocos2d::Sprite3DMaterial::createWithFilename(arg0); - object_to_luaval(tolua_S, "cc.Sprite3DMaterial",(cocos2d::Sprite3DMaterial*)ret); + cocos2d::MeshMaterial* ret = cocos2d::MeshMaterial::createWithFilename(arg0); + object_to_luaval(tolua_S, "cc.MeshMaterial",(cocos2d::MeshMaterial*)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Sprite3DMaterial:createWithFilename",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.MeshMaterial:createWithFilename",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DMaterial_createWithFilename'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshMaterial_createWithFilename'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3DMaterial_releaseCachedMaterial(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshMaterial_releaseCachedMaterial(lua_State* tolua_S) { int argc = 0; bool ok = true; @@ -5121,7 +5121,7 @@ int lua_cocos2dx_3d_Sprite3DMaterial_releaseCachedMaterial(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Sprite3DMaterial",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.MeshMaterial",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -5130,22 +5130,22 @@ int lua_cocos2dx_3d_Sprite3DMaterial_releaseCachedMaterial(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DMaterial_releaseCachedMaterial'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshMaterial_releaseCachedMaterial'", nullptr); return 0; } - cocos2d::Sprite3DMaterial::releaseCachedMaterial(); + cocos2d::MeshMaterial::releaseCachedMaterial(); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Sprite3DMaterial:releaseCachedMaterial",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.MeshMaterial:releaseCachedMaterial",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DMaterial_releaseCachedMaterial'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshMaterial_releaseCachedMaterial'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3DMaterial_createBuiltInMaterial(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshMaterial_createBuiltInMaterial(lua_State* tolua_S) { int argc = 0; bool ok = true; @@ -5154,7 +5154,7 @@ int lua_cocos2dx_3d_Sprite3DMaterial_createBuiltInMaterial(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Sprite3DMaterial",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.MeshMaterial",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; @@ -5163,7 +5163,7 @@ int lua_cocos2dx_3d_Sprite3DMaterial_createBuiltInMaterial(lua_State* tolua_S) { if (argc == 0) { - cocos2d::Sprite3DMaterial::createBuiltInMaterial(); + cocos2d::MeshMaterial::createBuiltInMaterial(); lua_settop(tolua_S, 1); return 1; } @@ -5173,27 +5173,27 @@ int lua_cocos2dx_3d_Sprite3DMaterial_createBuiltInMaterial(lua_State* tolua_S) { if (argc == 2) { - cocos2d::Sprite3DMaterial::MaterialType arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Sprite3DMaterial:createBuiltInMaterial"); + cocos2d::MeshMaterial::MaterialType arg0; + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.MeshMaterial:createBuiltInMaterial"); if (!ok) { break; } bool arg1; - ok &= luaval_to_boolean(tolua_S, 3,&arg1, "cc.Sprite3DMaterial:createBuiltInMaterial"); + ok &= luaval_to_boolean(tolua_S, 3,&arg1, "cc.MeshMaterial:createBuiltInMaterial"); if (!ok) { break; } - cocos2d::Sprite3DMaterial* ret = cocos2d::Sprite3DMaterial::createBuiltInMaterial(arg0, arg1); - object_to_luaval(tolua_S, "cc.Sprite3DMaterial",(cocos2d::Sprite3DMaterial*)ret); + cocos2d::MeshMaterial* ret = cocos2d::MeshMaterial::createBuiltInMaterial(arg0, arg1); + object_to_luaval(tolua_S, "cc.MeshMaterial",(cocos2d::MeshMaterial*)ret); return 1; } } while (0); ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.Sprite3DMaterial:createBuiltInMaterial",argc, 2); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.MeshMaterial:createBuiltInMaterial",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DMaterial_createBuiltInMaterial'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshMaterial_createBuiltInMaterial'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3DMaterial_releaseBuiltInMaterial(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshMaterial_releaseBuiltInMaterial(lua_State* tolua_S) { int argc = 0; bool ok = true; @@ -5203,7 +5203,7 @@ int lua_cocos2dx_3d_Sprite3DMaterial_releaseBuiltInMaterial(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Sprite3DMaterial",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.MeshMaterial",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -5212,22 +5212,22 @@ int lua_cocos2dx_3d_Sprite3DMaterial_releaseBuiltInMaterial(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DMaterial_releaseBuiltInMaterial'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshMaterial_releaseBuiltInMaterial'", nullptr); return 0; } - cocos2d::Sprite3DMaterial::releaseBuiltInMaterial(); + cocos2d::MeshMaterial::releaseBuiltInMaterial(); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Sprite3DMaterial:releaseBuiltInMaterial",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.MeshMaterial:releaseBuiltInMaterial",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DMaterial_releaseBuiltInMaterial'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshMaterial_releaseBuiltInMaterial'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3DMaterial_createWithProgramState(lua_State* tolua_S) +int lua_cocos2dx_3d_MeshMaterial_createWithProgramState(lua_State* tolua_S) { int argc = 0; bool ok = true; @@ -5237,7 +5237,7 @@ int lua_cocos2dx_3d_Sprite3DMaterial_createWithProgramState(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Sprite3DMaterial",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.MeshMaterial",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -5245,46 +5245,46 @@ int lua_cocos2dx_3d_Sprite3DMaterial_createWithProgramState(lua_State* tolua_S) if (argc == 1) { cocos2d::backend::ProgramState* arg0; - ok &= luaval_to_object(tolua_S, 2, "ccb.ProgramState",&arg0, "cc.Sprite3DMaterial:createWithProgramState"); + ok &= luaval_to_object(tolua_S, 2, "ccb.ProgramState",&arg0, "cc.MeshMaterial:createWithProgramState"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DMaterial_createWithProgramState'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_MeshMaterial_createWithProgramState'", nullptr); return 0; } - cocos2d::Sprite3DMaterial* ret = cocos2d::Sprite3DMaterial::createWithProgramState(arg0); - object_to_luaval(tolua_S, "cc.Sprite3DMaterial",(cocos2d::Sprite3DMaterial*)ret); + cocos2d::MeshMaterial* ret = cocos2d::MeshMaterial::createWithProgramState(arg0); + object_to_luaval(tolua_S, "cc.MeshMaterial",(cocos2d::MeshMaterial*)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Sprite3DMaterial:createWithProgramState",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.MeshMaterial:createWithProgramState",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DMaterial_createWithProgramState'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_MeshMaterial_createWithProgramState'.",&tolua_err); #endif return 0; } -static int lua_cocos2dx_3d_Sprite3DMaterial_finalize(lua_State* tolua_S) +static int lua_cocos2dx_3d_MeshMaterial_finalize(lua_State* tolua_S) { - printf("luabindings: finalizing LUA object (Sprite3DMaterial)"); + printf("luabindings: finalizing LUA object (MeshMaterial)"); return 0; } -int lua_register_cocos2dx_3d_Sprite3DMaterial(lua_State* tolua_S) +int lua_register_cocos2dx_3d_MeshMaterial(lua_State* tolua_S) { - tolua_usertype(tolua_S,"cc.Sprite3DMaterial"); - tolua_cclass(tolua_S,"Sprite3DMaterial","cc.Sprite3DMaterial","cc.Material",nullptr); + tolua_usertype(tolua_S,"cc.MeshMaterial"); + tolua_cclass(tolua_S,"MeshMaterial","cc.MeshMaterial","cc.Material",nullptr); - tolua_beginmodule(tolua_S,"Sprite3DMaterial"); - tolua_function(tolua_S,"getMaterialType",lua_cocos2dx_3d_Sprite3DMaterial_getMaterialType); - tolua_function(tolua_S,"createWithFilename", lua_cocos2dx_3d_Sprite3DMaterial_createWithFilename); - tolua_function(tolua_S,"releaseCachedMaterial", lua_cocos2dx_3d_Sprite3DMaterial_releaseCachedMaterial); - tolua_function(tolua_S,"createBuiltInMaterial", lua_cocos2dx_3d_Sprite3DMaterial_createBuiltInMaterial); - tolua_function(tolua_S,"releaseBuiltInMaterial", lua_cocos2dx_3d_Sprite3DMaterial_releaseBuiltInMaterial); - tolua_function(tolua_S,"createWithProgramState", lua_cocos2dx_3d_Sprite3DMaterial_createWithProgramState); + tolua_beginmodule(tolua_S,"MeshMaterial"); + tolua_function(tolua_S,"getMaterialType",lua_cocos2dx_3d_MeshMaterial_getMaterialType); + tolua_function(tolua_S,"createWithFilename", lua_cocos2dx_3d_MeshMaterial_createWithFilename); + tolua_function(tolua_S,"releaseCachedMaterial", lua_cocos2dx_3d_MeshMaterial_releaseCachedMaterial); + tolua_function(tolua_S,"createBuiltInMaterial", lua_cocos2dx_3d_MeshMaterial_createBuiltInMaterial); + tolua_function(tolua_S,"releaseBuiltInMaterial", lua_cocos2dx_3d_MeshMaterial_releaseBuiltInMaterial); + tolua_function(tolua_S,"createWithProgramState", lua_cocos2dx_3d_MeshMaterial_createWithProgramState); tolua_endmodule(tolua_S); - auto typeName = typeid(cocos2d::Sprite3DMaterial).name(); // rtti is literal storage - g_luaType[reinterpret_cast(typeName)] = "cc.Sprite3DMaterial"; - g_typeCast[typeName] = "cc.Sprite3DMaterial"; + auto typeName = typeid(cocos2d::MeshMaterial).name(); // rtti is literal storage + g_luaType[reinterpret_cast(typeName)] = "cc.MeshMaterial"; + g_typeCast[typeName] = "cc.MeshMaterial"; return 1; } @@ -6988,7 +6988,7 @@ TOLUA_API int register_all_cocos2dx_3d(lua_State* tolua_S) tolua_module(tolua_S,"cc",0); tolua_beginmodule(tolua_S,"cc"); - lua_register_cocos2dx_3d_Sprite3D(tolua_S); + lua_register_cocos2dx_3d_MeshRenderer(tolua_S); lua_register_cocos2dx_3d_TextureCube(tolua_S); lua_register_cocos2dx_3d_BillBoard(tolua_S); lua_register_cocos2dx_3d_Mesh(tolua_S); @@ -6996,8 +6996,8 @@ TOLUA_API int register_all_cocos2dx_3d(lua_State* tolua_S) lua_register_cocos2dx_3d_AttachNode(tolua_S); lua_register_cocos2dx_3d_Animation3D(tolua_S); lua_register_cocos2dx_3d_Skeleton3D(tolua_S); - lua_register_cocos2dx_3d_Sprite3DMaterial(tolua_S); - lua_register_cocos2dx_3d_Sprite3DCache(tolua_S); + lua_register_cocos2dx_3d_MeshMaterial(tolua_S); + lua_register_cocos2dx_3d_MeshRendererCache(tolua_S); lua_register_cocos2dx_3d_Terrain(tolua_S); lua_register_cocos2dx_3d_Bundle3D(tolua_S); lua_register_cocos2dx_3d_Skybox(tolua_S); diff --git a/extensions/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.cpp b/extensions/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.cpp index 1c82b364b3..6675ee663f 100644 --- a/extensions/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.cpp +++ b/extensions/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.cpp @@ -3972,10 +3972,10 @@ int lua_register_cocos2dx_physics3d_Physics3DComponent(lua_State* tolua_S) return 1; } -int lua_cocos2dx_physics3d_PhysicsSprite3D_syncNodeToPhysics(lua_State* tolua_S) +int lua_cocos2dx_physics3d_PhysicsMeshRenderer_syncNodeToPhysics(lua_State* tolua_S) { int argc = 0; - cocos2d::PhysicsSprite3D* cobj = nullptr; + cocos2d::PhysicsMeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -3984,15 +3984,15 @@ int lua_cocos2dx_physics3d_PhysicsSprite3D_syncNodeToPhysics(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.PhysicsSprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.PhysicsMeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::PhysicsSprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::PhysicsMeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_syncNodeToPhysics'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_PhysicsMeshRenderer_syncNodeToPhysics'", nullptr); return 0; } #endif @@ -4002,27 +4002,27 @@ int lua_cocos2dx_physics3d_PhysicsSprite3D_syncNodeToPhysics(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_syncNodeToPhysics'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_PhysicsMeshRenderer_syncNodeToPhysics'", nullptr); return 0; } cobj->syncNodeToPhysics(); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PhysicsSprite3D:syncNodeToPhysics",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PhysicsMeshRenderer:syncNodeToPhysics",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_syncNodeToPhysics'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_PhysicsMeshRenderer_syncNodeToPhysics'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_physics3d_PhysicsSprite3D_syncPhysicsToNode(lua_State* tolua_S) +int lua_cocos2dx_physics3d_PhysicsMeshRenderer_syncPhysicsToNode(lua_State* tolua_S) { int argc = 0; - cocos2d::PhysicsSprite3D* cobj = nullptr; + cocos2d::PhysicsMeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4031,15 +4031,15 @@ int lua_cocos2dx_physics3d_PhysicsSprite3D_syncPhysicsToNode(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.PhysicsSprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.PhysicsMeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::PhysicsSprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::PhysicsMeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_syncPhysicsToNode'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_PhysicsMeshRenderer_syncPhysicsToNode'", nullptr); return 0; } #endif @@ -4049,27 +4049,27 @@ int lua_cocos2dx_physics3d_PhysicsSprite3D_syncPhysicsToNode(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_syncPhysicsToNode'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_PhysicsMeshRenderer_syncPhysicsToNode'", nullptr); return 0; } cobj->syncPhysicsToNode(); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PhysicsSprite3D:syncPhysicsToNode",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PhysicsMeshRenderer:syncPhysicsToNode",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_syncPhysicsToNode'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_PhysicsMeshRenderer_syncPhysicsToNode'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_physics3d_PhysicsSprite3D_getPhysicsObj(lua_State* tolua_S) +int lua_cocos2dx_physics3d_PhysicsMeshRenderer_getPhysicsObj(lua_State* tolua_S) { int argc = 0; - cocos2d::PhysicsSprite3D* cobj = nullptr; + cocos2d::PhysicsMeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4078,15 +4078,15 @@ int lua_cocos2dx_physics3d_PhysicsSprite3D_getPhysicsObj(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.PhysicsSprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.PhysicsMeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::PhysicsSprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::PhysicsMeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_getPhysicsObj'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_PhysicsMeshRenderer_getPhysicsObj'", nullptr); return 0; } #endif @@ -4096,27 +4096,27 @@ int lua_cocos2dx_physics3d_PhysicsSprite3D_getPhysicsObj(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_getPhysicsObj'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_PhysicsMeshRenderer_getPhysicsObj'", nullptr); return 0; } cocos2d::Physics3DObject* ret = cobj->getPhysicsObj(); object_to_luaval(tolua_S, "cc.Physics3DObject",(cocos2d::Physics3DObject*)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PhysicsSprite3D:getPhysicsObj",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PhysicsMeshRenderer:getPhysicsObj",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_getPhysicsObj'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_PhysicsMeshRenderer_getPhysicsObj'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_physics3d_PhysicsSprite3D_setSyncFlag(lua_State* tolua_S) +int lua_cocos2dx_physics3d_PhysicsMeshRenderer_setSyncFlag(lua_State* tolua_S) { int argc = 0; - cocos2d::PhysicsSprite3D* cobj = nullptr; + cocos2d::PhysicsMeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4125,15 +4125,15 @@ int lua_cocos2dx_physics3d_PhysicsSprite3D_setSyncFlag(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.PhysicsSprite3D",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.PhysicsMeshRenderer",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::PhysicsSprite3D*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::PhysicsMeshRenderer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_setSyncFlag'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_PhysicsMeshRenderer_setSyncFlag'", nullptr); return 0; } #endif @@ -4143,30 +4143,30 @@ int lua_cocos2dx_physics3d_PhysicsSprite3D_setSyncFlag(lua_State* tolua_S) { cocos2d::Physics3DComponent::PhysicsSyncFlag arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.PhysicsSprite3D:setSyncFlag"); + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.PhysicsMeshRenderer:setSyncFlag"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_setSyncFlag'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_PhysicsMeshRenderer_setSyncFlag'", nullptr); return 0; } cobj->setSyncFlag(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PhysicsSprite3D:setSyncFlag",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PhysicsMeshRenderer:setSyncFlag",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_setSyncFlag'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_PhysicsMeshRenderer_setSyncFlag'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_physics3d_PhysicsSprite3D_constructor(lua_State* tolua_S) +int lua_cocos2dx_physics3d_PhysicsMeshRenderer_constructor(lua_State* tolua_S) { int argc = 0; - cocos2d::PhysicsSprite3D* cobj = nullptr; + cocos2d::PhysicsMeshRenderer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -4180,47 +4180,47 @@ int lua_cocos2dx_physics3d_PhysicsSprite3D_constructor(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_constructor'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_PhysicsMeshRenderer_constructor'", nullptr); return 0; } - cobj = new cocos2d::PhysicsSprite3D(); + cobj = new cocos2d::PhysicsMeshRenderer(); cobj->autorelease(); int ID = (int)cobj->_ID ; int* luaID = &cobj->_luaID ; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.PhysicsSprite3D"); + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.PhysicsMeshRenderer"); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PhysicsSprite3D:PhysicsSprite3D",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PhysicsMeshRenderer:PhysicsMeshRenderer",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_constructor'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_PhysicsMeshRenderer_constructor'.",&tolua_err); #endif return 0; } -static int lua_cocos2dx_physics3d_PhysicsSprite3D_finalize(lua_State* tolua_S) +static int lua_cocos2dx_physics3d_PhysicsMeshRenderer_finalize(lua_State* tolua_S) { - printf("luabindings: finalizing LUA object (PhysicsSprite3D)"); + printf("luabindings: finalizing LUA object (PhysicsMeshRenderer)"); return 0; } -int lua_register_cocos2dx_physics3d_PhysicsSprite3D(lua_State* tolua_S) +int lua_register_cocos2dx_physics3d_PhysicsMeshRenderer(lua_State* tolua_S) { - tolua_usertype(tolua_S,"cc.PhysicsSprite3D"); - tolua_cclass(tolua_S,"PhysicsSprite3D","cc.PhysicsSprite3D","cc.Sprite3D",nullptr); + tolua_usertype(tolua_S,"cc.PhysicsMeshRenderer"); + tolua_cclass(tolua_S,"PhysicsMeshRenderer","cc.PhysicsMeshRenderer","cc.Sprite3D",nullptr); - tolua_beginmodule(tolua_S,"PhysicsSprite3D"); - tolua_function(tolua_S,"new",lua_cocos2dx_physics3d_PhysicsSprite3D_constructor); - tolua_function(tolua_S,"syncNodeToPhysics",lua_cocos2dx_physics3d_PhysicsSprite3D_syncNodeToPhysics); - tolua_function(tolua_S,"syncPhysicsToNode",lua_cocos2dx_physics3d_PhysicsSprite3D_syncPhysicsToNode); - tolua_function(tolua_S,"getPhysicsObj",lua_cocos2dx_physics3d_PhysicsSprite3D_getPhysicsObj); - tolua_function(tolua_S,"setSyncFlag",lua_cocos2dx_physics3d_PhysicsSprite3D_setSyncFlag); + tolua_beginmodule(tolua_S,"PhysicsMeshRenderer"); + tolua_function(tolua_S,"new",lua_cocos2dx_physics3d_PhysicsMeshRenderer_constructor); + tolua_function(tolua_S,"syncNodeToPhysics",lua_cocos2dx_physics3d_PhysicsMeshRenderer_syncNodeToPhysics); + tolua_function(tolua_S,"syncPhysicsToNode",lua_cocos2dx_physics3d_PhysicsMeshRenderer_syncPhysicsToNode); + tolua_function(tolua_S,"getPhysicsObj",lua_cocos2dx_physics3d_PhysicsMeshRenderer_getPhysicsObj); + tolua_function(tolua_S,"setSyncFlag",lua_cocos2dx_physics3d_PhysicsMeshRenderer_setSyncFlag); tolua_endmodule(tolua_S); - auto typeName = typeid(cocos2d::PhysicsSprite3D).name(); // rtti is literal storage - g_luaType[reinterpret_cast(typeName)] = "cc.PhysicsSprite3D"; - g_typeCast[typeName] = "cc.PhysicsSprite3D"; + auto typeName = typeid(cocos2d::PhysicsMeshRenderer).name(); // rtti is literal storage + g_luaType[reinterpret_cast(typeName)] = "cc.PhysicsMeshRenderer"; + g_typeCast[typeName] = "cc.PhysicsMeshRenderer"; return 1; } @@ -12373,7 +12373,7 @@ TOLUA_API int register_all_cocos2dx_physics3d(lua_State* tolua_S) lua_register_cocos2dx_physics3d_Physics3DComponent(tolua_S); lua_register_cocos2dx_physics3d_Physics3DConeTwistConstraint(tolua_S); lua_register_cocos2dx_physics3d_Physics3DPointToPointConstraint(tolua_S); - lua_register_cocos2dx_physics3d_PhysicsSprite3D(tolua_S); + lua_register_cocos2dx_physics3d_PhysicsMeshRenderer(tolua_S); lua_register_cocos2dx_physics3d_Physics3DHingeConstraint(tolua_S); lua_register_cocos2dx_physics3d_Physics3DShape(tolua_S); diff --git a/extensions/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp b/extensions/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp index 69cd66a06c..904ab386bd 100644 --- a/extensions/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp +++ b/extensions/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp @@ -27,29 +27,29 @@ #include "scripting/lua-bindings/manual/LuaBasicConversions.h" #include "scripting/lua-bindings/manual/CCLuaEngine.h" #include "3d/CCBundle3D.h" -#include "3d/CCSprite3D.h" +#include "3d/CCMeshRenderer.h" #include "3d/CCTerrain.h" -int lua_cocos2dx_3d_Sprite3D_getAABB(lua_State* L) +int lua_cocos2dx_3d_MeshRenderer_getAABB(lua_State* L) { int argc = 0; - cocos2d::Sprite3D* cobj = nullptr; + cocos2d::MeshRenderer* cobj = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(L, 1, "cc.Sprite3D", 0, &tolua_err)) + if (!tolua_isusertype(L, 1, "cc.MeshRenderer", 0, &tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Sprite3D*)tolua_tousertype(L, 1, 0); + cobj = (cocos2d::MeshRenderer*)tolua_tousertype(L, 1, 0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(L, "invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_getAABB'", nullptr); + tolua_error(L, "invalid 'cobj' in function 'lua_cocos2dx_3d_MeshRenderer_getAABB'", nullptr); return 0; } #endif @@ -61,17 +61,17 @@ int lua_cocos2dx_3d_Sprite3D_getAABB(lua_State* L) object_to_luaval(L, "cc.AABB", (cocos2d::AABB*)ret); return 1; } - luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:getAABB", argc, 0); + luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MeshRenderer:getAABB", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(L, "#ferror in function 'lua_cocos2dx_3d_Sprite3D_getAABB'.", &tolua_err); + tolua_error(L, "#ferror in function 'lua_cocos2dx_3d_MeshRenderer_getAABB'.", &tolua_err); #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_createAsync(lua_State* L) +int lua_cocos2dx_3d_MeshRenderer_createAsync(lua_State* L) { int argc = 0; bool ok = true; @@ -80,7 +80,7 @@ int lua_cocos2dx_3d_Sprite3D_createAsync(lua_State* L) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(L, 1, "cc.Sprite3D", 0, &tolua_err)) + if (!tolua_isusertable(L, 1, "cc.MeshRenderer", 0, &tolua_err)) goto tolua_lerror; #endif @@ -91,11 +91,11 @@ int lua_cocos2dx_3d_Sprite3D_createAsync(lua_State* L) if (argc == 3) { std::string modelPath; - ok &= luaval_to_std_string(L, 2, &modelPath, "cc.Sprite3D:createAsync"); + ok &= luaval_to_std_string(L, 2, &modelPath, "cc.MeshRenderer:createAsync"); if (!ok) break; std::string texturePath; - ok &= luaval_to_std_string(L, 3, &texturePath, "cc.Sprite3D:createAsync"); + ok &= luaval_to_std_string(L, 3, &texturePath, "cc.MeshRenderer:createAsync"); if (!ok) break; @@ -107,13 +107,13 @@ int lua_cocos2dx_3d_Sprite3D_createAsync(lua_State* L) #endif LUA_FUNCTION handler = toluafix_ref_function(L, 4, 0); - cocos2d::Sprite3D::createAsync( + cocos2d::MeshRenderer::createAsync( modelPath, texturePath, - [=](cocos2d::Sprite3D* sprite, void* callbackparam) { + [=](cocos2d::MeshRenderer* mesh, void* callbackparam) { auto stack = LuaEngine::getInstance()->getLuaStack(); - int id = (sprite) ? (int)sprite->_ID : -1; - int* luaID = (sprite) ? &sprite->_luaID : nullptr; - toluafix_pushusertype_ccobject(stack->getLuaState(), id, luaID, (void*)sprite, "cc.Sprite3D"); + int id = (mesh) ? (int)mesh->_ID : -1; + int* luaID = (mesh) ? &mesh->_luaID : nullptr; + toluafix_pushusertype_ccobject(stack->getLuaState(), id, luaID, (void*)mesh, "cc.MeshRenderer"); stack->executeFunctionByHandler(handler, 1); }, nullptr); @@ -128,7 +128,7 @@ int lua_cocos2dx_3d_Sprite3D_createAsync(lua_State* L) if (argc == 2) { std::string modelPath; - ok &= luaval_to_std_string(L, 2, &modelPath, "cc.Sprite3D:createAsync"); + ok &= luaval_to_std_string(L, 2, &modelPath, "cc.MeshRenderer:createAsync"); if (!ok) break; @@ -140,13 +140,13 @@ int lua_cocos2dx_3d_Sprite3D_createAsync(lua_State* L) #endif LUA_FUNCTION handler = toluafix_ref_function(L, 3, 0); - cocos2d::Sprite3D::createAsync( + cocos2d::MeshRenderer::createAsync( modelPath, - [=](cocos2d::Sprite3D* sprite, void* callbackparam) { + [=](cocos2d::MeshRenderer* mesh, void* callbackparam) { auto stack = LuaEngine::getInstance()->getLuaStack(); - int id = (sprite) ? (int)sprite->_ID : -1; - int* luaID = (sprite) ? &sprite->_luaID : nullptr; - toluafix_pushusertype_ccobject(stack->getLuaState(), id, luaID, (void*)sprite, "cc.Sprite3D"); + int id = (mesh) ? (int)mesh->_ID : -1; + int* luaID = (mesh) ? &mesh->_luaID : nullptr; + toluafix_pushusertype_ccobject(stack->getLuaState(), id, luaID, (void*)mesh, "cc.MeshRenderer"); stack->executeFunctionByHandler(handler, 1); }, nullptr); @@ -156,23 +156,23 @@ int lua_cocos2dx_3d_Sprite3D_createAsync(lua_State* L) } } while (0); ok = true; - luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d", "cc.Sprite3D:createAsync", argc, 3); + luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d", "cc.MeshRenderer:createAsync", argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(L, "#ferror in function 'lua_cocos2dx_3d_Sprite3D_createAsync'.", &tolua_err); + tolua_error(L, "#ferror in function 'lua_cocos2dx_3d_MeshRenderer_createAsync'.", &tolua_err); #endif return 0; } -static void extendSprite3D(lua_State* L) +static void extendMeshRenderer(lua_State* L) { - lua_pushstring(L, "cc.Sprite3D"); + lua_pushstring(L, "cc.MeshRenderer"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L, -1)) { - tolua_function(L, "getAABB", lua_cocos2dx_3d_Sprite3D_getAABB); - tolua_function(L, "createAsync", lua_cocos2dx_3d_Sprite3D_createAsync); + tolua_function(L, "getAABB", lua_cocos2dx_3d_MeshRenderer_getAABB); + tolua_function(L, "createAsync", lua_cocos2dx_3d_MeshRenderer_createAsync); } lua_pop(L, 1); } @@ -656,7 +656,7 @@ static int register_all_cocos2dx_3d_manual(lua_State* L) if (nullptr == L) return 0; - extendSprite3D(L); + extendMeshRenderer(L); extendTerrain(L); extendBundle3D(L); return 0; diff --git a/extensions/scripting/lua-bindings/manual/physics3d/lua_cocos2dx_physics3d_manual.cpp b/extensions/scripting/lua-bindings/manual/physics3d/lua_cocos2dx_physics3d_manual.cpp index b6b29b609b..c3d2acdfbb 100644 --- a/extensions/scripting/lua-bindings/manual/physics3d/lua_cocos2dx_physics3d_manual.cpp +++ b/extensions/scripting/lua-bindings/manual/physics3d/lua_cocos2dx_physics3d_manual.cpp @@ -186,7 +186,7 @@ void Physics3DWorld_HitResult_to_luaval(lua_State* L, const cocos2d::Physics3DWo lua_rawset(L, -3); } -int lua_cocos2dx_physics3d_PhysicsSprite3D_create(lua_State* L) +int lua_cocos2dx_physics3d_PhysicsMeshRenderer_create(lua_State* L) { int argc = 0; bool ok = true; @@ -196,7 +196,7 @@ int lua_cocos2dx_physics3d_PhysicsSprite3D_create(lua_State* L) # endif # if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(L, 1, "cc.PhysicsSprite3D", 0, &tolua_err)) + if (!tolua_isusertable(L, 1, "cc.PhysicsMeshRenderer", 0, &tolua_err)) goto tolua_lerror; # endif @@ -206,15 +206,15 @@ int lua_cocos2dx_physics3d_PhysicsSprite3D_create(lua_State* L) { std::string arg0; cocos2d::Physics3DRigidBodyDes arg1; - ok &= luaval_to_std_string(L, 2, &arg0, "cc.PhysicsSprite3D:create"); - ok &= luaval_to_Physics3DRigidBodyDes(L, 3, &arg1, "cc.PhysicsSprite3D:create"); + ok &= luaval_to_std_string(L, 2, &arg0, "cc.PhysicsMeshRenderer:create"); + ok &= luaval_to_Physics3DRigidBodyDes(L, 3, &arg1, "cc.PhysicsMeshRenderer:create"); if (!ok) { - tolua_error(L, "invalid arguments in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_create'", nullptr); + tolua_error(L, "invalid arguments in function 'lua_cocos2dx_physics3d_PhysicsMeshRenderer_create'", nullptr); return 0; } - cocos2d::PhysicsSprite3D* ret = cocos2d::PhysicsSprite3D::create(arg0, &arg1); - object_to_luaval(L, "cc.PhysicsSprite3D", (cocos2d::PhysicsSprite3D*)ret); + cocos2d::PhysicsMeshRenderer* ret = cocos2d::PhysicsMeshRenderer::create(arg0, &arg1); + object_to_luaval(L, "cc.PhysicsMeshRenderer", (cocos2d::PhysicsMeshRenderer*)ret); return 1; } if (argc == 3) @@ -222,16 +222,16 @@ int lua_cocos2dx_physics3d_PhysicsSprite3D_create(lua_State* L) std::string arg0; cocos2d::Physics3DRigidBodyDes arg1; cocos2d::Vec3 arg2; - ok &= luaval_to_std_string(L, 2, &arg0, "cc.PhysicsSprite3D:create"); - ok &= luaval_to_Physics3DRigidBodyDes(L, 3, &arg1, "cc.PhysicsSprite3D:create"); - ok &= luaval_to_vec3(L, 4, &arg2, "cc.PhysicsSprite3D:create"); + ok &= luaval_to_std_string(L, 2, &arg0, "cc.PhysicsMeshRenderer:create"); + ok &= luaval_to_Physics3DRigidBodyDes(L, 3, &arg1, "cc.PhysicsMeshRenderer:create"); + ok &= luaval_to_vec3(L, 4, &arg2, "cc.PhysicsMeshRenderer:create"); if (!ok) { - tolua_error(L, "invalid arguments in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_create'", nullptr); + tolua_error(L, "invalid arguments in function 'lua_cocos2dx_physics3d_PhysicsMeshRenderer_create'", nullptr); return 0; } - cocos2d::PhysicsSprite3D* ret = cocos2d::PhysicsSprite3D::create(arg0, &arg1, arg2); - object_to_luaval(L, "cc.PhysicsSprite3D", (cocos2d::PhysicsSprite3D*)ret); + cocos2d::PhysicsMeshRenderer* ret = cocos2d::PhysicsMeshRenderer::create(arg0, &arg1, arg2); + object_to_luaval(L, "cc.PhysicsMeshRenderer", (cocos2d::PhysicsMeshRenderer*)ret); return 1; } if (argc == 4) @@ -240,35 +240,35 @@ int lua_cocos2dx_physics3d_PhysicsSprite3D_create(lua_State* L) cocos2d::Physics3DRigidBodyDes arg1; cocos2d::Vec3 arg2; cocos2d::Quaternion arg3; - ok &= luaval_to_std_string(L, 2, &arg0, "cc.PhysicsSprite3D:create"); - ok &= luaval_to_Physics3DRigidBodyDes(L, 3, &arg1, "cc.PhysicsSprite3D:create"); - ok &= luaval_to_vec3(L, 4, &arg2, "cc.PhysicsSprite3D:create"); + ok &= luaval_to_std_string(L, 2, &arg0, "cc.PhysicsMeshRenderer:create"); + ok &= luaval_to_Physics3DRigidBodyDes(L, 3, &arg1, "cc.PhysicsMeshRenderer:create"); + ok &= luaval_to_vec3(L, 4, &arg2, "cc.PhysicsMeshRenderer:create"); ok &= luaval_to_quaternion(L, 5, &arg3); if (!ok) { - tolua_error(L, "invalid arguments in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_create'", nullptr); + tolua_error(L, "invalid arguments in function 'lua_cocos2dx_physics3d_PhysicsMeshRenderer_create'", nullptr); return 0; } - cocos2d::PhysicsSprite3D* ret = cocos2d::PhysicsSprite3D::create(arg0, &arg1, arg2, arg3); - object_to_luaval(L, "cc.PhysicsSprite3D", (cocos2d::PhysicsSprite3D*)ret); + cocos2d::PhysicsMeshRenderer* ret = cocos2d::PhysicsMeshRenderer::create(arg0, &arg1, arg2, arg3); + object_to_luaval(L, "cc.PhysicsMeshRenderer", (cocos2d::PhysicsMeshRenderer*)ret); return 1; } - luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.PhysicsSprite3D:create", argc, 2); + luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.PhysicsMeshRenderer:create", argc, 2); return 0; # if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(L, "#ferror in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_create'.", &tolua_err); + tolua_error(L, "#ferror in function 'lua_cocos2dx_physics3d_PhysicsMeshRenderer_create'.", &tolua_err); # endif return 0; } -void extendPhysicsSprite3D(lua_State* L) +void extendPhysicsMeshRenderer(lua_State* L) { - lua_pushstring(L, "cc.PhysicsSprite3D"); + lua_pushstring(L, "cc.PhysicsMeshRenderer"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L, -1)) { - tolua_function(L, "create", lua_cocos2dx_physics3d_PhysicsSprite3D_create); + tolua_function(L, "create", lua_cocos2dx_physics3d_PhysicsMeshRenderer_create); } lua_pop(L, 1); } @@ -847,7 +847,7 @@ int register_all_physics3d_manual(lua_State* L) if (nullptr == L) return 0; - extendPhysicsSprite3D(L); + extendPhysicsMeshRenderer(L); extendPhysics3DRigidBody(L); extendPhysics3DComponent(L); extendPhysics3DWorld(L); diff --git a/tests/cpp-tests/CMakeLists.txt b/tests/cpp-tests/CMakeLists.txt index ef0a76ab3f..6b8e518bc3 100644 --- a/tests/cpp-tests/CMakeLists.txt +++ b/tests/cpp-tests/CMakeLists.txt @@ -160,8 +160,8 @@ list(APPEND GAME_HEADER Classes/ExtensionsTest/ExtensionsTest.h Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.h Classes/ExtensionsTest/TableViewTest/TableViewTestScene.h - Classes/Sprite3DTest/Sprite3DTest.h - Classes/Sprite3DTest/DrawNode3D.h + Classes/MeshRendererTest/MeshRendererTest.h + Classes/MeshRendererTest/DrawNode3D.h Classes/BaseTest.h Classes/SceneTest/SceneTest.h Classes/ReleasePoolTest/ReleasePoolTest.h @@ -296,8 +296,8 @@ list(APPEND GAME_SOURCE Classes/ShaderTest/ShaderTest2.cpp Classes/SpineTest/SpineTest.cpp # Classes/Scene3DTest/Scene3DTest.cpp - Classes/Sprite3DTest/DrawNode3D.cpp - Classes/Sprite3DTest/Sprite3DTest.cpp + Classes/MeshRendererTest/DrawNode3D.cpp + Classes/MeshRendererTest/MeshRendererTest.cpp Classes/SpritePolygonTest/SpritePolygonTest.cpp Classes/SpriteTest/SpriteTest.cpp Classes/TerrainTest/TerrainTest.cpp diff --git a/tests/cpp-tests/Classes/AppDelegate.cpp b/tests/cpp-tests/Classes/AppDelegate.cpp index 2c0fd009d3..7a5b6e4463 100644 --- a/tests/cpp-tests/Classes/AppDelegate.cpp +++ b/tests/cpp-tests/Classes/AppDelegate.cpp @@ -85,7 +85,12 @@ bool AppDelegate::applicationDidFinishLaunching() } director->setStatsDisplay(true); + +#ifdef CC_PLATFORM_PC + director->setAnimationInterval(1.0f / glfwGetVideoMode(glfwGetPrimaryMonitor())->refreshRate); +#else director->setAnimationInterval(1.0f / 60); +#endif auto screenSize = glview->getFrameSize(); diff --git a/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp b/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp index c23c610a84..d2f060925a 100644 --- a/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp +++ b/tests/cpp-tests/Classes/BillBoardTest/BillBoardTest.cpp @@ -47,11 +47,11 @@ BillBoardTests::BillBoardTests() //------------------------------------------------------------------ BillBoardRotationTest::BillBoardRotationTest() { - auto root = Sprite3D::create(); + auto root = MeshRenderer::create(); root->setPositionNormalized(Vec2(0.5f, 0.25f)); addChild(root); - auto model = Sprite3D::create("Sprite3DTest/orc.c3b"); + auto model = MeshRenderer::create("MeshRendererTest/orc.c3b"); model->setScale(5); model->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); root->addChild(model); @@ -150,11 +150,11 @@ BillBoardTest::BillBoardTest() : _camera(nullptr) _billboards.push_back(billboard); _billboards.push_back(billboard2); - auto sprite3d = Sprite3D::create("Sprite3DTest/orc.c3t"); - sprite3d->setScale(2.0f); - sprite3d->addChild(billboard); - sprite3d->runAction(RepeatForever::create(RotateBy::create(10.0f, Vec3(0.0f, 360.0f, 0.0f)))); - _layerBillBoard->addChild(sprite3d); + auto mesh = MeshRenderer::create("MeshRendererTest/orc.c3t"); + mesh->setScale(2.0f); + mesh->addChild(billboard); + mesh->runAction(RepeatForever::create(RotateBy::create(10.0f, Vec3(0.0f, 360.0f, 0.0f)))); + _layerBillBoard->addChild(mesh); } addNewBillBoardWithCoords(Vec3(20.0f, 5.0f, 0.0f)); diff --git a/tests/cpp-tests/Classes/BugsTest/Bug-15594.cpp b/tests/cpp-tests/Classes/BugsTest/Bug-15594.cpp index 9ff0cf758e..9e0deeb34a 100644 --- a/tests/cpp-tests/Classes/BugsTest/Bug-15594.cpp +++ b/tests/cpp-tests/Classes/BugsTest/Bug-15594.cpp @@ -40,15 +40,15 @@ bool Bug15594Layer::init() { if (BugsTestBase::init()) { - auto sprite3d = Sprite3D::create("Images/bugs/bug15594.c3t", "Images/bugs/bug15594.jpg"); - addChild(sprite3d); + auto mesh = MeshRenderer::create("Images/bugs/bug15594.c3t", "Images/bugs/bug15594.jpg"); + addChild(mesh); auto size = Director::getInstance()->getWinSize(); - sprite3d->setPosition(size / 2); + mesh->setPosition(size / 2); auto animation = Animation3D::create("Images/bugs/bug15594.c3t"); auto animate = Animate3D::create(animation); auto repeat = RepeatForever::create(animate); - sprite3d->runAction(repeat); + mesh->runAction(repeat); return true; } diff --git a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp index 3d0c1bbd57..1ce2fabc71 100644 --- a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp +++ b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp @@ -77,14 +77,14 @@ CameraRotationTest::CameraRotationTest() _camNode->setPositionZ(Camera::getDefaultCamera()->getPosition3D().z); _camControlNode->addChild(_camNode); - auto sp3d = Sprite3D::create(); - sp3d->setPosition(s.width / 2, s.height / 2); - addChild(sp3d); + auto mesh = MeshRenderer::create(); + mesh->setPosition(s.width / 2, s.height / 2); + addChild(mesh); auto lship = Label::create(); lship->setString("Ship"); lship->setPosition(0, 20); - sp3d->addChild(lship); + mesh->addChild(lship); // Billboards // Yellow is at the back @@ -92,7 +92,7 @@ CameraRotationTest::CameraRotationTest() bill1->setPosition3D(Vec3(50.0f, 10.0f, -10.0f)); bill1->setColor(Color3B::YELLOW); bill1->setScale(0.6f); - sp3d->addChild(bill1); + mesh->addChild(bill1); l1 = Label::create(); l1->setPosition(Vec2(0.0f, -10.0f)); @@ -108,7 +108,7 @@ CameraRotationTest::CameraRotationTest() bill2 = BillBoard::create("Images/Icon.png"); bill2->setPosition3D(Vec3(-50.0f, -10.0f, 10.0f)); bill2->setScale(0.6f); - sp3d->addChild(bill2); + mesh->addChild(bill2); l2 = Label::create(); l2->setString("Billboard2"); @@ -122,9 +122,9 @@ CameraRotationTest::CameraRotationTest() bill2->addChild(p2); // 3D models - auto model = Sprite3D::create("Sprite3DTest/boss1.obj"); + auto model = MeshRenderer::create("MeshRendererTest/boss1.obj"); model->setScale(4); - model->setTexture("Sprite3DTest/boss.png"); + model->setTexture("MeshRendererTest/boss.png"); model->setPosition3D(Vec3(s.width / 2, s.height / 2, 0)); addChild(model); @@ -226,8 +226,8 @@ void Camera3DTestDemo::SwitchViewCallback(Ref* sender, CameraType cameraType) _cameraType = cameraType; if (_cameraType == CameraType::Free) { - _camera->setPosition3D(Vec3(0, 130, 130) + _sprite3D->getPosition3D()); - _camera->lookAt(_sprite3D->getPosition3D()); + _camera->setPosition3D(Vec3(0, 130, 130) + _mesh->getPosition3D()); + _camera->lookAt(_mesh->getPosition3D()); _RotateRightlabel->setColor(Color3B::WHITE); _RotateLeftlabel->setColor(Color3B::WHITE); @@ -237,10 +237,10 @@ void Camera3DTestDemo::SwitchViewCallback(Ref* sender, CameraType cameraType) else if (_cameraType == CameraType::FirstPerson) { Vec3 newFaceDir; - _sprite3D->getWorldToNodeTransform().getForwardVector(&newFaceDir); + _mesh->getWorldToNodeTransform().getForwardVector(&newFaceDir); newFaceDir.normalize(); - _camera->setPosition3D(Vec3(0, 35, 0) + _sprite3D->getPosition3D()); - _camera->lookAt(_sprite3D->getPosition3D() + newFaceDir * 50); + _camera->setPosition3D(Vec3(0, 35, 0) + _mesh->getPosition3D()); + _camera->lookAt(_mesh->getPosition3D() + newFaceDir * 50); _RotateRightlabel->setColor(Color3B::WHITE); _RotateLeftlabel->setColor(Color3B::WHITE); @@ -249,8 +249,8 @@ void Camera3DTestDemo::SwitchViewCallback(Ref* sender, CameraType cameraType) } else if (_cameraType == CameraType::ThirdPerson) { - _camera->setPosition3D(Vec3(0, 130, 130) + _sprite3D->getPosition3D()); - _camera->lookAt(_sprite3D->getPosition3D()); + _camera->setPosition3D(Vec3(0, 130, 130) + _mesh->getPosition3D()); + _camera->lookAt(_mesh->getPosition3D()); _RotateRightlabel->setColor(Color3B::GRAY); _RotateLeftlabel->setColor(Color3B::GRAY); @@ -261,7 +261,7 @@ void Camera3DTestDemo::SwitchViewCallback(Ref* sender, CameraType cameraType) void Camera3DTestDemo::onEnter() { CameraBaseTest::onEnter(); - _sprite3D = nullptr; + _mesh = nullptr; auto s = Director::getInstance()->getWinSize(); auto listener = EventListenerTouchAllAtOnce::create(); listener->onTouchesBegan = CC_CALLBACK_2(Camera3DTestDemo::onTouchesBegan, this); @@ -272,7 +272,7 @@ void Camera3DTestDemo::onEnter() addChild(layer3D, 0); _layer3D = layer3D; _curState = State_None; - addNewSpriteWithCoords(Vec3(0, 0, 0), "Sprite3DTest/girl.c3b", true, 0.2f, true); + addNewSpriteWithCoords(Vec3(0, 0, 0), "MeshRendererTest/girl.c3b", true, 0.2f, true); TTFConfig ttfConfig("fonts/arial.ttf", 20); auto containerForLabel1 = Node::create(); @@ -389,25 +389,25 @@ void Camera3DTestDemo::addNewSpriteWithCoords(Vec3 p, float scale, bool bindCamera) { - auto sprite = Sprite3D::create(fileName); - _layer3D->addChild(sprite); - float globalZOrder = sprite->getGlobalZOrder(); - sprite->setPosition3D(Vec3(p.x, p.y, p.z)); - sprite->setGlobalZOrder(globalZOrder); + auto mesh = MeshRenderer::create(fileName); + _layer3D->addChild(mesh); + float globalZOrder = mesh->getGlobalZOrder(); + mesh->setPosition3D(Vec3(p.x, p.y, p.z)); + mesh->setGlobalZOrder(globalZOrder); if (playAnimation) { auto animation = Animation3D::create(fileName, "Take 001"); if (animation) { auto animate = Animate3D::create(animation); - sprite->runAction(RepeatForever::create(animate)); + mesh->runAction(RepeatForever::create(animate)); } } if (bindCamera) { - _sprite3D = sprite; + _mesh = mesh; } - sprite->setScale(scale); + mesh->setScale(scale); } void Camera3DTestDemo::onTouchesBegan(const std::vector& touches, cocos2d::Event* event) {} void Camera3DTestDemo::onTouchesMoved(const std::vector& touches, cocos2d::Event* event) @@ -431,25 +431,25 @@ void Camera3DTestDemo::onTouchesMoved(const std::vector& touches, cocos2 cameraPos += cameraDir * newPos.y * 0.1f; cameraPos += cameraRightDir * newPos.x * 0.1f; _camera->setPosition3D(cameraPos); - if (_sprite3D && _cameraType == CameraType::FirstPerson) + if (_mesh && _cameraType == CameraType::FirstPerson) { - _sprite3D->setPosition3D(Vec3(_camera->getPositionX(), 0, _camera->getPositionZ())); - _targetPos = _sprite3D->getPosition3D(); + _mesh->setPosition3D(Vec3(_camera->getPositionX(), 0, _camera->getPositionZ())); + _targetPos = _mesh->getPosition3D(); } } } } void Camera3DTestDemo::move3D(float elapsedTime) { - if (_sprite3D) + if (_mesh) { - Vec3 curPos = _sprite3D->getPosition3D(); + Vec3 curPos = _mesh->getPosition3D(); Vec3 newFaceDir = _targetPos - curPos; newFaceDir.y = 0.0f; newFaceDir.normalize(); Vec3 offset = newFaceDir * 25.0f * elapsedTime; curPos += offset; - _sprite3D->setPosition3D(curPos); + _mesh->setPosition3D(curPos); if (_cameraType == CameraType::ThirdPerson) { Vec3 cameraPos = _camera->getPosition3D(); @@ -461,11 +461,11 @@ void Camera3DTestDemo::move3D(float elapsedTime) } void Camera3DTestDemo::updateState(float elapsedTime) { - if (_sprite3D) + if (_mesh) { - Vec3 curPos = _sprite3D->getPosition3D(); + Vec3 curPos = _mesh->getPosition3D(); Vec3 curFaceDir; - _sprite3D->getNodeToWorldTransform().getForwardVector(&curFaceDir); + _mesh->getNodeToWorldTransform().getForwardVector(&curFaceDir); curFaceDir = -curFaceDir; curFaceDir.normalize(); Vec3 newFaceDir = _targetPos - curPos; @@ -497,7 +497,7 @@ void Camera3DTestDemo::onTouchesEnded(const std::vector& touches, cocos2 auto location = touch->getLocationInView(); if (_camera) { - if (_sprite3D && _cameraType == CameraType::ThirdPerson && _bZoomOut == false && _bZoomIn == false && + if (_mesh && _cameraType == CameraType::ThirdPerson && _bZoomOut == false && _bZoomIn == false && _bRotateLeft == false && _bRotateRight == false) { Vec3 nearP(location.x, location.y, -1.0f), farP(location.x, location.y, 1.0f); @@ -531,7 +531,7 @@ void Camera3DTestDemo::onTouchesEnded(const std::vector& touches, cocos2 void onTouchesCancelled(const std::vector& touches, cocos2d::Event* event) {} void Camera3DTestDemo::updateCamera(float fDelta) { - if (_sprite3D) + if (_mesh) { if (_cameraType == CameraType::ThirdPerson) { @@ -541,13 +541,13 @@ void Camera3DTestDemo::updateCamera(float fDelta) move3D(fDelta); if (isState(_curState, State_Rotate)) { - Vec3 curPos = _sprite3D->getPosition3D(); + Vec3 curPos = _mesh->getPosition3D(); Vec3 newFaceDir = _targetPos - curPos; newFaceDir.y = 0; newFaceDir.normalize(); Vec3 up; - _sprite3D->getNodeToWorldTransform().getUpVector(&up); + _mesh->getNodeToWorldTransform().getUpVector(&up); up.normalize(); Vec3 right; Vec3::cross(-newFaceDir, up, &right); @@ -573,7 +573,7 @@ void Camera3DTestDemo::updateCamera(float fDelta) mat.m[13] = pos.y; mat.m[14] = pos.z; mat.m[15] = 1.0f; - _sprite3D->setAdditionalTransform(&mat); + _mesh->setAdditionalTransform(&mat); } } } @@ -583,7 +583,7 @@ void Camera3DTestDemo::updateCamera(float fDelta) { if (_cameraType == CameraType::ThirdPerson) { - Vec3 lookDir = _camera->getPosition3D() - _sprite3D->getPosition3D(); + Vec3 lookDir = _camera->getPosition3D() - _mesh->getPosition3D(); Vec3 cameraPos = _camera->getPosition3D(); if (lookDir.length() <= 300) { @@ -608,7 +608,7 @@ void Camera3DTestDemo::updateCamera(float fDelta) { if (_cameraType == CameraType::ThirdPerson) { - Vec3 lookDir = _camera->getPosition3D() - _sprite3D->getPosition3D(); + Vec3 lookDir = _camera->getPosition3D() - _mesh->getPosition3D(); Vec3 cameraPos = _camera->getPosition3D(); if (lookDir.length() >= 50) { @@ -747,9 +747,9 @@ void CameraCullingDemo::onEnter() // + - MenuItemFont::setFontSize(40); - auto decrease = MenuItemFont::create(" - ", CC_CALLBACK_1(CameraCullingDemo::delSpriteCallback, this)); + auto decrease = MenuItemFont::create(" - ", CC_CALLBACK_1(CameraCullingDemo::delMeshCallback, this)); decrease->setColor(Color3B(0, 200, 20)); - auto increase = MenuItemFont::create(" + ", CC_CALLBACK_1(CameraCullingDemo::addSpriteCallback, this)); + auto increase = MenuItemFont::create(" + ", CC_CALLBACK_1(CameraCullingDemo::addMeshCallback, this)); increase->setColor(Color3B(0, 200, 20)); menu = Menu::create(decrease, increase, nullptr); @@ -758,10 +758,10 @@ void CameraCullingDemo::onEnter() addChild(menu, 1); TTFConfig ttfCount("fonts/Marker Felt.ttf", 30); - _labelSprite3DCount = Label::createWithTTF(ttfCount, "0 sprits"); - _labelSprite3DCount->setColor(Color3B(0, 200, 20)); - _labelSprite3DCount->setPosition(Vec2(s.width / 2, VisibleRect::top().y - 70)); - addChild(_labelSprite3DCount); + _labelMeshCount = Label::createWithTTF(ttfCount, "0 sprits"); + _labelMeshCount->setColor(Color3B(0, 200, 20)); + _labelMeshCount->setPosition(Vec2(s.width / 2, VisibleRect::top().y - 70)); + addChild(_labelMeshCount); // aabb drawNode3D _drawAABB = DrawNode3D::create(); @@ -777,7 +777,7 @@ void CameraCullingDemo::onEnter() switchViewCallback(this); // add sprite - addSpriteCallback(nullptr); + addMeshCallback(nullptr); } void CameraCullingDemo::onExit() @@ -805,7 +805,7 @@ void CameraCullingDemo::update(float dt) for (const auto& iter : children) { - const AABB& aabb = static_cast(iter)->getAABB(); + const AABB& aabb = static_cast(iter)->getAABB(); if (_cameraFirst->isVisibleInFrustum(&aabb)) { aabb.getCorners(corners); @@ -872,7 +872,7 @@ void CameraCullingDemo::switchViewCallback(Ref* sender) } } -void CameraCullingDemo::addSpriteCallback(Ref* sender) +void CameraCullingDemo::addMeshCallback(Ref* sender) { _layer3D->removeAllChildren(); _objects.clear(); @@ -883,7 +883,7 @@ void CameraCullingDemo::addSpriteCallback(Ref* sender) { for (int z = -_row; z < _row; z++) { - auto sprite = Sprite3D::create("Sprite3DTest/orc.c3b"); + auto sprite = MeshRenderer::create("MeshRendererTest/orc.c3b"); sprite->setPosition3D(Vec3(x * 30.0f, 0.0f, z * 30.0f)); sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); _objects.push_back(sprite); @@ -897,10 +897,10 @@ void CameraCullingDemo::addSpriteCallback(Ref* sender) // update sprite number char szText[16]; sprintf(szText, "%d sprits", static_cast(_layer3D->getChildrenCount())); - _labelSprite3DCount->setString(szText); + _labelMeshCount->setString(szText); } -void CameraCullingDemo::delSpriteCallback(Ref* sender) +void CameraCullingDemo::delMeshCallback(Ref* sender) { if (_row == 0) return; @@ -913,7 +913,7 @@ void CameraCullingDemo::delSpriteCallback(Ref* sender) { for (int z = -_row; z < _row; z++) { - auto sprite = Sprite3D::create("Sprite3DTest/orc.c3b"); + auto sprite = MeshRenderer::create("MeshRendererTest/orc.c3b"); sprite->setPosition3D(Vec3(x * 30.0f, 0.0f, z * 30.0f)); _objects.push_back(sprite); _layer3D->addChild(sprite); @@ -926,7 +926,7 @@ void CameraCullingDemo::delSpriteCallback(Ref* sender) // update sprite number char szText[16]; sprintf(szText, "%l sprits", static_cast(_layer3D->getChildrenCount())); - _labelSprite3DCount->setString(szText); + _labelMeshCount->setString(szText); } void CameraCullingDemo::drawCameraFrustum() @@ -993,8 +993,8 @@ CameraArcBallDemo::CameraArcBallDemo() , _operate(OperateCamType::RotateCamera) , _center(Vec3(0, 0, 0)) , _target(0) - , _sprite3D1(nullptr) - , _sprite3D2(nullptr) + , _mesh1(nullptr) + , _mesh2(nullptr) {} CameraArcBallDemo::~CameraArcBallDemo() {} @@ -1043,17 +1043,17 @@ void CameraArcBallDemo::onEnter() _layer3D->addChild(_camera); } - _sprite3D1 = Sprite3D::create("Sprite3DTest/orc.c3b"); - _sprite3D1->setScale(0.5); - _sprite3D1->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); - _sprite3D1->setPosition3D(Vec3(0, 0, 0)); - _layer3D->addChild(_sprite3D1); + _mesh1 = MeshRenderer::create("MeshRendererTest/orc.c3b"); + _mesh1->setScale(0.5); + _mesh1->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); + _mesh1->setPosition3D(Vec3(0, 0, 0)); + _layer3D->addChild(_mesh1); - _sprite3D2 = Sprite3D::create("Sprite3DTest/boss.c3b"); - _sprite3D2->setScale(0.6f); - _sprite3D2->setRotation3D(Vec3(-90.0f, 0.0f, 0.0f)); - _sprite3D2->setPosition3D(Vec3(20.0f, 0.0f, 0.0f)); - _layer3D->addChild(_sprite3D2); + _mesh2 = MeshRenderer::create("MeshRendererTest/boss.c3b"); + _mesh2->setScale(0.6f); + _mesh2->setRotation3D(Vec3(-90.0f, 0.0f, 0.0f)); + _mesh2->setPosition3D(Vec3(20.0f, 0.0f, 0.0f)); + _layer3D->addChild(_mesh2); _drawGrid = DrawNode3D::create(); @@ -1187,13 +1187,13 @@ void CameraArcBallDemo::switchTargetCallback(Ref* sender) if (_target == 0) { _target = 1; - _center = _sprite3D2->getPosition3D(); + _center = _mesh2->getPosition3D(); updateCameraTransform(); } else if (_target == 1) { _target = 0; - _center = _sprite3D1->getPosition3D(); + _center = _mesh1->getPosition3D(); updateCameraTransform(); } } @@ -1253,18 +1253,18 @@ void FogTestDemo::onEnter() CC_SAFE_RELEASE_NULL(_programState1); CC_SAFE_RELEASE_NULL(_programState2); - auto vertexSource = FileUtils::getInstance()->getStringFromFile("Sprite3DTest/fog.vert"); - auto fragSource = FileUtils::getInstance()->getStringFromFile("Sprite3DTest/fog.frag"); + auto vertexSource = FileUtils::getInstance()->getStringFromFile("MeshRendererTest/fog.vert"); + auto fragSource = FileUtils::getInstance()->getStringFromFile("MeshRendererTest/fog.frag"); auto program = backend::Device::getInstance()->newProgram(vertexSource, fragSource); _programState1 = new backend::ProgramState(program); _programState2 = new backend::ProgramState(program); CC_SAFE_RELEASE(program); - _sprite3D1 = Sprite3D::create("Sprite3DTest/teapot.c3b"); - _sprite3D2 = Sprite3D::create("Sprite3DTest/teapot.c3b"); + _mesh1 = MeshRenderer::create("MeshRendererTest/teapot.c3b"); + _mesh2 = MeshRenderer::create("MeshRendererTest/teapot.c3b"); - _sprite3D1->setProgramState(_programState1); - _sprite3D2->setProgramState(_programState2); + _mesh1->setProgramState(_programState1); + _mesh2->setProgramState(_programState2); auto fogColor = Vec4(0.5, 0.5, 0.5, 1.0); float fogStart = 10; @@ -1276,15 +1276,15 @@ void FogTestDemo::onEnter() SET_UNIFORM("u_fogEnd", &fogEnd, sizeof(fogEnd)); SET_UNIFORM("u_fogEquation", &fogEquation, sizeof(fogEquation)); - _layer3D->addChild(_sprite3D1); - _sprite3D1->setPosition3D(Vec3(0, 0, 0)); - _sprite3D1->setScale(2.0f); - _sprite3D1->setRotation3D(Vec3(-90.0f, 180.0f, 0.0f)); + _layer3D->addChild(_mesh1); + _mesh1->setPosition3D(Vec3(0, 0, 0)); + _mesh1->setScale(2.0f); + _mesh1->setRotation3D(Vec3(-90.0f, 180.0f, 0.0f)); - _layer3D->addChild(_sprite3D2); - _sprite3D2->setPosition3D(Vec3(0.0f, 0.0f, -20.0f)); - _sprite3D2->setScale(2.0f); - _sprite3D2->setRotation3D(Vec3(-90.0f, 180.0f, 0.0f)); + _layer3D->addChild(_mesh2); + _mesh2->setPosition3D(Vec3(0.0f, 0.0f, -20.0f)); + _mesh2->setScale(2.0f); + _mesh2->setRotation3D(Vec3(-90.0f, 180.0f, 0.0f)); if (_camera == nullptr) { @@ -1303,14 +1303,14 @@ void FogTestDemo::onEnter() CC_SAFE_RELEASE_NULL(_programState1); CC_SAFE_RELEASE_NULL(_programState2); - auto vertexSource = FileUtils::getInstance()->getStringFromFile("Sprite3DTest/fog.vert"); - auto fragSource = FileUtils::getInstance()->getStringFromFile("Sprite3DTest/fog.frag"); + auto vertexSource = FileUtils::getInstance()->getStringFromFile("MeshRendererTest/fog.vert"); + auto fragSource = FileUtils::getInstance()->getStringFromFile("MeshRendererTest/fog.frag"); auto program = backend::Device::getInstance()->newProgram(vertexSource, fragSource); _programState1 = new backend::ProgramState(program); _programState2 = new backend::ProgramState(program); - _sprite3D1->setProgramState(_programState1); - _sprite3D2->setProgramState(_programState2); + _mesh1->setProgramState(_programState1); + _mesh2->setProgramState(_programState2); CC_SAFE_RELEASE(program); auto fogColor = Vec4(0.5, 0.5, 0.5, 1.0); @@ -1429,8 +1429,8 @@ void FogTestDemo::onTouchesMoved(const std::vector& touches, cocos2d::Ev // CameraBaseTest::onEnter(); // //auto sprite = Sprite::createWithTexture(fbo); // //sprite->setPosition(Vec2(100,100)); -// //std::string filename = "Sprite3DTest/girl.c3b"; -// //auto sprite = Sprite3D::create(filename); +// //std::string filename = "MeshRendererTest/girl.c3b"; +// //auto sprite = MeshRenderer::create(filename); // //sprite->setScale(1.0); // //auto animation = Animation3D::create(filename); // //if (animation) @@ -1500,10 +1500,10 @@ void BackgroundColorBrushTest::onEnter() addChild(camera); // 3D model - auto model = Sprite3D::create("Sprite3DTest/boss1.obj"); + auto model = MeshRenderer::create("MeshRendererTest/boss1.obj"); model->setScale(4); model->setPosition3D(Vec3(20.0f, 0.0f, 0.0f)); - model->setTexture("Sprite3DTest/boss.png"); + model->setTexture("MeshRendererTest/boss.png"); model->setCameraMask(static_cast(CameraFlag::USER1)); addChild(model); model->runAction(RepeatForever::create(RotateBy::create(1.f, Vec3(10.0f, 20.0f, 30.0f)))); @@ -1538,10 +1538,10 @@ void BackgroundColorBrushTest::onEnter() addChild(slider); // 3D model for 2nd camera - auto model = Sprite3D::create("Sprite3DTest/boss1.obj"); + auto model = MeshRenderer::create("MeshRendererTest/boss1.obj"); model->setScale(4); model->setPosition3D(Vec3(-20.0f, 0.0f, 0.0f)); - model->setTexture("Sprite3DTest/boss.png"); + model->setTexture("MeshRendererTest/boss.png"); model->setCameraMask(static_cast(CameraFlag::USER2)); base->addChild(model); model->runAction(RepeatForever::create(RotateBy::create(1.f, Vec3(10.0f, 20.0f, 30.0f)))); diff --git a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.h b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.h index a484ca6b64..060cba780e 100644 --- a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.h +++ b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.h @@ -26,7 +26,7 @@ THE SOFTWARE. #pragma once #include "../BaseTest.h" -#include "../Sprite3DTest/DrawNode3D.h" +#include "../MeshRendererTest/DrawNode3D.h" #include "renderer/backend/ProgramState.h" #include "renderer/backend/Types.h" @@ -35,7 +35,7 @@ THE SOFTWARE. namespace cocos2d { -class Sprite3D; +class MeshRenderer; class Delay; } // namespace cocos2d @@ -142,7 +142,7 @@ public: protected: std::string _title; cocos2d::Layer* _layer3D; - cocos2d::Sprite3D* _sprite3D; + cocos2d::MeshRenderer* _mesh; cocos2d::Vec3 _targetPos; CameraType _cameraType; cocos2d::MenuItem* _incRot; @@ -176,15 +176,15 @@ public: virtual std::string title() const override; void reachEndCallBack(); void switchViewCallback(cocos2d::Ref* sender); - void addSpriteCallback(cocos2d::Ref* sender); - void delSpriteCallback(cocos2d::Ref* sender); + void addMeshCallback(cocos2d::Ref* sender); + void delMeshCallback(cocos2d::Ref* sender); void drawCameraFrustum(); protected: - cocos2d::Label* _labelSprite3DCount; + cocos2d::Label* _labelMeshCount; cocos2d::Layer* _layer3D; - std::vector _objects; + std::vector _objects; CameraType _cameraType; cocos2d::Camera* _cameraFirst; cocos2d::Camera* _cameraThird; @@ -232,8 +232,8 @@ protected: OperateCamType _operate; // switch rotate or zoom cocos2d::Vec3 _center; // camera look target int _target; // switch camera look target - cocos2d::Sprite3D* _sprite3D1; - cocos2d::Sprite3D* _sprite3D2; + cocos2d::MeshRenderer* _mesh1; + cocos2d::MeshRenderer* _mesh2; }; class FogTestDemo : public CameraBaseTest @@ -259,8 +259,8 @@ protected: CameraType _cameraType = CameraType::Free; cocos2d::Layer* _layer3D = nullptr; cocos2d::Camera* _camera = nullptr; - cocos2d::Sprite3D* _sprite3D1 = nullptr; - cocos2d::Sprite3D* _sprite3D2 = nullptr; + cocos2d::MeshRenderer* _mesh1 = nullptr; + cocos2d::MeshRenderer* _mesh2 = nullptr; cocos2d::backend::ProgramState* _programState1 = nullptr; cocos2d::backend::ProgramState* _programState2 = nullptr; diff --git a/tests/cpp-tests/Classes/LightTest/LightTest.cpp b/tests/cpp-tests/Classes/LightTest/LightTest.cpp index 9d3a49cf01..fa3fda7020 100644 --- a/tests/cpp-tests/Classes/LightTest/LightTest.cpp +++ b/tests/cpp-tests/Classes/LightTest/LightTest.cpp @@ -108,8 +108,8 @@ void LightTest::addSprite() auto s = Director::getInstance()->getWinSize(); //{ - // std::string fileName = "Sprite3DTest/plane.c3b"; - // auto sprite = Sprite3D::create(fileName); + // std::string fileName = "MeshRendererTest/plane.c3b"; + // auto sprite = MeshRenderer::create(fileName); // sprite->setRotation3D(Vec3(-90.0, 0.0, 0.0)); // sprite->setScale(5.0f); // sprite->setPosition(Vec2(0.0, -50.0)); @@ -118,35 +118,35 @@ void LightTest::addSprite() //} { - std::string fileName = "Sprite3DTest/orc.c3b"; - auto sprite = Sprite3D::create(fileName); - sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); - sprite->setPosition(Vec2(0.0f, 0.0f)); - sprite->setScale(2.0); - auto sp = Sprite3D::create("Sprite3DTest/axe.c3b"); - sprite->getAttachNode("Bip001 R Hand")->addChild(sp); + std::string fileName = "MeshRendererTest/orc.c3b"; + auto mesh = MeshRenderer::create(fileName); + mesh->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); + mesh->setPosition(Vec2(0.0f, 0.0f)); + mesh->setScale(2.0); + auto m = MeshRenderer::create("MeshRendererTest/axe.c3b"); + mesh->getAttachNode("Bip001 R Hand")->addChild(m); auto animation = Animation3D::create(fileName); if (animation) { auto animate = Animate3D::create(animation); - sprite->runAction(RepeatForever::create(animate)); + mesh->runAction(RepeatForever::create(animate)); } - addChild(sprite); - sprite->setCameraMask(2); + addChild(mesh); + mesh->setCameraMask(2); } { - std::string fileName = "Sprite3DTest/sphere.c3b"; - auto sprite = Sprite3D::create(fileName); + std::string fileName = "MeshRendererTest/sphere.c3b"; + auto sprite = MeshRenderer::create(fileName); sprite->setPosition(Vec2(30.0f, 0.0f)); addChild(sprite); sprite->setCameraMask(2); } { - std::string fileName = "Sprite3DTest/sphere.c3b"; - auto sprite = Sprite3D::create(fileName); + std::string fileName = "MeshRendererTest/sphere.c3b"; + auto sprite = MeshRenderer::create(fileName); sprite->setScale(0.5f); sprite->setPosition(Vec2(-50.0f, 0.0f)); addChild(sprite); @@ -154,8 +154,8 @@ void LightTest::addSprite() } { - std::string fileName = "Sprite3DTest/sphere.c3b"; - auto sprite = Sprite3D::create(fileName); + std::string fileName = "MeshRendererTest/sphere.c3b"; + auto sprite = MeshRenderer::create(fileName); sprite->setScale(0.5f); sprite->setPosition(Vec2(-30.0f, 10.0f)); addChild(sprite); diff --git a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp index 90905776a6..8d4acb9f6f 100644 --- a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp +++ b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp @@ -45,8 +45,8 @@ MaterialSystemTest::MaterialSystemTest() ADD_TEST_CASE(Material_AutoBindings); ADD_TEST_CASE(Material_setTechnique); ADD_TEST_CASE(Material_clone); - ADD_TEST_CASE(Material_MultipleSprite3D); - ADD_TEST_CASE(Material_Sprite3DTest); + ADD_TEST_CASE(Material_MultipleMeshRenderer); + ADD_TEST_CASE(Material_MeshRendererTest); ADD_TEST_CASE(Material_parsePerformance); } @@ -57,30 +57,30 @@ std::string MaterialSystemBaseTest::title() const // MARK: Tests start here -void Material_Sprite3DTest::onEnter() +void Material_MeshRendererTest::onEnter() { MaterialSystemBaseTest::onEnter(); - auto sprite = Sprite3D::create("Sprite3DTest/boss1.obj"); - sprite->setScale(8.f); - sprite->setTexture("Sprite3DTest/boss.png"); - this->addChild(sprite); - sprite->setPositionNormalized(Vec2(0.5f, 0.5f)); + auto mesh = MeshRenderer::create("MeshRendererTest/boss1.obj"); + mesh->setScale(8.f); + mesh->setTexture("MeshRendererTest/boss.png"); + this->addChild(mesh); + mesh->setPositionNormalized(Vec2(0.5f, 0.5f)); } -std::string Material_Sprite3DTest::subtitle() const +std::string Material_MeshRendererTest::subtitle() const { - return "Material System on Sprite3D"; + return "Material System on MeshRenderer"; } -void Material_MultipleSprite3D::onEnter() +void Material_MultipleMeshRenderer::onEnter() { MaterialSystemBaseTest::onEnter(); const char* names[] = { - "Sprite3DTest/ReskinGirl.c3b", "Sprite3DTest/ReskinGirl.c3b", "Sprite3DTest/ReskinGirl.c3b", - "Sprite3DTest/ReskinGirl.c3b", "Sprite3DTest/ReskinGirl.c3b", "Sprite3DTest/ReskinGirl.c3b", - "Sprite3DTest/ReskinGirl.c3b", "Sprite3DTest/ReskinGirl.c3b", + "MeshRendererTest/ReskinGirl.c3b", "MeshRendererTest/ReskinGirl.c3b", "MeshRendererTest/ReskinGirl.c3b", + "MeshRendererTest/ReskinGirl.c3b", "MeshRendererTest/ReskinGirl.c3b", "MeshRendererTest/ReskinGirl.c3b", + "MeshRendererTest/ReskinGirl.c3b", "MeshRendererTest/ReskinGirl.c3b", }; const int totalNames = sizeof(names) / sizeof(names[0]); @@ -89,14 +89,14 @@ void Material_MultipleSprite3D::onEnter() for (int i = 0; i < totalNames; i++) { - auto sprite = Sprite3D::create(names[i]); - this->addChild(sprite); - sprite->setPosition(Vec2((size.width / (totalNames + 1)) * (i + 1), size.height / 4)); - sprite->setScale(3); + auto mesh = MeshRenderer::create(names[i]); + this->addChild(mesh); + mesh->setPosition(Vec2((size.width / (totalNames + 1)) * (i + 1), size.height / 4)); + mesh->setScale(3); } } -std::string Material_MultipleSprite3D::subtitle() const +std::string Material_MultipleMeshRenderer::subtitle() const { return "Sprites with multiple meshes"; } @@ -115,40 +115,40 @@ void Material_2DEffects::onEnter() Material* mat1 = Material::createWithProperties(properties); - auto spriteBlur = Sprite::create("Images/grossini.png"); - spriteBlur->setPositionNormalized(Vec2(0.2f, 0.5f)); - this->addChild(spriteBlur); - spriteBlur->setProgramState(mat1->getTechniqueByName("blur")->getPassByIndex(0)->getProgramState()); + auto meshBlur = Sprite::create("Images/grossini.png"); + meshBlur->setPositionNormalized(Vec2(0.2f, 0.5f)); + this->addChild(meshBlur); + meshBlur->setProgramState(mat1->getTechniqueByName("blur")->getPassByIndex(0)->getProgramState()); - auto spriteOutline = Sprite::create("Images/grossini.png"); - spriteOutline->setPositionNormalized(Vec2(0.4f, 0.5f)); - this->addChild(spriteOutline); - spriteOutline->setProgramState(mat1->getTechniqueByName("outline")->getPassByIndex(0)->getProgramState()); + auto meshOutline = Sprite::create("Images/grossini.png"); + meshOutline->setPositionNormalized(Vec2(0.4f, 0.5f)); + this->addChild(meshOutline); + meshOutline->setProgramState(mat1->getTechniqueByName("outline")->getPassByIndex(0)->getProgramState()); - auto spriteNoise = Sprite::create("Images/grossini.png"); - spriteNoise->setPositionNormalized(Vec2(0.6f, 0.5f)); - this->addChild(spriteNoise); - spriteNoise->setProgramState(mat1->getTechniqueByName("noise")->getPassByIndex(0)->getProgramState()); + auto meshNoise = Sprite::create("Images/grossini.png"); + meshNoise->setPositionNormalized(Vec2(0.6f, 0.5f)); + this->addChild(meshNoise); + meshNoise->setProgramState(mat1->getTechniqueByName("noise")->getPassByIndex(0)->getProgramState()); - auto spriteEdgeDetect = Sprite::create("Images/grossini.png"); - spriteEdgeDetect->setPositionNormalized(Vec2(0.8f, 0.5f)); - this->addChild(spriteEdgeDetect); - spriteEdgeDetect->setProgramState(mat1->getTechniqueByName("edge_detect")->getPassByIndex(0)->getProgramState()); + auto meshEdgeDetect = Sprite::create("Images/grossini.png"); + meshEdgeDetect->setPositionNormalized(Vec2(0.8f, 0.5f)); + this->addChild(meshEdgeDetect); + meshEdgeDetect->setProgramState(mat1->getTechniqueByName("edge_detect")->getPassByIndex(0)->getProgramState()); timeUniforms.clear(); -#define FETCH_CCTIME_LOCATION(sprite) \ +#define FETCH_CCTIME_LOCATION(mesh) \ do \ { \ - auto programState = sprite->getProgramState(); \ + auto programState = mesh->getProgramState(); \ auto location = programState->getUniformLocation("u_Time"); \ timeUniforms.emplace_back(programState, location); \ } while (0) - FETCH_CCTIME_LOCATION(spriteBlur); - FETCH_CCTIME_LOCATION(spriteOutline); - FETCH_CCTIME_LOCATION(spriteNoise); - FETCH_CCTIME_LOCATION(spriteEdgeDetect); + FETCH_CCTIME_LOCATION(meshBlur); + FETCH_CCTIME_LOCATION(meshOutline); + FETCH_CCTIME_LOCATION(meshNoise); + FETCH_CCTIME_LOCATION(meshEdgeDetect); schedule(CC_SCHEDULE_SELECTOR(Material_2DEffects::updateCCTimeUniforms)); @@ -245,27 +245,27 @@ void Material_AutoBindings::onEnter() Material* mat1 = Material::createWithProperties(properties); - auto spriteBlur = Sprite::create("Images/grossini.png"); - spriteBlur->setPositionNormalized(Vec2(0.2f, 0.5f)); - this->addChild(spriteBlur); - spriteBlur->setProgramState(mat1->getTechniqueByName("blur")->getPassByIndex(0)->getProgramState()); + auto meshBlur = Sprite::create("Images/grossini.png"); + meshBlur->setPositionNormalized(Vec2(0.2f, 0.5f)); + this->addChild(meshBlur); + meshBlur->setProgramState(mat1->getTechniqueByName("blur")->getPassByIndex(0)->getProgramState()); - auto spriteOutline = Sprite::create("Images/grossini.png"); - spriteOutline->setPositionNormalized(Vec2(0.4f, 0.5f)); - this->addChild(spriteOutline); - spriteOutline->setProgramState(mat1->getTechniqueByName("outline")->getPassByIndex(0)->getProgramState()); + auto meshOutline = Sprite::create("Images/grossini.png"); + meshOutline->setPositionNormalized(Vec2(0.4f, 0.5f)); + this->addChild(meshOutline); + meshOutline->setProgramState(mat1->getTechniqueByName("outline")->getPassByIndex(0)->getProgramState()); - auto spriteNoise = Sprite::create("Images/grossini.png"); - spriteNoise->setPositionNormalized(Vec2(0.6f, 0.5f)); - this->addChild(spriteNoise); - spriteNoise->setProgramState(mat1->getTechniqueByName("noise")->getPassByIndex(0)->getProgramState()); + auto meshNoise = Sprite::create("Images/grossini.png"); + meshNoise->setPositionNormalized(Vec2(0.6f, 0.5f)); + this->addChild(meshNoise); + meshNoise->setProgramState(mat1->getTechniqueByName("noise")->getPassByIndex(0)->getProgramState()); - auto spriteEdgeDetect = Sprite::create("Images/grossini.png"); - spriteEdgeDetect->setPositionNormalized(Vec2(0.8f, 0.5f)); - this->addChild(spriteEdgeDetect); - spriteEdgeDetect->setProgramState(mat1->getTechniqueByName("edge_detect")->getPassByIndex(0)->getProgramState()); + auto meshEdgeDetect = Sprite::create("Images/grossini.png"); + meshEdgeDetect->setPositionNormalized(Vec2(0.8f, 0.5f)); + this->addChild(meshEdgeDetect); + meshEdgeDetect->setProgramState(mat1->getTechniqueByName("edge_detect")->getPassByIndex(0)->getProgramState()); - _noiseProgramState = spriteNoise->getProgramState(); + _noiseProgramState = meshNoise->getProgramState(); _locationTime = _noiseProgramState->getUniformLocation("u_Time"); schedule(CC_SCHEDULE_SELECTOR(Material_AutoBindings::updateUniformTime)); @@ -292,14 +292,14 @@ void Material_setTechnique::onEnter() { MaterialSystemBaseTest::onEnter(); - auto sprite = Sprite3D::create("Sprite3DTest/boss1.obj"); - sprite->setScale(6); - this->addChild(sprite); - sprite->setPositionNormalized(Vec2(0.5f, 0.5f)); - _sprite = sprite; + auto mesh = MeshRenderer::create("MeshRendererTest/boss1.obj"); + mesh->setScale(6); + this->addChild(mesh); + mesh->setPositionNormalized(Vec2(0.5f, 0.5f)); + _mesh = mesh; Material* mat = Material::createWithFilename("Materials/3d_effects.material"); - sprite->setMaterial(mat); + mesh->setMaterial(mat); // lights auto light1 = AmbientLight::create(Color3B::RED); @@ -313,7 +313,7 @@ void Material_setTechnique::onEnter() auto rot = RotateBy::create(5, Vec3(30.0f, 60.0f, 270.0f)); auto repeat = RepeatForever::create(rot); - sprite->runAction(repeat); + mesh->runAction(repeat); } std::string Material_setTechnique::subtitle() const @@ -327,13 +327,13 @@ void Material_setTechnique::changeMaterial(float dt) switch (_techniqueState) { case 0: - _sprite->getMaterial(0)->setTechnique("lit"); + _mesh->getMaterial(0)->setTechnique("lit"); break; case 1: - _sprite->getMaterial(0)->setTechnique("normal"); + _mesh->getMaterial(0)->setTechnique("normal"); break; case 2: - _sprite->getMaterial(0)->setTechnique("outline"); + _mesh->getMaterial(0)->setTechnique("outline"); break; default: break; @@ -349,40 +349,40 @@ void Material_clone::onEnter() { MaterialSystemBaseTest::onEnter(); - auto sprite = Sprite3D::create("Sprite3DTest/boss1.obj"); - sprite->setScale(3); - this->addChild(sprite); - sprite->setPositionNormalized(Vec2(0.25f, 0.5f)); + auto mesh = MeshRenderer::create("MeshRendererTest/boss1.obj"); + mesh->setScale(3); + this->addChild(mesh); + mesh->setPositionNormalized(Vec2(0.25f, 0.5f)); Material* mat = Material::createWithFilename("Materials/3d_effects.material"); - sprite->setMaterial(mat); + mesh->setMaterial(mat); auto rot = RotateBy::create(5, Vec3(360.0f, 240.0f, 120.0f)); auto repeat = RepeatForever::create(rot); - sprite->runAction(repeat); + mesh->runAction(repeat); - // sprite 2... using same material - auto sprite2 = Sprite3D::create("Sprite3DTest/boss1.obj"); - sprite2->setScale(3); - this->addChild(sprite2); - sprite2->setPositionNormalized(Vec2(0.5f, 0.5f)); - sprite2->setMaterial(mat); - sprite2->runAction(repeat->clone()); + // mesh 2... using same material + auto mesh2 = MeshRenderer::create("MeshRendererTest/boss1.obj"); + mesh2->setScale(3); + this->addChild(mesh2); + mesh2->setPositionNormalized(Vec2(0.5f, 0.5f)); + mesh2->setMaterial(mat); + mesh2->runAction(repeat->clone()); - // sprite 3... using cloned material - auto sprite3 = Sprite3D::create("Sprite3DTest/boss1.obj"); - sprite3->setScale(3); - this->addChild(sprite3); - sprite3->setPositionNormalized(Vec2(0.75f, 0.5f)); + // mesh 3... using cloned material + auto mesh3 = MeshRenderer::create("MeshRendererTest/boss1.obj"); + mesh3->setScale(3); + this->addChild(mesh3); + mesh3->setPositionNormalized(Vec2(0.75f, 0.5f)); auto mat2 = mat->clone(); - sprite3->setMaterial(mat2); - sprite3->runAction(repeat->clone()); + mesh3->setMaterial(mat2); + mesh3->runAction(repeat->clone()); // testing clone - // should affect both sprite 1 and sprite 2 + // should affect both mesh 1 and mesh 2 mat->setTechnique("outline"); - // should affect only sprite 3 + // should affect only mesh 3 // mat2->setTechnique("normal"); } diff --git a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.h b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.h index 841c66e271..0406f57873 100644 --- a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.h +++ b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.h @@ -39,19 +39,19 @@ public: virtual std::string title() const override; }; -class Material_Sprite3DTest : public MaterialSystemBaseTest +class Material_MeshRendererTest : public MaterialSystemBaseTest { public: - CREATE_FUNC(Material_Sprite3DTest); + CREATE_FUNC(Material_MeshRendererTest); virtual void onEnter() override; virtual std::string subtitle() const override; }; -class Material_MultipleSprite3D : public MaterialSystemBaseTest +class Material_MultipleMeshRenderer : public MaterialSystemBaseTest { public: - CREATE_FUNC(Material_MultipleSprite3D); + CREATE_FUNC(Material_MultipleMeshRenderer); virtual void onEnter() override; virtual std::string subtitle() const override; @@ -110,7 +110,7 @@ public: private: void changeMaterial(float dt); - cocos2d::Sprite3D* _sprite; + cocos2d::MeshRenderer* _mesh; int _techniqueState; }; diff --git a/tests/cpp-tests/Classes/Sprite3DTest/DrawNode3D.cpp b/tests/cpp-tests/Classes/MeshRendererTest/DrawNode3D.cpp similarity index 100% rename from tests/cpp-tests/Classes/Sprite3DTest/DrawNode3D.cpp rename to tests/cpp-tests/Classes/MeshRendererTest/DrawNode3D.cpp diff --git a/tests/cpp-tests/Classes/Sprite3DTest/DrawNode3D.h b/tests/cpp-tests/Classes/MeshRendererTest/DrawNode3D.h similarity index 100% rename from tests/cpp-tests/Classes/Sprite3DTest/DrawNode3D.h rename to tests/cpp-tests/Classes/MeshRendererTest/DrawNode3D.h diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/MeshRendererTest/MeshRendererTest.cpp similarity index 66% rename from tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp rename to tests/cpp-tests/Classes/MeshRendererTest/MeshRendererTest.cpp index 3dd9c0d34e..c2463cc8de 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/MeshRendererTest/MeshRendererTest.cpp @@ -24,10 +24,10 @@ THE SOFTWARE. ****************************************************************************/ -#include "Sprite3DTest.h" +#include "MeshRendererTest.h" #include "DrawNode3D.h" #include "2d/CCCameraBackgroundBrush.h" -#include "3d/CCSprite3DMaterial.h" +#include "3d/CCMeshMaterial.h" #include "3d/CCMotionStreak3D.h" #include "extensions/Particle3D/PU/CCPUParticleSystem3D.h" @@ -37,65 +37,65 @@ USING_NS_CC; -Sprite3DTests::Sprite3DTests() +MeshRendererTests::MeshRendererTests() { - ADD_TEST_CASE(Sprite3DBasicTest); - ADD_TEST_CASE(Sprite3DHitTest); - ADD_TEST_CASE(AsyncLoadSprite3DTest); + ADD_TEST_CASE(MeshRendererBasicTest); + ADD_TEST_CASE(MeshRendererHitTest); + ADD_TEST_CASE(AsyncLoadMeshRendererTest); // // 3DEffect use custom shader which is not supported on WP8/WinRT yet. - ADD_TEST_CASE(Sprite3DEffectTest); - ADD_TEST_CASE(Sprite3DUVAnimationTest); - ADD_TEST_CASE(Sprite3DFakeShadowTest); - ADD_TEST_CASE(Sprite3DBasicToonShaderTest); - ADD_TEST_CASE(Sprite3DLightMapTest); - ADD_TEST_CASE(Sprite3DWithSkinTest); - ADD_TEST_CASE(Sprite3DWithSkinOutlineTest); + ADD_TEST_CASE(MeshRendererEffectTest); + ADD_TEST_CASE(MeshRendererUVAnimationTest); + ADD_TEST_CASE(MeshRendererFakeShadowTest); + ADD_TEST_CASE(MeshRendererBasicToonShaderTest); + ADD_TEST_CASE(MeshRendererLightMapTest); + ADD_TEST_CASE(MeshRendererWithSkinTest); + ADD_TEST_CASE(MeshRendererWithSkinOutlineTest); ADD_TEST_CASE(Animate3DTest); ADD_TEST_CASE(AttachmentTest); - ADD_TEST_CASE(Sprite3DReskinTest); - ADD_TEST_CASE(Sprite3DWithOBBPerformanceTest); - ADD_TEST_CASE(Sprite3DMirrorTest); + ADD_TEST_CASE(MeshRendererReskinTest); + ADD_TEST_CASE(MeshRendererWithOBBPerformanceTest); + ADD_TEST_CASE(MeshRendererMirrorTest); ADD_TEST_CASE(QuaternionTest); - ADD_TEST_CASE(Sprite3DEmptyTest); - ADD_TEST_CASE(UseCaseSprite3D); - ADD_TEST_CASE(Sprite3DForceDepthTest); - ADD_TEST_CASE(Sprite3DCubeMapTest); + ADD_TEST_CASE(MeshRendererEmptyTest); + ADD_TEST_CASE(UseCaseMeshRenderer); + ADD_TEST_CASE(MeshRendererForceDepthTest); + ADD_TEST_CASE(MeshRendererCubeMapTest); ADD_TEST_CASE(NodeAnimationTest); ADD_TEST_CASE(Issue9767); - ADD_TEST_CASE(Sprite3DClippingTest); + ADD_TEST_CASE(MeshRendererClippingTest); ADD_TEST_CASE(Animate3DCallbackTest); ADD_TEST_CASE(CameraBackgroundClearTest); - ADD_TEST_CASE(Sprite3DVertexColorTest); + ADD_TEST_CASE(MeshRendererVertexColorTest); ADD_TEST_CASE(MotionStreak3DTest); - ADD_TEST_CASE(Sprite3DPropertyTest); - ADD_TEST_CASE(Sprite3DNormalMappingTest); + ADD_TEST_CASE(MeshRendererPropertyTest); + ADD_TEST_CASE(MeshRendererNormalMappingTest); ADD_TEST_CASE(Issue16155Test); }; //------------------------------------------------------------------ // -// SpriteTestDemo +// MeshRendererTestDemo // //------------------------------------------------------------------ -std::string Sprite3DTestDemo::title() const +std::string MeshRendererTestDemo::title() const { return "No title"; } -Sprite3DTestDemo::~Sprite3DTestDemo() +MeshRendererTestDemo::~MeshRendererTestDemo() { - Sprite3DMaterial::releaseCachedMaterial(); + MeshMaterial::releaseCachedMaterial(); } //------------------------------------------------------------------ // -// Sprite3DForceDepthTest +// MeshRendererForceDepthTest // //------------------------------------------------------------------ -Sprite3DForceDepthTest::Sprite3DForceDepthTest() +MeshRendererForceDepthTest::MeshRendererForceDepthTest() { - auto orc = cocos2d::Sprite3D::create("Sprite3DTest/orc.c3b"); + auto orc = cocos2d::MeshRenderer::create("MeshRendererTest/orc.c3b"); orc->setScale(5); orc->setPositionNormalized(Vec2(.5f, .3f)); orc->setPositionZ(40); @@ -104,9 +104,9 @@ Sprite3DForceDepthTest::Sprite3DForceDepthTest() addChild(orc); - auto ship = Sprite3D::create("Sprite3DTest/boss1.obj"); + auto ship = MeshRenderer::create("MeshRendererTest/boss1.obj"); ship->setScale(5); - ship->setTexture("Sprite3DTest/boss.png"); + ship->setTexture("MeshRendererTest/boss.png"); ship->setPositionNormalized(Vec2(.5f, .5f)); ship->setRotation3D(Vec3(90.0f, 0.0f, 0.0f)); ship->setForceDepthWrite(true); @@ -114,24 +114,24 @@ Sprite3DForceDepthTest::Sprite3DForceDepthTest() addChild(ship); } -std::string Sprite3DForceDepthTest::title() const +std::string MeshRendererForceDepthTest::title() const { return "Force Depth Write Error Test"; } -std::string Sprite3DForceDepthTest::subtitle() const +std::string MeshRendererForceDepthTest::subtitle() const { return "Ship should always appear behind orc"; } //------------------------------------------------------------------ // -// Sprite3DEmptyTest +// MeshRendererEmptyTest // //------------------------------------------------------------------ -Sprite3DEmptyTest::Sprite3DEmptyTest() +MeshRendererEmptyTest::MeshRendererEmptyTest() { - auto s = Sprite3D::create(); + auto s = MeshRenderer::create(); s->setPositionNormalized(Vec2(.5f, .5f)); auto l = Label::create(); l->setString("Test"); @@ -139,53 +139,53 @@ Sprite3DEmptyTest::Sprite3DEmptyTest() addChild(s); } -std::string Sprite3DEmptyTest::title() const +std::string MeshRendererEmptyTest::title() const { - return "Testing Sprite3D Container"; + return "Testing MeshRenderer Container"; } -std::string Sprite3DEmptyTest::subtitle() const +std::string MeshRendererEmptyTest::subtitle() const { - return "Sprite3D can act as containers for 2D objects"; + return "MeshRenderer can act as containers for 2D objects"; } //------------------------------------------------------------------ // -// Sprite3DBasicTest +// MeshRendererBasicTest // //------------------------------------------------------------------ -Sprite3DBasicTest::Sprite3DBasicTest() +MeshRendererBasicTest::MeshRendererBasicTest() { auto listener = EventListenerTouchAllAtOnce::create(); - listener->onTouchesEnded = CC_CALLBACK_2(Sprite3DBasicTest::onTouchesEnded, this); + listener->onTouchesEnded = CC_CALLBACK_2(MeshRendererBasicTest::onTouchesEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); auto s = Director::getInstance()->getWinSize(); - addNewSpriteWithCoords(Vec2(s.width / 2, s.height / 2)); + addNewMeshWithCoords(Vec2(s.width / 2, s.height / 2)); } -void Sprite3DBasicTest::addNewSpriteWithCoords(Vec2 p) +void MeshRendererBasicTest::addNewMeshWithCoords(Vec2 p) { // int idx = (int)(CCRANDOM_0_1() * 1400.0f / 100.0f); // int x = (idx%5) * 85; // int y = (idx/5) * 121; // //option 1: load a obj that contain the texture in it - // auto sprite = Sprite3D::create("sprite3dTest/scene01.obj"); + // auto mesh = MeshRenderer::create("mesh3dTest/scene01.obj"); // option 2: load obj and assign the texture - auto sprite = Sprite3D::create("Sprite3DTest/boss1.obj"); - sprite->setScale(3.f); - sprite->setTexture("Sprite3DTest/boss.png"); + auto mesh = MeshRenderer::create("MeshRendererTest/boss1.obj"); + mesh->setScale(3.f); + mesh->setTexture("MeshRendererTest/boss.png"); // - // sprite->setEffect(cocos2d::EFFECT_OUTLINE); + // mesh->setEffect(cocos2d::EFFECT_OUTLINE); // add to scene - addChild(sprite); + addChild(mesh); - sprite->setPosition(Vec2(p.x, p.y)); + mesh->setPosition(Vec2(p.x, p.y)); ActionInterval* action; float random = CCRANDOM_0_1(); @@ -203,36 +203,36 @@ void Sprite3DBasicTest::addNewSpriteWithCoords(Vec2 p) auto action_back = action->reverse(); auto seq = Sequence::create(action, action_back, nullptr); - sprite->runAction(RepeatForever::create(seq)); + mesh->runAction(RepeatForever::create(seq)); } -void Sprite3DBasicTest::onTouchesEnded(const std::vector& touches, Event* event) +void MeshRendererBasicTest::onTouchesEnded(const std::vector& touches, Event* event) { for (auto touch : touches) { auto location = touch->getLocation(); - addNewSpriteWithCoords(location); + addNewMeshWithCoords(location); } } -std::string Sprite3DBasicTest::title() const +std::string MeshRendererBasicTest::title() const { - return "Testing Sprite3D"; + return "Testing MeshRenderer"; } -std::string Sprite3DBasicTest::subtitle() const +std::string MeshRendererBasicTest::subtitle() const { - return "Tap screen to add more sprites"; + return "Tap screen to add more meshes"; } //------------------------------------------------------------------ // -// Sprite3DUVAnimationTest +// MeshRendererUVAnimationTest // //------------------------------------------------------------------ -Sprite3DUVAnimationTest::Sprite3DUVAnimationTest() +MeshRendererUVAnimationTest::MeshRendererUVAnimationTest() { // the offset use to translating texture _cylinder_texture_offset = 0; @@ -244,8 +244,8 @@ Sprite3DUVAnimationTest::Sprite3DUVAnimationTest() camera->setCameraFlag(CameraFlag::USER1); // create cylinder - auto cylinder = Sprite3D::create("Sprite3DTest/cylinder.c3b"); - auto mat = Sprite3DMaterial::createWithFilename("Sprite3DTest/UVAnimation.material"); + auto cylinder = MeshRenderer::create("MeshRendererTest/cylinder.c3b"); + auto mat = MeshMaterial::createWithFilename("MeshRendererTest/UVAnimation.material"); _state = mat->getTechniqueByIndex(0)->getPassByIndex(0)->getProgramState(); cylinder->setMaterial(mat); @@ -258,11 +258,11 @@ Sprite3DUVAnimationTest::Sprite3DUVAnimationTest() cylinder->setRotation3D(Vec3(-90.0f, 0.0f, 0.0f)); // the callback function update cylinder's texcoord - schedule(CC_SCHEDULE_SELECTOR(Sprite3DUVAnimationTest::cylinderUpdate)); + schedule(CC_SCHEDULE_SELECTOR(MeshRendererUVAnimationTest::cylinderUpdate)); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) _backToForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [=](EventCustom*) { - auto mat = Sprite3DMaterial::createWithFilename("Sprite3DTest/UVAnimation.material"); + auto mat = MeshMaterial::createWithFilename("MeshRendererTest/UVAnimation.material"); cylinder->setMaterial(mat); _state = mat->getTechniqueByIndex(0)->getPassByIndex(0)->getProgramState(); @@ -271,24 +271,24 @@ Sprite3DUVAnimationTest::Sprite3DUVAnimationTest() #endif } -Sprite3DUVAnimationTest::~Sprite3DUVAnimationTest() +MeshRendererUVAnimationTest::~MeshRendererUVAnimationTest() { #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundListener); #endif } -std::string Sprite3DUVAnimationTest::title() const +std::string MeshRendererUVAnimationTest::title() const { return "Testing UV Animation"; } -std::string Sprite3DUVAnimationTest::subtitle() const +std::string MeshRendererUVAnimationTest::subtitle() const { return ""; } -void Sprite3DUVAnimationTest::cylinderUpdate(float dt) +void MeshRendererUVAnimationTest::cylinderUpdate(float dt) { // callback function to update cylinder's texcoord static bool fade_in = true; @@ -316,17 +316,17 @@ void Sprite3DUVAnimationTest::cylinderUpdate(float dt) //------------------------------------------------------------------ // -// Sprite3DFakeShadowTest +// MeshRendererFakeShadowTest // //------------------------------------------------------------------ -Sprite3DFakeShadowTest::Sprite3DFakeShadowTest() +MeshRendererFakeShadowTest::MeshRendererFakeShadowTest() { Size visibleSize = Director::getInstance()->getVisibleSize(); auto listener = EventListenerTouchAllAtOnce::create(); - listener->onTouchesBegan = CC_CALLBACK_2(Sprite3DFakeShadowTest::onTouchesBegan, this); - listener->onTouchesMoved = CC_CALLBACK_2(Sprite3DFakeShadowTest::onTouchesMoved, this); - listener->onTouchesEnded = CC_CALLBACK_2(Sprite3DFakeShadowTest::onTouchesEnded, this); + listener->onTouchesBegan = CC_CALLBACK_2(MeshRendererFakeShadowTest::onTouchesBegan, this); + listener->onTouchesMoved = CC_CALLBACK_2(MeshRendererFakeShadowTest::onTouchesMoved, this); + listener->onTouchesEnded = CC_CALLBACK_2(MeshRendererFakeShadowTest::onTouchesEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); auto layer = Layer::create(); @@ -338,10 +338,10 @@ Sprite3DFakeShadowTest::Sprite3DFakeShadowTest() _camera->setRotation3D(Vec3(-60.0f, 0.0f, 0.0f)); // create a plane - _plane = Sprite3D::create("Sprite3DTest/plane.c3t"); + _plane = MeshRenderer::create("MeshRendererTest/plane.c3t"); _plane->setRotation3D(Vec3(90.0f, 0.0f, 0.0f)); - auto mat = Sprite3DMaterial::createWithFilename("Sprite3DTest/FakeShadow.material"); + auto mat = MeshMaterial::createWithFilename("MeshRendererTest/FakeShadow.material"); _state = mat->getTechniqueByIndex(0)->getPassByIndex(0)->getProgramState(); _plane->setMaterial(mat); @@ -352,7 +352,7 @@ Sprite3DFakeShadowTest::Sprite3DFakeShadowTest() layer->addChild(_plane); // create the orc - _orc = Sprite3D::create("Sprite3DTest/orc.c3b"); + _orc = MeshRenderer::create("MeshRendererTest/orc.c3b"); _orc->setScale(0.2f); _orc->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); _orc->setPosition3D(Vec3(0.0f, 0.0f, 10.0f)); @@ -363,11 +363,11 @@ Sprite3DFakeShadowTest::Sprite3DFakeShadowTest() layer->addChild(_camera); layer->setCameraMask(2); - schedule(CC_SCHEDULE_SELECTOR(Sprite3DFakeShadowTest::updateCamera), 0.0f); + schedule(CC_SCHEDULE_SELECTOR(MeshRendererFakeShadowTest::updateCamera), 0.0f); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) _backToForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom*) { - auto mat = Sprite3DMaterial::createWithFilename("Sprite3DTest/FakeShadow.material"); + auto mat = MeshMaterial::createWithFilename("MeshRendererTest/FakeShadow.material"); _state = mat->getTechniqueByIndex(0)->getPassByIndex(0)->getProgramState(); _plane->setMaterial(mat); backend::UniformLocation loc = _state->getUniformLocation("u_model_matrix"); @@ -381,29 +381,29 @@ Sprite3DFakeShadowTest::Sprite3DFakeShadowTest() #endif } -Sprite3DFakeShadowTest::~Sprite3DFakeShadowTest() +MeshRendererFakeShadowTest::~MeshRendererFakeShadowTest() { #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundListener); #endif } -std::string Sprite3DFakeShadowTest::title() const +std::string MeshRendererFakeShadowTest::title() const { return "fake shadow effect"; } -std::string Sprite3DFakeShadowTest::subtitle() const +std::string MeshRendererFakeShadowTest::subtitle() const { return "touch the screen to move around"; } -void Sprite3DFakeShadowTest::Move(cocos2d::Ref* sender, int value) +void MeshRendererFakeShadowTest::Move(cocos2d::Ref* sender, int value) { _orc->setPositionX(_orc->getPositionX() + value); } -void Sprite3DFakeShadowTest::updateCamera(float fDelta) +void MeshRendererFakeShadowTest::updateCamera(float fDelta) { updateState(fDelta); if (isState(_curState, State_Move)) @@ -448,7 +448,7 @@ void Sprite3DFakeShadowTest::updateCamera(float fDelta) } } -void Sprite3DFakeShadowTest::move3D(float elapsedTime) +void MeshRendererFakeShadowTest::move3D(float elapsedTime) { Vec3 curPos = _orc->getPosition3D(); Vec3 newFaceDir = _targetPos - curPos; @@ -465,7 +465,7 @@ void Sprite3DFakeShadowTest::move3D(float elapsedTime) _state->setUniform(location, &position, sizeof(position)); } -void Sprite3DFakeShadowTest::updateState(float elapsedTime) +void MeshRendererFakeShadowTest::updateState(float elapsedTime) { Vec3 curPos = _orc->getPosition3D(); Vec3 curFaceDir; @@ -493,16 +493,16 @@ void Sprite3DFakeShadowTest::updateState(float elapsedTime) } } -bool Sprite3DFakeShadowTest::isState(unsigned int state, unsigned int bit) const +bool MeshRendererFakeShadowTest::isState(unsigned int state, unsigned int bit) const { return (state & bit) == bit; } -void Sprite3DFakeShadowTest::onTouchesBegan(const std::vector& touches, cocos2d::Event* event) {} +void MeshRendererFakeShadowTest::onTouchesBegan(const std::vector& touches, cocos2d::Event* event) {} -void Sprite3DFakeShadowTest::onTouchesMoved(const std::vector& touches, cocos2d::Event* event) {} +void MeshRendererFakeShadowTest::onTouchesMoved(const std::vector& touches, cocos2d::Event* event) {} -void Sprite3DFakeShadowTest::onTouchesEnded(const std::vector& touches, cocos2d::Event* event) +void MeshRendererFakeShadowTest::onTouchesEnded(const std::vector& touches, cocos2d::Event* event) { for (auto& item : touches) { @@ -543,17 +543,17 @@ void Sprite3DFakeShadowTest::onTouchesEnded(const std::vector& touches, //------------------------------------------------------------------ // -// Sprite3DBasicToonShaderTest +// MeshRendererBasicToonShaderTest // //------------------------------------------------------------------ -Sprite3DBasicToonShaderTest::Sprite3DBasicToonShaderTest() +MeshRendererBasicToonShaderTest::MeshRendererBasicToonShaderTest() { Size visibleSize = Director::getInstance()->getVisibleSize(); auto _camera = Camera::createPerspective(60, visibleSize.width / visibleSize.height, 0.1f, 200); _camera->setCameraFlag(CameraFlag::USER1); // create a teapot - auto teapot = Sprite3D::create("Sprite3DTest/teapot.c3b"); - auto mat = Sprite3DMaterial::createWithFilename("Sprite3DTest/BasicToon.material"); + auto teapot = MeshRenderer::create("MeshRendererTest/teapot.c3b"); + auto mat = MeshMaterial::createWithFilename("MeshRendererTest/BasicToon.material"); _state = mat->getTechniqueByIndex(0)->getPassByIndex(0)->getProgramState(); teapot->setMaterial(mat); @@ -566,7 +566,7 @@ Sprite3DBasicToonShaderTest::Sprite3DBasicToonShaderTest() setCameraMask(2); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) _backToForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [=](EventCustom*) { - auto mat = Sprite3DMaterial::createWithFilename("Sprite3DTest/BasicToon.material"); + auto mat = MeshMaterial::createWithFilename("MeshRendererTest/BasicToon.material"); _state = mat->getTechniqueByIndex(0)->getPassByIndex(0)->getProgramState(); teapot->setMaterial(mat); }); @@ -574,29 +574,29 @@ Sprite3DBasicToonShaderTest::Sprite3DBasicToonShaderTest() #endif } -Sprite3DBasicToonShaderTest::~Sprite3DBasicToonShaderTest() +MeshRendererBasicToonShaderTest::~MeshRendererBasicToonShaderTest() { #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundListener); #endif } -std::string Sprite3DBasicToonShaderTest::title() const +std::string MeshRendererBasicToonShaderTest::title() const { return "basic toon shader test"; } -std::string Sprite3DBasicToonShaderTest::subtitle() const +std::string MeshRendererBasicToonShaderTest::subtitle() const { return " "; } //------------------------------------------------------------------ // -// Sprite3DLightMapTest +// MeshRendererLightMapTest // //------------------------------------------------------------------ -Sprite3DLightMapTest::Sprite3DLightMapTest() +MeshRendererLightMapTest::MeshRendererLightMapTest() { // the assets are from the OpenVR demo // get the visible size. @@ -605,7 +605,7 @@ Sprite3DLightMapTest::Sprite3DLightMapTest() _camera->setCameraFlag(CameraFlag::USER1); _camera->setPosition3D(Vec3(0.0f, 25.0f, 15.0f)); _camera->setRotation3D(Vec3(-35.0f, 0.0f, 0.0f)); - auto LightMapScene = Sprite3D::create("Sprite3DTest/LightMapScene.c3b"); + auto LightMapScene = MeshRenderer::create("MeshRendererTest/LightMapScene.c3b"); LightMapScene->setScale(0.1f); addChild(LightMapScene); addChild(_camera); @@ -620,21 +620,21 @@ Sprite3DLightMapTest::Sprite3DLightMapTest() // create a listener auto listener = EventListenerTouchAllAtOnce::create(); - listener->onTouchesMoved = CC_CALLBACK_2(Sprite3DLightMapTest::onTouchesMoved, this); + listener->onTouchesMoved = CC_CALLBACK_2(MeshRendererLightMapTest::onTouchesMoved, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); } -Sprite3DLightMapTest::~Sprite3DLightMapTest() {} -std::string Sprite3DLightMapTest::title() const +MeshRendererLightMapTest::~MeshRendererLightMapTest() {} +std::string MeshRendererLightMapTest::title() const { return "light map test"; } -std::string Sprite3DLightMapTest::subtitle() const +std::string MeshRendererLightMapTest::subtitle() const { return "drag the screen to move around"; } -void Sprite3DLightMapTest::onTouchesMoved(const std::vector& touches, cocos2d::Event* event) +void MeshRendererLightMapTest::onTouchesMoved(const std::vector& touches, cocos2d::Event* event) { if (touches.size() == 1) { @@ -661,45 +661,45 @@ void Sprite3DLightMapTest::onTouchesMoved(const std::vector& to //------------------------------------------------------------------ // -// Sprite3DHitTest +// MeshRendererHitTest // //------------------------------------------------------------------ -Sprite3DHitTest::Sprite3DHitTest() +MeshRendererHitTest::MeshRendererHitTest() { auto s = Director::getInstance()->getWinSize(); - auto sprite1 = Sprite3D::create("Sprite3DTest/boss1.obj"); + auto mesh1 = MeshRenderer::create("MeshRendererTest/boss1.obj"); - sprite1->setScale(4.f); - sprite1->setTexture("Sprite3DTest/boss.png"); - sprite1->setPosition(Vec2(s.width / 2, s.height / 2)); + mesh1->setScale(4.f); + mesh1->setTexture("MeshRendererTest/boss.png"); + mesh1->setPosition(Vec2(s.width / 2, s.height / 2)); // add to scene - addChild(sprite1); - sprite1->runAction(RepeatForever::create(RotateBy::create(3.0f, 360.0f))); + addChild(mesh1); + mesh1->runAction(RepeatForever::create(RotateBy::create(3.0f, 360.0f))); - auto sprite2 = Sprite3D::create("Sprite3DTest/boss1.obj"); + auto mesh2 = MeshRenderer::create("MeshRendererTest/boss1.obj"); - sprite2->setScale(4.f); - sprite2->setTexture("Sprite3DTest/boss.png"); - sprite2->setPosition(Vec2(s.width / 2, s.height / 2)); - sprite2->setAnchorPoint(Vec2(0.5f, 0.5f)); + mesh2->setScale(4.f); + mesh2->setTexture("MeshRendererTest/boss.png"); + mesh2->setPosition(Vec2(s.width / 2, s.height / 2)); + mesh2->setAnchorPoint(Vec2(0.5f, 0.5f)); // add to scene - addChild(sprite2); - sprite2->runAction(RepeatForever::create(RotateBy::create(3.0f, -360.0f))); + addChild(mesh2); + mesh2->runAction(RepeatForever::create(RotateBy::create(3.0f, -360.0f))); - // Make sprite1 touchable + // Make mesh1 touchable auto listener1 = EventListenerTouchOneByOne::create(); listener1->setSwallowTouches(true); listener1->onTouchBegan = [](Touch* touch, Event* event) { - auto target = static_cast(event->getCurrentTarget()); + auto target = static_cast(event->getCurrentTarget()); Rect rect = target->getBoundingBox(); if (rect.containsPoint(touch->getLocation())) { - log("sprite3d began... x = %f, y = %f", touch->getLocation().x, touch->getLocation().y); + log("mesh3d began... x = %f, y = %f", touch->getLocation().x, touch->getLocation().y); target->setOpacity(100); return true; } @@ -707,81 +707,81 @@ Sprite3DHitTest::Sprite3DHitTest() }; listener1->onTouchMoved = [](Touch* touch, Event* event) { - auto target = static_cast(event->getCurrentTarget()); + auto target = static_cast(event->getCurrentTarget()); target->setPosition(target->getPosition() + touch->getDelta()); }; listener1->onTouchEnded = [=](Touch* touch, Event* event) { - auto target = static_cast(event->getCurrentTarget()); - log("sprite3d onTouchesEnded.. "); + auto target = static_cast(event->getCurrentTarget()); + log("mesh3d onTouchesEnded.. "); target->setOpacity(255); }; - _eventDispatcher->addEventListenerWithSceneGraphPriority(listener1, sprite1); - _eventDispatcher->addEventListenerWithSceneGraphPriority(listener1->clone(), sprite2); + _eventDispatcher->addEventListenerWithSceneGraphPriority(listener1, mesh1); + _eventDispatcher->addEventListenerWithSceneGraphPriority(listener1->clone(), mesh2); } -std::string Sprite3DHitTest::title() const +std::string MeshRendererHitTest::title() const { - return "Testing Sprite3D Touch in 2D"; + return "Testing MeshRenderer Touch in 2D"; } -std::string Sprite3DHitTest::subtitle() const +std::string MeshRendererHitTest::subtitle() const { - return "Tap Sprite3D and Drag"; + return "Tap MeshRenderer and Drag"; } -Sprite3DEffectTest::Sprite3DEffectTest() +MeshRendererEffectTest::MeshRendererEffectTest() { auto s = Director::getInstance()->getWinSize(); - addNewSpriteWithCoords(Vec2(s.width / 2, s.height / 2)); + addNewMeshWithCoords(Vec2(s.width / 2, s.height / 2)); auto listener = EventListenerTouchAllAtOnce::create(); - listener->onTouchesEnded = CC_CALLBACK_2(Sprite3DEffectTest::onTouchesEnded, this); + listener->onTouchesEnded = CC_CALLBACK_2(MeshRendererEffectTest::onTouchesEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) _backToForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom*) { - auto material = Sprite3DMaterial::createWithFilename("Sprite3DTest/outline.material"); + auto material = MeshMaterial::createWithFilename("MeshRendererTest/outline.material"); material->setTechnique("outline_noneskinned"); - for (auto& sprite : _sprites) + for (auto& mesh : _meshes) { - sprite->setMaterial(material->clone()); + mesh->setMaterial(material->clone()); } }); Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundListener, 1); #endif } -Sprite3DEffectTest::~Sprite3DEffectTest() +MeshRendererEffectTest::~MeshRendererEffectTest() { #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundListener); #endif } -std::string Sprite3DEffectTest::title() const +std::string MeshRendererEffectTest::title() const { - return "Testing Sprite3D"; + return "Testing MeshRenderer"; } -std::string Sprite3DEffectTest::subtitle() const +std::string MeshRendererEffectTest::subtitle() const { - return "Sprite3d with effects"; + return "MeshRenderer with effects"; } -void Sprite3DEffectTest::addNewSpriteWithCoords(Vec2 p) +void MeshRendererEffectTest::addNewMeshWithCoords(Vec2 p) { // option 2: load obj and assign the texture - auto sprite = Sprite3D::create("Sprite3DTest/boss1.obj"); - auto material = Sprite3DMaterial::createWithFilename("Sprite3DTest/outline.material"); + auto mesh = MeshRenderer::create("MeshRendererTest/boss1.obj"); + auto material = MeshMaterial::createWithFilename("MeshRendererTest/outline.material"); material->setTechnique("outline_noneskinned"); - sprite->setMaterial(material); - sprite->setScale(6.f); + mesh->setMaterial(material); + mesh->setScale(6.f); Director::getInstance()->getTextureCache()->removeUnusedTextures(); // add to scene - addChild(sprite); + addChild(mesh); - sprite->setPosition(Vec2(p.x, p.y)); + mesh->setPosition(Vec2(p.x, p.y)); ActionInterval* action; float random = CCRANDOM_0_1(); @@ -799,31 +799,31 @@ void Sprite3DEffectTest::addNewSpriteWithCoords(Vec2 p) auto action_back = action->reverse(); auto seq = Sequence::create(action, action_back, nullptr); - sprite->runAction(RepeatForever::create(seq)); - _sprites.push_back(sprite); + mesh->runAction(RepeatForever::create(seq)); + _meshes.push_back(mesh); } -void Sprite3DEffectTest::onTouchesEnded(const std::vector& touches, Event* event) +void MeshRendererEffectTest::onTouchesEnded(const std::vector& touches, Event* event) { for (auto touch : touches) { auto location = touch->getLocation(); - addNewSpriteWithCoords(location); + addNewMeshWithCoords(location); } } -AsyncLoadSprite3DTest::AsyncLoadSprite3DTest() +AsyncLoadMeshRendererTest::AsyncLoadMeshRendererTest() { - _paths.push_back("Sprite3DTest/girl.c3b"); - _paths.push_back("Sprite3DTest/orc.c3b"); - _paths.push_back("Sprite3DTest/ReskinGirl.c3b"); - _paths.push_back("Sprite3DTest/axe.c3b"); + _paths.push_back("MeshRendererTest/girl.c3b"); + _paths.push_back("MeshRendererTest/orc.c3b"); + _paths.push_back("MeshRendererTest/ReskinGirl.c3b"); + _paths.push_back("MeshRendererTest/axe.c3b"); TTFConfig ttfConfig("fonts/arial.ttf", 15); - auto label1 = Label::createWithTTF(ttfConfig, "AsyncLoad Sprite3D"); + auto label1 = Label::createWithTTF(ttfConfig, "AsyncLoad MeshRenderer"); auto item1 = - MenuItemLabel::create(label1, CC_CALLBACK_1(AsyncLoadSprite3DTest::menuCallback_asyncLoadSprite, this)); + MenuItemLabel::create(label1, CC_CALLBACK_1(AsyncLoadMeshRendererTest::menuCallback_asyncLoadMesh, this)); auto s = Director::getInstance()->getWinSize(); item1->setPosition(s.width * .5f, s.height * .8f); @@ -836,90 +836,90 @@ AsyncLoadSprite3DTest::AsyncLoadSprite3DTest() node->setTag(101); this->addChild(node); - menuCallback_asyncLoadSprite(nullptr); + menuCallback_asyncLoadMesh(nullptr); } -AsyncLoadSprite3DTest::~AsyncLoadSprite3DTest() {} +AsyncLoadMeshRendererTest::~AsyncLoadMeshRendererTest() {} -std::string AsyncLoadSprite3DTest::title() const +std::string AsyncLoadMeshRendererTest::title() const { - return "Testing Sprite3D::createAsync"; + return "Testing MeshRenderer::createAsync"; } -std::string AsyncLoadSprite3DTest::subtitle() const +std::string AsyncLoadMeshRendererTest::subtitle() const { return ""; } -void AsyncLoadSprite3DTest::menuCallback_asyncLoadSprite(Ref* sender) +void AsyncLoadMeshRendererTest::menuCallback_asyncLoadMesh(Ref* sender) { // Note that you must stop the tasks before leaving the scene. AsyncTaskPool::getInstance()->stopTasks(AsyncTaskPool::TaskType::TASK_IO); auto node = getChildByTag(101); - node->removeAllChildren(); // remove all loaded sprite + node->removeAllChildren(); // remove all loaded mesh // remove cache data - Sprite3DCache::getInstance()->removeAllSprite3DData(); + MeshRendererCache::getInstance()->removeAllMeshRendererData(); int32_t index = 0; for (const auto& path : _paths) { - Sprite3D::createAsync(path, CC_CALLBACK_2(AsyncLoadSprite3DTest::asyncLoad_Callback, this), (void*)index++); + MeshRenderer::createAsync(path, CC_CALLBACK_2(AsyncLoadMeshRendererTest::asyncLoad_Callback, this), (void*)index++); } } -void AsyncLoadSprite3DTest::asyncLoad_Callback(Sprite3D* sprite, void* param) +void AsyncLoadMeshRendererTest::asyncLoad_Callback(MeshRenderer* mesh, void* param) { auto index = static_cast((uintptr_t)param); auto node = getChildByTag(101); auto s = Director::getInstance()->getWinSize(); float width = s.width / _paths.size(); Vec2 point(width * (0.5f + index), s.height / 2.f); - sprite->setPosition(point); - node->addChild(sprite); + mesh->setPosition(point); + node->addChild(mesh); } -Sprite3DWithSkinTest::Sprite3DWithSkinTest() +MeshRendererWithSkinTest::MeshRendererWithSkinTest() { auto listener = EventListenerTouchAllAtOnce::create(); - listener->onTouchesEnded = CC_CALLBACK_2(Sprite3DWithSkinTest::onTouchesEnded, this); + listener->onTouchesEnded = CC_CALLBACK_2(MeshRendererWithSkinTest::onTouchesEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); - // switch animation quality. In fact, you can set the sprite3d out of frustum to Animate3DQuality::QUALITY_NONE, it + // switch animation quality. In fact, you can set the mesh3d out of frustum to Animate3DQuality::QUALITY_NONE, it // can save a lot of cpu time MenuItemFont::setFontName("fonts/arial.ttf"); MenuItemFont::setFontSize(15); _animateQuality = (int)Animate3DQuality::QUALITY_LOW; _menuItem = MenuItemFont::create(getAnimationQualityMessage(), - CC_CALLBACK_1(Sprite3DWithSkinTest::switchAnimationQualityCallback, this)); + CC_CALLBACK_1(MeshRendererWithSkinTest::switchAnimationQualityCallback, this)); _menuItem->setColor(Color3B(0, 200, 20)); auto menu = Menu::create(_menuItem, NULL); menu->setPosition(Vec2::ZERO); _menuItem->setPosition(VisibleRect::left().x + 50, VisibleRect::top().y - 70); addChild(menu, 1); - _sprits.clear(); + _meshes.clear(); auto s = Director::getInstance()->getWinSize(); - addNewSpriteWithCoords(Vec2(s.width / 2, s.height / 2)); + addNewMeshWithCoords(Vec2(s.width / 2, s.height / 2)); } -std::string Sprite3DWithSkinTest::title() const +std::string MeshRendererWithSkinTest::title() const { - return "Testing Sprite3D"; + return "Testing MeshRenderer"; } -std::string Sprite3DWithSkinTest::subtitle() const +std::string MeshRendererWithSkinTest::subtitle() const { - return "Tap screen to add more sprite3D"; + return "Tap screen to add more mesh3D"; } -void Sprite3DWithSkinTest::addNewSpriteWithCoords(Vec2 p) +void MeshRendererWithSkinTest::addNewMeshWithCoords(Vec2 p) { - std::string fileName = "Sprite3DTest/orc.c3b"; - auto sprite = Sprite3D::create(fileName); - sprite->setScale(3); - sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); - sprite->setPosition(Vec2(p.x, p.y)); - addChild(sprite); - _sprits.push_back(sprite); + std::string fileName = "MeshRendererTest/orc.c3b"; + auto mesh = MeshRenderer::create(fileName); + mesh->setScale(3); + mesh->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); + mesh->setPosition(Vec2(p.x, p.y)); + addChild(mesh); + _meshes.push_back(mesh); auto animation = Animation3D::create(fileName); if (animation) @@ -942,11 +942,11 @@ void Sprite3DWithSkinTest::addNewSpriteWithCoords(Vec2 p) animate->setQuality((Animate3DQuality)_animateQuality); auto repeat = RepeatForever::create(animate); repeat->setTag(110); - sprite->runAction(repeat); + mesh->runAction(repeat); } } -std::string Sprite3DWithSkinTest::getAnimationQualityMessage() const +std::string MeshRendererWithSkinTest::getAnimationQualityMessage() const { if (_animateQuality == (int)Animate3DQuality::QUALITY_NONE) return "None Quality"; @@ -958,7 +958,7 @@ std::string Sprite3DWithSkinTest::getAnimationQualityMessage() const return ""; } -void Sprite3DWithSkinTest::switchAnimationQualityCallback(Ref* sender) +void MeshRendererWithSkinTest::switchAnimationQualityCallback(Ref* sender) { ++_animateQuality; if (_animateQuality > (int)Animate3DQuality::QUALITY_HIGH) @@ -966,7 +966,7 @@ void Sprite3DWithSkinTest::switchAnimationQualityCallback(Ref* sender) _menuItem->setString(getAnimationQualityMessage()); - for (auto iter : _sprits) + for (auto iter : _meshes) { RepeatForever* repAction = dynamic_cast(iter->getActionByTag(110)); Animate3D* animate3D = dynamic_cast(repAction->getInnerAction()); @@ -974,66 +974,66 @@ void Sprite3DWithSkinTest::switchAnimationQualityCallback(Ref* sender) } } -void Sprite3DWithSkinTest::onTouchesEnded(const std::vector& touches, Event* event) +void MeshRendererWithSkinTest::onTouchesEnded(const std::vector& touches, Event* event) { for (auto touch : touches) { auto location = touch->getLocation(); - addNewSpriteWithCoords(location); + addNewMeshWithCoords(location); } } -Sprite3DWithSkinOutlineTest::Sprite3DWithSkinOutlineTest() +MeshRendererWithSkinOutlineTest::MeshRendererWithSkinOutlineTest() { auto listener = EventListenerTouchAllAtOnce::create(); - listener->onTouchesEnded = CC_CALLBACK_2(Sprite3DWithSkinOutlineTest::onTouchesEnded, this); + listener->onTouchesEnded = CC_CALLBACK_2(MeshRendererWithSkinOutlineTest::onTouchesEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); auto s = Director::getInstance()->getWinSize(); - addNewSpriteWithCoords(Vec2(s.width / 2, s.height / 2)); + addNewMeshWithCoords(Vec2(s.width / 2, s.height / 2)); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) _backToForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom*) { - auto material = Sprite3DMaterial::createWithFilename("Sprite3DTest/outline.material"); + auto material = MeshMaterial::createWithFilename("MeshRendererTest/outline.material"); material->setTechnique("outline_skinned"); - for (auto& sprite : _sprites) + for (auto& mesh : _meshes) { - sprite->setMaterial(material->clone()); + mesh->setMaterial(material->clone()); } }); Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundListener, 1); #endif } -Sprite3DWithSkinOutlineTest::~Sprite3DWithSkinOutlineTest() +MeshRendererWithSkinOutlineTest::~MeshRendererWithSkinOutlineTest() { #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundListener); #endif } -std::string Sprite3DWithSkinOutlineTest::title() const +std::string MeshRendererWithSkinOutlineTest::title() const { - return "Testing Sprite3D for skinned outline"; + return "Testing MeshRenderer for skinned outline"; } -std::string Sprite3DWithSkinOutlineTest::subtitle() const +std::string MeshRendererWithSkinOutlineTest::subtitle() const { - return "Tap screen to add more sprite3D"; + return "Tap screen to add more mesh3D"; } -void Sprite3DWithSkinOutlineTest::addNewSpriteWithCoords(Vec2 p) +void MeshRendererWithSkinOutlineTest::addNewMeshWithCoords(Vec2 p) { - std::string fileName = "Sprite3DTest/orc.c3b"; - auto sprite = Sprite3D::create(fileName); + std::string fileName = "MeshRendererTest/orc.c3b"; + auto mesh = MeshRenderer::create(fileName); - auto material = Sprite3DMaterial::createWithFilename("Sprite3DTest/outline.material"); + auto material = MeshMaterial::createWithFilename("MeshRendererTest/outline.material"); material->setTechnique("outline_skinned"); - sprite->setMaterial(material); + mesh->setMaterial(material); - sprite->setScale(3); - sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); - addChild(sprite); - sprite->setPosition(Vec2(p.x, p.y)); + mesh->setScale(3); + mesh->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); + addChild(mesh); + mesh->setPosition(Vec2(p.x, p.y)); auto animation = Animation3D::create(fileName); if (animation) @@ -1053,24 +1053,24 @@ void Sprite3DWithSkinOutlineTest::addNewSpriteWithCoords(Vec2 p) } animate->setSpeed(inverse ? -speed : speed); - sprite->runAction(RepeatForever::create(animate)); + mesh->runAction(RepeatForever::create(animate)); } } -void Sprite3DWithSkinOutlineTest::onTouchesEnded(const std::vector& touches, Event* event) +void MeshRendererWithSkinOutlineTest::onTouchesEnded(const std::vector& touches, Event* event) { for (auto touch : touches) { auto location = touch->getLocation(); - addNewSpriteWithCoords(location); + addNewMeshWithCoords(location); } } Animate3DTest::Animate3DTest() - : _sprite(nullptr), _swim(nullptr), _hurt(nullptr), _elapseTransTime(0.f), _moveAction(nullptr) + : _mesh(nullptr), _swim(nullptr), _hurt(nullptr), _elapseTransTime(0.f), _moveAction(nullptr) { - addSprite3D(); + addMeshRenderer(); auto listener = EventListenerTouchAllAtOnce::create(); listener->onTouchesEnded = CC_CALLBACK_2(Animate3DTest::onTouchesEnded, this); @@ -1104,7 +1104,7 @@ void Animate3DTest::update(float dt) if (_elapseTransTime >= Animate3D::getTransitionTime()) { - _sprite->stopAction(_hurt); + _mesh->stopAction(_hurt); _state = State::SWIMMING; } } @@ -1113,27 +1113,27 @@ void Animate3DTest::update(float dt) _elapseTransTime += dt; if (_elapseTransTime >= Animate3D::getTransitionTime()) { - _sprite->stopAction(_swim); + _mesh->stopAction(_swim); _state = State::HURT; } } } -void Animate3DTest::addSprite3D() +void Animate3DTest::addMeshRenderer() { - std::string fileName = "Sprite3DTest/tortoise.c3b"; - auto sprite = Sprite3D::create(fileName); - sprite->setScale(0.1f); + std::string fileName = "MeshRendererTest/tortoise.c3b"; + auto mesh = MeshRenderer::create(fileName); + mesh->setScale(0.1f); auto s = Director::getInstance()->getWinSize(); - sprite->setPosition(Vec2(s.width * 4.f / 5.f, s.height / 2.f)); - addChild(sprite); - _sprite = sprite; + mesh->setPosition(Vec2(s.width * 4.f / 5.f, s.height / 2.f)); + addChild(mesh); + _mesh = mesh; auto animation = Animation3D::create(fileName); if (animation) { auto animate = Animate3D::create(animation, 0.f, 1.933f); _swim = RepeatForever::create(animate); - sprite->runAction(_swim); + mesh->runAction(_swim); _swim->retain(); _hurt = Animate3D::create(animation, 1.933f, 2.8f); @@ -1146,14 +1146,14 @@ void Animate3DTest::addSprite3D() auto seq = Sequence::create(_moveAction, CallFunc::create(CC_CALLBACK_0(Animate3DTest::reachEndCallBack, this)), nullptr); seq->setTag(100); - sprite->runAction(seq); + mesh->runAction(seq); } void Animate3DTest::reachEndCallBack() { auto s = Director::getInstance()->getWinSize(); - _sprite->stopActionByTag(100); - auto inverse = MoveTo::create(4.f, Vec2(s.width - _sprite->getPositionX(), s.height / 2.f)); + _mesh->stopActionByTag(100); + auto inverse = MoveTo::create(4.f, Vec2(s.width - _mesh->getPositionX(), s.height / 2.f)); inverse->retain(); _moveAction->release(); _moveAction = inverse; @@ -1161,13 +1161,13 @@ void Animate3DTest::reachEndCallBack() auto seq = Sequence::create(rot, _moveAction, CallFunc::create(CC_CALLBACK_0(Animate3DTest::reachEndCallBack, this)), nullptr); seq->setTag(100); - _sprite->runAction(seq); + _mesh->runAction(seq); } void Animate3DTest::renewCallBack() { // rerun swim action - _sprite->runAction(_swim); + _mesh->runAction(_swim); _state = State::HURT_TO_SWIMMING; _elapseTransTime = 0.0f; } @@ -1178,9 +1178,9 @@ void Animate3DTest::onTouchesEnded(const std::vector& touches, Event* ev { auto location = touch->getLocation(); - if (_sprite) + if (_mesh) { - float len = (_sprite->getPosition() - location).length(); + float len = (_mesh->getPosition() - location).length(); if (len < 40) { // hurt the tortoise @@ -1188,13 +1188,13 @@ void Animate3DTest::onTouchesEnded(const std::vector& touches, Event* ev { _elapseTransTime = 0.0f; _state = State::SWIMMING_TO_HURT; - _sprite->stopAction(_hurt); - _sprite->runAction(_hurt); + _mesh->stopAction(_hurt); + _mesh->runAction(_hurt); auto delay = DelayTime::create(_hurt->getDuration() - Animate3D::getTransitionTime()); auto seq = Sequence::create( delay, CallFunc::create(CC_CALLBACK_0(Animate3DTest::renewCallBack, this)), nullptr); seq->setTag(101); - _sprite->runAction(seq); + _mesh->runAction(seq); } return; } @@ -1202,10 +1202,10 @@ void Animate3DTest::onTouchesEnded(const std::vector& touches, Event* ev } } -AttachmentTest::AttachmentTest() : _hasWeapon(false), _sprite(nullptr) +AttachmentTest::AttachmentTest() : _hasWeapon(false), _mesh(nullptr) { auto s = Director::getInstance()->getWinSize(); - addNewSpriteWithCoords(Vec2(s.width / 2, s.height / 2)); + addNewMeshWithCoords(Vec2(s.width / 2, s.height / 2)); auto listener = EventListenerTouchAllAtOnce::create(); listener->onTouchesEnded = CC_CALLBACK_2(AttachmentTest::onTouchesEnded, this); @@ -1213,34 +1213,34 @@ AttachmentTest::AttachmentTest() : _hasWeapon(false), _sprite(nullptr) } std::string AttachmentTest::title() const { - return "Testing Sprite3D Attachment"; + return "Testing MeshRenderer Attachment"; } std::string AttachmentTest::subtitle() const { return "touch to switch weapon"; } -void AttachmentTest::addNewSpriteWithCoords(Vec2 p) +void AttachmentTest::addNewMeshWithCoords(Vec2 p) { - std::string fileName = "Sprite3DTest/orc.c3b"; - auto sprite = Sprite3D::create(fileName); - sprite->setScale(5); - sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); - addChild(sprite); - sprite->setPosition(Vec2(p.x, p.y)); + std::string fileName = "MeshRendererTest/orc.c3b"; + auto mesh = MeshRenderer::create(fileName); + mesh->setScale(5); + mesh->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); + addChild(mesh); + mesh->setPosition(Vec2(p.x, p.y)); // test attach - auto sp = Sprite3D::create("Sprite3DTest/axe.c3b"); - sprite->getAttachNode("Bip001 R Hand")->addChild(sp); + auto sp = MeshRenderer::create("MeshRendererTest/axe.c3b"); + mesh->getAttachNode("Bip001 R Hand")->addChild(sp); auto animation = Animation3D::create(fileName); if (animation) { auto animate = Animate3D::create(animation); - sprite->runAction(RepeatForever::create(animate)); + mesh->runAction(RepeatForever::create(animate)); } - _sprite = sprite; + _mesh = mesh; _hasWeapon = true; } @@ -1248,35 +1248,35 @@ void AttachmentTest::onTouchesEnded(const std::vector& touches, Event* e { if (_hasWeapon) { - _sprite->removeAllAttachNode(); + _mesh->removeAllAttachNode(); } else { - auto sp = Sprite3D::create("Sprite3DTest/axe.c3b"); - _sprite->getAttachNode("Bip001 R Hand")->addChild(sp); + auto sp = MeshRenderer::create("MeshRendererTest/axe.c3b"); + _mesh->getAttachNode("Bip001 R Hand")->addChild(sp); } _hasWeapon = !_hasWeapon; } -Sprite3DReskinTest::Sprite3DReskinTest() : _sprite(nullptr) +MeshRendererReskinTest::MeshRendererReskinTest() : _mesh(nullptr) { auto s = Director::getInstance()->getWinSize(); - addNewSpriteWithCoords(Vec2(s.width / 2, s.height / 2)); + addNewMeshWithCoords(Vec2(s.width / 2, s.height / 2)); auto listener = EventListenerTouchAllAtOnce::create(); - listener->onTouchesEnded = CC_CALLBACK_2(Sprite3DReskinTest::onTouchesEnded, this); + listener->onTouchesEnded = CC_CALLBACK_2(MeshRendererReskinTest::onTouchesEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); TTFConfig ttfConfig("fonts/arial.ttf", 20); auto label1 = Label::createWithTTF(ttfConfig, "Hair"); - auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(Sprite3DReskinTest::menuCallback_reSkin, this)); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(MeshRendererReskinTest::menuCallback_reSkin, this)); auto label2 = Label::createWithTTF(ttfConfig, "Glasses"); - auto item2 = MenuItemLabel::create(label2, CC_CALLBACK_1(Sprite3DReskinTest::menuCallback_reSkin, this)); + auto item2 = MenuItemLabel::create(label2, CC_CALLBACK_1(MeshRendererReskinTest::menuCallback_reSkin, this)); auto label3 = Label::createWithTTF(ttfConfig, "Coat"); - auto item3 = MenuItemLabel::create(label3, CC_CALLBACK_1(Sprite3DReskinTest::menuCallback_reSkin, this)); + auto item3 = MenuItemLabel::create(label3, CC_CALLBACK_1(MeshRendererReskinTest::menuCallback_reSkin, this)); auto label4 = Label::createWithTTF(ttfConfig, "Pants"); - auto item4 = MenuItemLabel::create(label4, CC_CALLBACK_1(Sprite3DReskinTest::menuCallback_reSkin, this)); + auto item4 = MenuItemLabel::create(label4, CC_CALLBACK_1(MeshRendererReskinTest::menuCallback_reSkin, this)); auto label5 = Label::createWithTTF(ttfConfig, "Shoes"); - auto item5 = MenuItemLabel::create(label5, CC_CALLBACK_1(Sprite3DReskinTest::menuCallback_reSkin, this)); + auto item5 = MenuItemLabel::create(label5, CC_CALLBACK_1(MeshRendererReskinTest::menuCallback_reSkin, this)); item1->setPosition(Vec2(VisibleRect::left().x + 50, VisibleRect::bottom().y + item1->getContentSize().height * 4)); item2->setPosition(Vec2(VisibleRect::left().x + 50, VisibleRect::bottom().y + item1->getContentSize().height * 5)); item3->setPosition(Vec2(VisibleRect::left().x + 50, VisibleRect::bottom().y + item1->getContentSize().height * 6)); @@ -1291,7 +1291,7 @@ Sprite3DReskinTest::Sprite3DReskinTest() : _sprite(nullptr) pMenu1->setPosition(Vec2(0.0f, 0.0f)); this->addChild(pMenu1, 10); } -void Sprite3DReskinTest::menuCallback_reSkin(Ref* sender) +void MeshRendererReskinTest::menuCallback_reSkin(Ref* sender) { auto index = static_cast((uintptr_t)(((MenuItemLabel*)sender)->getUserData())); if (index < (int)SkinType::MAX_TYPE) @@ -1301,31 +1301,31 @@ void Sprite3DReskinTest::menuCallback_reSkin(Ref* sender) } } -std::string Sprite3DReskinTest::title() const +std::string MeshRendererReskinTest::title() const { - return "Testing Sprite3D Reskin"; + return "Testing MeshRenderer Reskin"; } -std::string Sprite3DReskinTest::subtitle() const +std::string MeshRendererReskinTest::subtitle() const { return ""; } -void Sprite3DReskinTest::addNewSpriteWithCoords(Vec2 p) +void MeshRendererReskinTest::addNewMeshWithCoords(Vec2 p) { - std::string fileName = "Sprite3DTest/ReskinGirl.c3b"; - auto sprite = Sprite3D::create(fileName); - sprite->setScale(4); - sprite->setRotation3D(Vec3(0.0f, 0.0f, 0.0f)); - addChild(sprite); - sprite->setPosition(Vec2(p.x, p.y - 60)); + std::string fileName = "MeshRendererTest/ReskinGirl.c3b"; + auto mesh = MeshRenderer::create(fileName); + mesh->setScale(4); + mesh->setRotation3D(Vec3(0.0f, 0.0f, 0.0f)); + addChild(mesh); + mesh->setPosition(Vec2(p.x, p.y - 60)); auto animation = Animation3D::create(fileName); if (animation) { auto animate = Animate3D::create(animation); - sprite->runAction(RepeatForever::create(animate)); + mesh->runAction(RepeatForever::create(animate)); } - _sprite = sprite; + _mesh = mesh; auto& body = _skins[(int)SkinType::UPPER_BODY]; body.push_back("Girl_UpperBody01"); @@ -1360,13 +1360,13 @@ void Sprite3DReskinTest::addNewSpriteWithCoords(Vec2 p) applyCurSkin(); } -void Sprite3DReskinTest::onTouchesEnded(const std::vector& touches, Event* event) {} +void MeshRendererReskinTest::onTouchesEnded(const std::vector& touches, Event* event) {} -void Sprite3DReskinTest::applyCurSkin() +void MeshRendererReskinTest::applyCurSkin() { - for (ssize_t i = 0; i < _sprite->getMeshCount(); i++) + for (ssize_t i = 0; i < _mesh->getMeshCount(); i++) { - auto mesh = _sprite->getMeshByIndex(static_cast(i)); + auto mesh = _mesh->getMeshByIndex(static_cast(i)); bool isVisible = false; for (int j = 0; j < (int)SkinType::MAX_TYPE; j++) { @@ -1376,26 +1376,26 @@ void Sprite3DReskinTest::applyCurSkin() break; } } - _sprite->getMeshByIndex(static_cast(i))->setVisible(isVisible); + _mesh->getMeshByIndex(static_cast(i))->setVisible(isVisible); } } -Sprite3DWithOBBPerformanceTest::Sprite3DWithOBBPerformanceTest() +MeshRendererWithOBBPerformanceTest::MeshRendererWithOBBPerformanceTest() { auto listener = EventListenerTouchAllAtOnce::create(); - listener->onTouchesBegan = CC_CALLBACK_2(Sprite3DWithOBBPerformanceTest::onTouchesBegan, this); - listener->onTouchesEnded = CC_CALLBACK_2(Sprite3DWithOBBPerformanceTest::onTouchesEnded, this); - listener->onTouchesMoved = CC_CALLBACK_2(Sprite3DWithOBBPerformanceTest::onTouchesMoved, this); + listener->onTouchesBegan = CC_CALLBACK_2(MeshRendererWithOBBPerformanceTest::onTouchesBegan, this); + listener->onTouchesEnded = CC_CALLBACK_2(MeshRendererWithOBBPerformanceTest::onTouchesEnded, this); + listener->onTouchesMoved = CC_CALLBACK_2(MeshRendererWithOBBPerformanceTest::onTouchesMoved, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); auto s = Director::getInstance()->getWinSize(); initDrawBox(); - addNewSpriteWithCoords(Vec2(s.width / 2, s.height / 2)); + addNewMeshWithCoords(Vec2(s.width / 2, s.height / 2)); MenuItemFont::setFontName("fonts/arial.ttf"); MenuItemFont::setFontSize(65); - auto decrease = MenuItemFont::create(" - ", CC_CALLBACK_1(Sprite3DWithOBBPerformanceTest::delOBBCallback, this)); + auto decrease = MenuItemFont::create(" - ", CC_CALLBACK_1(MeshRendererWithOBBPerformanceTest::delOBBCallback, this)); decrease->setColor(Color3B(0, 200, 20)); - auto increase = MenuItemFont::create(" + ", CC_CALLBACK_1(Sprite3DWithOBBPerformanceTest::addOBBCallback, this)); + auto increase = MenuItemFont::create(" + ", CC_CALLBACK_1(MeshRendererWithOBBPerformanceTest::addOBBCallback, this)); increase->setColor(Color3B(0, 200, 20)); auto menu = Menu::create(decrease, increase, nullptr); @@ -1412,15 +1412,15 @@ Sprite3DWithOBBPerformanceTest::Sprite3DWithOBBPerformanceTest() addOBBCallback(nullptr); scheduleUpdate(); } -std::string Sprite3DWithOBBPerformanceTest::title() const +std::string MeshRendererWithOBBPerformanceTest::title() const { return "OBB Collision Performance Test"; } -std::string Sprite3DWithOBBPerformanceTest::subtitle() const +std::string MeshRendererWithOBBPerformanceTest::subtitle() const { return ""; } -void Sprite3DWithOBBPerformanceTest::addNewOBBWithCoords(Vec2 p) +void MeshRendererWithOBBPerformanceTest::addNewOBBWithCoords(Vec2 p) { Vec3 extents = Vec3(10, 10, 10); AABB aabb(-extents, extents); @@ -1429,7 +1429,7 @@ void Sprite3DWithOBBPerformanceTest::addNewOBBWithCoords(Vec2 p) _obb.push_back(obb); } -void Sprite3DWithOBBPerformanceTest::onTouchesBegan(const std::vector& touches, Event* event) +void MeshRendererWithOBBPerformanceTest::onTouchesBegan(const std::vector& touches, Event* event) { for (const auto& touch : touches) { @@ -1452,9 +1452,9 @@ void Sprite3DWithOBBPerformanceTest::onTouchesBegan(const std::vector& t } } -void Sprite3DWithOBBPerformanceTest::onTouchesEnded(const std::vector& touches, Event* event) {} +void MeshRendererWithOBBPerformanceTest::onTouchesEnded(const std::vector& touches, Event* event) {} -void Sprite3DWithOBBPerformanceTest::onTouchesMoved(const std::vector& touches, Event* event) +void MeshRendererWithOBBPerformanceTest::onTouchesMoved(const std::vector& touches, Event* event) { for (const auto& touch : touches) { @@ -1469,7 +1469,7 @@ void Sprite3DWithOBBPerformanceTest::onTouchesMoved(const std::vector& t } } -void Sprite3DWithOBBPerformanceTest::update(float dt) +void MeshRendererWithOBBPerformanceTest::update(float dt) { char szText[16]; sprintf(szText, "%lu cubes", static_cast(_obb.size())); @@ -1479,7 +1479,7 @@ void Sprite3DWithOBBPerformanceTest::update(float dt) { _drawDebug->clear(); - Mat4 mat = _sprite->getNodeToWorldTransform(); + Mat4 mat = _mesh->getNodeToWorldTransform(); _obbt = _obbtOri; _obbt.transform(mat); @@ -1501,65 +1501,65 @@ void Sprite3DWithOBBPerformanceTest::update(float dt) } } -void Sprite3DWithOBBPerformanceTest::initDrawBox() +void MeshRendererWithOBBPerformanceTest::initDrawBox() { _drawOBB = DrawNode3D::create(); addChild(_drawOBB); } -void Sprite3DWithOBBPerformanceTest::addNewSpriteWithCoords(Vec2 p) +void MeshRendererWithOBBPerformanceTest::addNewMeshWithCoords(Vec2 p) { - std::string fileName = "Sprite3DTest/tortoise.c3b"; - auto sprite = Sprite3D::create(fileName); - AABB aabb = sprite->getAABB(); + std::string fileName = "MeshRendererTest/tortoise.c3b"; + auto mesh = MeshRenderer::create(fileName); + AABB aabb = mesh->getAABB(); _obbt = OBB(aabb); _obbtOri = _obbt; - sprite->setScale(0.1f); + mesh->setScale(0.1f); auto s = Director::getInstance()->getWinSize(); - sprite->setPosition(Vec2(s.width * 4.f / 5.f, s.height / 2.f)); - addChild(sprite); - _sprite = sprite; + mesh->setPosition(Vec2(s.width * 4.f / 5.f, s.height / 2.f)); + addChild(mesh); + _mesh = mesh; auto animation = Animation3D::create(fileName); if (animation) { auto animate = Animate3D::create(animation, 0.f, 1.933f); - sprite->runAction(RepeatForever::create(animate)); + mesh->runAction(RepeatForever::create(animate)); } _moveAction = MoveTo::create(4.f, Vec2(s.width / 5.f, s.height / 2.f)); _moveAction->retain(); auto seq = Sequence::create( - _moveAction, CallFunc::create(CC_CALLBACK_0(Sprite3DWithOBBPerformanceTest::reachEndCallBack, this)), nullptr); + _moveAction, CallFunc::create(CC_CALLBACK_0(MeshRendererWithOBBPerformanceTest::reachEndCallBack, this)), nullptr); seq->setTag(100); - sprite->runAction(seq); + mesh->runAction(seq); _drawDebug = DrawNode3D::create(); addChild(_drawDebug); } -void Sprite3DWithOBBPerformanceTest::reachEndCallBack() +void MeshRendererWithOBBPerformanceTest::reachEndCallBack() { auto s = Director::getInstance()->getWinSize(); - _sprite->stopActionByTag(100); - auto inverse = MoveTo::create(4.f, Vec2(s.width - _sprite->getPositionX(), s.height / 2.f)); + _mesh->stopActionByTag(100); + auto inverse = MoveTo::create(4.f, Vec2(s.width - _mesh->getPositionX(), s.height / 2.f)); inverse->retain(); _moveAction->release(); _moveAction = inverse; auto rot = RotateBy::create(1.0f, Vec3(0.f, 180.f, 0.f)); auto seq = Sequence::create(rot, _moveAction, - CallFunc::create(CC_CALLBACK_0(Sprite3DWithOBBPerformanceTest::reachEndCallBack, this)), + CallFunc::create(CC_CALLBACK_0(MeshRendererWithOBBPerformanceTest::reachEndCallBack, this)), nullptr); seq->setTag(100); - _sprite->runAction(seq); + _mesh->runAction(seq); } -void Sprite3DWithOBBPerformanceTest::addOBBCallback(Ref* sender) +void MeshRendererWithOBBPerformanceTest::addOBBCallback(Ref* sender) { addOBBWithCount(10); } -void Sprite3DWithOBBPerformanceTest::addOBBWithCount(float value) +void MeshRendererWithOBBPerformanceTest::addOBBWithCount(float value) { for (int i = 0; i < value; i++) { @@ -1573,12 +1573,12 @@ void Sprite3DWithOBBPerformanceTest::addOBBWithCount(float value) } } -void Sprite3DWithOBBPerformanceTest::delOBBCallback(Ref* sender) +void MeshRendererWithOBBPerformanceTest::delOBBCallback(Ref* sender) { delOBBWithCount(10); } -void Sprite3DWithOBBPerformanceTest::delOBBWithCount(float value) +void MeshRendererWithOBBPerformanceTest::delOBBWithCount(float value) { if (_obb.size() >= 10) { @@ -1588,7 +1588,7 @@ void Sprite3DWithOBBPerformanceTest::delOBBWithCount(float value) else return; } -void Sprite3DWithOBBPerformanceTest::unproject(const Mat4& viewProjection, const Size* viewport, Vec3* src, Vec3* dst) +void MeshRendererWithOBBPerformanceTest::unproject(const Mat4& viewProjection, const Size* viewport, Vec3* src, Vec3* dst) { assert(dst); @@ -1611,7 +1611,7 @@ void Sprite3DWithOBBPerformanceTest::unproject(const Mat4& viewProjection, const dst->set(screen.x, screen.y, screen.z); } -void Sprite3DWithOBBPerformanceTest::calculateRayByLocationInView(Ray* ray, const Vec2& location) +void MeshRendererWithOBBPerformanceTest::calculateRayByLocationInView(Ray* ray, const Vec2& location) { auto dir = Director::getInstance(); auto view = dir->getWinSize(); @@ -1633,70 +1633,70 @@ void Sprite3DWithOBBPerformanceTest::calculateRayByLocationInView(Ray* ray, cons ray->_direction = direction; } -Sprite3DMirrorTest::Sprite3DMirrorTest() : _sprite(nullptr), _mirrorSprite(nullptr) +MeshRendererMirrorTest::MeshRendererMirrorTest() : _mesh(nullptr), _mirrorMesh(nullptr) { auto s = Director::getInstance()->getWinSize(); - addNewSpriteWithCoords(Vec2(s.width / 2, s.height / 2)); + addNewMeshWithCoords(Vec2(s.width / 2, s.height / 2)); } -std::string Sprite3DMirrorTest::title() const +std::string MeshRendererMirrorTest::title() const { - return "Sprite3D Mirror Test"; + return "MeshRenderer Mirror Test"; } -std::string Sprite3DMirrorTest::subtitle() const +std::string MeshRendererMirrorTest::subtitle() const { return ""; } -void Sprite3DMirrorTest::addNewSpriteWithCoords(Vec2 p) +void MeshRendererMirrorTest::addNewMeshWithCoords(Vec2 p) { - std::string fileName = "Sprite3DTest/orc.c3b"; - auto sprite = Sprite3D::create(fileName); - sprite->setScale(5); - sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); - addChild(sprite); - sprite->setPosition(Vec2(p.x - 80, p.y)); + std::string fileName = "MeshRendererTest/orc.c3b"; + auto mesh = MeshRenderer::create(fileName); + mesh->setScale(5); + mesh->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); + addChild(mesh); + mesh->setPosition(Vec2(p.x - 80, p.y)); // test attach - auto sp = Sprite3D::create("Sprite3DTest/axe.c3b"); - sprite->getAttachNode("Bip001 R Hand")->addChild(sp); + auto sp = MeshRenderer::create("MeshRendererTest/axe.c3b"); + mesh->getAttachNode("Bip001 R Hand")->addChild(sp); auto animation = Animation3D::create(fileName); if (animation) { auto animate = Animate3D::create(animation); - sprite->runAction(RepeatForever::create(animate)); + mesh->runAction(RepeatForever::create(animate)); } - _sprite = sprite; + _mesh = mesh; _hasWeapon = true; - // create mirror Sprite3D - sprite = Sprite3D::create(fileName); - sprite->setScale(5); - sprite->setScaleX(-5); - sprite->setCullFace(CullFaceSide::FRONT); - sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); - addChild(sprite); - sprite->setPosition(Vec2(p.x + 80, p.y)); + // create mirror MeshRenderer + mesh = MeshRenderer::create(fileName); + mesh->setScale(5); + mesh->setScaleX(-5); + mesh->setCullFace(CullFaceSide::FRONT); + mesh->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); + addChild(mesh); + mesh->setPosition(Vec2(p.x + 80, p.y)); // test attach - sp = Sprite3D::create("Sprite3DTest/axe.c3b"); - sprite->getAttachNode("Bip001 R Hand")->addChild(sp); + sp = MeshRenderer::create("MeshRendererTest/axe.c3b"); + mesh->getAttachNode("Bip001 R Hand")->addChild(sp); animation = Animation3D::create(fileName); if (animation) { auto animate = Animate3D::create(animation); - sprite->runAction(RepeatForever::create(animate)); + mesh->runAction(RepeatForever::create(animate)); } - _mirrorSprite = sprite; + _mirrorMesh = mesh; } QuaternionTest::QuaternionTest() : _arcSpeed(CC_DEGREES_TO_RADIANS(90)), _radius(100.f), _accAngle(0.f) { auto s = Director::getInstance()->getWinSize(); - addNewSpriteWithCoords(Vec2(s.width / 2.f, s.height / 2.f)); + addNewMeshWithCoords(Vec2(s.width / 2.f, s.height / 2.f)); scheduleUpdate(); } std::string QuaternionTest::title() const @@ -1708,20 +1708,20 @@ std::string QuaternionTest::subtitle() const return ""; } -void QuaternionTest::addNewSpriteWithCoords(Vec2 p) +void QuaternionTest::addNewMeshWithCoords(Vec2 p) { - std::string fileName = "Sprite3DTest/tortoise.c3b"; - auto sprite = Sprite3D::create(fileName); - sprite->setScale(0.1f); + std::string fileName = "MeshRendererTest/tortoise.c3b"; + auto mesh = MeshRenderer::create(fileName); + mesh->setScale(0.1f); auto s = Director::getInstance()->getWinSize(); - sprite->setPosition(Vec2(s.width / 2.f + _radius * cosf(_accAngle), s.height / 2.f + _radius * sinf(_accAngle))); - addChild(sprite); - _sprite = sprite; + mesh->setPosition(Vec2(s.width / 2.f + _radius * cosf(_accAngle), s.height / 2.f + _radius * sinf(_accAngle))); + addChild(mesh); + _mesh = mesh; auto animation = Animation3D::create(fileName); if (animation) { auto animate = Animate3D::create(animation, 0.f, 1.933f); - sprite->runAction(RepeatForever::create(animate)); + mesh->runAction(RepeatForever::create(animate)); } } @@ -1733,18 +1733,18 @@ void QuaternionTest::update(float delta) _accAngle -= 2 * pi; auto s = Director::getInstance()->getWinSize(); - _sprite->setPosition(Vec2(s.width / 2.f + _radius * cosf(_accAngle), s.height / 2.f + _radius * sinf(_accAngle))); + _mesh->setPosition(Vec2(s.width / 2.f + _radius * cosf(_accAngle), s.height / 2.f + _radius * sinf(_accAngle))); Quaternion quat; Quaternion::createFromAxisAngle(Vec3(0.f, 0.f, 1.f), _accAngle - pi * 0.5f, &quat); - _sprite->setRotationQuat(quat); + _mesh->setRotationQuat(quat); } -UseCaseSprite3D::UseCaseSprite3D() : _caseIdx(0) +UseCaseMeshRenderer::UseCaseMeshRenderer() : _caseIdx(0) { auto s = Director::getInstance()->getWinSize(); - _useCaseTitles[0] = "transparent 3d sprite and 2d sprite"; + _useCaseTitles[0] = "transparent 3d mesh and 2d mesh"; _useCaseTitles[1] = "ui - 3d - ui"; auto itemPrev = MenuItemImage::create("Images/b1.png", "Images/b2.png", [&](Ref* sender) { @@ -1783,53 +1783,53 @@ UseCaseSprite3D::UseCaseSprite3D() : _caseIdx(0) switchCase(); } -std::string UseCaseSprite3D::title() const +std::string UseCaseMeshRenderer::title() const { return "Use Case For 2D + 3D"; } -std::string UseCaseSprite3D::subtitle() const +std::string UseCaseMeshRenderer::subtitle() const { return ""; } -void UseCaseSprite3D::switchCase() +void UseCaseMeshRenderer::switchCase() { removeChildByTag(101); auto s = Director::getInstance()->getWinSize(); _label->setString(_useCaseTitles[_caseIdx]); - if (_caseIdx == 0) // use case 1, 3d transparent sprite + 2d sprite + if (_caseIdx == 0) // use case 1, 3d transparent mesh + 2d mesh { - std::string filename = "Sprite3DTest/girl.c3b"; - auto sprite = Sprite3D::create(filename); - sprite->setScale(0.15f); + std::string filename = "MeshRendererTest/girl.c3b"; + auto mesh = MeshRenderer::create(filename); + mesh->setScale(0.15f); auto animation = Animation3D::create(filename); if (animation) { auto animate = Animate3D::create(animation); - sprite->runAction(RepeatForever::create(animate)); + mesh->runAction(RepeatForever::create(animate)); } - auto circleBack = Sprite3D::create(); - auto circle = Sprite::create("Sprite3DTest/circle.png"); + auto circleBack = MeshRenderer::create(); + auto circle = Sprite::create("MeshRendererTest/circle.png"); circleBack->setScale(0.5f); circleBack->addChild(circle); circle->runAction(RepeatForever::create(RotateBy::create(3, Vec3(0.f, 0.f, 360.f)))); circleBack->setRotation3D(Vec3(-90.0f, -90.0f, 0.0f)); - auto pos = sprite->getPosition3D(); + auto pos = mesh->getPosition3D(); circleBack->setPosition3D(Vec3(pos.x, pos.y, pos.z - 1)); - sprite->setOpacity(250); - sprite->setCameraMask(2); + mesh->setOpacity(250); + mesh->setCameraMask(2); circleBack->setCameraMask(2); - sprite->setTag(3); + mesh->setTag(3); circleBack->setTag(2); auto node = Node::create(); - node->addChild(sprite); + node->addChild(mesh); node->addChild(circleBack); node->setTag(101); addChild(node); @@ -1844,23 +1844,23 @@ void UseCaseSprite3D::switchCase() layer->setGlobalZOrder(-1); addChild(layer); - std::string filename = "Sprite3DTest/girl.c3b"; - auto sprite = Sprite3D::create(filename); - sprite->setScale(0.5f); + std::string filename = "MeshRendererTest/girl.c3b"; + auto mesh = MeshRenderer::create(filename); + mesh->setScale(0.5f); auto animation = Animation3D::create(filename); if (animation) { auto animate = Animate3D::create(animation); - sprite->runAction(RepeatForever::create(animate)); + mesh->runAction(RepeatForever::create(animate)); } - sprite->setPosition(s.width * 0.25f, s.height * 0.125f); - layer->addChild(sprite); + mesh->setPosition(s.width * 0.25f, s.height * 0.125f); + layer->addChild(mesh); TTFConfig ttfConfig("fonts/arial.ttf", 15); auto label1 = Label::createWithTTF(ttfConfig, "Message"); - auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UseCaseSprite3D::menuCallback_Message, this)); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UseCaseMeshRenderer::menuCallback_Message, this)); auto label2 = Label::createWithTTF(ttfConfig, "Message"); - auto item2 = MenuItemLabel::create(label2, CC_CALLBACK_1(UseCaseSprite3D::menuCallback_Message, this)); + auto item2 = MenuItemLabel::create(label2, CC_CALLBACK_1(UseCaseMeshRenderer::menuCallback_Message, this)); item1->setPosition(Vec2(s.width * 0.5f - item1->getContentSize().width * 0.5f, s.height * 0.5f - item1->getContentSize().height)); @@ -1875,7 +1875,7 @@ void UseCaseSprite3D::switchCase() } } -void UseCaseSprite3D::menuCallback_Message(Ref* sender) +void UseCaseMeshRenderer::menuCallback_Message(Ref* sender) { auto layer = getChildByTag(101); auto message = layer->getChildByTag(102); // message layer @@ -1897,7 +1897,7 @@ void UseCaseSprite3D::menuCallback_Message(Ref* sender) } } -void UseCaseSprite3D::update(float delta) +void UseCaseMeshRenderer::update(float delta) { if (_caseIdx == 0) { @@ -1908,11 +1908,11 @@ void UseCaseSprite3D::update(float delta) float x = cosf(accAngle) * radius, z = sinf(accAngle) * radius; auto node = getChildByTag(101); - auto sprite3d = node->getChildByTag(3); + auto mesh3d = node->getChildByTag(3); auto circle = node->getChildByTag(2); - sprite3d->setPositionX(x); - sprite3d->setPositionZ(z); + mesh3d->setPositionX(x); + mesh3d->setPositionZ(z); circle->setPositionX(x); circle->setPositionZ(z); } @@ -1925,27 +1925,27 @@ NodeAnimationTest::NodeAnimationTest() : _vectorIndex(0) auto s = Director::getInstance()->getWinSize(); auto itemPrev = MenuItemImage::create("Images/b1.png", "Images/b2.png", [&](Ref* sender) { - _sprites[_vectorIndex]->setVisible(false); + _meshes[_vectorIndex]->setVisible(false); int tIndex = _vectorIndex - 1; if (tIndex < 0) - _vectorIndex = (int)_sprites.size() - 1; + _vectorIndex = (int)_meshes.size() - 1; else _vectorIndex--; - _sprites[_vectorIndex]->setVisible(true); + _meshes[_vectorIndex]->setVisible(true); }); auto itemNext = MenuItemImage::create("Images/f1.png", "Images/f2.png", [&](Ref* sender) { - _sprites[_vectorIndex]->setVisible(false); + _meshes[_vectorIndex]->setVisible(false); int tIndex = _vectorIndex + 1; - if (tIndex >= static_cast(_sprites.size())) + if (tIndex >= static_cast(_meshes.size())) _vectorIndex = 0; else _vectorIndex++; - _sprites[_vectorIndex]->setVisible(true); + _meshes[_vectorIndex]->setVisible(true); }); auto menu = Menu::create(itemPrev, itemNext, nullptr); @@ -1955,7 +1955,7 @@ NodeAnimationTest::NodeAnimationTest() : _vectorIndex(0) menu->setPosition(Vec2(s.width / 2, 70.0f)); addChild(menu); - addNewSpriteWithCoords(Vec2(s.width / 2.f, s.height / 2.f)); + addNewMeshWithCoords(Vec2(s.width / 2.f, s.height / 2.f)); } std::string NodeAnimationTest::title() const { @@ -1966,17 +1966,17 @@ std::string NodeAnimationTest::subtitle() const return "Jumping animation"; } -void NodeAnimationTest::addNewSpriteWithCoords(Vec2 p) +void NodeAnimationTest::addNewMeshWithCoords(Vec2 p) { auto s = Director::getInstance()->getWinSize(); // add jumping ball - std::string fileName = "Sprite3DTest/ball.c3b"; - auto sprite = Sprite3D::create(fileName); - sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); - sprite->setScale(3); - sprite->setPosition(Vec2(s.width / 2.f, s.height / 3.f)); - sprite->setTexture("Sprite3DTest/teapot.png"); + std::string fileName = "MeshRendererTest/ball.c3b"; + auto mesh = MeshRenderer::create(fileName); + mesh->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); + mesh->setScale(3); + mesh->setPosition(Vec2(s.width / 2.f, s.height / 3.f)); + mesh->setTexture("MeshRendererTest/teapot.png"); auto light1 = PointLight::create(Vec3(s.width * 0.2f, s.height * 0.8f, 100.0f), Color3B(200, 200, 200), 10000.0f); addChild(light1); @@ -1989,37 +1989,37 @@ void NodeAnimationTest::addNewSpriteWithCoords(Vec2 p) auto animate = Animate3D::create(animation); auto act = RepeatForever::create(animate); act->setTag(0); - sprite->runAction(act); + mesh->runAction(act); } - addChild(sprite); - _sprites.push_back(sprite); + addChild(mesh); + _meshes.push_back(mesh); // add jumping orc - fileName = "Sprite3DTest/orc_jump.c3t"; - sprite = Sprite3D::create(fileName); - sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); - sprite->setScale(3); - sprite->setPosition(Vec2(s.width / 2.f, s.height / 3.f)); - sprite->setVisible(false); + fileName = "MeshRendererTest/orc_jump.c3t"; + mesh = MeshRenderer::create(fileName); + mesh->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); + mesh->setScale(3); + mesh->setPosition(Vec2(s.width / 2.f, s.height / 3.f)); + mesh->setVisible(false); animation = Animation3D::create(fileName); if (animation) { auto animate = Animate3D::create(animation); auto act = RepeatForever::create(animate); act->setTag(0); - sprite->runAction(act); + mesh->runAction(act); } - addChild(sprite); - _sprites.push_back(sprite); + addChild(mesh); + _meshes.push_back(mesh); } -Sprite3DCubeMapTest::Sprite3DCubeMapTest() : _textureCube(nullptr), _skyBox(nullptr), _teapot(nullptr) +MeshRendererCubeMapTest::MeshRendererCubeMapTest() : _textureCube(nullptr), _skyBox(nullptr), _teapot(nullptr) { auto s = Director::getInstance()->getWinSize(); - addNewSpriteWithCoords(Vec2(s.width / 2, s.height / 2)); + addNewMeshWithCoords(Vec2(s.width / 2, s.height / 2)); } -Sprite3DCubeMapTest::~Sprite3DCubeMapTest() +MeshRendererCubeMapTest::~MeshRendererCubeMapTest() { #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundListener); @@ -2030,17 +2030,17 @@ Sprite3DCubeMapTest::~Sprite3DCubeMapTest() _textureCube->release(); } -std::string Sprite3DCubeMapTest::title() const +std::string MeshRendererCubeMapTest::title() const { return "CubeMap & Skybox Test"; } -std::string Sprite3DCubeMapTest::subtitle() const +std::string MeshRendererCubeMapTest::subtitle() const { return ""; } -void Sprite3DCubeMapTest::addNewSpriteWithCoords(Vec2 p) +void MeshRendererCubeMapTest::addNewMeshWithCoords(Vec2 p) { Size visibleSize = Director::getInstance()->getVisibleSize(); _camera = Camera::createPerspective(60, visibleSize.width / visibleSize.height, 10, 1000); @@ -2048,17 +2048,17 @@ void Sprite3DCubeMapTest::addNewSpriteWithCoords(Vec2 p) _camera->setCameraFlag(CameraFlag::USER1); auto listener = EventListenerTouchAllAtOnce::create(); - listener->onTouchesMoved = CC_CALLBACK_2(Sprite3DCubeMapTest::onTouchesMoved, this); + listener->onTouchesMoved = CC_CALLBACK_2(MeshRendererCubeMapTest::onTouchesMoved, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); // create a teapot - _teapot = Sprite3D::create("Sprite3DTest/teapot.c3b"); + _teapot = MeshRenderer::create("MeshRendererTest/teapot.c3b"); _teapot->retain(); // create the second texture for cylinder - _textureCube = TextureCube::create("Sprite3DTest/skybox/left.jpg", "Sprite3DTest/skybox/right.jpg", - "Sprite3DTest/skybox/top.jpg", "Sprite3DTest/skybox/bottom.jpg", - "Sprite3DTest/skybox/front.jpg", "Sprite3DTest/skybox/back.jpg"); + _textureCube = TextureCube::create("MeshRendererTest/skybox/left.jpg", "MeshRendererTest/skybox/right.jpg", + "MeshRendererTest/skybox/top.jpg", "MeshRendererTest/skybox/bottom.jpg", + "MeshRendererTest/skybox/front.jpg", "MeshRendererTest/skybox/back.jpg"); _textureCube->retain(); @@ -2070,7 +2070,7 @@ void Sprite3DCubeMapTest::addNewSpriteWithCoords(Vec2 p) tRepeatParams.tAddressMode = backend::SamplerAddressMode::CLAMP_TO_EDGE; _textureCube->setTexParameters(tRepeatParams); - auto mat = Sprite3DMaterial::createWithFilename("Sprite3DTest/CubeMap.material"); + auto mat = MeshMaterial::createWithFilename("MeshRendererTest/CubeMap.material"); auto state = mat->getTechniqueByIndex(0)->getPassByIndex(0)->getProgramState(); _teapot->setMaterial(mat); @@ -2100,9 +2100,9 @@ void Sprite3DCubeMapTest::addNewSpriteWithCoords(Vec2 p) #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) _backToForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom*) { CC_SAFE_RELEASE(_textureCube); - _textureCube = TextureCube::create("Sprite3DTest/skybox/left.jpg", "Sprite3DTest/skybox/right.jpg", - "Sprite3DTest/skybox/top.jpg", "Sprite3DTest/skybox/bottom.jpg", - "Sprite3DTest/skybox/front.jpg", "Sprite3DTest/skybox/back.jpg"); + _textureCube = TextureCube::create("MeshRendererTest/skybox/left.jpg", "MeshRendererTest/skybox/right.jpg", + "MeshRendererTest/skybox/top.jpg", "MeshRendererTest/skybox/bottom.jpg", + "MeshRendererTest/skybox/front.jpg", "MeshRendererTest/skybox/back.jpg"); _textureCube->retain(); // set texture parameters @@ -2113,7 +2113,7 @@ void Sprite3DCubeMapTest::addNewSpriteWithCoords(Vec2 p) tRepeatParams.tAddressMode = backend::SamplerAddressMode::CLAMP_TO_EDGE; _textureCube->setTexParameters(tRepeatParams); - auto mat = Sprite3DMaterial::createWithFilename("Sprite3DTest/CubeMap.material"); + auto mat = MeshMaterial::createWithFilename("MeshRendererTest/CubeMap.material"); auto state = mat->getTechniqueByIndex(0)->getPassByIndex(0)->getProgramState(); _teapot->setMaterial(mat); _skyBox->setTexture(_textureCube); @@ -2125,7 +2125,7 @@ void Sprite3DCubeMapTest::addNewSpriteWithCoords(Vec2 p) #endif } -void Sprite3DCubeMapTest::onTouchesMoved(const std::vector& touches, cocos2d::Event* event) +void MeshRendererCubeMapTest::onTouchesMoved(const std::vector& touches, cocos2d::Event* event) { if (touches.size()) { @@ -2144,12 +2144,12 @@ Issue9767::Issue9767() _shaderType = Issue9767::ShaderType::SHADER_TEX; auto s = Director::getInstance()->getWinSize(); - auto sprite = Sprite3D::create("Sprite3DTest/boss1.obj"); - sprite->setScale(3.f); - sprite->setTexture("Sprite3DTest/boss.png"); - addChild(sprite); - sprite->setPosition(Vec2(s.width / 2, s.height / 2)); - _sprite = sprite; + auto mesh = MeshRenderer::create("MeshRendererTest/boss1.obj"); + mesh->setScale(3.f); + mesh->setTexture("MeshRendererTest/boss.png"); + addChild(mesh); + mesh->setPosition(Vec2(s.width / 2, s.height / 2)); + _mesh = mesh; TTFConfig ttfConfig("fonts/arial.ttf", 15); auto label1 = Label::createWithTTF(ttfConfig, "switch shader"); @@ -2180,7 +2180,7 @@ void Issue9767::menuCallback_SwitchShader(cocos2d::Ref* sender) auto program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_3D); _programState = new backend::ProgramState(program); } - _sprite->setProgramState(_programState); + _mesh->setProgramState(_programState); } std::string Issue9767::title() const @@ -2193,38 +2193,38 @@ std::string Issue9767::subtitle() const return ""; } -Sprite3DClippingTest::Sprite3DClippingTest() +MeshRendererClippingTest::MeshRendererClippingTest() { auto size = Director::getInstance()->getWinSize(); auto stencil = Sprite::create("Images/close.png"); - auto clipSprite3D = ClippingNode::create(); - clipSprite3D->setStencil(stencil); - this->addChild(clipSprite3D); - clipSprite3D->setScale(3.0f); + auto clipMeshRenderer = ClippingNode::create(); + clipMeshRenderer->setStencil(stencil); + this->addChild(clipMeshRenderer); + clipMeshRenderer->setScale(3.0f); - auto sprite3D = Sprite3D::create("Sprite3DTest/orc.c3b"); - sprite3D->setScale(1.0f); - sprite3D->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); - clipSprite3D->addChild(sprite3D); // 5 + auto mesh3D = MeshRenderer::create("MeshRendererTest/orc.c3b"); + mesh3D->setScale(1.0f); + mesh3D->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); + clipMeshRenderer->addChild(mesh3D); // 5 - clipSprite3D->setPosition(Vec2(size.width / 2, size.height / 2)); + clipMeshRenderer->setPosition(Vec2(size.width / 2, size.height / 2)); auto seq = Sequence::create(ScaleTo::create(2.f, 3), ScaleTo::create(2.f, 0.5f), NULL); - sprite3D->runAction(RepeatForever::create(seq)); - auto animation = Animation3D::create("Sprite3DTest/orc.c3b"); + mesh3D->runAction(RepeatForever::create(seq)); + auto animation = Animation3D::create("MeshRendererTest/orc.c3b"); auto animate = Animate3D::create(animation); - sprite3D->runAction(RepeatForever::create(animate)); - sprite3D->setForce2DQueue(true); + mesh3D->runAction(RepeatForever::create(animate)); + mesh3D->setForce2DQueue(true); } -Sprite3DClippingTest::~Sprite3DClippingTest() {} +MeshRendererClippingTest::~MeshRendererClippingTest() {} -std::string Sprite3DClippingTest::title() const +std::string MeshRendererClippingTest::title() const { - return "Sprite3D Clipping Test"; + return "MeshRenderer Clipping Test"; } -std::string Sprite3DClippingTest::subtitle() const +std::string MeshRendererClippingTest::subtitle() const { return ""; } @@ -2235,27 +2235,27 @@ Animate3DCallbackTest::Animate3DCallbackTest() FileUtils::getInstance()->addSearchPath("Particle3D/scripts"); auto s = Director::getInstance()->getWinSize(); - _sprite3d = Sprite3D::create("Sprite3DTest/ReskinGirl.c3b"); - _sprite3d->setPosition(Vec2(s.width / 2.0f, s.height / 3.0f)); - _sprite3d->setScale(3.0f); - _sprite3d->setRotation3D(Vec3(0.0f, 90.0f, 0.0f)); - this->addChild(_sprite3d); + _meshRenderer = MeshRenderer::create("MeshRendererTest/ReskinGirl.c3b"); + _meshRenderer->setPosition(Vec2(s.width / 2.0f, s.height / 3.0f)); + _meshRenderer->setScale(3.0f); + _meshRenderer->setRotation3D(Vec3(0.0f, 90.0f, 0.0f)); + this->addChild(_meshRenderer); - _sprite3d->getMeshByName("Girl_UpperBody02")->setVisible(false); - _sprite3d->getMeshByName("Girl_LowerBody02")->setVisible(false); - _sprite3d->getMeshByName("Girl_Shoes02")->setVisible(false); - _sprite3d->getMeshByName("Girl_Hair02")->setVisible(false); + _meshRenderer->getMeshByName("Girl_UpperBody02")->setVisible(false); + _meshRenderer->getMeshByName("Girl_LowerBody02")->setVisible(false); + _meshRenderer->getMeshByName("Girl_Shoes02")->setVisible(false); + _meshRenderer->getMeshByName("Girl_Hair02")->setVisible(false); auto rootps = PUParticleSystem3D::create("explosionSystem.pu"); rootps->stopParticleSystem(); rootps->setScale(4.0f); this->addChild(rootps, 0, 100); - auto animation = Animation3D::create("Sprite3DTest/ReskinGirl.c3b"); + auto animation = Animation3D::create("MeshRendererTest/ReskinGirl.c3b"); if (animation) { auto animate = Animate3D::create(animation); - _sprite3d->runAction(RepeatForever::create(animate)); + _meshRenderer->runAction(RepeatForever::create(animate)); ValueMap valuemap0; animate->setKeyFrameUserInfo(275, valuemap0); @@ -2265,8 +2265,8 @@ Animate3DCallbackTest::Animate3DCallbackTest() auto node = getChildByTag(100); if (node) { - auto mat = _sprite3d->getNodeToWorldTransform() * - _sprite3d->getSkeleton()->getBoneByName("Bip01 R Hand")->getWorldMat(); + auto mat = _meshRenderer->getNodeToWorldTransform() * + _meshRenderer->getSkeleton()->getBoneByName("Bip01 R Hand")->getWorldMat(); node->setPosition3D(Vec3(mat.m[12] + 100, mat.m[13], mat.m[14])); ((PUParticleSystem3D*)node)->startParticleSystem(); } @@ -2289,19 +2289,19 @@ std::string Animate3DCallbackTest::subtitle() const return ""; } -Sprite3DVertexColorTest::Sprite3DVertexColorTest() +MeshRendererVertexColorTest::MeshRendererVertexColorTest() { auto s = Director::getInstance()->getWinSize(); - auto sprite = Sprite3D::create("Sprite3DTest/box_VertexCol.c3t"); - sprite->setPosition(Vec2(0.0f, 0.0f)); - sprite->setScale(1.0f); - sprite->setCameraMask(2); - auto mat = Sprite3DMaterial::createWithFilename("Sprite3DTest/VertexColor.material"); - sprite->setMaterial(mat); - sprite->runAction(RepeatForever::create(RotateBy::create(1.0f, Vec3(10.0f, 50.0f, 10.0f)))); + auto mesh = MeshRenderer::create("MeshRendererTest/box_VertexCol.c3t"); + mesh->setPosition(Vec2(0.0f, 0.0f)); + mesh->setScale(1.0f); + mesh->setCameraMask(2); + auto mat = MeshMaterial::createWithFilename("MeshRendererTest/VertexColor.material"); + mesh->setMaterial(mat); + mesh->runAction(RepeatForever::create(RotateBy::create(1.0f, Vec3(10.0f, 50.0f, 10.0f)))); - this->addChild(sprite); + this->addChild(mesh); // setup camera auto camera = Camera::createPerspective(40, s.width / s.height, 0.01f, 1000.f); @@ -2312,26 +2312,26 @@ Sprite3DVertexColorTest::Sprite3DVertexColorTest() #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) _backToForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [=](EventCustom*) { - auto mat = Sprite3DMaterial::createWithFilename("Sprite3DTest/VertexColor.material"); - sprite->setMaterial(mat); + auto mat = MeshMaterial::createWithFilename("MeshRendererTest/VertexColor.material"); + mesh->setMaterial(mat); }); Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundListener, 1); #endif } -Sprite3DVertexColorTest::~Sprite3DVertexColorTest() +MeshRendererVertexColorTest::~MeshRendererVertexColorTest() { #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundListener); #endif } -std::string Sprite3DVertexColorTest::title() const +std::string MeshRendererVertexColorTest::title() const { return "Testing Vertex Color"; } -std::string Sprite3DVertexColorTest::subtitle() const +std::string MeshRendererVertexColorTest::subtitle() const { return ""; } @@ -2356,9 +2356,9 @@ CameraBackgroundClearTest::CameraBackgroundClearTest() _camera->lookAt(Vec3(0.f, 0.f, 0.f)); addChild(_camera); - auto sprite = Sprite3D::create("Sprite3DTest/orc.c3b"); - addChild(sprite); - sprite->setCameraMask(2); + auto mesh = MeshRenderer::create("MeshRendererTest/orc.c3b"); + addChild(mesh); + mesh->setCameraMask(2); _label = Label::createWithTTF(ttfConfig, "Depth Clear Brush"); addChild(_label); @@ -2393,8 +2393,8 @@ void CameraBackgroundClearTest::switch_CameraClearMode(cocos2d::Ref* sender) else if (type == CameraBackgroundBrush::BrushType::COLOR) { _camera->setBackgroundBrush(CameraBackgroundBrush::createSkyboxBrush( - "Sprite3DTest/skybox/left.jpg", "Sprite3DTest/skybox/right.jpg", "Sprite3DTest/skybox/top.jpg", - "Sprite3DTest/skybox/bottom.jpg", "Sprite3DTest/skybox/front.jpg", "Sprite3DTest/skybox/back.jpg")); + "MeshRendererTest/skybox/left.jpg", "MeshRendererTest/skybox/right.jpg", "MeshRendererTest/skybox/top.jpg", + "MeshRendererTest/skybox/bottom.jpg", "MeshRendererTest/skybox/front.jpg", "MeshRendererTest/skybox/back.jpg")); _label->setString("Skybox Clear Brush"); } else if (type == CameraBackgroundBrush::BrushType::SKYBOX) @@ -2424,16 +2424,16 @@ MotionStreak3DTest::MotionStreak3DTest() camera->lookAt(Vec3(0.f, 0.f, 0.f)); addChild(camera); - auto sprite = Sprite3D::create("Sprite3DTest/orc.c3b"); - sprite->setPosition(20.f, 0.f); - addChild(sprite); + auto mesh = MeshRenderer::create("MeshRendererTest/orc.c3b"); + mesh->setPosition(20.f, 0.f); + addChild(mesh); auto streak = MotionStreak3D::create(1.0f, 1.0f, 5.f, Color3B(255, 255, 0), "Images/Icon.png"); addChild(streak); setCameraMask(2); - _sprite = sprite; + _mesh = mesh; _streak = streak; scheduleUpdate(); } @@ -2453,36 +2453,36 @@ void MotionStreak3DTest::update(float delta) float angle = t * M_PI; float r = 20.f; - _sprite->setPosition3D(Vec3(r * cosf(angle), 0, r * sinf(angle))); - _streak->setPosition3D(_sprite->getPosition3D()); + _mesh->setPosition3D(Vec3(r * cosf(angle), 0, r * sinf(angle))); + _streak->setPosition3D(_mesh->getPosition3D()); _streak->setSweepAxis(Vec3(cosf(angle), 0, sinf(angle))); } -Sprite3DNormalMappingTest::Sprite3DNormalMappingTest() +MeshRendererNormalMappingTest::MeshRendererNormalMappingTest() { auto s = Director::getInstance()->getWinSize(); { - auto sprite = Sprite3D::create("Sprite3DTest/sphere.c3b"); - sprite->setPosition(Vec2(-30.0f, 0.0f)); - sprite->setRotation3D(Vec3(90.0f, 0.0f, 0.0f)); - sprite->setScale(2.0); - sprite->setCameraMask(2); - sprite->setTexture("Sprite3DTest/brickwork-texture.jpg"); - addChild(sprite); + auto mesh = MeshRenderer::create("MeshRendererTest/sphere.c3b"); + mesh->setPosition(Vec2(-30.0f, 0.0f)); + mesh->setRotation3D(Vec3(90.0f, 0.0f, 0.0f)); + mesh->setScale(2.0); + mesh->setCameraMask(2); + mesh->setTexture("MeshRendererTest/brickwork-texture.jpg"); + addChild(mesh); } int maxAttributes = Configuration::getInstance()->getMaxAttributes(); CCASSERT(maxAttributes > 8, "attributes supported must be greater than 8"); if (maxAttributes > 8) { - auto sprite = Sprite3D::create("Sprite3DTest/sphere_bumped.c3b"); - sprite->setPosition(Vec2(30.0f, 0.0f)); - sprite->setRotation3D(Vec3(90.0f, 0.0f, 0.0f)); - sprite->setScale(20.0); - sprite->setCameraMask(2); - sprite->setTexture("Sprite3DTest/brickwork-texture.jpg"); - addChild(sprite); + auto mesh = MeshRenderer::create("MeshRendererTest/sphere_bumped.c3b"); + mesh->setPosition(Vec2(30.0f, 0.0f)); + mesh->setRotation3D(Vec3(90.0f, 0.0f, 0.0f)); + mesh->setScale(20.0); + mesh->setCameraMask(2); + mesh->setTexture("MeshRendererTest/brickwork-texture.jpg"); + addChild(mesh); } // setup camera @@ -2499,7 +2499,7 @@ Sprite3DNormalMappingTest::Sprite3DNormalMappingTest() scheduleUpdate(); } -void Sprite3DNormalMappingTest::update(float dt) +void MeshRendererNormalMappingTest::update(float dt) { static float angle = 0.0f; static bool reverseDir = false; @@ -2521,19 +2521,19 @@ void Sprite3DNormalMappingTest::update(float dt) } } -Sprite3DNormalMappingTest::~Sprite3DNormalMappingTest() {} +MeshRendererNormalMappingTest::~MeshRendererNormalMappingTest() {} -std::string Sprite3DNormalMappingTest::title() const +std::string MeshRendererNormalMappingTest::title() const { return "NormalMapping Test"; } -std::string Sprite3DNormalMappingTest::subtitle() const +std::string MeshRendererNormalMappingTest::subtitle() const { return ""; } -Sprite3DPropertyTest::Sprite3DPropertyTest() +MeshRendererPropertyTest::MeshRendererPropertyTest() { auto s = Director::getInstance()->getWinSize(); @@ -2543,27 +2543,27 @@ Sprite3DPropertyTest::Sprite3DPropertyTest() camera->lookAt(Vec3(0.f, 0.f, 0.f)); addChild(camera); - _sprite = Sprite3D::create("Sprite3DTest/orc.c3b"); - _sprite->setPosition(20.f, 0.f); - _sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); - _meshTex = _sprite->getMesh()->getTexture(); + _mesh = MeshRenderer::create("MeshRendererTest/orc.c3b"); + _mesh->setPosition(20.f, 0.f); + _mesh->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); + _meshTex = _mesh->getMesh()->getTexture(); _texFile = _meshTex->getPath(); - addChild(_sprite); + addChild(_mesh); setCameraMask(2); // auto listener = EventListenerTouchAllAtOnce::create(); - ////listener->onTouchesEnded = CC_CALLBACK_2(Sprite3DReskinTest::onTouchesEnded, this); + ////listener->onTouchesEnded = CC_CALLBACK_2(MeshRendererReskinTest::onTouchesEnded, this); //_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); TTFConfig ttfConfig("fonts/arial.ttf", 20); auto label1 = Label::createWithTTF(ttfConfig, "Print Mesh Name"); - auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(Sprite3DPropertyTest::printMeshName, this)); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(MeshRendererPropertyTest::printMeshName, this)); auto label2 = Label::createWithTTF(ttfConfig, "Remove Used Texture"); - auto item2 = MenuItemLabel::create(label2, CC_CALLBACK_1(Sprite3DPropertyTest::removeUsedTexture, this)); + auto item2 = MenuItemLabel::create(label2, CC_CALLBACK_1(MeshRendererPropertyTest::removeUsedTexture, this)); auto label3 = Label::createWithTTF(ttfConfig, "Reset"); - auto item3 = MenuItemLabel::create(label3, CC_CALLBACK_1(Sprite3DPropertyTest::resetTexture, this)); + auto item3 = MenuItemLabel::create(label3, CC_CALLBACK_1(MeshRendererPropertyTest::resetTexture, this)); item1->setPosition(Vec2(VisibleRect::left().x + 100, VisibleRect::bottom().y + item1->getContentSize().height * 4)); item2->setPosition(Vec2(VisibleRect::left().x + 100, VisibleRect::bottom().y + item1->getContentSize().height * 5)); @@ -2575,47 +2575,47 @@ Sprite3DPropertyTest::Sprite3DPropertyTest() scheduleUpdate(); } -std::string Sprite3DPropertyTest::title() const +std::string MeshRendererPropertyTest::title() const { - return "Sprite3DPropertyTest Test"; + return "MeshRendererPropertyTest Test"; } -std::string Sprite3DPropertyTest::subtitle() const +std::string MeshRendererPropertyTest::subtitle() const { return ""; } -void Sprite3DPropertyTest::update(float delta) {} -void Sprite3DPropertyTest::printMeshName(cocos2d::Ref* sender) +void MeshRendererPropertyTest::update(float delta) {} +void MeshRendererPropertyTest::printMeshName(cocos2d::Ref* sender) { CCLOG("MeshName Begin"); - Vector meshes = _sprite->getMeshes(); + Vector meshes = _mesh->getMeshes(); for (Mesh* mesh : meshes) { log("MeshName: %s ", mesh->getName().data()); } CCLOG("MeshName End"); } -void Sprite3DPropertyTest::removeUsedTexture(cocos2d::Ref* sender) +void MeshRendererPropertyTest::removeUsedTexture(cocos2d::Ref* sender) { if (_meshTex != nullptr) { Director::getInstance()->getTextureCache()->removeTexture(_meshTex); - this->refreshSpriteRender(); + this->refreshMeshRender(); } } -void Sprite3DPropertyTest::resetTexture(cocos2d::Ref* sender) +void MeshRendererPropertyTest::resetTexture(cocos2d::Ref* sender) { if (_meshTex != nullptr) { _meshTex = Director::getInstance()->getTextureCache()->addImage(_texFile); - this->refreshSpriteRender(); + this->refreshMeshRender(); } } -void Sprite3DPropertyTest::refreshSpriteRender() +void MeshRendererPropertyTest::refreshMeshRender() { - Vector meshes = _sprite->getMeshes(); + Vector meshes = _mesh->getMeshes(); for (Mesh* mesh : meshes) { std::string file = mesh->getTextureFileName(); @@ -2639,11 +2639,11 @@ Issue16155Test::Issue16155Test() { auto s = Director::getInstance()->getWinSize(); - auto sprite = Sprite3D::create("Sprite3DTest/orc.c3b"); + auto mesh = MeshRenderer::create("MeshRendererTest/orc.c3b"); - int rcBefore = sprite->getMeshByIndex(0)->getTexture()->getReferenceCount(); - addChild(sprite); - removeChild(sprite); + int rcBefore = mesh->getMeshByIndex(0)->getTexture()->getReferenceCount(); + addChild(mesh); + removeChild(mesh); cocos2d::log("Issue 16155: Ref count:%d. Run this test again. RC should be the same", rcBefore); } diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h b/tests/cpp-tests/Classes/MeshRendererTest/MeshRendererTest.h similarity index 69% rename from tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h rename to tests/cpp-tests/Classes/MeshRendererTest/MeshRendererTest.h index 3f1b89a11c..a5b8995f8d 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h +++ b/tests/cpp-tests/Classes/MeshRendererTest/MeshRendererTest.h @@ -31,7 +31,7 @@ namespace cocos2d { class Animate3D; -class Sprite3D; +class MeshRenderer; class Delay; class Ray; class DrawNode3D; @@ -39,53 +39,53 @@ class GLProgramState; class MotionStreak3D; } // namespace cocos2d -DEFINE_TEST_SUITE(Sprite3DTests); +DEFINE_TEST_SUITE(MeshRendererTests); -class Sprite3DTestDemo : public TestCase +class MeshRendererTestDemo : public TestCase { public: // overrides virtual std::string title() const override; - virtual ~Sprite3DTestDemo(); + virtual ~MeshRendererTestDemo(); }; -class Sprite3DForceDepthTest : public Sprite3DTestDemo +class MeshRendererForceDepthTest : public MeshRendererTestDemo { public: - CREATE_FUNC(Sprite3DForceDepthTest); - Sprite3DForceDepthTest(); + CREATE_FUNC(MeshRendererForceDepthTest); + MeshRendererForceDepthTest(); virtual std::string title() const override; virtual std::string subtitle() const override; }; -class Sprite3DEmptyTest : public Sprite3DTestDemo +class MeshRendererEmptyTest : public MeshRendererTestDemo { public: - CREATE_FUNC(Sprite3DEmptyTest); - Sprite3DEmptyTest(); + CREATE_FUNC(MeshRendererEmptyTest); + MeshRendererEmptyTest(); virtual std::string title() const override; virtual std::string subtitle() const override; }; -class Sprite3DBasicTest : public Sprite3DTestDemo +class MeshRendererBasicTest : public MeshRendererTestDemo { public: - CREATE_FUNC(Sprite3DBasicTest); - Sprite3DBasicTest(); + CREATE_FUNC(MeshRendererBasicTest); + MeshRendererBasicTest(); virtual std::string title() const override; virtual std::string subtitle() const override; - void addNewSpriteWithCoords(cocos2d::Vec2 p); + void addNewMeshWithCoords(cocos2d::Vec2 p); void onTouchesEnded(const std::vector& touches, cocos2d::Event* event); }; -class Sprite3DUVAnimationTest : public Sprite3DTestDemo +class MeshRendererUVAnimationTest : public MeshRendererTestDemo { public: - CREATE_FUNC(Sprite3DUVAnimationTest); - Sprite3DUVAnimationTest(); - virtual ~Sprite3DUVAnimationTest(); + CREATE_FUNC(MeshRendererUVAnimationTest); + MeshRendererUVAnimationTest(); + virtual ~MeshRendererUVAnimationTest(); virtual std::string title() const override; virtual std::string subtitle() const override; @@ -101,7 +101,7 @@ protected: #endif }; -class Sprite3DFakeShadowTest : public Sprite3DTestDemo +class MeshRendererFakeShadowTest : public MeshRendererTestDemo { public: enum State @@ -111,9 +111,9 @@ public: State_Move = 0x02, State_Rotate = 0x04 }; - CREATE_FUNC(Sprite3DFakeShadowTest); - Sprite3DFakeShadowTest(); - virtual ~Sprite3DFakeShadowTest(); + CREATE_FUNC(MeshRendererFakeShadowTest); + MeshRendererFakeShadowTest(); + virtual ~MeshRendererFakeShadowTest(); virtual std::string title() const override; virtual std::string subtitle() const override; void Move(cocos2d::Ref* sender, int value); @@ -129,8 +129,8 @@ private: cocos2d::Camera* _camera; cocos2d::Vec3 _targetPos; unsigned int _curState; - cocos2d::Sprite3D* _plane; - cocos2d::Sprite3D* _orc; + cocos2d::MeshRenderer* _plane; + cocos2d::MeshRenderer* _orc; cocos2d::backend::ProgramState* _state = nullptr; #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) @@ -138,12 +138,12 @@ private: #endif }; -class Sprite3DLightMapTest : public Sprite3DTestDemo +class MeshRendererLightMapTest : public MeshRendererTestDemo { public: - CREATE_FUNC(Sprite3DLightMapTest); - Sprite3DLightMapTest(); - virtual ~Sprite3DLightMapTest(); + CREATE_FUNC(MeshRendererLightMapTest); + MeshRendererLightMapTest(); + virtual ~MeshRendererLightMapTest(); virtual std::string title() const override; virtual std::string subtitle() const override; void onTouchesMoved(const std::vector& touches, cocos2d::Event* event); @@ -152,12 +152,12 @@ private: cocos2d::Camera* _camera; }; -class Sprite3DBasicToonShaderTest : public Sprite3DTestDemo +class MeshRendererBasicToonShaderTest : public MeshRendererTestDemo { public: - CREATE_FUNC(Sprite3DBasicToonShaderTest); - Sprite3DBasicToonShaderTest(); - virtual ~Sprite3DBasicToonShaderTest(); + CREATE_FUNC(MeshRendererBasicToonShaderTest); + MeshRendererBasicToonShaderTest(); + virtual ~MeshRendererBasicToonShaderTest(); virtual std::string title() const override; virtual std::string subtitle() const override; @@ -169,62 +169,62 @@ protected: #endif }; -class Sprite3DHitTest : public Sprite3DTestDemo +class MeshRendererHitTest : public MeshRendererTestDemo { public: - CREATE_FUNC(Sprite3DHitTest); - Sprite3DHitTest(); + CREATE_FUNC(MeshRendererHitTest); + MeshRendererHitTest(); virtual std::string title() const override; virtual std::string subtitle() const override; }; -class Sprite3DEffectTest : public Sprite3DTestDemo +class MeshRendererEffectTest : public MeshRendererTestDemo { public: - CREATE_FUNC(Sprite3DEffectTest); - Sprite3DEffectTest(); - virtual ~Sprite3DEffectTest(); + CREATE_FUNC(MeshRendererEffectTest); + MeshRendererEffectTest(); + virtual ~MeshRendererEffectTest(); virtual std::string title() const override; virtual std::string subtitle() const override; - void addNewSpriteWithCoords(cocos2d::Vec2 p); + void addNewMeshWithCoords(cocos2d::Vec2 p); void onTouchesEnded(const std::vector& touches, cocos2d::Event* event); protected: - std::vector _sprites; + std::vector _meshes; #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) cocos2d::EventListenerCustom* _backToForegroundListener; #endif }; -class AsyncLoadSprite3DTest : public Sprite3DTestDemo +class AsyncLoadMeshRendererTest : public MeshRendererTestDemo { public: - CREATE_FUNC(AsyncLoadSprite3DTest); - AsyncLoadSprite3DTest(); - virtual ~AsyncLoadSprite3DTest(); + CREATE_FUNC(AsyncLoadMeshRendererTest); + AsyncLoadMeshRendererTest(); + virtual ~AsyncLoadMeshRendererTest(); virtual std::string title() const override; virtual std::string subtitle() const override; - void menuCallback_asyncLoadSprite(cocos2d::Ref* sender); + void menuCallback_asyncLoadMesh(cocos2d::Ref* sender); - void asyncLoad_Callback(cocos2d::Sprite3D* sprite, void* param); + void asyncLoad_Callback(cocos2d::MeshRenderer* mesh, void* param); protected: std::vector _paths; // model paths to be loaded }; -class Sprite3DWithSkinTest : public Sprite3DTestDemo +class MeshRendererWithSkinTest : public MeshRendererTestDemo { public: - CREATE_FUNC(Sprite3DWithSkinTest); - Sprite3DWithSkinTest(); + CREATE_FUNC(MeshRendererWithSkinTest); + MeshRendererWithSkinTest(); virtual std::string title() const override; virtual std::string subtitle() const override; - void addNewSpriteWithCoords(cocos2d::Vec2 p); + void addNewMeshWithCoords(cocos2d::Vec2 p); void switchAnimationQualityCallback(cocos2d::Ref* sender); void onTouchesEnded(const std::vector& touches, cocos2d::Event* event); @@ -232,33 +232,33 @@ public: std::string getAnimationQualityMessage() const; private: - std::vector _sprits; + std::vector _meshes; int _animateQuality; cocos2d::MenuItemFont* _menuItem; }; -class Sprite3DWithSkinOutlineTest : public Sprite3DTestDemo +class MeshRendererWithSkinOutlineTest : public MeshRendererTestDemo { public: - CREATE_FUNC(Sprite3DWithSkinOutlineTest); - Sprite3DWithSkinOutlineTest(); - virtual ~Sprite3DWithSkinOutlineTest(); + CREATE_FUNC(MeshRendererWithSkinOutlineTest); + MeshRendererWithSkinOutlineTest(); + virtual ~MeshRendererWithSkinOutlineTest(); virtual std::string title() const override; virtual std::string subtitle() const override; - void addNewSpriteWithCoords(cocos2d::Vec2 p); + void addNewMeshWithCoords(cocos2d::Vec2 p); void onTouchesEnded(const std::vector& touches, cocos2d::Event* event); protected: - std::vector _sprites; + std::vector _meshes; #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) cocos2d::EventListenerCustom* _backToForegroundListener; #endif }; -class Animate3DTest : public Sprite3DTestDemo +class Animate3DTest : public MeshRendererTestDemo { public: CREATE_FUNC(Animate3DTest); @@ -272,7 +272,7 @@ public: virtual void update(float dt) override; protected: - void addSprite3D(); + void addMeshRenderer(); enum class State { @@ -286,7 +286,7 @@ protected: void renewCallBack(); - cocos2d::Sprite3D* _sprite; + cocos2d::MeshRenderer* _mesh; cocos2d::Action* _swim; cocos2d::Animate3D* _hurt; @@ -298,7 +298,7 @@ protected: cocos2d::MoveTo* _moveAction; }; -class AttachmentTest : public Sprite3DTestDemo +class AttachmentTest : public MeshRendererTestDemo { public: CREATE_FUNC(AttachmentTest); @@ -308,22 +308,22 @@ public: void onTouchesEnded(const std::vector& touches, cocos2d::Event* event); - void addNewSpriteWithCoords(cocos2d::Vec2 p); + void addNewMeshWithCoords(cocos2d::Vec2 p); protected: bool _hasWeapon; - cocos2d::Sprite3D* _sprite; + cocos2d::MeshRenderer* _mesh; }; -class Sprite3DReskinTest : public Sprite3DTestDemo +class MeshRendererReskinTest : public MeshRendererTestDemo { public: - CREATE_FUNC(Sprite3DReskinTest); - Sprite3DReskinTest(); + CREATE_FUNC(MeshRendererReskinTest); + MeshRendererReskinTest(); virtual std::string title() const override; virtual std::string subtitle() const override; void onTouchesEnded(const std::vector& touches, cocos2d::Event* event); - void addNewSpriteWithCoords(cocos2d::Vec2 p); + void addNewMeshWithCoords(cocos2d::Vec2 p); void menuCallback_reSkin(cocos2d::Ref* sender); @@ -344,19 +344,19 @@ protected: std::vector _skins[(int)SkinType::MAX_TYPE]; // all skins int _curSkin[(int)SkinType::MAX_TYPE]; // current skin index - cocos2d::Sprite3D* _sprite; + cocos2d::MeshRenderer* _mesh; }; -class Sprite3DWithOBBPerformanceTest : public Sprite3DTestDemo +class MeshRendererWithOBBPerformanceTest : public MeshRendererTestDemo { public: - CREATE_FUNC(Sprite3DWithOBBPerformanceTest); - Sprite3DWithOBBPerformanceTest(); + CREATE_FUNC(MeshRendererWithOBBPerformanceTest); + MeshRendererWithOBBPerformanceTest(); virtual std::string title() const override; virtual std::string subtitle() const override; virtual void update(float dt) override; void addNewOBBWithCoords(cocos2d::Vec2 p); - void addNewSpriteWithCoords(cocos2d::Vec2 p); + void addNewMeshWithCoords(cocos2d::Vec2 p); void onTouchesBegan(const std::vector& touches, cocos2d::Event* event); void onTouchesEnded(const std::vector& touches, cocos2d::Event* event); void onTouchesMoved(const std::vector& touches, cocos2d::Event* event); @@ -366,7 +366,7 @@ public: void delOBBWithCount(float value); protected: - cocos2d::Sprite3D* _sprite; + cocos2d::MeshRenderer* _mesh; std::vector _obb; cocos2d::DrawNode3D* _drawOBB; cocos2d::Label* _labelCubeCount; @@ -386,23 +386,23 @@ protected: void calculateRayByLocationInView(cocos2d::Ray* ray, const cocos2d::Vec2& location); }; -class Sprite3DMirrorTest : public Sprite3DTestDemo +class MeshRendererMirrorTest : public MeshRendererTestDemo { public: - CREATE_FUNC(Sprite3DMirrorTest); - Sprite3DMirrorTest(); + CREATE_FUNC(MeshRendererMirrorTest); + MeshRendererMirrorTest(); virtual std::string title() const override; virtual std::string subtitle() const override; - void addNewSpriteWithCoords(cocos2d::Vec2 p); + void addNewMeshWithCoords(cocos2d::Vec2 p); protected: bool _hasWeapon; - cocos2d::Sprite3D* _sprite; - cocos2d::Sprite3D* _mirrorSprite; + cocos2d::MeshRenderer* _mesh; + cocos2d::MeshRenderer* _mirrorMesh; }; -class QuaternionTest : public Sprite3DTestDemo +class QuaternionTest : public MeshRendererTestDemo { public: CREATE_FUNC(QuaternionTest); @@ -410,22 +410,22 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; - void addNewSpriteWithCoords(cocos2d::Vec2 p); + void addNewMeshWithCoords(cocos2d::Vec2 p); virtual void update(float delta) override; protected: - cocos2d::Sprite3D* _sprite; + cocos2d::MeshRenderer* _mesh; float _arcSpeed; float _radius; float _accAngle; }; // 3d + 2d use case -class UseCaseSprite3D : public Sprite3DTestDemo +class UseCaseMeshRenderer : public MeshRendererTestDemo { public: - CREATE_FUNC(UseCaseSprite3D); - UseCaseSprite3D(); + CREATE_FUNC(UseCaseMeshRenderer); + UseCaseMeshRenderer(); virtual std::string title() const override; virtual std::string subtitle() const override; @@ -448,7 +448,7 @@ protected: }; // node animation test, cocos2d-x supports both skeletal animation and node animation -class NodeAnimationTest : public Sprite3DTestDemo +class NodeAnimationTest : public MeshRendererTestDemo { public: CREATE_FUNC(NodeAnimationTest); @@ -456,10 +456,10 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; - void addNewSpriteWithCoords(cocos2d::Vec2 p); + void addNewMeshWithCoords(cocos2d::Vec2 p); protected: - std::vector _sprites; + std::vector _meshes; int _vectorIndex; }; @@ -469,23 +469,23 @@ class TextureCube; class Skybox; } // namespace cocos2d -class Sprite3DCubeMapTest : public Sprite3DTestDemo +class MeshRendererCubeMapTest : public MeshRendererTestDemo { public: - CREATE_FUNC(Sprite3DCubeMapTest); - Sprite3DCubeMapTest(); - ~Sprite3DCubeMapTest(); + CREATE_FUNC(MeshRendererCubeMapTest); + MeshRendererCubeMapTest(); + ~MeshRendererCubeMapTest(); virtual std::string title() const override; virtual std::string subtitle() const override; - void addNewSpriteWithCoords(cocos2d::Vec2); + void addNewMeshWithCoords(cocos2d::Vec2); void onTouchesMoved(const std::vector& touches, cocos2d::Event* event); protected: cocos2d::TextureCube* _textureCube; cocos2d::Skybox* _skyBox; - cocos2d::Sprite3D* _teapot; + cocos2d::MeshRenderer* _teapot; cocos2d::Camera* _camera; #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) @@ -494,7 +494,7 @@ protected: }; /// issue 9767 setGLProgram -class Issue9767 : public Sprite3DTestDemo +class Issue9767 : public MeshRendererTestDemo { enum class ShaderType { @@ -513,21 +513,21 @@ public: protected: ShaderType _shaderType; - cocos2d::Sprite3D* _sprite; + cocos2d::MeshRenderer* _mesh; }; -/// Clipping Sprite3D -class Sprite3DClippingTest : public Sprite3DTestDemo +/// Clipping MeshRenderer +class MeshRendererClippingTest : public MeshRendererTestDemo { public: - CREATE_FUNC(Sprite3DClippingTest); - Sprite3DClippingTest(); - ~Sprite3DClippingTest(); + CREATE_FUNC(MeshRendererClippingTest); + MeshRendererClippingTest(); + ~MeshRendererClippingTest(); virtual std::string title() const override; virtual std::string subtitle() const override; }; -class Animate3DCallbackTest : public Sprite3DTestDemo +class Animate3DCallbackTest : public MeshRendererTestDemo { public: CREATE_FUNC(Animate3DCallbackTest); @@ -537,10 +537,10 @@ public: virtual std::string subtitle() const override; protected: - cocos2d::Sprite3D* _sprite3d; + cocos2d::MeshRenderer* _meshRenderer; }; -class CameraBackgroundClearTest : public Sprite3DTestDemo +class CameraBackgroundClearTest : public MeshRendererTestDemo { public: CREATE_FUNC(CameraBackgroundClearTest); @@ -555,24 +555,24 @@ protected: cocos2d::Label* _label; }; -class Sprite3DVertexColorTest : public Sprite3DTestDemo +class MeshRendererVertexColorTest : public MeshRendererTestDemo { public: - CREATE_FUNC(Sprite3DVertexColorTest); - Sprite3DVertexColorTest(); + CREATE_FUNC(MeshRendererVertexColorTest); + MeshRendererVertexColorTest(); virtual std::string title() const override; virtual std::string subtitle() const override; - virtual ~Sprite3DVertexColorTest(); + virtual ~MeshRendererVertexColorTest(); protected: - cocos2d::Sprite3D* _sprite; + cocos2d::MeshRenderer* _mesh; #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) cocos2d::EventListenerCustom* _backToForegroundListener; #endif }; -class MotionStreak3DTest : public Sprite3DTestDemo +class MotionStreak3DTest : public MeshRendererTestDemo { public: CREATE_FUNC(MotionStreak3DTest); @@ -582,27 +582,27 @@ public: virtual void update(float delta) override; protected: - cocos2d::Sprite3D* _sprite; + cocos2d::MeshRenderer* _mesh; cocos2d::MotionStreak3D* _streak; }; -class Sprite3DNormalMappingTest : public Sprite3DTestDemo +class MeshRendererNormalMappingTest : public MeshRendererTestDemo { public: - CREATE_FUNC(Sprite3DNormalMappingTest); - Sprite3DNormalMappingTest(); + CREATE_FUNC(MeshRendererNormalMappingTest); + MeshRendererNormalMappingTest(); virtual std::string title() const override; virtual std::string subtitle() const override; virtual void update(float dt) override; - virtual ~Sprite3DNormalMappingTest(); + virtual ~MeshRendererNormalMappingTest(); }; -class Sprite3DPropertyTest : public Sprite3DTestDemo +class MeshRendererPropertyTest : public MeshRendererTestDemo { public: - CREATE_FUNC(Sprite3DPropertyTest); - Sprite3DPropertyTest(); + CREATE_FUNC(MeshRendererPropertyTest); + MeshRendererPropertyTest(); virtual std::string title() const override; virtual std::string subtitle() const override; virtual void update(float delta) override; @@ -611,15 +611,15 @@ public: void removeUsedTexture(cocos2d::Ref* sender); void resetTexture(cocos2d::Ref* sender); - void refreshSpriteRender(); + void refreshMeshRender(); protected: - cocos2d::Sprite3D* _sprite; + cocos2d::MeshRenderer* _mesh; cocos2d::Texture2D* _meshTex; std::string _texFile; }; -class Issue16155Test : public Sprite3DTestDemo +class Issue16155Test : public MeshRendererTestDemo { public: CREATE_FUNC(Issue16155Test); diff --git a/tests/cpp-tests/Classes/NavMeshTest/NavMeshTest.cpp b/tests/cpp-tests/Classes/NavMeshTest/NavMeshTest.cpp index c588c641ee..2c423f0501 100644 --- a/tests/cpp-tests/Classes/NavMeshTest/NavMeshTest.cpp +++ b/tests/cpp-tests/Classes/NavMeshTest/NavMeshTest.cpp @@ -146,10 +146,10 @@ void NavMeshBaseTestDemo::initScene() rbDes.shape = Physics3DShape::createMesh(&trianglesList[0], (int)trianglesList.size() / 3); auto rigidBody = Physics3DRigidBody::create(&rbDes); auto component = Physics3DComponent::create(rigidBody); - auto sprite = Sprite3D::create("NavMesh/scene.obj"); - sprite->addComponent(component); - sprite->setCameraMask((unsigned short)CameraFlag::USER1); - this->addChild(sprite); + auto mesh = MeshRenderer::create("NavMesh/scene.obj"); + mesh->addComponent(component); + mesh->setCameraMask((unsigned short)CameraFlag::USER1); + this->addChild(mesh); setPhysics3DDebugCamera(_camera); auto navMesh = NavMesh::create("NavMesh/all_tiles_tilecache.bin", "NavMesh/geomset.txt"); @@ -168,13 +168,13 @@ void NavMeshBaseTestDemo::initScene() void NavMeshBaseTestDemo::createAgent(const Vec3& pos) { - std::string filePath = "Sprite3DTest/girl.c3b"; + std::string filePath = "MeshRendererTest/girl.c3b"; NavMeshAgentParam param; param.radius = 2.0f; param.height = 8.0f; param.maxSpeed = 8.0f; auto agent = NavMeshAgent::create(param); - auto agentNode = Sprite3D::create(filePath); + auto agentNode = MeshRenderer::create(filePath); agent->setOrientationRefAxes(Vec3(-1.0f, 0.0f, 1.0f)); AgentUserData* data = new AgentUserData{0.0f}; agent->setUserData(data); @@ -201,7 +201,7 @@ void NavMeshBaseTestDemo::createAgent(const Vec3& pos) void NavMeshBaseTestDemo::createObstacle(const Vec3& pos) { auto obstacle = NavMeshObstacle::create(2.0f, 8.0f); - auto obstacleNode = Sprite3D::create("Sprite3DTest/cylinder.c3b"); + auto obstacleNode = MeshRenderer::create("MeshRendererTest/cylinder.c3b"); obstacleNode->setPosition3D(pos + Vec3(0.0f, -0.5f, 0.0f)); obstacleNode->setRotation3D(Vec3(-90.0f, 0.0f, 0.0f)); obstacleNode->setScale(0.3f); diff --git a/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.cpp b/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.cpp index feb4abc150..21430944fc 100644 --- a/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.cpp +++ b/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.cpp @@ -48,7 +48,7 @@ Particle3DTests::Particle3DTests() ADD_TEST_CASE(Particle3DCanOfWormsDemo); ADD_TEST_CASE(Particle3DRibbonTrailDemo); ADD_TEST_CASE(Particle3DWeaponTrailDemo); - ADD_TEST_CASE(Particle3DWithSprite3DDemo); + ADD_TEST_CASE(Particle3DWithMeshRendererDemo); } std::string Particle3DTestDemo::title() const @@ -63,7 +63,7 @@ bool Particle3DTestDemo::init() FileUtils::getInstance()->addSearchPath("Particle3D/materials"); FileUtils::getInstance()->addSearchPath("Particle3D/scripts"); - FileUtils::getInstance()->addSearchPath("Sprite3DTest"); + FileUtils::getInstance()->addSearchPath("MeshRendererTest"); // FileUtils::getInstance()->addSearchPath("Particle3D/textures"); Size size = Director::getInstance()->getWinSize(); @@ -427,18 +427,18 @@ bool Particle3DWeaponTrailDemo::init() return true; } -std::string Particle3DWithSprite3DDemo::subtitle() const +std::string Particle3DWithMeshRendererDemo::subtitle() const { - return "Particle3DWithSprite3D"; + return "Particle3DWithMeshRenderer"; } -bool Particle3DWithSprite3DDemo::init() +bool Particle3DWithMeshRendererDemo::init() { if (!Particle3DTestDemo::init()) return false; - std::string c3bfileName = "Sprite3DTest/orc.c3b"; - auto sprite = Sprite3D::create(c3bfileName); + std::string c3bfileName = "MeshRendererTest/orc.c3b"; + auto sprite = MeshRenderer::create(c3bfileName); this->addChild(sprite); sprite->setPosition3D(Vec3(-20.0f, 0.0f, 0.0f)); sprite->setRotation3D(Vec3(0, 180, 0)); diff --git a/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.h b/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.h index f7333f732d..dbed470d45 100644 --- a/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.h +++ b/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.h @@ -223,12 +223,12 @@ public: virtual bool init() override; }; -class Particle3DWithSprite3DDemo : public Particle3DTestDemo +class Particle3DWithMeshRendererDemo : public Particle3DTestDemo { public: - CREATE_FUNC(Particle3DWithSprite3DDemo); - Particle3DWithSprite3DDemo(){}; - virtual ~Particle3DWithSprite3DDemo(){}; + CREATE_FUNC(Particle3DWithMeshRendererDemo); + Particle3DWithMeshRendererDemo(){}; + virtual ~Particle3DWithMeshRendererDemo(){}; virtual std::string subtitle() const override; diff --git a/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp b/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp index 7a41c71df6..c763850202 100644 --- a/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp +++ b/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp @@ -196,25 +196,25 @@ void Physics3DTestDemo::shootBox(const cocos2d::Vec3& des) rbDes.originalTransform.translate(_camera->getPosition3D()); rbDes.mass = 1.f; rbDes.shape = Physics3DShape::createBox(Vec3(0.5f, 0.5f, 0.5f)); - auto sprite = PhysicsSprite3D::create("Sprite3DTest/box.c3t", &rbDes); - sprite->setTexture("Images/Icon.png"); + auto mesh = PhysicsMeshRenderer::create("MeshRendererTest/box.c3t", &rbDes); + mesh->setTexture("Images/Icon.png"); - auto rigidBody = static_cast(sprite->getPhysicsObj()); + auto rigidBody = static_cast(mesh->getPhysicsObj()); rigidBody->setLinearFactor(Vec3::ONE); rigidBody->setLinearVelocity(linearVel); rigidBody->setAngularVelocity(Vec3::ZERO); rigidBody->setCcdMotionThreshold(0.5f); rigidBody->setCcdSweptSphereRadius(0.4f); - this->addChild(sprite); - sprite->setPosition3D(_camera->getPosition3D()); - sprite->setScale(0.5f); - sprite->syncNodeToPhysics(); + this->addChild(mesh); + mesh->setPosition3D(_camera->getPosition3D()); + mesh->setScale(0.5f); + mesh->syncNodeToPhysics(); // optimize, only sync node to physics - sprite->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::PHYSICS_TO_NODE); // sync node to physics + mesh->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::PHYSICS_TO_NODE); // sync node to physics - sprite->setCameraMask((unsigned short)CameraFlag::USER1); + mesh->setCameraMask((unsigned short)CameraFlag::USER1); } std::string BasicPhysics3DDemo::subtitle() const @@ -232,8 +232,8 @@ bool BasicPhysics3DDemo::init() rbDes.mass = 0.0f; rbDes.shape = Physics3DShape::createBox(Vec3(60.0f, 1.0f, 60.0f)); - auto floor = PhysicsSprite3D::create("Sprite3DTest/box.c3t", &rbDes); - floor->setTexture("Sprite3DTest/plane.png"); + auto floor = PhysicsMeshRenderer::create("MeshRendererTest/box.c3t", &rbDes); + floor->setTexture("MeshRendererTest/plane.png"); floor->setScaleX(60); floor->setScaleZ(60); this->addChild(floor); @@ -242,7 +242,7 @@ bool BasicPhysics3DDemo::init() // static object sync is not needed floor->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::NONE); - // create several boxes using PhysicsSprite3D + // create several boxes using PhysicsMeshRenderer rbDes.mass = 1.f; rbDes.shape = Physics3DShape::createBox(Vec3(0.8f, 0.8f, 0.8f)); float start_x = START_POS_X - ARRAY_SIZE_X / 2; @@ -259,14 +259,14 @@ bool BasicPhysics3DDemo::init() float y = 5.0 + 1.0 * k + start_y; float z = 1.0 * j + start_z; - auto sprite = PhysicsSprite3D::create("Sprite3DTest/box.c3t", &rbDes); - sprite->setTexture("Images/CyanSquare.png"); - sprite->setPosition3D(Vec3(x, y, z)); - sprite->syncNodeToPhysics(); - sprite->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::PHYSICS_TO_NODE); - sprite->setCameraMask((unsigned short)CameraFlag::USER1); - sprite->setScale(0.8f); - this->addChild(sprite); + auto mesh = PhysicsMeshRenderer::create("MeshRendererTest/box.c3t", &rbDes); + mesh->setTexture("Images/CyanSquare.png"); + mesh->setPosition3D(Vec3(x, y, z)); + mesh->syncNodeToPhysics(); + mesh->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::PHYSICS_TO_NODE); + mesh->setCameraMask((unsigned short)CameraFlag::USER1); + mesh->setScale(0.8f); + this->addChild(mesh); } } } @@ -295,8 +295,8 @@ bool Physics3DKinematicDemo::init() Physics3DRigidBodyDes rbDes; rbDes.mass = 0.0f; rbDes.shape = Physics3DShape::createBox(Vec3(60.0f, 1.0f, 60.0f)); - auto floor = PhysicsSprite3D::create("Sprite3DTest/box.c3t", &rbDes); - floor->setTexture("Sprite3DTest/plane.png"); + auto floor = PhysicsMeshRenderer::create("MeshRendererTest/box.c3t", &rbDes); + floor->setTexture("MeshRendererTest/plane.png"); floor->setScaleX(60); floor->setScaleZ(60); floor->setPosition3D(Vec3(0.f, -1.f, 0.f)); @@ -312,18 +312,18 @@ bool Physics3DKinematicDemo::init() rbDes.mass = 0.f; // kinematic objects. zero mass so that it can not be affected by other dynamic objects rbDes.shape = Physics3DShape::createBox(Vec3(2.0f, 2.0f, 2.0f)); - auto sprite = PhysicsSprite3D::create("Sprite3DTest/box.c3t", &rbDes); - sprite->setTexture("Images/CyanSquare.png"); - sprite->setCameraMask((unsigned short)CameraFlag::USER1); - auto rigidBody = static_cast(sprite->getPhysicsObj()); + auto mesh = PhysicsMeshRenderer::create("MeshRendererTest/box.c3t", &rbDes); + mesh->setTexture("Images/CyanSquare.png"); + mesh->setCameraMask((unsigned short)CameraFlag::USER1); + auto rigidBody = static_cast(mesh->getPhysicsObj()); rigidBody->setKinematic(true); - this->addChild(sprite); + this->addChild(mesh); - sprite->setScale(2.0f); - sprite->setPosition3D(Vec3(-15.0f, 0.0f, 15.0f - 15.0f * i)); + mesh->setScale(2.0f); + mesh->setPosition3D(Vec3(-15.0f, 0.0f, 15.0f - 15.0f * i)); auto moveby = MoveBy::create(2.0f + i, Vec3(30.0f, 0.0f, 0.0f)); - sprite->runAction(RepeatForever::create(Sequence::create(moveby, moveby->reverse(), nullptr))); + mesh->runAction(RepeatForever::create(Sequence::create(moveby, moveby->reverse(), nullptr))); } // create Dynamic @@ -347,15 +347,15 @@ bool Physics3DKinematicDemo::init() rbDes.originalTransform.setIdentity(); rbDes.originalTransform.translate(x, y, z); - auto sprite = PhysicsSprite3D::create("Sprite3DTest/sphere.c3b", &rbDes); - sprite->setTexture("Sprite3DTest/plane.png"); - sprite->setCameraMask((unsigned short)CameraFlag::USER1); - sprite->setScale(1.0f / sprite->getContentSize().width); - this->addChild(sprite); - sprite->setPosition3D(Vec3(x, y, z)); - sprite->syncNodeToPhysics(); + auto mesh = PhysicsMeshRenderer::create("MeshRendererTest/sphere.c3b", &rbDes); + mesh->setTexture("MeshRendererTest/plane.png"); + mesh->setCameraMask((unsigned short)CameraFlag::USER1); + mesh->setScale(1.0f / mesh->getContentSize().width); + this->addChild(mesh); + mesh->setPosition3D(Vec3(x, y, z)); + mesh->syncNodeToPhysics(); - sprite->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::PHYSICS_TO_NODE); + mesh->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::PHYSICS_TO_NODE); } } } @@ -370,11 +370,11 @@ bool Physics3DConstraintDemo::init() if (!Physics3DTestDemo::init()) return false; - // PhysicsSprite3D = Sprite3D + Physics3DComponent + // PhysicsMeshRenderer = MeshRenderer + Physics3DComponent Physics3DRigidBodyDes rbDes; rbDes.disableSleep = true; // create box - auto sprite = Sprite3D::create("Sprite3DTest/orc.c3b"); + auto mesh = MeshRenderer::create("MeshRendererTest/orc.c3b"); rbDes.mass = 10.f; rbDes.shape = Physics3DShape::createBox(Vec3(5.0f, 5.0f, 5.0f)); auto rigidBody = Physics3DRigidBody::create(&rbDes); @@ -382,11 +382,11 @@ bool Physics3DConstraintDemo::init() Quaternion::createFromAxisAngle(Vec3(0.f, 1.f, 0.f), CC_DEGREES_TO_RADIANS(180), &quat); auto component = Physics3DComponent::create(rigidBody, Vec3(0.f, -3.f, 0.f), quat); - sprite->addComponent(component); - addChild(sprite); - sprite->setCameraMask((unsigned short)CameraFlag::USER1); - sprite->setScale(0.4f); - sprite->setPosition3D(Vec3(-20.f, 5.f, 0.f)); + mesh->addComponent(component); + addChild(mesh); + mesh->setCameraMask((unsigned short)CameraFlag::USER1); + mesh->setScale(0.4f); + mesh->setPosition3D(Vec3(-20.f, 5.f, 0.f)); // sync node position to physics component->syncNodeToPhysics(); // physics controlled, we will not set position for it, so we can skip sync node position to physics @@ -403,14 +403,14 @@ bool Physics3DConstraintDemo::init() rbDes.shape = Physics3DShape::createBox(Vec3(8.0f, 8.0f, 1.f)); rigidBody = Physics3DRigidBody::create(&rbDes); component = Physics3DComponent::create(rigidBody); - sprite = Sprite3D::create("Sprite3DTest/box.c3t"); - sprite->setTexture("Sprite3DTest/plane.png"); - sprite->setScaleX(8.f); - sprite->setScaleY(8.f); - sprite->setPosition3D(Vec3(5.f, 0.f, 0.f)); - sprite->addComponent(component); - sprite->setCameraMask((unsigned short)CameraFlag::USER1); - this->addChild(sprite); + mesh = MeshRenderer::create("MeshRendererTest/box.c3t"); + mesh->setTexture("MeshRendererTest/plane.png"); + mesh->setScaleX(8.f); + mesh->setScaleY(8.f); + mesh->setPosition3D(Vec3(5.f, 0.f, 0.f)); + mesh->addComponent(component); + mesh->setCameraMask((unsigned short)CameraFlag::USER1); + this->addChild(mesh); component->syncNodeToPhysics(); rigidBody->setAngularVelocity(Vec3(0, 3, 0)); constraint = Physics3DHingeConstraint::create(rigidBody, Vec3(4.f, 4.f, 0.5f), Vec3(0.f, 1.f, 0.f)); @@ -421,14 +421,14 @@ bool Physics3DConstraintDemo::init() rbDes.shape = Physics3DShape::createBox(Vec3(3.0f, 2.0f, 3.f)); rigidBody = Physics3DRigidBody::create(&rbDes); component = Physics3DComponent::create(rigidBody); - sprite = Sprite3D::create("Sprite3DTest/box.c3t"); - sprite->setTexture("Sprite3DTest/plane.png"); - sprite->setScaleX(3.f); - sprite->setScaleZ(3.f); - sprite->setPosition3D(Vec3(30.f, 15.f, 0.f)); - sprite->addComponent(component); - sprite->setCameraMask((unsigned short)CameraFlag::USER1); - this->addChild(sprite); + mesh = MeshRenderer::create("MeshRendererTest/box.c3t"); + mesh->setTexture("MeshRendererTest/plane.png"); + mesh->setScaleX(3.f); + mesh->setScaleZ(3.f); + mesh->setPosition3D(Vec3(30.f, 15.f, 0.f)); + mesh->addComponent(component); + mesh->setCameraMask((unsigned short)CameraFlag::USER1); + this->addChild(mesh); component->syncNodeToPhysics(); rigidBody->setLinearVelocity(Vec3(0, 3, 0)); @@ -436,13 +436,13 @@ bool Physics3DConstraintDemo::init() rbDes.shape = Physics3DShape::createBox(Vec3(3.0f, 3.0f, 3.f)); auto rigidBodyB = Physics3DRigidBody::create(&rbDes); component = Physics3DComponent::create(rigidBodyB); - sprite = Sprite3D::create("Sprite3DTest/box.c3t"); - sprite->setTexture("Sprite3DTest/plane.png"); - sprite->setScale(3.f); - sprite->setPosition3D(Vec3(30.f, 5.f, 0.f)); - sprite->addComponent(component); - sprite->setCameraMask((unsigned short)CameraFlag::USER1); - this->addChild(sprite); + mesh = MeshRenderer::create("MeshRendererTest/box.c3t"); + mesh->setTexture("MeshRendererTest/plane.png"); + mesh->setScale(3.f); + mesh->setPosition3D(Vec3(30.f, 5.f, 0.f)); + mesh->addComponent(component); + mesh->setCameraMask((unsigned short)CameraFlag::USER1); + this->addChild(mesh); component->syncNodeToPhysics(); Mat4 frameInA, frameInB; @@ -460,13 +460,13 @@ bool Physics3DConstraintDemo::init() rbDes.shape = Physics3DShape::createBox(Vec3(3.f, 3.f, 3.f)); rigidBody = Physics3DRigidBody::create(&rbDes); component = Physics3DComponent::create(rigidBody); - sprite = Sprite3D::create("Sprite3DTest/box.c3t"); - sprite->setTexture("Sprite3DTest/plane.png"); - sprite->setScale(3.f); - sprite->setPosition3D(Vec3(-10.f, 5.f, 0.f)); - sprite->addComponent(component); - sprite->setCameraMask((unsigned short)CameraFlag::USER1); - this->addChild(sprite); + mesh = MeshRenderer::create("MeshRendererTest/box.c3t"); + mesh->setTexture("MeshRendererTest/plane.png"); + mesh->setScale(3.f); + mesh->setPosition3D(Vec3(-10.f, 5.f, 0.f)); + mesh->addComponent(component); + mesh->setCameraMask((unsigned short)CameraFlag::USER1); + this->addChild(mesh); component->syncNodeToPhysics(); Mat4::createRotationZ(CC_DEGREES_TO_RADIANS(90), &frameInA); @@ -483,13 +483,13 @@ bool Physics3DConstraintDemo::init() rbDes.shape = Physics3DShape::createBox(Vec3(3.0f, 3.0f, 3.f)); rigidBody = Physics3DRigidBody::create(&rbDes); component = Physics3DComponent::create(rigidBody); - sprite = Sprite3D::create("Sprite3DTest/box.c3t"); - sprite->setTexture("Sprite3DTest/plane.png"); - sprite->setScale(3.f); - sprite->setPosition3D(Vec3(30.f, -5.f, 0.f)); - sprite->addComponent(component); - sprite->setCameraMask((unsigned short)CameraFlag::USER1); - this->addChild(sprite); + mesh = MeshRenderer::create("MeshRendererTest/box.c3t"); + mesh->setTexture("MeshRendererTest/plane.png"); + mesh->setScale(3.f); + mesh->setPosition3D(Vec3(30.f, -5.f, 0.f)); + mesh->addComponent(component); + mesh->setCameraMask((unsigned short)CameraFlag::USER1); + this->addChild(mesh); component->syncNodeToPhysics(); frameInA.setIdentity(); constraint = Physics3D6DofConstraint::create(rigidBody, frameInA, false); @@ -617,30 +617,30 @@ bool Physics3DTerrainDemo::init() float y = 5.0 + 1.0 * k + start_y; float z = 1.0 * j + start_z; - auto sprite = PhysicsSprite3D::create("Sprite3DTest/sphere.c3b", &rbDes); - sprite->setTexture("Sprite3DTest/plane.png"); - sprite->setCameraMask((unsigned short)CameraFlag::USER1); - sprite->setScale(1.0f / sprite->getContentSize().width); - sprite->setPosition3D(Vec3(x, y, z)); - this->addChild(sprite); - sprite->syncNodeToPhysics(); - sprite->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::PHYSICS_TO_NODE); + auto mesh = PhysicsMeshRenderer::create("MeshRendererTest/sphere.c3b", &rbDes); + mesh->setTexture("MeshRendererTest/plane.png"); + mesh->setCameraMask((unsigned short)CameraFlag::USER1); + mesh->setScale(1.0f / mesh->getContentSize().width); + mesh->setPosition3D(Vec3(x, y, z)); + this->addChild(mesh); + mesh->syncNodeToPhysics(); + mesh->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::PHYSICS_TO_NODE); } } } // create mesh - std::vector trianglesList = Bundle3D::getTrianglesList("Sprite3DTest/boss.c3b"); + std::vector trianglesList = Bundle3D::getTrianglesList("MeshRendererTest/boss.c3b"); colliderDes.shape = Physics3DShape::createMesh(&trianglesList[0], (int)trianglesList.size() / 3); - auto sprite = PhysicsSprite3D::createWithCollider("Sprite3DTest/boss.c3b", &colliderDes); - sprite->setRotation3D(Vec3(-90.0f, 0.0f, 0.0f)); - sprite->setPosition3D(Vec3(0.0f, 15.0f, 0.0f)); - sprite->setCameraMask(2); - this->addChild(sprite); - sprite->syncNodeToPhysics(); - sprite->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::NONE); + auto mesh = PhysicsMeshRenderer::createWithCollider("MeshRendererTest/boss.c3b", &colliderDes); + mesh->setRotation3D(Vec3(-90.0f, 0.0f, 0.0f)); + mesh->setPosition3D(Vec3(0.0f, 15.0f, 0.0f)); + mesh->setCameraMask(2); + this->addChild(mesh); + mesh->syncNodeToPhysics(); + mesh->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::NONE); std::vector> shapeList; { @@ -668,13 +668,13 @@ bool Physics3DTerrainDemo::init() rbDes.shape = Physics3DShape::createCompoundShape(shapeList); auto rigidBody = Physics3DRigidBody::create(&rbDes); component = Physics3DComponent::create(rigidBody); - auto sprite = Sprite3D::create("Sprite3DTest/orc.c3b"); - sprite->addComponent(component); - sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); - sprite->setPosition3D(Vec3(-5.0f, 20.0f, 0.0f)); - sprite->setScale(0.4f); - sprite->setCameraMask(2); - this->addChild(sprite); + auto mesh = MeshRenderer::create("MeshRendererTest/orc.c3b"); + mesh->addComponent(component); + mesh->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); + mesh->setPosition3D(Vec3(-5.0f, 20.0f, 0.0f)); + mesh->setScale(0.4f); + mesh->setCameraMask(2); + this->addChild(mesh); } physicsScene->setPhysics3DDebugCamera(_camera); @@ -700,7 +700,7 @@ bool Physics3DCollisionCallbackDemo::init() Physics3DRigidBodyDes rbDes; float scale = 2.0f; - std::vector trianglesList = Bundle3D::getTrianglesList("Sprite3DTest/boss.c3b"); + std::vector trianglesList = Bundle3D::getTrianglesList("MeshRendererTest/boss.c3b"); for (auto& it : trianglesList) { it *= scale; @@ -710,12 +710,12 @@ bool Physics3DCollisionCallbackDemo::init() rbDes.shape = Physics3DShape::createMesh(&trianglesList[0], (int)trianglesList.size() / 3); auto rigidBody = Physics3DRigidBody::create(&rbDes); auto component = Physics3DComponent::create(rigidBody); - auto sprite = Sprite3D::create("Sprite3DTest/boss.c3b"); - sprite->addComponent(component); - sprite->setRotation3D(Vec3(-90.0f, 0.0f, 0.0f)); - sprite->setScale(scale); - sprite->setCameraMask((unsigned short)CameraFlag::USER1); - this->addChild(sprite); + auto mesh = MeshRenderer::create("MeshRendererTest/boss.c3b"); + mesh->addComponent(component); + mesh->setRotation3D(Vec3(-90.0f, 0.0f, 0.0f)); + mesh->setScale(scale); + mesh->setCameraMask((unsigned short)CameraFlag::USER1); + this->addChild(mesh); // preload // rigidBody->setCollisionCallback([=](const Physics3DCollisionInfo& ci) { @@ -766,15 +766,15 @@ bool Physics3DColliderDemo::init() auto playerBody = Physics3DRigidBody::create(&rbDes); auto component = Physics3DComponent::create(playerBody); playerBody->setKinematic(true); - auto sprite = Sprite3D::create("Sprite3DTest/box.c3t"); - sprite->setTexture("Sprite3DTest/plane.png"); - sprite->setScale(3.f); - sprite->setPosition3D(Vec3(0.0f, 0.f, 30.f)); - sprite->addComponent(component); - sprite->setCameraMask((unsigned short)CameraFlag::USER1); + auto mesh = MeshRenderer::create("MeshRendererTest/box.c3t"); + mesh->setTexture("MeshRendererTest/plane.png"); + mesh->setScale(3.f); + mesh->setPosition3D(Vec3(0.0f, 0.f, 30.f)); + mesh->addComponent(component); + mesh->setCameraMask((unsigned short)CameraFlag::USER1); auto moveby = MoveBy::create(5.0f, Vec3(0.0f, 0.0f, -60.0f)); - sprite->runAction(RepeatForever::create(Sequence::create(moveby, moveby->reverse(), nullptr))); - this->addChild(sprite); + mesh->runAction(RepeatForever::create(Sequence::create(moveby, moveby->reverse(), nullptr))); + this->addChild(mesh); { Physics3DColliderDes colliderDes; @@ -793,8 +793,8 @@ bool Physics3DColliderDemo::init() auto rigidBody = Physics3DRigidBody::create(&rbDes); component = Physics3DComponent::create(rigidBody); rigidBody->setKinematic(true); - auto doorLeft = Sprite3D::create("Sprite3DTest/box.c3t"); - doorLeft->setTexture("Sprite3DTest/plane.png"); + auto doorLeft = MeshRenderer::create("MeshRendererTest/box.c3t"); + doorLeft->setTexture("MeshRendererTest/plane.png"); doorLeft->setScaleX(10.0f); doorLeft->setScaleY(10.0f); doorLeft->setScaleZ(1.0f); @@ -808,8 +808,8 @@ bool Physics3DColliderDemo::init() rigidBody = Physics3DRigidBody::create(&rbDes); component = Physics3DComponent::create(rigidBody); rigidBody->setKinematic(true); - auto doorRight = Sprite3D::create("Sprite3DTest/box.c3t"); - doorRight->setTexture("Sprite3DTest/plane.png"); + auto doorRight = MeshRenderer::create("MeshRendererTest/box.c3t"); + doorRight->setTexture("MeshRendererTest/plane.png"); doorRight->setScaleX(10.0f); doorRight->setScaleY(10.0f); doorRight->setScaleZ(1.0f); diff --git a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp index 3b0caedcce..5b388eaed5 100644 --- a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp +++ b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp @@ -37,7 +37,6 @@ RenderTextureTests::RenderTextureTests() ADD_TEST_CASE(SpriteRenderTextureBug); ADD_TEST_CASE(RenderTexturePartTest); ADD_TEST_CASE(Issue16113Test); - // ADD_TEST_CASE(RenderTextureWithSprite3DIssue16894); this Test makes no sense }; /** @@ -811,94 +810,3 @@ std::string Issue16113Test::subtitle() const { return "aaa.png file without white border on iOS"; } - -// -// RenderTextureWithSprite3DIssue16894 -// -RenderTextureWithSprite3DIssue16894::RenderTextureWithSprite3DIssue16894() -{ - auto visibleSize = Director::getInstance()->getVisibleSize(); - Vec2 origin = Director::getInstance()->getVisibleOrigin(); - - for (int i = 0; i < 3; ++i) - { - // Ship - Model is from cocos2d-x test project - auto ship = Sprite3D::create("Sprite3DTest/boss.c3b"); - ship->setScale(6); - ship->setRotation3D(Vec3(180.0f, 45.0f, 0.0f)); - ship->setPosition(Vec2(visibleSize.width / 4 + origin.x, visibleSize.height / 2 + origin.y)); - ship->setForce2DQueue(true); - ship->retain(); - - if (i == 0) - { - addChild(ship, 1); - //// Rotate Ship - auto spin = RotateBy::create(4, Vec3(0.0f, 180.0f, 0.0f)); - auto repeatspin = RepeatForever::create(spin); - ship->runAction(repeatspin); - } - _ship[i] = ship; - } - - // RenderTextures - _renderTexDefault = RenderTexture::create(visibleSize.width, visibleSize.height, backend::PixelFormat::RGBA8); - _renderTexDefault->setKeepMatrix(true); - addChild(_renderTexDefault); - _renderTexDefault->setPosition(visibleSize.width / 4 * 3, visibleSize.height / 2); - - _renderTexWithBuffer = RenderTexture::create(visibleSize.width, visibleSize.height, backend::PixelFormat::RGBA8, - backend::PixelFormat::D24S8); - _renderTexWithBuffer->setKeepMatrix(true); - addChild(_renderTexWithBuffer); - _renderTexWithBuffer->setPosition(visibleSize.width / 4 * 4, visibleSize.height / 2); - - // Update - scheduleUpdate(); - - auto label1 = Label::createWithTTF("Normal Sprite3D\n", "fonts/arial.ttf", 10); - label1->setPosition(Vec2(visibleSize.width / 4 * 1, 60.0f)); - this->addChild(label1, 1); - - auto label2 = Label::createWithTTF("RenderTexture\nDefault - No depth buffer", "fonts/arial.ttf", 10); - label2->setPosition(Vec2(visibleSize.width / 4 * 2, 60.0f)); - this->addChild(label2, 1); - - auto label3 = Label::createWithTTF("RenderTexture\nGL_DEPTH24_STENCIL8", "fonts/arial.ttf", 10); - label3->setPosition(Vec2(visibleSize.width / 4 * 3, 60.0f)); - this->addChild(label3, 1); -} - -RenderTextureWithSprite3DIssue16894::~RenderTextureWithSprite3DIssue16894() -{ - for (int i = 0; i < 3; ++i) - { - _ship[i]->release(); - } -} - -void RenderTextureWithSprite3DIssue16894::visit(Renderer* renderer, const Mat4& parentTransform, uint32_t parentFlags) -{ - RenderTextureTest::visit(renderer, parentTransform, parentFlags); - - _ship[1]->setRotation3D(_ship[0]->getRotation3D()); - _ship[2]->setRotation3D(_ship[0]->getRotation3D()); - - _renderTexDefault->beginWithClear(0, 0, 0, 0, 0, 0); - _ship[1]->visit(Director::getInstance()->getRenderer(), Mat4::IDENTITY, 0); - _renderTexDefault->end(); - - _renderTexWithBuffer->beginWithClear(0, 0, 0, 0, 1, 0); - _ship[2]->visit(Director::getInstance()->getRenderer(), Mat4::IDENTITY, 0); - _renderTexWithBuffer->end(); -} - -std::string RenderTextureWithSprite3DIssue16894::title() const -{ - return "Issue16894: Render Sprite3D to texture"; -} - -std::string RenderTextureWithSprite3DIssue16894::subtitle() const -{ - return "3 ships, 1st & 3rd are the same"; -} diff --git a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h index 9bc5795429..5c1e7e09d9 100644 --- a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h +++ b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h @@ -182,25 +182,4 @@ public: virtual std::string subtitle() const override; }; -class RenderTextureWithSprite3DIssue16894 : public RenderTextureTest -{ -public: - CREATE_FUNC(RenderTextureWithSprite3DIssue16894); - RenderTextureWithSprite3DIssue16894(); - virtual ~RenderTextureWithSprite3DIssue16894(); - - virtual void visit(cocos2d::Renderer* renderer, - const cocos2d::Mat4& parentTransform, - uint32_t parentFlags) override; - - virtual std::string title() const override; - virtual std::string subtitle() const override; - -private: - cocos2d::Sprite3D* _ship[3]; - - cocos2d::RenderTexture* _renderTexDefault; - cocos2d::RenderTexture* _renderTexWithBuffer; -}; - #endif diff --git a/tests/cpp-tests/Classes/TerrainTest/TerrainTest.cpp b/tests/cpp-tests/Classes/TerrainTest/TerrainTest.cpp index d4bcb788c9..377419d3d4 100644 --- a/tests/cpp-tests/Classes/TerrainTest/TerrainTest.cpp +++ b/tests/cpp-tests/Classes/TerrainTest/TerrainTest.cpp @@ -136,7 +136,7 @@ TerrainWalkThru::TerrainWalkThru() _terrain->setSkirtHeightRatio(3); _terrain->setLODDistance(64, 128, 192); - _player = Player::create("Sprite3DTest/girl.c3b", _camera, _terrain); + _player = Player::create("MeshRendererTest/girl.c3b", _camera, _terrain); _player->setCameraMask(2); _player->setScale(0.08f); _player->setPositionY(_terrain->getHeight(_player->getPositionX(), _player->getPositionZ()) + PLAYER_HEIGHT); @@ -154,7 +154,7 @@ TerrainWalkThru::TerrainWalkThru() billboard->setCameraMask((unsigned short)CameraFlag::USER1); _player->addChild(billboard); - auto animation = Animation3D::create("Sprite3DTest/girl.c3b", "Take 001"); + auto animation = Animation3D::create("MeshRendererTest/girl.c3b", "Take 001"); if (animation) { auto animate = Animate3D::create(animation); @@ -210,7 +210,7 @@ bool Player::isDone() const void Player::update(float dt) { - auto player = (Sprite3D*)this; + auto player = (MeshRenderer*)this; switch (_playerState) { case PLAYER_STATE_IDLE: @@ -301,7 +301,7 @@ void Player::backward() void Player::updateState() { - auto player = (Sprite3D*)this; + auto player = (MeshRenderer*)this; switch (_playerState) { case PLAYER_STATE_FORWARD: @@ -323,18 +323,18 @@ void Player::updateState() Player* Player::create(const char* file, Camera* cam, Terrain* terrain) { // - auto sprite = new Player(); - if (sprite->initWithFile(file)) + auto player = new Player(); + if (player->initWithFile(file)) { - sprite->_headingAngle = 0; - sprite->_playerState = PLAYER_STATE_IDLE; - sprite->_cam = cam; - sprite->_terrain = terrain; - sprite->autorelease(); - sprite->scheduleUpdate(); - return sprite; + player->_headingAngle = 0; + player->_playerState = PLAYER_STATE_IDLE; + player->_cam = cam; + player->_terrain = terrain; + player->autorelease(); + player->scheduleUpdate(); + return player; } - CC_SAFE_DELETE(sprite); + CC_SAFE_DELETE(player); return nullptr; } diff --git a/tests/cpp-tests/Classes/TerrainTest/TerrainTest.h b/tests/cpp-tests/Classes/TerrainTest/TerrainTest.h index 9fd5e295bb..cf17e03034 100644 --- a/tests/cpp-tests/Classes/TerrainTest/TerrainTest.h +++ b/tests/cpp-tests/Classes/TerrainTest/TerrainTest.h @@ -24,12 +24,12 @@ #ifndef TERRAIN_TESH_H -# include "../BaseTest.h" +#include "../BaseTest.h" -# include "3d/CCSprite3D.h" -# include "3d/CCTerrain.h" -# include "2d/CCCamera.h" -# include "2d/CCAction.h" +#include "3d/CCMeshRenderer.h" +#include "3d/CCTerrain.h" +#include "2d/CCCamera.h" +#include "2d/CCAction.h" DEFINE_TEST_SUITE(TerrainTests); @@ -59,7 +59,7 @@ protected: # define PLAYER_STATE_FORWARD 3 # define PLAYER_STATE_BACKWARD 4 -class Player : public cocos2d::Sprite3D +class Player : public cocos2d::MeshRenderer { public: static Player* create(const char* file, cocos2d::Camera* cam, cocos2d::Terrain* terrain); diff --git a/tests/cpp-tests/Classes/controller.cpp b/tests/cpp-tests/Classes/controller.cpp index 59b610ff7f..a62889f72b 100644 --- a/tests/cpp-tests/Classes/controller.cpp +++ b/tests/cpp-tests/Classes/controller.cpp @@ -102,7 +102,7 @@ public: addTest("Node: Scene", []() { return new SceneTests(); }); addTest("Node: Spine", []() { return new SpineTests(); }); addTest("Node: Sprite", []() { return new SpriteTests(); }); - addTest("Node: Sprite3D", []() { return new Sprite3DTests(); }); + addTest("Node: MeshRenderer", []() { return new MeshRendererTests(); }); addTest("Node: SpritePolygon", []() { return new SpritePolygonTest(); }); addTest("Node: Terrain", []() { return new TerrainTests(); }); addTest("Node: FastTileMap", []() { return new FastTileMapTests(); }); diff --git a/tests/cpp-tests/Classes/tests.h b/tests/cpp-tests/Classes/tests.h index 6201204aac..aef45692cf 100644 --- a/tests/cpp-tests/Classes/tests.h +++ b/tests/cpp-tests/Classes/tests.h @@ -101,7 +101,7 @@ #include "ShaderTest/ShaderTest.h" #include "ShaderTest/ShaderTest2.h" #include "SpineTest/SpineTest.h" -#include "Sprite3DTest/Sprite3DTest.h" +#include "MeshRendererTest/MeshRendererTest.h" #include "SpritePolygonTest/SpritePolygonTest.h" #include "SpriteTest/SpriteTest.h" #include "TerrainTest/TerrainTest.h"