static geometry
This commit is contained in:
parent
5404460fce
commit
835e481330
|
|
@ -19,14 +19,19 @@ namespace RNR
|
|||
virtual std::string getClassName() { return "Workspace"; }
|
||||
virtual void onChildAdded(RNR::Instance* childAdded);
|
||||
virtual void onChildRemoved(RNR::Instance* childRemoved);
|
||||
|
||||
void buildLegacyGeom();
|
||||
|
||||
Camera* getCurrentCamera() const;
|
||||
void setCurrentCamera(Camera *value);
|
||||
private:
|
||||
bool m_instancingEnabled;
|
||||
bool m_legacyDirty;
|
||||
std::vector<Ogre::InstancedEntity*> m_objects;
|
||||
Ogre::StaticGeometry* m_legacyGeom; // use in case of InstanceManager either not working or not being supported
|
||||
Ogre::InstanceManager* m_instMan;
|
||||
Ogre::SceneNode* m_worldspawn;
|
||||
Ogre::Entity* m_partEntity;
|
||||
|
||||
std::shared_ptr<Camera> currentCamera;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,11 +7,13 @@ namespace RNR
|
|||
{
|
||||
Workspace::Workspace() : ModelInstance()
|
||||
{
|
||||
m_instancingEnabled = true;
|
||||
m_instancingEnabled = false;
|
||||
setName("Workspace");
|
||||
m_instMan = world->getOgreSceneManager()->createInstanceManager("workspacePartInstanceManager", "fonts/Cube.mesh", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::InstanceManager::InstancingTechnique::HWInstancingBasic, 255);
|
||||
m_instMan->setNumCustomParams(2);
|
||||
m_worldspawn = world->getOgreSceneManager()->getRootSceneNode()->createChildSceneNode();
|
||||
m_legacyGeom = world->getOgreSceneManager()->createStaticGeometry("workspaceGeom");
|
||||
m_partEntity = world->getOgreSceneManager()->createEntity("fonts/Cube.mesh");
|
||||
}
|
||||
|
||||
void Workspace::onChildAdded(Instance* childAdded)
|
||||
|
|
@ -19,29 +21,46 @@ namespace RNR
|
|||
PartInstance* child_part = dynamic_cast<PartInstance*>(childAdded);
|
||||
if(child_part)
|
||||
{
|
||||
Ogre::InstancedEntity* child_ent = (Ogre::InstancedEntity*)childAdded->getObject();
|
||||
if(!child_ent)
|
||||
if(m_instancingEnabled)
|
||||
{
|
||||
child_ent = m_instMan->createInstancedEntity("materials/partinstanced");
|
||||
assert(child_ent != NULL);
|
||||
childAdded->setObject(child_ent);
|
||||
m_objects.push_back(child_ent);
|
||||
Ogre::InstancedEntity* child_ent = (Ogre::InstancedEntity*)childAdded->getObject();
|
||||
if(!child_ent)
|
||||
{
|
||||
child_ent = m_instMan->createInstancedEntity("materials/partinstanced");
|
||||
assert(child_ent != NULL);
|
||||
childAdded->setObject(child_ent);
|
||||
m_objects.push_back(child_ent);
|
||||
}
|
||||
child_ent->setPosition(child_part->getCFrame().getPosition());
|
||||
child_ent->setOrientation(Ogre::Quaternion(child_part->getCFrame().getRotation()));
|
||||
Ogre::Vector3 size = child_part->getSize();
|
||||
child_ent->setScale(size);
|
||||
child_ent->setCustomParam(0, Ogre::Vector4(
|
||||
size.x,
|
||||
size.y,
|
||||
size.z,
|
||||
0.0f
|
||||
));
|
||||
child_ent->setCustomParam(1, child_part->getColor());
|
||||
child_ent->setCastShadows(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_legacyGeom->addEntity(m_partEntity,
|
||||
child_part->getCFrame().getPosition(),
|
||||
Ogre::Quaternion(child_part->getCFrame().getRotation()),
|
||||
child_part->getSize());
|
||||
m_legacyDirty = true;
|
||||
}
|
||||
child_ent->setPosition(child_part->getCFrame().getPosition());
|
||||
child_ent->setOrientation(Ogre::Quaternion(child_part->getCFrame().getRotation()));
|
||||
Ogre::Vector3 size = child_part->getSize();
|
||||
child_ent->setScale(size);
|
||||
child_ent->setCustomParam(0, Ogre::Vector4(
|
||||
size.x,
|
||||
size.y,
|
||||
size.z,
|
||||
0.0f
|
||||
));
|
||||
child_ent->setCustomParam(1, child_part->getColor());
|
||||
child_ent->setCastShadows(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Workspace::buildLegacyGeom()
|
||||
{
|
||||
m_legacyGeom->build();
|
||||
m_legacyDirty = false;
|
||||
}
|
||||
|
||||
void Workspace::onChildRemoved(Instance* childRemoved)
|
||||
{
|
||||
Ogre::InstancedEntity* child_ent = (Ogre::InstancedEntity*)childRemoved->getObject();
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ namespace RNR
|
|||
m_datamodel->setName("DataModel");
|
||||
m_workspace = new Workspace();
|
||||
m_workspace->setParent(m_datamodel);
|
||||
|
||||
load("/home/caesium/Downloads/Telegram Desktop/Destroy-History-1.rbxl");
|
||||
}
|
||||
|
||||
World::~World()
|
||||
|
|
@ -95,6 +97,6 @@ namespace RNR
|
|||
|
||||
void World::update()
|
||||
{
|
||||
//
|
||||
m_workspace->buildLegacyGeom();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue