1 // =============================================================================
2 // PROJECT CHRONO - http://projectchrono.org
3 //
4 // Copyright (c) 2014 projectchrono.org
5 // All rights reserved.
6 //
7 // Use of this source code is governed by a BSD-style license that can be found
8 // in the LICENSE file at the top level of the distribution and at
9 // http://projectchrono.org/license-chrono.txt.
10 //
11 // =============================================================================
12
13 #include "chrono_irrlicht/ChIrrUtils.h"
14
15 namespace chrono {
16 namespace irrlicht {
17 namespace tools {
18
19 using namespace irr;
20
add_typical_Logo(IrrlichtDevice * device,const std::string & mlogofilename)21 void add_typical_Logo(IrrlichtDevice* device, const std::string& mlogofilename) {
22 device->getGUIEnvironment()->addImage(device->getVideoDriver()->getTexture(mlogofilename.c_str()),
23 irr::core::position2d<s32>(10, 10));
24 }
25
add_typical_Lights(IrrlichtDevice * device,irr::core::vector3df pos1,irr::core::vector3df pos2,double rad1,double rad2,irr::video::SColorf col1,irr::video::SColorf col2)26 void add_typical_Lights(IrrlichtDevice* device,
27 irr::core::vector3df pos1,
28 irr::core::vector3df pos2,
29 double rad1,
30 double rad2,
31 irr::video::SColorf col1,
32 irr::video::SColorf col2) {
33 // create lights
34 /*scene::ILightSceneNode* mlight1 = */
35 device->getSceneManager()->addLightSceneNode(0, pos1, col1, (f32)rad1);
36 scene::ILightSceneNode* mlight2 = device->getSceneManager()->addLightSceneNode(0, pos2, col2, (f32)rad2);
37
38 mlight2->enableCastShadow(false);
39 }
40
add_typical_Sky(IrrlichtDevice * device,bool y_up,const std::string & mtexturedir)41 void add_typical_Sky(IrrlichtDevice* device, bool y_up, const std::string& mtexturedir) {
42 // create sky box
43 std::string str_lf = mtexturedir + "sky_lf.jpg";
44 std::string str_up = mtexturedir + "sky_up.jpg";
45 std::string str_dn = mtexturedir + "sky_dn.jpg";
46
47 irr::video::ITexture* map_skybox_side = device->getVideoDriver()->getTexture(str_lf.c_str());
48
49 auto mbox = device->getSceneManager()->addSkyBoxSceneNode(
50 device->getVideoDriver()->getTexture(str_up.c_str()), device->getVideoDriver()->getTexture(str_dn.c_str()),
51 map_skybox_side, map_skybox_side, map_skybox_side, map_skybox_side);
52
53 if (!y_up)
54 mbox->setRotation(irr::core::vector3df(90, 0, 0));
55 }
56
add_typical_Camera(IrrlichtDevice * device,irr::core::vector3df pos,irr::core::vector3df targ,bool y_up)57 void add_typical_Camera(IrrlichtDevice* device, irr::core::vector3df pos, irr::core::vector3df targ, bool y_up) {
58 // create and init camera
59 RTSCamera* camera = new RTSCamera(device, device->getSceneManager()->getRootSceneNode(), device->getSceneManager(),
60 -1, -160.0f, 1.0f, 0.003f);
61
62 // camera->bindTargetAndRotation(true);
63 if (!y_up)
64 camera->setZUp();
65 camera->setPosition(pos);
66 camera->setTarget(targ);
67
68 camera->setNearValue(0.1f);
69 camera->setMinZoom(0.6f);
70 }
71
72 } // end namespace tools
73 } // end namespace irrlicht
74 } // end namespace chrono
75