bring back Models in dm load; add model icon
This commit is contained in:
parent
c92d01b2c9
commit
27e43889e9
|
|
@ -0,0 +1,137 @@
|
||||||
|
material sparkle/sparkleMatl
|
||||||
|
{
|
||||||
|
technique
|
||||||
|
{
|
||||||
|
pass
|
||||||
|
{
|
||||||
|
lighting off
|
||||||
|
depth_write off
|
||||||
|
scene_blend add
|
||||||
|
|
||||||
|
texture_unit
|
||||||
|
{
|
||||||
|
texture sparkle.png
|
||||||
|
colour_op modulate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sparkle/sparkle1
|
||||||
|
{
|
||||||
|
quota 40
|
||||||
|
material sparkle/sparkleMatl
|
||||||
|
particle_width 1
|
||||||
|
particle_height 1
|
||||||
|
cull_each false
|
||||||
|
renderer billboard
|
||||||
|
sorted false
|
||||||
|
local_space false
|
||||||
|
iteration_interval 0
|
||||||
|
nonvisible_update_timeout 0
|
||||||
|
billboard_type point
|
||||||
|
billboard_origin center
|
||||||
|
billboard_rotation_type vertex
|
||||||
|
common_up_vector 0 1 0
|
||||||
|
point_rendering false
|
||||||
|
accurate_facing false
|
||||||
|
|
||||||
|
emitter Point
|
||||||
|
{
|
||||||
|
angle 180
|
||||||
|
colour 0.3 0.3 0.3 .6
|
||||||
|
colour_range_start 0.25 0.25 0.25 1
|
||||||
|
colour_range_end 0.5 0.5 0.5 1
|
||||||
|
direction 0 -1 0
|
||||||
|
emission_rate 160
|
||||||
|
position 0 0 0
|
||||||
|
velocity_min 5
|
||||||
|
velocity_max 10
|
||||||
|
duration .2
|
||||||
|
time_to_live 1
|
||||||
|
}
|
||||||
|
|
||||||
|
affector Rotator
|
||||||
|
{
|
||||||
|
rotation_speed_range_end 360
|
||||||
|
rotation_range_start 0
|
||||||
|
rotation_range_end 360
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
material explosion/explosionMatl
|
||||||
|
{
|
||||||
|
technique
|
||||||
|
{
|
||||||
|
pass
|
||||||
|
{
|
||||||
|
lighting off
|
||||||
|
depth_write off
|
||||||
|
scene_blend add
|
||||||
|
|
||||||
|
texture_unit
|
||||||
|
{
|
||||||
|
texture explosion.png
|
||||||
|
colour_op modulate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
explosion/explosion1
|
||||||
|
{
|
||||||
|
quota 400
|
||||||
|
material explosion/explosionMatl
|
||||||
|
particle_width 5
|
||||||
|
particle_height 5
|
||||||
|
cull_each false
|
||||||
|
renderer billboard
|
||||||
|
sorted false
|
||||||
|
local_space false
|
||||||
|
iteration_interval 0
|
||||||
|
nonvisible_update_timeout 0
|
||||||
|
billboard_type point
|
||||||
|
billboard_origin center
|
||||||
|
billboard_rotation_type vertex
|
||||||
|
common_up_vector 0 1 0
|
||||||
|
point_rendering false
|
||||||
|
accurate_facing false
|
||||||
|
|
||||||
|
emitter Point
|
||||||
|
{
|
||||||
|
angle 180
|
||||||
|
colour 0.3 0.3 0.3 .6
|
||||||
|
colour_range_start 0.25 0.25 0.25 1
|
||||||
|
colour_range_end 0.5 0.5 0.5 1
|
||||||
|
direction 0 -1 0
|
||||||
|
emission_rate 20000
|
||||||
|
position 0 0 0
|
||||||
|
velocity 30
|
||||||
|
velocity_min 20
|
||||||
|
velocity_max 30
|
||||||
|
time_to_live 0.3
|
||||||
|
time_to_live_min 0.25
|
||||||
|
time_to_live_max 0.35
|
||||||
|
duration 1.2
|
||||||
|
duration_min 1.2
|
||||||
|
duration_max 1.2
|
||||||
|
repeat_delay 10000
|
||||||
|
repeat_delay_min 10000
|
||||||
|
repeat_delay_max 10000
|
||||||
|
}
|
||||||
|
|
||||||
|
affector DeflectorPlane
|
||||||
|
{
|
||||||
|
plane_point 0 0 0
|
||||||
|
plane_normal 0 1 0
|
||||||
|
bounce 0
|
||||||
|
}
|
||||||
|
|
||||||
|
affector DirectionRandomiser
|
||||||
|
{
|
||||||
|
randomness 0
|
||||||
|
scope 1
|
||||||
|
keep_velocity false
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
|
|
@ -20,18 +20,15 @@ namespace RNR
|
||||||
virtual void onChildAdded(RNR::Instance* childAdded);
|
virtual void onChildAdded(RNR::Instance* childAdded);
|
||||||
virtual void onChildRemoved(RNR::Instance* childRemoved);
|
virtual void onChildRemoved(RNR::Instance* childRemoved);
|
||||||
|
|
||||||
void buildLegacyGeom();
|
void buildGeom();
|
||||||
|
|
||||||
Camera* getCurrentCamera() const;
|
Camera* getCurrentCamera() const;
|
||||||
void setCurrentCamera(Camera *value);
|
void setCurrentCamera(Camera *value);
|
||||||
private:
|
private:
|
||||||
void buildGeomInstance(Instance* instance);
|
void buildGeomInstance(Instance* instance);
|
||||||
|
|
||||||
bool m_instancingEnabled;
|
bool m_geomDirty;
|
||||||
bool m_legacyDirty;
|
Ogre::StaticGeometry* m_geom;
|
||||||
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::SceneNode* m_worldspawn;
|
||||||
Ogre::Entity* m_partEntity;
|
Ogre::Entity* m_partEntity;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,55 +7,22 @@ namespace RNR
|
||||||
{
|
{
|
||||||
Workspace::Workspace() : ModelInstance()
|
Workspace::Workspace() : ModelInstance()
|
||||||
{
|
{
|
||||||
m_instancingEnabled = false;
|
|
||||||
setName("Workspace");
|
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_worldspawn = world->getOgreSceneManager()->getRootSceneNode()->createChildSceneNode();
|
||||||
m_legacyGeom = world->getOgreSceneManager()->createStaticGeometry("workspaceGeom");
|
m_geom = world->getOgreSceneManager()->createStaticGeometry("workspaceGeom");
|
||||||
m_partEntity = world->getOgreSceneManager()->createEntity("fonts/Cube.mesh");
|
m_partEntity = world->getOgreSceneManager()->createEntity("fonts/Cube.mesh");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspace::onChildAdded(Instance* childAdded)
|
void Workspace::onChildAdded(Instance* childAdded)
|
||||||
{
|
{
|
||||||
PartInstance* child_part = dynamic_cast<PartInstance*>(childAdded);
|
m_geomDirty = true;
|
||||||
if(child_part)
|
|
||||||
{
|
|
||||||
if(m_instancingEnabled)
|
|
||||||
{
|
|
||||||
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_legacyDirty = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspace::buildGeomInstance(Instance* instance)
|
void Workspace::buildGeomInstance(Instance* instance)
|
||||||
{
|
{
|
||||||
PartInstance* child_part = dynamic_cast<PartInstance*>(instance);
|
PartInstance* child_part = dynamic_cast<PartInstance*>(instance);
|
||||||
if(child_part)
|
if(child_part)
|
||||||
m_legacyGeom->addEntity(m_partEntity,
|
m_geom->addEntity(m_partEntity,
|
||||||
child_part->getCFrame().getPosition(),
|
child_part->getCFrame().getPosition(),
|
||||||
Ogre::Quaternion(child_part->getCFrame().getRotation()),
|
Ogre::Quaternion(child_part->getCFrame().getRotation()),
|
||||||
child_part->getSize());
|
child_part->getSize());
|
||||||
|
|
@ -63,44 +30,20 @@ namespace RNR
|
||||||
buildGeomInstance(child);
|
buildGeomInstance(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspace::buildLegacyGeom()
|
void Workspace::buildGeom()
|
||||||
{
|
{
|
||||||
if(!m_legacyDirty)
|
if(!m_geomDirty)
|
||||||
return;
|
return;
|
||||||
m_legacyGeom->reset();
|
m_geom->reset();
|
||||||
for(auto& child : *getChildren())
|
for(auto& child : *getChildren())
|
||||||
buildGeomInstance(child);
|
buildGeomInstance(child);
|
||||||
m_legacyGeom->build();
|
m_geom->build();
|
||||||
m_legacyDirty = false;
|
m_geomDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspace::onChildRemoved(Instance* childRemoved)
|
void Workspace::onChildRemoved(Instance* childRemoved)
|
||||||
{
|
{
|
||||||
PartInstance* child_part = dynamic_cast<PartInstance*>(childRemoved);
|
m_geomDirty = true;
|
||||||
if(m_instancingEnabled)
|
|
||||||
{
|
|
||||||
Ogre::InstancedEntity* child_ent = (Ogre::InstancedEntity*)childRemoved->getObject();
|
|
||||||
if(child_ent)
|
|
||||||
{
|
|
||||||
if(child_part)
|
|
||||||
{
|
|
||||||
child_ent->_getOwner()->removeInstancedEntity(child_ent);
|
|
||||||
child_part->setObject(NULL);
|
|
||||||
|
|
||||||
auto child_it = std::find(m_objects.begin(), m_objects.end(), child_ent);
|
|
||||||
if (child_it != m_objects.end())
|
|
||||||
{
|
|
||||||
m_objects.erase(child_it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delete child_ent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Camera* Workspace::getCurrentCamera() const
|
Camera* Workspace::getCurrentCamera() const
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,9 @@ namespace RNR
|
||||||
{
|
{
|
||||||
instance = m_workspace;
|
instance = m_workspace;
|
||||||
}
|
}
|
||||||
else if(class_attr.as_string() == std::string("Model")) // FIXME: Workspace has onChildAdded but not onDescendantAdded so adding parts to models wont let them render. Eventually this must be fixed
|
else if(class_attr.as_string() == std::string("Model"))
|
||||||
{
|
{
|
||||||
instance = parent;
|
instance = new ModelInstance();
|
||||||
skip = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -97,6 +96,6 @@ namespace RNR
|
||||||
|
|
||||||
void World::update()
|
void World::update()
|
||||||
{
|
{
|
||||||
m_workspace->buildLegacyGeom();
|
m_workspace->buildGeom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue