• R/O
  • SSH
  • HTTPS

opennurbsviewer: Commit


Commit MetaInfo

Revisão12 (tree)
Hora2016-04-25 04:12:52
Autormocchi_2012

Mensagem de Log

・STL対応
・色をONX_Modelから取得するように変更

Mudança Sumário

Diff

--- trunk/src/OpenNurbsViewer/CONObjSceneNode.cpp (revision 11)
+++ trunk/src/OpenNurbsViewer/CONObjSceneNode.cpp (revision 12)
@@ -49,8 +49,6 @@
4949 Selected = false;
5050 setAutomaticCulling(EAC_OFF);
5151
52- ON_Color col = GetColorFromAttr(attr, model->m_layer_table);
53-
5452 // 色は選択・非選択で変えたいため、 render 関数で設定する。
5553 Material.Wireframe = false;
5654 Material.Lighting = true;
@@ -88,7 +86,7 @@
8886 const ON_3fPointArray &pts = mesh->m_V;
8987 const ON_3fVectorArray &nrms = mesh->m_N;
9088 for (s32 i = 0; i < pts.Count(); ++i){
91- ON_Color col = (mesh->m_C.Count() > i) ? mesh->m_C[i] : ON_Color(0,0,0,0);
89+ ON_Color col = (mesh->m_C.Count() > i) ? mesh->m_C[i] : attr.m_color;
9290 SColor irrcol(255-col.Alpha(), col.Red(), col.Green(), col.Blue());
9391 vector3df nrm(nrms[i].x, nrms[i].y, nrms[i].z);
9492 if (upv.getLengthSQ() > 0 && nrm.dotProduct(upv) < 0) nrm.invert();
@@ -339,7 +337,7 @@
339337 if (!(*show_flag)) return;
340338
341339 // ON_Color col = Selected ? ON_Color(255, 128, 0, 255) : GetColorFromAttr(ONAttribute, ONModel->m_layer_table);
342- ON_Color col = Selected ? ON_Color(255, 128, 0, 255) : ON_Color(0, 0, 0);
340+ ON_Color col = Selected ? ON_Color(255, 128, 0, 255) : ONAttribute.m_color;
343341
344342 Material.SpecularColor = Selected ? irr::video::SColor(255-col.Alpha(), 0, 0, 0) : irr::video::SColor(255-col.Alpha(), 128, 128, 128);
345343 Material.AmbientColor = irr::video::SColor(255-col.Alpha(), 64 + col.Red()*3/4, 64 + col.Green()*3/4, 64 + col.Blue()*3/4);
@@ -381,7 +379,7 @@
381379 WVertices.reallocate(Vertices.size());
382380 for (u32 i = 0; i < Vertices.size(); ++i){
383381 WVertices.push_back(Vertices[i]);
384- WVertices.getLast().Pos += Vertices[i].Normal * ((j == 0) ? 0.125f : -0.125f);
382+ WVertices.getLast().Pos += Vertices[i].Normal * ((j == 0) ? 0.03125f : -0.03125f);
385383 }
386384 }
387385 driver->drawVertexPrimitiveList(&WVertices[0], WVertices.size(), pWIndices, cntWIndices, video::EVT_STANDARD, type, video::EIT_32BIT);
--- trunk/src/OpenNurbsViewer/App.cpp (revision 11)
+++ trunk/src/OpenNurbsViewer/App.cpp (revision 12)
@@ -544,10 +544,10 @@
544544 void CreateShowHideList(){
545545 using namespace irr::gui;
546546 GUIEnv = Device->getGUIEnvironment();
547- IGUITabControl* tabctrl = GUIEnv->addTabControl(core::rect<int>(0,10,160,400), 0, true, true);
547+ IGUITabControl* tabctrl = GUIEnv->addTabControl(core::rect<int>(0,10,160,600), 0, true, true);
548548 IGUITab* showhideTab = tabctrl->addTab(L"Show/Hide");
549549 int idx = 1;
550- int wy = 5, height = 25;
550+ int wy = 5, height = 20;
551551 for (list<Group>::ConstIterator iter = groups.begin(); iter != groups.end(); ++iter, ++idx, wy += height){
552552 const Group &gr = *iter;
553553 GUIEnv->addCheckBox(gr.showflag, core::rect<int>( 5, wy, 140, wy + height), showhideTab, idx, ON_wString(gr.name));
@@ -614,10 +614,10 @@
614614
615615 // 光源設定
616616 double diag = bbox.getExtent().getLength();
617- vector3df dir[3] = {vector3df(1.0f, 0.8f, -0.5f), vector3df(-1.0f, -0.5f, 0.0f), vector3df(-1.0f, -0.8f, 0.5f)};
617+ vector3df lightpos = bbox.MaxEdge * 1.5 - bbox.getCenter();
618618 for (int i = 0; i < 1; ++i){
619619 ILightSceneNode* lightNode =
620- Smgr->addLightSceneNode(0, bbox.MaxEdge, video::SColorf(0.5f, 0.5f, 0.5f, 1.0f), 0.01f);
620+ Smgr->addLightSceneNode(0, lightpos, video::SColorf(0.5f, 0.5f, 0.5f, 1.0f), 0.01f);
621621 lightNode->getLightData().Attenuation.set(1.0f/diag, 1.0f/diag, 0);
622622 lightNode->getLightData().DiffuseColor.set(0.0f, 0.0f, 0.0f);
623623 lightNode->getLightData().AmbientColor.set(0.5f, 0.5f, 0.5f);
@@ -652,13 +652,6 @@
652652 camera->setTarget(TargetPos);
653653 camera->setPosition(EyePos);
654654 camera->setUpVector(UpVector);
655-
656- /*
657- The second special effect is very basic, I bet you saw it already in
658- some Irrlicht Engine demos: A transparent billboard combined with a
659- dynamic light. We simply create a light scene node, let it fly around,
660- and to make it look more cool, we attach a billboard scene node to it.
661- */
662655 }
663656
664657 void Run(){
@@ -756,23 +749,60 @@
756749 if (argc >= 2){
757750 for (int i = 1; i < argc; ++i){
758751 ONX_Model model;
759- model.Read(argv[i]);
760- ON_String name = argv[i];
752+ ON_String filename = argv[i];
753+ ON_String ext;
754+ int idx = filename.ReverseFind('.');
755+ if (idx >= 0) ext = filename.Mid(idx);
756+
757+ if (ext.CompareNoCase(".3dm") == 0 || ext.CompareNoCase(".stl") == 0){
758+ ON_String name = argv[i];
761759
762- // パスからディレクトリを除外
763- name.Replace("\\", "/");
764- int idx = name.ReverseFind('/');
765- if (idx < 0) idx = 0;
766- else ++idx;
767- name = name.Mid(idx);
760+ // パスからディレクトリを除外
761+ name.Replace("\\", "/");
762+ int idx = name.ReverseFind('/');
763+ if (idx < 0) idx = 0;
764+ else ++idx;
765+ name = name.Mid(idx);
768766
769- // ファイル名から拡張子を除外
770- idx = name.ReverseFind('.');
771- if (idx >= 0) name = name.Left(idx-1);
767+ // ファイル名から拡張子を除外
768+ name.SetLength(name.Length()-ext.Length());
772769
773- app.addSceneNodes(model, name);
770+ idx = name.ReverseFind('.');
771+ if (idx >= 0) name = name.Left(idx-1);
774772
775- std::fprintf(stderr, "%s loaded\n", name.Array());
773+ if (ext.CompareNoCase(".3dm") == 0){
774+ model.Read(filename);
775+ }else{
776+ ON_Mesh mesh, *pmesh;
777+ pmesh = mesh.Duplicate();
778+ ONX_Model_Object &obj = model.m_object_table.AppendNew();
779+ obj.m_object = pmesh;
780+ obj.m_bDeleteObject = true;
781+
782+ FILE *fp = std::fopen(filename, "rb");
783+ if (!fp) continue;
784+ do{
785+ if (std::fseek(fp, 80, SEEK_SET)) break;
786+ u32 num_triangles;
787+ if (std::fread(&num_triangles, 4, 1, fp) != 1) continue;
788+ for (u32 i = 0, i3 = 0; i < num_triangles; ++i, i3 += 3){
789+ f32 v[12];
790+ if (std::fread(v, 4, 12, fp) != 12) break;
791+ pmesh->m_FN.Append(ON_3fVector(v));
792+ pmesh->SetVertex(i3, ON_3fPoint(v+3));
793+ pmesh->SetVertex(i3+1, ON_3fPoint(v+6));
794+ pmesh->SetVertex(i3+2, ON_3fPoint(v+9));
795+ pmesh->SetTriangle(i, i3, i3+1, i3+2);
796+ if (std::fseek(fp, 2, SEEK_CUR)) break;
797+ }
798+ }while(0);
799+ std::fclose(fp);
800+ pmesh->CombineIdenticalVertices(false, true);
801+ }
802+ app.addSceneNodes(model, name);
803+
804+ std::fprintf(stderr, "%s(%s) loaded\n", name.Array(), ext.Array());
805+ }
776806 }
777807 }else{
778808 return 0;
Show on old repository browser