fix corrupted mesh & fix instancing
This commit is contained in:
parent
4f0ebdffd0
commit
a203911dee
|
|
@ -1,5 +1,5 @@
|
|||
// generated by blender2ogre 0.8.3 on 2023-07-17 02:58:22
|
||||
material materials/BackMaterial {
|
||||
material BackMaterial {
|
||||
receive_shadows on
|
||||
technique {
|
||||
pass {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// generated by blender2ogre 0.8.3 on 2023-07-17 02:58:22
|
||||
material materials/BottomMaterial {
|
||||
material BottomMaterial {
|
||||
receive_shadows on
|
||||
technique {
|
||||
pass {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// generated by blender2ogre 0.8.3 on 2023-07-17 02:58:22
|
||||
material materials/FrontMaterial {
|
||||
material FrontMaterial {
|
||||
receive_shadows on
|
||||
technique {
|
||||
pass {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
// generated by blender2ogre 0.8.3 on 2023-07-20 04:32:47
|
||||
material InstancedMaterial {
|
||||
receive_shadows on
|
||||
technique {
|
||||
pass {
|
||||
diffuse 0.8 0.8 0.8 1.0
|
||||
specular 0.5 0.0 0 0 0
|
||||
rtshader_system {
|
||||
lighting_stage metal_roughness
|
||||
texturing_stage late_add_blend
|
||||
transform_stage instanced
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// generated by blender2ogre 0.8.3 on 2023-07-17 02:58:22
|
||||
material materials/LeftMaterial {
|
||||
material LeftMaterial {
|
||||
receive_shadows on
|
||||
technique {
|
||||
pass {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// generated by blender2ogre 0.8.3 on 2023-07-17 02:58:22
|
||||
material materials/RightMaterial {
|
||||
material RightMaterial {
|
||||
receive_shadows on
|
||||
technique {
|
||||
pass {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// generated by blender2ogre 0.8.3 on 2023-07-17 02:58:22
|
||||
material materials/TopMaterial {
|
||||
material TopMaterial {
|
||||
receive_shadows on
|
||||
technique {
|
||||
pass {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,26 @@
|
|||
material materials/PartInstanced/shadow_caster
|
||||
{
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
rtshader_system
|
||||
{
|
||||
lighting_stage gbuffer depth
|
||||
transform_stage instanced
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material materials/PartInstanced
|
||||
{
|
||||
receive_shadows on
|
||||
|
||||
technique
|
||||
{
|
||||
shadow_caster_material materials/PartInstanced/shadow_caster
|
||||
|
||||
pass
|
||||
{
|
||||
specular 1 1 1 1 12.5
|
||||
|
|
@ -17,6 +34,7 @@ material materials/PartInstanced
|
|||
rtshader_system
|
||||
{
|
||||
lighting_stage per_pixel
|
||||
transform_stage instanced
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- exporter: blender2ogre 0.8.3 -->
|
||||
<!-- export_time: Mon, 17 Jul 2023 06:58:22 +0000 -->
|
||||
<!-- previous_export_time: Mon, 17 Jul 2023 06:14:49 +0000 -->
|
||||
<!-- export_time: Thu, 20 Jul 2023 08:20:08 +0000 -->
|
||||
<!-- previous_export_time: Mon, 17 Jul 2023 06:58:22 +0000 -->
|
||||
<scene author="caesium" formatVersion="1.1" >
|
||||
<nodes >
|
||||
<node name="Cube" >
|
||||
|
|
@ -15,22 +15,22 @@
|
|||
</nodes>
|
||||
<externals >
|
||||
<item type="material" >
|
||||
<file name="../materials/TopMaterial.material" />
|
||||
<file name="TopMaterial.material" />
|
||||
</item>
|
||||
<item type="material" >
|
||||
<file name="../materials/BackMaterial.material" />
|
||||
<file name="BackMaterial.material" />
|
||||
</item>
|
||||
<item type="material" >
|
||||
<file name="../materials/BottomMaterial.material" />
|
||||
<file name="BottomMaterial.material" />
|
||||
</item>
|
||||
<item type="material" >
|
||||
<file name="../materials/FrontMaterial.material" />
|
||||
<file name="FrontMaterial.material" />
|
||||
</item>
|
||||
<item type="material" >
|
||||
<file name="../materials/LeftMaterial.material" />
|
||||
<file name="LeftMaterial.material" />
|
||||
</item>
|
||||
<item type="material" >
|
||||
<file name="../materials/RightMaterial.material" />
|
||||
<file name="RightMaterial.material" />
|
||||
</item>
|
||||
</externals>
|
||||
<environment >
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- exporter: blender2ogre 0.8.3 -->
|
||||
<!-- export_time: Thu, 20 Jul 2023 08:32:47 +0000 -->
|
||||
<!-- previous_export_time: Mon, 17 Jul 2023 06:58:22 +0000 -->
|
||||
<scene author="caesium" formatVersion="1.1" >
|
||||
<nodes >
|
||||
<node name="Cube_Instanced" >
|
||||
<position x="0.000000" y="0.000000" z="0.000000" />
|
||||
<rotation qw="1.000000" qx="0.000000" qy="0.000000" qz="0.000000" />
|
||||
<scale x="1.000000" y="1.000000" z="1.000000" />
|
||||
<entity meshFile="Cube_Instanced.mesh" name="Cube_Instanced" >
|
||||
<userData />
|
||||
</entity>
|
||||
</node>
|
||||
</nodes>
|
||||
<externals >
|
||||
<item type="material" >
|
||||
<file name="InstancedMaterial.material" />
|
||||
</item>
|
||||
</externals>
|
||||
<environment >
|
||||
<colourBackground b="0.050876" g="0.050876" r="0.050876" />
|
||||
</environment>
|
||||
</scene>
|
||||
|
|
@ -32,7 +32,7 @@ int main(int argc, char** argv)
|
|||
|
||||
while (window.isVisible())
|
||||
{
|
||||
window.statusBar()->showMessage(QString::asprintf("Dt=%f, Rt=%f, FPS=%f", window.ogreWidget->delta, window.ogreWidget->render_time, 1 / window.ogreWidget->delta));
|
||||
window.statusBar()->showMessage(QString::asprintf("Dt=%f, Rt=%f, Pt=%f, FPS=%f, pFPS=%f", window.ogreWidget->delta, window.ogreWidget->render_time, window.ogreWidget->world->getPhysicsTime(), 1 / window.ogreWidget->delta, 1 / window.ogreWidget->world->getLastPhysicsDelta()));
|
||||
app.processEvents();
|
||||
window.ogreWidget->render();
|
||||
world->update();
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace RNR
|
|||
m_reflectance = 0.0;
|
||||
|
||||
setNode(world->getOgreSceneManager()->getRootSceneNode()->createChildSceneNode());
|
||||
setObject(world->getOgreSceneManager()->createEntity("meshes/cube.mesh"));
|
||||
setObject(world->getOgreSceneManager()->createEntity("meshes/Cube.mesh"));
|
||||
getNode()->attachObject(getObject());
|
||||
|
||||
updateMatrix();
|
||||
|
|
@ -24,9 +24,23 @@ namespace RNR
|
|||
m_matrix = m_cframe.getMatrix();
|
||||
m_position = m_cframe.getPosition();
|
||||
|
||||
getNode()->setOrientation(Ogre::Quaternion(m_cframe.getRotation()));
|
||||
getNode()->setPosition(m_position);
|
||||
getNode()->setScale(m_size);
|
||||
if(getNode())
|
||||
{
|
||||
getNode()->setOrientation(Ogre::Quaternion(m_cframe.getRotation()));
|
||||
getNode()->setPosition(m_position);
|
||||
getNode()->setScale(m_size);
|
||||
}
|
||||
|
||||
if(getObject() && dynamic_cast<Ogre::InstancedEntity*>(getObject()))
|
||||
{
|
||||
Ogre::InstancedEntity* object = (Ogre::InstancedEntity*)getObject();
|
||||
|
||||
object->setOrientation(Ogre::Quaternion(m_cframe.getRotation()));
|
||||
object->setPosition(m_position);
|
||||
object->setScale(m_size);
|
||||
|
||||
object->updateTransforms();
|
||||
}
|
||||
|
||||
Ogre::Entity* entity = (Ogre::Entity*)getObject();
|
||||
for(auto& subentity : entity->getSubEntities())
|
||||
|
|
|
|||
|
|
@ -8,14 +8,14 @@ namespace RNR
|
|||
Workspace::Workspace() : ModelInstance()
|
||||
{
|
||||
setName("Workspace");
|
||||
m_batchMode = BATCH_STATIC_GEOMETRY;
|
||||
m_batchMode = BATCH_INSTANCED;
|
||||
|
||||
m_worldspawn = world->getOgreSceneManager()->getRootSceneNode()->createChildSceneNode();
|
||||
|
||||
|
||||
switch(m_batchMode)
|
||||
{
|
||||
case BATCH_INSTANCED:
|
||||
m_instanceManager = world->getOgreSceneManager()->createInstanceManager("workspaceInstanceManager", "fonts/Cube.mesh", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::InstanceManager::InstancingTechnique::HWInstancingBasic, 255);
|
||||
m_instanceManager = world->getOgreSceneManager()->createInstanceManager("workspaceInstanceManager", "meshes/Cube_Instanced.mesh", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::InstanceManager::InstancingTechnique::HWInstancingBasic, 255);
|
||||
break;
|
||||
case BATCH_STATIC_GEOMETRY:
|
||||
m_geom = world->getOgreSceneManager()->createStaticGeometry("workspaceGeom");
|
||||
|
|
@ -37,11 +37,13 @@ namespace RNR
|
|||
{
|
||||
case BATCH_INSTANCED:
|
||||
{
|
||||
Ogre::Entity* childEntity = (Ogre::Entity*)childAdded->getObject();
|
||||
Ogre::InstancedEntity* replica = m_instanceManager->createInstancedEntity("materials/PartInstanced");
|
||||
replica->setPosition(part->getPosition());
|
||||
Ogre::InstancedEntity* replica = m_instanceManager->createInstancedEntity(BrickColor::material(part->getBrickColor())->getName());
|
||||
part->updateMatrix();
|
||||
replica->setPosition(part->getCFrame().getPosition());
|
||||
replica->setOrientation(part->getCFrame().getRotation());
|
||||
replica->setScale(part->getSize());
|
||||
replica->setCastShadows(true);
|
||||
m_worldspawn->attachObject(replica);
|
||||
childAdded->setObject(replica);
|
||||
child_node->setVisible(false);
|
||||
}
|
||||
|
|
@ -55,6 +57,7 @@ namespace RNR
|
|||
m_geomDirty = true;
|
||||
break;
|
||||
case BATCH_DONT:
|
||||
child_node->setVisible(true);
|
||||
break;
|
||||
}
|
||||
world->registerPhysicsPart(part);
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ namespace RNR
|
|||
m_runPhysics = true;
|
||||
m_physicsTimer = new Ogre::Timer();
|
||||
m_physicsThread = std::thread(physicsThread, this);
|
||||
m_physicsTime = 0.0;
|
||||
|
||||
m_tmb = new TopMenuBar(this);
|
||||
|
||||
|
|
@ -168,16 +169,20 @@ namespace RNR
|
|||
m_inputManager->frame();
|
||||
m_tmb->frame();
|
||||
m_lastDelta = timestep;
|
||||
physicsIterateLock.lock();
|
||||
for(int j = m_dynamicsWorld->getNumCollisionObjects() - 1; j >= 0; j--)
|
||||
if(m_runService && m_runService->getRunning() && !m_runService->getPaused())
|
||||
{
|
||||
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[j];
|
||||
if(!obj->isActive())
|
||||
continue;
|
||||
PartInstance* part = (PartInstance*)obj->getUserPointer();
|
||||
part->updateMatrix();
|
||||
physicsIterateLock.lock();
|
||||
for(int j = m_dynamicsWorld->getNumCollisionObjects() - 1; j >= 0; j--)
|
||||
{
|
||||
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[j];
|
||||
if(!obj->isActive())
|
||||
continue;
|
||||
PartInstance* part = (PartInstance*)obj->getUserPointer();
|
||||
part->updateMatrix();
|
||||
}
|
||||
update();
|
||||
physicsIterateLock.unlock();
|
||||
}
|
||||
physicsIterateLock.unlock();
|
||||
}
|
||||
|
||||
void World::preStep()
|
||||
|
|
@ -243,7 +248,7 @@ namespace RNR
|
|||
btVector3 localInertia = btVector3(0,0,0);
|
||||
if(mass)
|
||||
partShape->calculateLocalInertia(mass, localInertia);
|
||||
|
||||
|
||||
btDefaultMotionState* partMotionState = new btDefaultMotionState(partTransform);
|
||||
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, partMotionState, partShape, localInertia);
|
||||
btRigidBody* body = new btRigidBody(rbInfo);
|
||||
|
|
|
|||
Loading…
Reference in New Issue