bring back Models in dm load; add model icon

This commit is contained in:
floralrainfall 2023-07-16 01:45:44 -04:00
parent c92d01b2c9
commit 27e43889e9
5 changed files with 152 additions and 76 deletions

View File

@ -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

View File

@ -20,18 +20,15 @@ namespace RNR
virtual void onChildAdded(RNR::Instance* childAdded);
virtual void onChildRemoved(RNR::Instance* childRemoved);
void buildLegacyGeom();
void buildGeom();
Camera* getCurrentCamera() const;
void setCurrentCamera(Camera *value);
private:
void buildGeomInstance(Instance* instance);
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;
bool m_geomDirty;
Ogre::StaticGeometry* m_geom;
Ogre::SceneNode* m_worldspawn;
Ogre::Entity* m_partEntity;

View File

@ -7,55 +7,22 @@ namespace RNR
{
Workspace::Workspace() : ModelInstance()
{
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_geom = world->getOgreSceneManager()->createStaticGeometry("workspaceGeom");
m_partEntity = world->getOgreSceneManager()->createEntity("fonts/Cube.mesh");
}
void Workspace::onChildAdded(Instance* childAdded)
{
PartInstance* child_part = dynamic_cast<PartInstance*>(childAdded);
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;
}
}
m_geomDirty = true;
}
void Workspace::buildGeomInstance(Instance* instance)
{
PartInstance* child_part = dynamic_cast<PartInstance*>(instance);
if(child_part)
m_legacyGeom->addEntity(m_partEntity,
m_geom->addEntity(m_partEntity,
child_part->getCFrame().getPosition(),
Ogre::Quaternion(child_part->getCFrame().getRotation()),
child_part->getSize());
@ -63,44 +30,20 @@ namespace RNR
buildGeomInstance(child);
}
void Workspace::buildLegacyGeom()
void Workspace::buildGeom()
{
if(!m_legacyDirty)
if(!m_geomDirty)
return;
m_legacyGeom->reset();
m_geom->reset();
for(auto& child : *getChildren())
buildGeomInstance(child);
m_legacyGeom->build();
m_legacyDirty = false;
m_geom->build();
m_geomDirty = false;
}
void Workspace::onChildRemoved(Instance* childRemoved)
{
PartInstance* child_part = dynamic_cast<PartInstance*>(childRemoved);
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
{
}
m_geomDirty = true;
}
Camera* Workspace::getCurrentCamera() const

View File

@ -39,10 +39,9 @@ namespace RNR
{
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;
skip = true;
instance = new ModelInstance();
}
else
{
@ -97,6 +96,6 @@ namespace RNR
void World::update()
{
m_workspace->buildLegacyGeom();
m_workspace->buildGeom();
}
}