97 lines
2.5 KiB
C++
97 lines
2.5 KiB
C++
#pragma once
|
|
|
|
#include "dvc_config.h"
|
|
#include "dvc_pre_declare.h"
|
|
|
|
DV_CORE_BEGIN_NAMESPACE
|
|
|
|
class DV_CORE_API Scene
|
|
{
|
|
public:
|
|
void init(void);
|
|
void clear(void);
|
|
|
|
public:
|
|
DeviceBufferPtr newDeviceBuffer(void);
|
|
int32_t getDeviceBufferCounts(void) const {
|
|
return (int32_t)m_deviceBufferArray.size();
|
|
}
|
|
DeviceBufferConstPtr getDeviceBuffer(int32_t index) const;
|
|
|
|
DeviceBufferViewPtr newDeviceBufferView(DeviceBufferConstPtr buffer, size_t offset, size_t length, size_t stride);
|
|
int32_t getDeviceBufferViewCounts(void) const {
|
|
return (int32_t)m_bufferViewArray.size();
|
|
}
|
|
DeviceBufferViewPtr getDeviceBufferView(int32_t index) const;
|
|
|
|
DeviceBufferAccessorPtr newDeviceBufferAccessor(DeviceBufferViewConstPtr bufferView, size_t offset,
|
|
size_t count, ComponentType componentType, DataType dataType);
|
|
int32_t getDeviceBufferAccessorCounts(void) const {
|
|
return (int32_t)m_bufferAccessorArray.size();
|
|
}
|
|
DeviceBufferAccessorPtr getDeviceBufferAccessor(int32_t index) const;
|
|
|
|
int32_t pushNewMeshAsset(MeshPtr mesh);
|
|
int32_t getMeshCounts(void) const {
|
|
return (int32_t)m_meshArray.size();
|
|
}
|
|
MeshConstPtr getMesh(int32_t index) const;
|
|
|
|
public:
|
|
SceneNodePtr newSceneNode(const std::string& name);
|
|
SceneNodePtr getRootSceneNode() const;
|
|
void buildRenderableQueue(RenderPipe& pipe) const;
|
|
|
|
public:
|
|
template<typename ComponentType>
|
|
SceneNodeConstPtr getNodeWithComponent(const char* name = nullptr) const
|
|
{
|
|
return getNodeWithComponent<ComponentType>(name, getRootSceneNode());
|
|
}
|
|
|
|
template<typename ComponentType>
|
|
SceneNodeConstPtr getNodeWithComponent(const char* name, SceneNodeConstPtr node) const
|
|
{
|
|
size_t counts = node->getChildCounts();
|
|
for (size_t i = 0; i < counts; i++)
|
|
{
|
|
SceneNodeConstPtr childNodePtr = node->getChild(i);
|
|
if (name != nullptr && childNodePtr->getName() != name)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
std::shared_ptr<const ComponentType> component = childNodePtr->getComponent<ComponentType>();
|
|
if (component)
|
|
{
|
|
return childNodePtr;
|
|
}
|
|
|
|
//get from child
|
|
SceneNodeConstPtr cameraNode = getNodeWithComponent<ComponentType>(name, childNodePtr);
|
|
if (cameraNode != nullptr)
|
|
{
|
|
return cameraNode;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
protected:
|
|
SceneNodePtr m_rootSceneNode;
|
|
|
|
//device resources
|
|
std::vector<DeviceBufferPtr> m_deviceBufferArray;
|
|
std::vector<DeviceBufferViewPtr> m_bufferViewArray;
|
|
std::vector<DeviceBufferAccessorPtr> m_bufferAccessorArray;
|
|
|
|
//asset resources
|
|
std::vector<MeshPtr> m_meshArray;
|
|
|
|
public:
|
|
Scene();
|
|
~Scene();
|
|
};
|
|
|
|
DV_CORE_END_NAMESPACE
|