// Copyright (c) 2008-2023 the Urho3D project // License: MIT #pragma once #include "../Graphics/AnimatedModel.h" #include "../Graphics/Animation.h" #include "../Graphics/AnimationController.h" #include "../Graphics/AnimationController.h" #include "../Graphics/AnimationState.h" #include "../Graphics/Graphics.h" #include "../Graphics/Material.h" #include "../Graphics/Model.h" #include "../Graphics/Octree.h" #include "../Graphics/ParticleEffect.h" #include "../Graphics/Renderer.h" #include "../Graphics/RenderPath.h" #include "../Graphics/Technique.h" #include "../GraphicsAPI/GraphicsDefs.h" #include "../GraphicsAPI/IndexBuffer.h" #include "../GraphicsAPI/Texture2D.h" #include "../GraphicsAPI/TextureCube.h" #include "../GraphicsAPI/VertexBuffer.h" namespace Urho3D { // Vector RenderPath::renderTargets_ | File: ../Graphics/RenderPath.h template RenderTargetInfo* RenderPath_GetRenderTarget(unsigned index, T* ptr) { if (index >= ptr->renderTargets_.Size()) { asIScriptContext* context = asGetActiveContext(); if (context) context->SetException("Index out of bounds"); return nullptr; } else return &ptr->renderTargets_[index]; } // Vector RenderPath::commands_ | File: ../Graphics/RenderPath.h template RenderPathCommand* RenderPath_GetCommand(unsigned index, T* ptr) { if (index >= ptr->commands_.Size()) { asIScriptContext* context = asGetActiveContext(); if (context) context->SetException("Index out of bounds"); return nullptr; } else return &ptr->commands_[index]; } #define REGISTER_MEMBERS_MANUAL_PART_RenderPath() \ /* Vector RenderPath::renderTargets_ | File: ../Graphics/RenderPath.h */ \ engine->RegisterObjectMethod(className, "const RenderTargetInfo& get_renderTargets(uint) const", AS_FUNCTION_OBJLAST(RenderPath_GetRenderTarget), AS_CALL_CDECL_OBJLAST); \ \ /* Vector RenderPath::commands_ | File: ../Graphics/RenderPath.h */ \ engine->RegisterObjectMethod(className, "const RenderPathCommand& get_commands(uint) const", AS_FUNCTION_OBJLAST(RenderPath_GetCommand), AS_CALL_CDECL_OBJLAST); // ======================================================================================== // SharedPtr TechniqueEntry::technique_ | File: ../Graphics/Material.h template void TechniqueEntry_SetTechnique(Technique* technique, T* ptr) { ptr->technique_ = technique; } // SharedPtr TechniqueEntry::technique_ | File: ../Graphics/Material.h template Technique* TechniqueEntry_GetTechnique(T* ptr) { return ptr->technique_; } #define REGISTER_MEMBERS_MANUAL_PART_TechniqueEntry() \ /* SharedPtr TechniqueEntry::technique_ | File: ../Graphics/Material.h */ \ engine->RegisterObjectMethod(className, "void set_technique(Technique@+)", AS_FUNCTION_OBJLAST(TechniqueEntry_SetTechnique), AS_CALL_CDECL_OBJLAST); \ engine->RegisterObjectMethod(className, "Technique@+ get_technique() const", AS_FUNCTION_OBJLAST(TechniqueEntry_GetTechnique), AS_CALL_CDECL_OBJLAST); // ======================================================================================== extern TechniqueEntry noTechniqueEntry; template bool Material_Load_File(File* file, T* ptr) { return file && ptr->Resource::Load(*file); } // const HashMap& Material::GetShaderParameters() const | File: ../Graphics/Material.h template CScriptArray* Material_GetShaderParameterNames(T* material) { Vector result; const HashMap& parameters = material->GetShaderParameters(); for (HashMap::ConstIterator i = parameters.Begin(); i != parameters.End(); ++i) result.Push(i->second_.name_); Sort(result.Begin(), result.End()); return VectorToArray(result, "Array"); } // const TechniqueEntry& Material::GetTechniqueEntry(unsigned index) const | File: ../Graphics/Material.h template const TechniqueEntry& Material_GetTechniqueEntry(unsigned index, T* ptr) { if (index >= ptr->GetNumTechniques()) { asGetActiveContext()->SetException("Index out of bounds"); return noTechniqueEntry; } return ptr->GetTechniqueEntry(index); } #define REGISTER_MEMBERS_MANUAL_PART_Material() \ /* const HashMap& Material::GetShaderParameters() const | File: ../Graphics/Material.h */ \ engine->RegisterObjectMethod(className, "Array@ get_shaderParameterNames() const", AS_FUNCTION_OBJLAST(Material_GetShaderParameterNames), AS_CALL_CDECL_OBJLAST); \ \ /* const TechniqueEntry& Material::GetTechniqueEntry(unsigned index) const | File: ../Graphics/Material.h */ \ engine->RegisterObjectMethod(className, "const TechniqueEntry& get_techniqueEntries(uint) const", AS_FUNCTION_OBJLAST(Material_GetTechniqueEntry), AS_CALL_CDECL_OBJLAST); // ======================================================================================== template VectorBuffer VertexBuffer_GetData(T* ptr) { VectorBuffer ret; void* data = ptr->Lock(0, ptr->GetVertexCount(), false); if (data) { ret.Write(data, ptr->GetVertexCount() * ptr->GetVertexSize()); ret.Seek(0); ptr->Unlock(); } return ret; } // bool VertexBuffer::SetData(const void* data) | File: ../GraphicsAPI/VertexBuffer.h template bool VertexBuffer_SetData(VectorBuffer& src, T* ptr) { // Make sure there is enough data if (ptr->GetVertexCount() && src.GetSize() >= ptr->GetVertexCount() * ptr->GetVertexSize()) return ptr->SetData(&src.GetBuffer()[0]); else return false; } // bool VertexBuffer::SetDataRange(const void* data, unsigned start, unsigned count, bool discard = false) | File: ../GraphicsAPI/VertexBuffer.h template bool VertexBuffer_SetDataRange(VectorBuffer& src, unsigned start, unsigned count, bool discard, T* ptr) { // Make sure there is enough data if (ptr->GetVertexCount() && src.GetSize() >= count * ptr->GetVertexSize()) return ptr->SetDataRange(&src.GetBuffer()[0], start, count, discard); else return false; } #define REGISTER_MEMBERS_MANUAL_PART_VertexBuffer() \ engine->RegisterObjectMethod(className, "VectorBuffer GetData() const", AS_FUNCTION_OBJLAST(VertexBuffer_GetData), AS_CALL_CDECL_OBJLAST); \ \ /* bool VertexBuffer::SetData(const void* data) | File: ../GraphicsAPI/VertexBuffer.h */ \ engine->RegisterObjectMethod(className, "bool SetData(VectorBuffer&)", AS_FUNCTION_OBJLAST(VertexBuffer_SetData), AS_CALL_CDECL_OBJLAST); \ \ /* bool VertexBuffer::SetDataRange(const void* data, unsigned start, unsigned count, bool discard = false) | File: ../GraphicsAPI/VertexBuffer.h */ \ engine->RegisterObjectMethod(className, "bool SetDataRange(VectorBuffer&, uint, uint, bool = false)", AS_FUNCTION_OBJLAST(VertexBuffer_SetDataRange), AS_CALL_CDECL_OBJLAST); // ======================================================================================== template VectorBuffer IndexBuffer_GetData(T* ptr) { VectorBuffer ret; void* data = ptr->Lock(0, ptr->GetIndexCount(), false); if (data) { ret.Write(data, ptr->GetIndexCount() * ptr->GetIndexSize()); ret.Seek(0); ptr->Unlock(); } return ret; } // bool IndexBuffer::SetData(const void* data) | File: ../GraphicsAPI/IndexBuffer.h template bool IndexBuffer_SetData(VectorBuffer& src, T* ptr) { // Make sure there is enough data if (ptr->GetIndexCount() && src.GetSize() >= ptr->GetIndexCount() * ptr->GetIndexSize()) return ptr->SetData(&src.GetBuffer()[0]); else return false; } // bool IndexBuffer::SetDataRange(const void* data, unsigned start, unsigned count, bool discard = false) | File: ../GraphicsAPI/IndexBuffer.h template bool IndexBuffer_SetDataRange(VectorBuffer& src, unsigned start, unsigned count, bool discard, T* ptr) { // Make sure there is enough data if (ptr->GetIndexCount() && src.GetSize() >= count * ptr->GetIndexSize()) return ptr->SetDataRange(&src.GetBuffer()[0], start, count, discard); else return false; } #define REGISTER_MEMBERS_MANUAL_PART_IndexBuffer() \ engine->RegisterObjectMethod(className, "VectorBuffer GetData()", AS_FUNCTION_OBJLAST(IndexBuffer_GetData), AS_CALL_CDECL_OBJLAST); \ \ /* bool IndexBuffer::SetData(const void* data) | File: ../GraphicsAPI/IndexBuffer.h */ \ engine->RegisterObjectMethod(className, "bool SetData(VectorBuffer&)", AS_FUNCTION_OBJLAST(IndexBuffer_SetData), AS_CALL_CDECL_OBJLAST); \ \ /* bool IndexBuffer::SetDataRange(const void* data, unsigned start, unsigned count, bool discard = false) | File: ../GraphicsAPI/IndexBuffer.h */ \ engine->RegisterObjectMethod(className, "bool SetDataRange(VectorBuffer&, uint, uint, bool discard = false)", AS_FUNCTION_OBJLAST(IndexBuffer_SetDataRange), AS_CALL_CDECL_OBJLAST); // ======================================================================================== #define REGISTER_MEMBERS_MANUAL_PART_AnimationTrack() \ /* AnimationKeyFrame* AnimationTrack::GetKeyFrame(unsigned index) | File: ../Graphics/Animation.h */ \ engine->RegisterObjectMethod(className, "const AnimationKeyFrame& get_keyFrames(uint) const", AS_METHOD(T, GetKeyFrame), AS_CALL_THISCALL); // ======================================================================================== // AnimationTriggerPoint* Animation::GetTrigger(unsigned index) | File: ../Graphics/Animation.h template AnimationTriggerPoint* Animation_GetTrigger(unsigned index, T* ptr) { if (index >= ptr->GetNumTriggers()) { asIScriptContext* context = asGetActiveContext(); if (context) context->SetException("Index out of bounds"); return nullptr; } else return ptr->GetTrigger(index); } #define REGISTER_MEMBERS_MANUAL_PART_Animation() \ /* AnimationTriggerPoint* Animation::GetTrigger(unsigned index) | File: ../Graphics/Animation.h */ \ engine->RegisterObjectMethod(className, "const AnimationTriggerPoint& get_triggers(uint) const", AS_FUNCTION_OBJLAST(Animation_GetTrigger), AS_CALL_CDECL_OBJLAST); // ======================================================================================== #define REGISTER_MEMBERS_MANUAL_PART_CascadeParameters() \ /* Vector4 CascadeParameters::splits_ | File: ../Graphics/Light.h */ \ engine->RegisterObjectProperty(className, "float split1", offsetof(T, splits_.x_)); \ engine->RegisterObjectProperty(className, "float split2", offsetof(T, splits_.y_)); \ engine->RegisterObjectProperty(className, "float split3", offsetof(T, splits_.z_)); \ engine->RegisterObjectProperty(className, "float split4", offsetof(T, splits_.w_)); // ======================================================================================== // void AnimationState::SetBoneWeight(const String& name, float weight, bool recursive = false) | File: ../Graphics/AnimationState.h template void AnimationState_SetBoneWeight(const String& name, float weight, T* ptr) { ptr->SetBoneWeight(name, weight); } #define REGISTER_MEMBERS_MANUAL_PART_AnimationState() \ /* void AnimationState::SetBoneWeight(const String& name, float weight, bool recursive = false) | File: ../Graphics/AnimationState.h */ \ engine->RegisterObjectMethod(className, "void set_boneWeights(const String&in, float)", AS_FUNCTION_OBJLAST(AnimationState_SetBoneWeight), AS_CALL_CDECL_OBJLAST); // ======================================================================================== // virtual void StaticModel::SetModel(Model* model) | File: ../Graphics/StaticModel.h template void StaticModel_SetModel(Model* model, T* ptr) { // Check type here to allow operating on both AnimatedModel and StaticModel without calling the wrong function, // as AnimatedModel can be cast to StaticModel if (ptr->GetType() == AnimatedModel::GetTypeStatic()) ((AnimatedModel*)ptr)->SetModel(model); else ptr->SetModel(model); } #define REGISTER_MEMBERS_MANUAL_PART_StaticModel() \ /* virtual void StaticModel::SetModel(Model* model) | File: ../Graphics/StaticModel.h */ \ engine->RegisterObjectMethod(className, "void SetModel(Model@+)", AS_FUNCTION_OBJLAST(StaticModel_SetModel), AS_CALL_CDECL_OBJLAST); \ engine->RegisterObjectMethod(className, "void set_model(Model@+)", AS_FUNCTION_OBJLAST(StaticModel_SetModel), AS_CALL_CDECL_OBJLAST); // ======================================================================================== // const Vector& AnimatedModel::GetMorphs() const | File: ../Graphics/AnimatedModel.h template const String& AnimatedModel_GetMorphName(unsigned index, T* ptr) { const Vector& morphs = ptr->GetMorphs(); return index < morphs.Size() ? morphs[index].name_ : String::EMPTY; } // void AnimatedModel::SetModel(Model* model, bool createBones = true) | File: ../Graphics/AnimatedModel.h template void AnimatedModel_SetModel(Model* model, T* ptr) { ptr->SetModel(model); } #define REGISTER_MEMBERS_MANUAL_PART_AnimatedModel() \ /* const Vector& AnimatedModel::GetMorphs() const | File: ../Graphics/AnimatedModel.h */ \ engine->RegisterObjectMethod(className, "const String& get_morphNames(uint) const", AS_FUNCTION_OBJLAST(AnimatedModel_GetMorphName), AS_CALL_CDECL_OBJLAST); // ======================================================================================== // const Vector& AnimationController::GetAnimations() const | File: ../Graphics/AnimationController.h template unsigned AnimationController_GetNumAnimations(T* controller) { return controller->GetAnimations().Size(); } // const Vector& AnimationController::GetAnimations() const | File: ../Graphics/AnimationController.h template const AnimationControl* AnimationController_GetAnimation(unsigned index, T* controller) { const Vector& animations = controller->GetAnimations(); return (index < animations.Size()) ? &animations[index] : nullptr; } #define REGISTER_MEMBERS_MANUAL_PART_AnimationController() \ /* const Vector& AnimationController::GetAnimations() const | File: ../Graphics/AnimationController.h */ \ engine->RegisterObjectMethod(className, "uint get_numAnimations() const", AS_FUNCTION_OBJLAST(AnimationController_GetNumAnimations), AS_CALL_CDECL_OBJLAST); \ \ /* const Vector& AnimationController::GetAnimations() const | File: ../Graphics/AnimationController.h */ \ engine->RegisterObjectMethod(className, "const AnimationControl@ get_animations(uint) const", AS_FUNCTION_OBJLAST(AnimationController_GetAnimation), AS_CALL_CDECL_OBJLAST); // ======================================================================================== // void Graphics::PrecacheShaders(Deserializer& source) | File: ../Graphics/Graphics.h template void Graphics_PrecacheShaders_File(File* file, T* ptr) { if (file) ptr->PrecacheShaders(*file); } // void Graphics::PrecacheShaders(Deserializer& source) | File: ../Graphics/Graphics.h template void Graphics_PrecacheShaders_VectorBuffer(VectorBuffer& buffer, T* ptr) { ptr->PrecacheShaders(buffer); } #define REGISTER_MEMBERS_MANUAL_PART_Graphics() \ /* void Graphics::PrecacheShaders(Deserializer& source) | File: ../Graphics/Graphics.h */ \ engine->RegisterObjectMethod(className, "void PrecacheShaders(File@+)", AS_FUNCTION_OBJLAST(Graphics_PrecacheShaders_File), AS_CALL_CDECL_OBJLAST); \ \ /* void Graphics::PrecacheShaders(Deserializer& source) | File: ../Graphics/Graphics.h */ \ engine->RegisterObjectMethod(className, "void PrecacheShaders(VectorBuffer&)", AS_FUNCTION_OBJLAST(Graphics_PrecacheShaders_VectorBuffer), AS_CALL_CDECL_OBJLAST); // ======================================================================================== // Drawable* RayQueryResult::drawable_ | File: ../Graphics/OctreeQuery.h template Drawable* RayQueryResult_GetDrawable(T* ptr) { return ptr->drawable_; } // Node* RayQueryResult::node_ | File: ../Graphics/OctreeQuery.h template Node* RayQueryResult_GetNode(T* ptr) { return ptr->node_; } #define REGISTER_MEMBERS_MANUAL_PART_RayQueryResult() \ /* Drawable* RayQueryResult::drawable_ | File: ../Graphics/OctreeQuery.h */ \ engine->RegisterObjectMethod(className, "Drawable@+ get_drawable() const", AS_FUNCTION_OBJLAST(RayQueryResult_GetDrawable), AS_CALL_CDECL_OBJLAST); \ \ /* Node* RayQueryResult::node_ | File: ../Graphics/OctreeQuery.h */ \ engine->RegisterObjectMethod(className, "Node@+ get_node() const", AS_FUNCTION_OBJLAST(RayQueryResult_GetNode), AS_CALL_CDECL_OBJLAST); // ======================================================================================== // void Octree::Raycast(RayOctreeQuery& query) const | File: ../Graphics/Octree.h template CScriptArray* Octree_Raycast(const Ray& ray, RayQueryLevel level, float maxDistance, DrawableTypes drawableTypes, unsigned viewMask, Octree* ptr) { Vector result; RayOctreeQuery query(result, ray, level, maxDistance, drawableTypes, viewMask); ptr->Raycast(query); return VectorToArray(result, "Array"); } // void Octree::RaycastSingle(RayOctreeQuery& query) const | File: ../Graphics/Octree.h template RayQueryResult Octree_RaycastSingle(const Ray& ray, RayQueryLevel level, float maxDistance, DrawableTypes drawableTypes, unsigned viewMask, Octree* ptr) { Vector result; RayOctreeQuery query(result, ray, level, maxDistance, drawableTypes, viewMask); ptr->RaycastSingle(query); if (!query.result_.Empty()) { return query.result_[0]; } else { RayQueryResult empty; empty.position_ = Vector3::ZERO; empty.normal_ = Vector3::ZERO; empty.distance_ = M_INFINITY; empty.subObject_ = 0; return empty; } } // void Octree::GetDrawables(OctreeQuery& query) const | File: ../Graphics/Octree.h template CScriptArray* Octree_GetDrawables_Point(const Vector3& point, DrawableTypes drawableTypes, unsigned viewMask, Octree* ptr) { Vector result; PointOctreeQuery query(result, point, drawableTypes, viewMask); ptr->GetDrawables(query); return VectorToHandleArray(result, "Array"); } // void Octree::GetDrawables(OctreeQuery& query) const | File: ../Graphics/Octree.h template CScriptArray* Octree_GetDrawables_Box(const BoundingBox& box, DrawableTypes drawableTypes, unsigned viewMask, Octree* ptr) { Vector result; BoxOctreeQuery query(result, box, drawableTypes, viewMask); ptr->GetDrawables(query); return VectorToHandleArray(result, "Array"); } // void Octree::GetDrawables(OctreeQuery& query) const | File: ../Graphics/Octree.h template CScriptArray* Octree_GetDrawables_Frustum(const Frustum& frustum, DrawableTypes drawableTypes, unsigned viewMask, Octree* ptr) { Vector result; FrustumOctreeQuery query(result, frustum, drawableTypes, viewMask); ptr->GetDrawables(query); return VectorToHandleArray(result, "Array"); } // void Octree::GetDrawables(OctreeQuery& query) const | File: ../Graphics/Octree.h template CScriptArray* Octree_GetDrawables_Sphere(const Sphere& sphere, DrawableTypes drawableTypes, unsigned viewMask, Octree* ptr) { Vector result; SphereOctreeQuery query(result, sphere, drawableTypes, viewMask); ptr->GetDrawables(query); return VectorToHandleArray(result, "Array"); } // void Octree::GetDrawables(OctreeQuery& query) const | File: ../Graphics/Octree.h template CScriptArray* Octree_GetDrawables_All(DrawableTypes drawableTypes, unsigned viewMask, Octree* ptr) { Vector result; AllContentOctreeQuery query(result, drawableTypes, viewMask); ptr->GetDrawables(query); return VectorToHandleArray(result, "Array"); } #define REGISTER_MEMBERS_MANUAL_PART_Octree() \ /* void Octree::Raycast(RayOctreeQuery& query) const | File: ../Graphics/Octree.h */ \ engine->RegisterObjectMethod(className, "Array@ Raycast(const Ray&in, RayQueryLevel = RAY_TRIANGLE, float = M_INFINITY, DrawableTypes = DrawableTypes::Any, uint = DEFAULT_VIEWMASK) const", AS_FUNCTION_OBJLAST(Octree_Raycast), AS_CALL_CDECL_OBJLAST); \ \ /* void Octree::RaycastSingle(RayOctreeQuery& query) const | File: ../Graphics/Octree.h */ \ engine->RegisterObjectMethod(className, "RayQueryResult RaycastSingle(const Ray&in, RayQueryLevel = RAY_TRIANGLE, float = M_INFINITY, DrawableTypes = DrawableTypes::Any, uint = DEFAULT_VIEWMASK) const", AS_FUNCTION_OBJLAST(Octree_RaycastSingle), AS_CALL_CDECL_OBJLAST); \ \ /* void Octree::GetDrawables(OctreeQuery& query) const | File: ../Graphics/Octree.h */ \ engine->RegisterObjectMethod(className, "Array@ GetDrawables(const Vector3&in, DrawableTypes = DrawableTypes::Any, uint = DEFAULT_VIEWMASK)", AS_FUNCTION_OBJLAST(Octree_GetDrawables_Point), AS_CALL_CDECL_OBJLAST); \ engine->RegisterObjectMethod(className, "Array@ GetDrawables(const BoundingBox&in, DrawableTypes = DrawableTypes::Any, uint = DEFAULT_VIEWMASK)", AS_FUNCTION_OBJLAST(Octree_GetDrawables_Box), AS_CALL_CDECL_OBJLAST); \ engine->RegisterObjectMethod(className, "Array@ GetDrawables(const Frustum&in, DrawableTypes = DrawableTypes::Any, uint = DEFAULT_VIEWMASK)", AS_FUNCTION_OBJLAST(Octree_GetDrawables_Frustum), AS_CALL_CDECL_OBJLAST); \ engine->RegisterObjectMethod(className, "Array@ GetDrawables(const Sphere&in, DrawableTypes = DrawableTypes::Any, uint = DEFAULT_VIEWMASK)", AS_FUNCTION_OBJLAST(Octree_GetDrawables_Sphere), AS_CALL_CDECL_OBJLAST); \ engine->RegisterObjectMethod(className, "Array@ GetAllDrawables(DrawableTypes = DrawableTypes::Any, uint = DEFAULT_VIEWMASK)", AS_FUNCTION_OBJLAST(Octree_GetDrawables_All), AS_CALL_CDECL_OBJLAST); // ======================================================================================== // void Renderer::SetVSMShadowParameters(float minVariance, float lightBleedingReduction) | File: ../Graphics/Renderer.h template void Renderer_SetVSMShadowParameters(const Vector2& parameters, T* ptr) { ptr->SetVSMShadowParameters(parameters.x_, parameters.y_); } #define REGISTER_MEMBERS_MANUAL_PART_Renderer() \ /* void Renderer::SetVSMShadowParameters(float minVariance, float lightBleedingReduction) | File: ../Graphics/Renderer.h */ \ engine->RegisterObjectMethod("Renderer", "void set_vsmShadowParameters(const Vector2&in)", AS_FUNCTION_OBJLAST(Renderer_SetVSMShadowParameters), AS_CALL_CDECL_OBJLAST); }