Skip to content

Commit

Permalink
more object info text, mats, lods etc
Browse files Browse the repository at this point in the history
  • Loading branch information
cryham committed Jan 27, 2024
1 parent d91a45f commit 362ef92
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
4 changes: 2 additions & 2 deletions data/gui/Editor.layout
Original file line number Diff line number Diff line change
Expand Up @@ -3253,9 +3253,9 @@
<Property key="Colour" value="0.9 0.9 0.7"/>
</Widget>

<Widget type="TextBox" skin="TextBox" position="530 40 220 100" name="ObjInfo">
<Widget type="TextBox" skin="TextBox" position="530 40 220 500" name="ObjInfo">
<Property key="FontName" value="font.small"/>
<Property key="TextColour" value="0.8 0.8 0.76"/>
<Property key="TextColour" value="0.84 0.84 0.86"/>
</Widget>

</Widget>
Expand Down
32 changes: 31 additions & 1 deletion src/common/PreviewScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <OgreSceneManager.h>
#include <OgreSceneNode.h>
#include <OgreItem.h>
#include <OgreSubMesh2.h>
using namespace Ogre;


Expand Down Expand Up @@ -108,7 +109,36 @@ bool PreviewScene::Load(Ogre::String mesh)

try
{ item = mgr->createItem(mesh);
mat = item->getSubItem(0)->getDatablockOrMaterialName(); // for info

// txt for info --------
sInfo.clear();
int all = item->getNumSubItems(), all_tris = 0, lods = 0;
for (int i=0; i < all; ++i)
{
auto* si = item->getSubItem(i);
if (!i) lods = si->getSubMesh()->mVao[0].size(); // once
int tris = si->getSubMesh()->mVao[0][0]->getPrimitiveCount();
sInfo += " "+si->getSubMesh()->getMaterialName()+" "+fToStr(tris /1000.f,1,4)+" k "+"\n";
all_tris += tris;
}
sTotal = ": "+toStr(all)+" Tris: "+fToStr(all_tris /1000.f,0,2)+" k" + " LODs: "+toStr(lods);
// lods --------
sLods.clear();
for (int lod=0; lod < lods; ++lod)
{
int lod_tris = 0;
for (int i=0; i < all; ++i)
{
auto* si = item->getSubItem(i);
int lods = si->getSubMesh()->mVao[0].size();
if (lod < lods)
{ int tris = si->getSubMesh()->mVao[0][lod]->getPrimitiveCount();
lod_tris += tris;
} }
sLods += " "+toStr(lod+1)+" "+fToStr(lod_tris /1000.f,1,4)+" k "+
fToStr(100.f * lod_tris / all_tris,1,4)+"%\n";
}

node = mgr->getRootSceneNode()->createChildSceneNode();
node->attachObject(item);
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/PreviewScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PreviewScene
float yaw =0.f; // rot angle

Ogre::Vector3 dim{1,1,1}; // after load
Ogre::String mat;
Ogre::String sInfo, sTotal, sLods;

Ogre::SceneManager* mgr = 0;
Ogre::Camera* cam = 0;
Expand Down
16 changes: 7 additions & 9 deletions src/editor/Gui_Events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,18 +307,16 @@ void CGui::updVegetInfo()
vb = d * svLTrMaxSc.getF();
float wa = std::max(va.x, va.z),
wb = std::max(vb.x, vb.z);
txVHmin->setCaption(fToStr(va.y, 1,4));
txVHmax->setCaption(fToStr(vb.y, 1,4));
txVWmin->setCaption(fToStr(wa, 1,4));
txVWmax->setCaption(fToStr(wb, 1,4));
txVHmin->setCaption(fToStr(va.y, 1,4)); txVWmin->setCaption(fToStr(wa, 1,4));
txVHmax->setCaption(fToStr(vb.y, 1,4)); txVWmax->setCaption(fToStr(wb, 1,4));

// 📦🏢 Objects tab
UString s =
TR("#{GrMaterial}") + ":\n" + app->prvScene.mat +
TR("\n\n#{Size}:") +
"\n x " + fToStr(d.x, 1,4)+
"\n y " + fToStr(d.y, 1,4)+
"\n z " + fToStr(d.z, 1,4);
TR("#60E060 #{Size} [#{UnitM}]: #D0E0F0 \n") +
" x " + fToStr(d.x, 1,4)+"\n y " + fToStr(d.y, 1,4)+"\n z " + fToStr(d.z, 1,4) +"\n\n"+
TR("#E0E060 #{RplAll}")+ app->prvScene.sTotal +"\n\n"+
TR("#60E060 #{GrMaterial} : Tris #D0E0F0 \n") + app->prvScene.sInfo +"\n"+
"#E08030 LOD Tris #A0A0D0\n"+ app->prvScene.sLods;
objInfo->setCaption(s);
}

Expand Down

0 comments on commit 362ef92

Please sign in to comment.