Revisão | 10 (tree) |
---|---|
Hora | 2016-04-24 12:14:02 |
Autor | mocchi_2012 |
・ マテリアル設定の調整(調整中)
・ カメラが勝手に動き出す現象の修正
@@ -15,4 +15,4 @@ | ||
15 | 15 | void Convert(const irr::core::line3df &li, ON_Line &lo){ |
16 | 16 | Convert(li.start, lo.from); |
17 | 17 | Convert(li.end, lo.to); |
18 | -} | |
\ No newline at end of file | ||
18 | +} |
@@ -54,7 +54,7 @@ | ||
54 | 54 | Material.DiffuseColor = irr::video::SColor(255,col.Red()/4,col.Green()/4,col.Blue()/4); |
55 | 55 | Material.SpecularColor = irr::video::SColor(255,255,255,255); |
56 | 56 | Material.EmissiveColor = irr::video::SColor(255,col.Red()/4,col.Green()/4,col.Blue()/4); |
57 | - Material.Shininess = 0.5f; | |
57 | + Material.Shininess = 0.2f; | |
58 | 58 | Material.FrontfaceCulling = false; |
59 | 59 | Material.BackfaceCulling = false; |
60 | 60 | Material.ZBuffer = true; |
@@ -122,6 +122,7 @@ | ||
122 | 122 | Box.reset(Vertices[0].Pos); |
123 | 123 | for (u32 i=1; i<Vertices.size(); ++i) |
124 | 124 | Box.addInternalPoint(Vertices[i].Pos); |
125 | + | |
125 | 126 | } |
126 | 127 | |
127 | 128 | CONObjSceneNode::CONObjSceneNode(const ONX_Model *model, const ON_Brep *brep, ON_3dmObjectAttributes &attr, ISceneNode* parent, ISceneManager* mgr, s32 id) |
@@ -141,11 +142,12 @@ | ||
141 | 142 | Material.DiffuseColor = irr::video::SColor(255-col.Alpha(),col.Red()*3/4,col.Green()*3/4,col.Blue()*3/4); |
142 | 143 | Material.SpecularColor = irr::video::SColor(255-col.Alpha(),255,255,255); |
143 | 144 | Material.EmissiveColor = irr::video::SColor(255-col.Alpha(),col.Red()/2,col.Green()/2,col.Blue()/2); |
144 | - Material.Shininess = 10.0f; | |
145 | + Material.Shininess = 0.2f; | |
145 | 146 | Material.FrontfaceCulling = false; |
146 | 147 | Material.BackfaceCulling = false; |
147 | 148 | Material.GouraudShading = true; |
148 | 149 | Material.ZBuffer = true; |
150 | + Material.NormalizeNormals = true; | |
149 | 151 | |
150 | 152 | // Material.ZBuffer = false; |
151 | 153 | // Material.MaterialType = EMT_TRANSPARENT_ADD_COLOR; |
@@ -298,10 +300,10 @@ | ||
298 | 300 | |
299 | 301 | ON_Color col = Selected ? ON_Color(255, 128, 0, 255) : GetColorFromAttr(ONAttribute, ONModel->m_layer_table); |
300 | 302 | |
301 | - Material.SpecularColor = irr::video::SColor(255-col.Alpha(),255,255,255); | |
302 | - Material.AmbientColor = irr::video::SColor(255-col.Alpha(),col.Red()*3/4,col.Green()*3/4,col.Blue()*3/4); | |
303 | - Material.DiffuseColor = irr::video::SColor(255-col.Alpha(),col.Red()*3/4,col.Green()*3/4,col.Blue()*3/4); | |
304 | - Material.EmissiveColor = irr::video::SColor(255-col.Alpha(),col.Red()/2,col.Green()/2,col.Blue()/2); | |
303 | + Material.SpecularColor = Selected ? irr::video::SColor(255-col.Alpha(), 0, 0, 0) : irr::video::SColor(255-col.Alpha(), 64, 64, 64); | |
304 | + Material.AmbientColor = irr::video::SColor(255-col.Alpha(), 64 + col.Red()*3/4, 64 + col.Green()*3/4, 64 + col.Blue()*3/4); | |
305 | + Material.DiffuseColor = irr::video::SColor(255-col.Alpha(), 64 + col.Red()*3/4, 64 + col.Green()*3/4, 64 + col.Blue()*3/4); | |
306 | + Material.EmissiveColor = irr::video::SColor(255-col.Alpha(), 64 + col.Red()/2, 64 + col.Green()/2, 64 + col.Blue()/2); | |
305 | 307 | |
306 | 308 | using namespace irr::core; |
307 | 309 | video::IVideoDriver* driver = SceneManager->getVideoDriver(); |
@@ -446,6 +446,10 @@ | ||
446 | 446 | |
447 | 447 | LightNodes[0]->getLightData().Direction = (TargetPos - EyePos).normalize(); |
448 | 448 | LightNodes[0]->getLightData().Position = EyePos; |
449 | +#if 0 | |
450 | + LightNodes[1]->getLightData().Direction = LightNodes[0]->getLightData().Direction * (-1.0f); | |
451 | + LightNodes[1]->getLightData().Position = TargetPos * 2.0 - EyePos; | |
452 | +#endif | |
449 | 453 | MouseState.Position.X = event.MouseInput.X; |
450 | 454 | MouseState.Position.Y = event.MouseInput.Y; |
451 | 455 | break; |
@@ -452,7 +456,8 @@ | ||
452 | 456 | } |
453 | 457 | |
454 | 458 | case EMIE_MOUSE_WHEEL:{ |
455 | - f32 r = (event.MouseInput.Wheel == -1.0f) ? 1.15f : 0.85f; | |
459 | + std::fprintf(stderr, "wheel %f\n", static_cast<double>(event.MouseInput.Wheel)); | |
460 | + f32 r = std::pow((event.MouseInput.Wheel < 0) ? 1.15f : 0.85f, static_cast<int>(std::abs(event.MouseInput.Wheel))); | |
456 | 461 | CameraWidth *= r; |
457 | 462 | CameraHeight *= r; |
458 | 463 | break; |
@@ -462,6 +467,8 @@ | ||
462 | 467 | // We won't use the wheel |
463 | 468 | break; |
464 | 469 | } |
470 | + } else if (event.EventType == irr::EET_KEY_INPUT_EVENT) { | |
471 | + | |
465 | 472 | } |
466 | 473 | return false; |
467 | 474 | } |
@@ -607,15 +614,18 @@ | ||
607 | 614 | */ |
608 | 615 | |
609 | 616 | // create light |
610 | - ILightSceneNode* lightNode = Smgr->addLightSceneNode(0, camera->getPosition(), | |
611 | - video::SColorf(1.0f, 1.0f, 1.0f, 1.0f), 1000.0f); | |
612 | - lightNode->getLightData().Direction.set(-1.0f, 0.0f, 0.0f); | |
613 | - lightNode->getLightData().Attenuation.set(1.0f, 0.0f, 0.0f); | |
614 | - lightNode->getLightData().AmbientColor.set(1.0f, 0.0f, 0.0f, 0.0f); | |
615 | - lightNode->getLightData().DiffuseColor.set(1.0f, 1.0f, 1.0f, 1.0f); | |
616 | - lightNode->getLightData().SpecularColor.set(1.0f, 1.0f, 1.0f, 1.0f); | |
617 | - lightNode->setLightType(irr::video::ELT_DIRECTIONAL); | |
618 | - LightNodes.push_back(lightNode); | |
617 | + for (int i = 0; i < 1; ++i){ | |
618 | + ILightSceneNode* lightNode = Smgr->addLightSceneNode(0, camera->getPosition(), | |
619 | + video::SColorf(1.0f, 1.0f, 1.0f, 1.0f), 1000.0f); | |
620 | + lightNode->getLightData().Direction.set(-1.0f, 0.0f, 0.0f); | |
621 | + lightNode->getLightData().Attenuation.set(1.0f, 0.0f, 0.0f); | |
622 | + lightNode->getLightData().AmbientColor.set(1.0f, 1.0f, 1.0f, 1.0f); | |
623 | + lightNode->getLightData().DiffuseColor.set(1.0f, 1.0f, 1.0f, 1.0f); | |
624 | + lightNode->getLightData().SpecularColor.set(1.0f, 0.5f, 0.5f, 0.5f); | |
625 | + lightNode->setLightType(irr::video::ELT_DIRECTIONAL); | |
626 | + lightNode->enableCastShadow(false); | |
627 | + LightNodes.push_back(lightNode); | |
628 | + } | |
619 | 629 | |
620 | 630 | #if 0 |
621 | 631 | ISceneNodeAnimator* anim = 0; |
@@ -641,20 +651,23 @@ | ||
641 | 651 | Now draw everything and finish. |
642 | 652 | */ |
643 | 653 | u32 frames=0; |
654 | + s32 PrevWindowWidth = 0, PrevWindowHeight = 0; | |
644 | 655 | while(Device->run()) |
645 | 656 | { |
657 | + // 新しい画面サイズの取得 | |
646 | 658 | rect<s32> vp = Driver->getViewPort(); |
647 | 659 | WindowWidth = vp.getWidth(), WindowHeight = vp.getHeight(); |
648 | 660 | |
649 | - { | |
661 | + if (PrevWindowWidth != WindowWidth || PrevWindowHeight != WindowHeight) { | |
650 | 662 | double cw = static_cast<double>(CameraWidth), ch = static_cast<double>(CameraHeight); |
651 | 663 | double diag2 = cw * cw + ch * ch; |
652 | 664 | double ww_wh = static_cast<double>(WindowWidth) / static_cast<double>(WindowHeight); |
653 | 665 | ch = std::sqrt(diag2 / (1 + ww_wh * ww_wh)); |
654 | - CameraHeight = static_cast<s32>(ch); | |
655 | - CameraWidth = static_cast<s32>(ch * ww_wh); | |
666 | + CameraHeight = static_cast<s32>(ch), CameraWidth = static_cast<s32>(ch * ww_wh); | |
667 | + PrevWindowWidth = WindowWidth, PrevWindowHeight = WindowHeight; | |
656 | 668 | } |
657 | 669 | |
670 | + // カメラの更新 | |
658 | 671 | // CameraWidth = static_cast<f32>(vp.getWidth()) / 10.0f, CameraHeight = static_cast<f32>(vp.getHeight()) / 10.0f; |
659 | 672 | { |
660 | 673 | matrix4 proj; |
@@ -667,13 +680,15 @@ | ||
667 | 680 | camera->setProjectionMatrix(proj, true); |
668 | 681 | #endif |
669 | 682 | } |
683 | + | |
684 | + // オブジェクトの描画 | |
670 | 685 | Driver->beginScene(true, true, SColor(0,30,30,30)); |
671 | 686 | |
672 | 687 | matrix4 mat = Driver->getTransform(ETS_PROJECTION); |
673 | - | |
674 | 688 | Smgr->drawAll(); |
675 | 689 | |
676 | 690 | Driver->endScene(); |
691 | + | |
677 | 692 | if (++frames==100) |
678 | 693 | { |
679 | 694 | core::stringw str = L"Irrlicht Engine ["; |