workspace instancing (needs shader)
This commit is contained in:
parent
c37a4fbfcf
commit
0caf3b96b4
|
|
@ -1,4 +1,4 @@
|
|||
// generated by blender2ogre 0.8.3 on 2023-07-10 17:26:00
|
||||
// generated by blender2ogre 0.8.3 on 2023-07-10 20:18:50
|
||||
material Material {
|
||||
receive_shadows on
|
||||
technique {
|
||||
|
|
@ -6,6 +6,11 @@ material Material {
|
|||
diffuse 0.8 0.8 0.8 1.0
|
||||
specular 0.512 0.512 0.512 1.0 64.0
|
||||
|
||||
texture_unit {
|
||||
texture fonts/brick_tex.PNG
|
||||
tex_address_mode wrap
|
||||
colour_op modulate
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
17:26:00: XMLMeshSerializer reading mesh data from /home/caesium/projects/rbxnu/Content/fonts/Cube.mesh.xml...
|
||||
17:26:00: Reading geometry...
|
||||
17:26:00: Geometry done...
|
||||
17:26:00: Reading submeshes...
|
||||
17:26:00: Submeshes done.
|
||||
17:26:00: Reading mesh names...
|
||||
17:26:00: Mesh names done.
|
||||
17:26:00: XMLMeshSerializer import successful.
|
||||
17:26:00: MeshSerializer writing mesh data to stream /home/caesium/projects/rbxnu/Content/fonts/Cube.mesh...
|
||||
17:26:00: File header written.
|
||||
17:26:00: Writing mesh data...
|
||||
17:26:00: Writing submesh...
|
||||
17:26:00: Exporting submesh texture aliases...
|
||||
17:26:00: Submesh texture aliases exported.
|
||||
17:26:00: Submesh exported.
|
||||
17:26:00: Exporting bounds information....
|
||||
17:26:00: Bounds information exported.
|
||||
17:26:00: Exporting submesh name table...
|
||||
17:26:00: Submesh name table exported.
|
||||
17:26:00: Mesh data exported.
|
||||
17:26:00: MeshSerializer export successful.
|
||||
20:18:50: XMLMeshSerializer reading mesh data from /home/caesium/projects/rbxnu/Content/fonts/Cube.mesh.xml...
|
||||
20:18:50: Reading geometry...
|
||||
20:18:50: Geometry done...
|
||||
20:18:50: Reading submeshes...
|
||||
20:18:50: Submeshes done.
|
||||
20:18:50: Reading mesh names...
|
||||
20:18:50: Mesh names done.
|
||||
20:18:50: XMLMeshSerializer import successful.
|
||||
20:18:50: MeshSerializer writing mesh data to stream /home/caesium/projects/rbxnu/Content/fonts/Cube.mesh...
|
||||
20:18:50: File header written.
|
||||
20:18:50: Writing mesh data...
|
||||
20:18:50: Writing submesh...
|
||||
20:18:50: Exporting submesh texture aliases...
|
||||
20:18:50: Submesh texture aliases exported.
|
||||
20:18:50: Submesh exported.
|
||||
20:18:50: Exporting bounds information....
|
||||
20:18:50: Bounds information exported.
|
||||
20:18:50: Exporting submesh name table...
|
||||
20:18:50: Submesh name table exported.
|
||||
20:18:50: Mesh data exported.
|
||||
20:18:50: MeshSerializer export successful.
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
|
|
@ -21,10 +21,6 @@ int main(int argc, char** argv)
|
|||
window.ogreWidget->initializeOgre();
|
||||
|
||||
RNR::World* world = new RNR::World(window.ogreWidget->ogreRoot, window.ogreWidget->ogreSceneManager);
|
||||
Ogre::SceneNode* workspace_node = window.ogreWidget->ogreSceneManager->getRootSceneNode()->createChildSceneNode();
|
||||
workspace_node->attachObject(world->getWorkspace());
|
||||
workspace_node->setVisible(true);
|
||||
printf("main: workspace = %p (%p)\n",workspace_node, world->getWorkspace());
|
||||
window.updateTree(world->getDatamodel());
|
||||
|
||||
while (window.isVisible())
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ namespace RNR
|
|||
class CoordinateFrame
|
||||
{
|
||||
Ogre::Vector3 m_position;
|
||||
Ogre::Vector3 m_scale;
|
||||
Ogre::Matrix3 m_rotation;
|
||||
public:
|
||||
CoordinateFrame();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include <OGRE/Ogre.h>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <Helpers/Name.hpp>
|
||||
|
|
@ -18,6 +19,8 @@ namespace RNR
|
|||
|
||||
private:
|
||||
|
||||
Ogre::SceneNode* m_node;
|
||||
Ogre::MovableObject* m_object;
|
||||
std::string m_name;
|
||||
RNR::Instance* m_parent;
|
||||
std::vector<RNR::Instance*> m_children;
|
||||
|
|
@ -44,6 +47,10 @@ namespace RNR
|
|||
|
||||
void setParent(RNR::Instance* newParent);
|
||||
void setName(std::string name);
|
||||
void setNode(Ogre::SceneNode* node) { m_node = node; };
|
||||
Ogre::SceneNode* getNode() { return m_node; };
|
||||
void setObject(Ogre::MovableObject* object) { m_object = object; };
|
||||
Ogre::MovableObject* getObject() { return m_object; };
|
||||
std::vector<RNR::Instance*>* getChildren() { return &this->m_children; };
|
||||
int numChildren() { return this->m_children.size(); };
|
||||
|
||||
|
|
|
|||
|
|
@ -5,22 +5,16 @@
|
|||
|
||||
namespace RNR
|
||||
{
|
||||
// this acts as both an Instance to fit in the RNR graph, and as an Ogre MovableObject to fit in the Ogre graph
|
||||
// all instances that are Renderable are stored in the children of this
|
||||
class Workspace : public Instance, public Ogre::MovableObject
|
||||
class Workspace : public Instance
|
||||
{
|
||||
public:
|
||||
Workspace();
|
||||
|
||||
virtual void _updateRenderQueue(Ogre::RenderQueue* queue);
|
||||
virtual const Ogre::String& getMovableType(void) const;
|
||||
virtual const Ogre::AxisAlignedBox& getBoundingBox(void) const;
|
||||
virtual Ogre::Real getBoundingRadius(void) const;
|
||||
virtual void visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables);
|
||||
void build();
|
||||
private:
|
||||
Ogre::AxisAlignedBox m_bbox;
|
||||
Ogre::String m_type;
|
||||
|
||||
void renderQueueAddInstance(Ogre::RenderQueue* queue, Instance* instance);
|
||||
Ogre::InstanceManager* m_instMan;
|
||||
Ogre::SceneNode* m_worldspawn;
|
||||
|
||||
void buildChild(Instance* child);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace RNR
|
||||
{
|
||||
CoordinateFrame::CoordinateFrame() : m_position(0.f,0.f,0.f), m_rotation()
|
||||
CoordinateFrame::CoordinateFrame() : m_position(0.f,0.f,0.f), m_scale(1.f,1.f,1.f), m_rotation()
|
||||
{
|
||||
m_rotation.FromEulerAnglesXYZ(Ogre::Radian(0.f), Ogre::Radian(0.f), Ogre::Radian(0.f));
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ namespace RNR
|
|||
Ogre::Matrix4 CoordinateFrame::getMatrix()
|
||||
{
|
||||
Ogre::Matrix4 res = Ogre::Matrix4();
|
||||
res.makeTransform(m_position, Ogre::Vector3(1.f,1.f,1.f), Ogre::Quaternion(m_rotation));
|
||||
res.makeTransform(m_position, m_scale, Ogre::Quaternion(m_rotation));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ namespace RNR
|
|||
m_nearbyLights = Ogre::LightList();
|
||||
m_nearbyLights.insert(m_nearbyLights.begin(), world->getOgreSceneManager()->getLight("SunLight"));
|
||||
|
||||
m_material = Ogre::MaterialManager::getSingletonPtr()->create("part", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
|
||||
|
||||
if(m_partMesh == 0)
|
||||
m_partMesh = Ogre::Root::getSingletonPtr()->getMeshManager()->load("fonts/Cube.mesh", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
|
||||
m_material = m_partMesh->getSubMesh(0)->getMaterial();
|
||||
}
|
||||
|
||||
void BasePart::updateMatrix()
|
||||
|
|
@ -27,8 +27,7 @@ namespace RNR
|
|||
|
||||
const Ogre::MaterialPtr& BasePart::getMaterial() const
|
||||
{
|
||||
Ogre::SubMesh* submesh = m_partMesh->getSubMesh(0);
|
||||
return submesh->getMaterial();
|
||||
return m_material;
|
||||
}
|
||||
|
||||
void BasePart::getRenderOperation(Ogre::RenderOperation& op)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ namespace RNR
|
|||
|
||||
Instance::Instance()
|
||||
{
|
||||
m_node = 0;
|
||||
m_object = 0;
|
||||
m_parent = 0;
|
||||
setName("Instance");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,54 +1,36 @@
|
|||
#include <App/V8/World/Workspace.hpp>
|
||||
#include <App/V8/World/World.hpp>
|
||||
#include <App/V8/DataModel/BasePart.hpp>
|
||||
|
||||
namespace RNR
|
||||
{
|
||||
Workspace::Workspace() : Instance(), Ogre::MovableObject()
|
||||
Workspace::Workspace() : Instance()
|
||||
{
|
||||
setName("Workspace");
|
||||
m_type = Ogre::String("Entity");
|
||||
m_bbox = Ogre::AxisAlignedBox(-1000,-1000,-1000, 1000,1000,1000);
|
||||
m_instMan = world->getOgreSceneManager()->createInstanceManager("workspacePartInstanceManager", "fonts/Cube.mesh", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::InstanceManager::InstancingTechnique::HWInstancingBasic, 255);
|
||||
m_worldspawn = world->getOgreSceneManager()->getRootSceneNode()->createChildSceneNode();
|
||||
}
|
||||
|
||||
void Workspace::_updateRenderQueue(Ogre::RenderQueue* queue)
|
||||
void Workspace::build()
|
||||
{
|
||||
std::vector<Instance*>* children = getChildren();
|
||||
for(auto& child : *children)
|
||||
for(auto& child : *getChildren())
|
||||
buildChild(child);
|
||||
}
|
||||
|
||||
void Workspace::buildChild(Instance* child)
|
||||
{
|
||||
for(auto& child2 : *child->getChildren())
|
||||
buildChild(child2);
|
||||
BasePart* child_part = (BasePart*)child;
|
||||
Ogre::InstancedEntity* child_ent = (Ogre::InstancedEntity*)child->getObject();
|
||||
if(!child_ent)
|
||||
{
|
||||
renderQueueAddInstance(queue, child);
|
||||
child_ent = m_instMan->createInstancedEntity("fonts/Material");
|
||||
child_ent->setUserAny(child);
|
||||
child->setObject(child_ent);
|
||||
}
|
||||
}
|
||||
|
||||
void Workspace::renderQueueAddInstance(Ogre::RenderQueue* queue, Instance* instance)
|
||||
{
|
||||
std::vector<Instance*>* children = instance->getChildren();
|
||||
BasePart* rend = dynamic_cast<BasePart*>(instance);
|
||||
queue->addRenderable(rend);
|
||||
|
||||
for(auto& child : *children)
|
||||
{
|
||||
renderQueueAddInstance(queue, child);
|
||||
}
|
||||
}
|
||||
|
||||
const Ogre::String& Workspace::getMovableType(void) const
|
||||
{
|
||||
printf("Workspace::getMovableType\n");
|
||||
return m_type;
|
||||
}
|
||||
|
||||
const Ogre::AxisAlignedBox& Workspace::getBoundingBox(void) const
|
||||
{
|
||||
return m_bbox;
|
||||
}
|
||||
|
||||
Ogre::Real Workspace::getBoundingRadius(void) const
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
void Workspace::visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables)
|
||||
{
|
||||
child_ent->setPosition(child_part->getCFrame().getPosition());
|
||||
child_ent->setOrientation(Ogre::Quaternion(child_part->getCFrame().getRotation()));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -18,6 +18,8 @@ namespace RNR
|
|||
BasePart* test2 = new BasePart();
|
||||
test->setParent(m_datamodel);
|
||||
test2->setParent(m_workspace);
|
||||
|
||||
m_workspace->build();
|
||||
}
|
||||
|
||||
World::~World()
|
||||
|
|
|
|||
Loading…
Reference in New Issue