本文整理汇总了C++中ISceneManager::addLightSceneNode方法的典型用法代码示例。如果您正苦于以下问题:C++ ISceneManager::addLightSceneNode方法的具体用法?C++ ISceneManager::addLightSceneNode怎么用?C++ ISceneManager::addLightSceneNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISceneManager
的用法示例。
在下文中一共展示了ISceneManager::addLightSceneNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool GLscene::init(int w, int h)
{
m_device =
createDevice( video::EDT_OPENGL, dimension2d<u32>(w, h), 32,
false, false, false, 0);
if (!m_device) return false;
m_device->setWindowCaption(L"Irrlicht");
ISceneManager* smgr = m_device->getSceneManager();
smgr->addLightSceneNode(0, vector3df(18,-12,6), SColorf(1.0, 1.0, 1.0), 30.0f);
smgr->addLightSceneNode(0, vector3df(-18,12,6), SColorf(1.0, 1.0, 1.0), 30.0f);
m_cnode = smgr->addCameraSceneNode();
#if 1
m_cnode->setTarget(vector3df(0,0,0.7));
m_cnode->setUpVector(vector3df(0,0,1));
#endif
m_receiver = new MyEventReceiver(m_cnode, 3);
m_device->setEventReceiver(m_receiver);
m_defaultCamera = new GLcamera(m_cnode);
setCamera(m_defaultCamera);
return true;
}
示例2: LoadScene
void Editor::LoadScene()
{
IVideoDriver *driver = device->getVideoDriver();
ISceneManager *smgr = device->getSceneManager();
// Calculate Projection Matrix
matrix4 projMat;
irr::f32 orth_w = (float)(driver->getScreenSize().Width - 256) / (float)driver->getScreenSize().Height;
orth_w = 3 * orth_w;
projMat.buildProjectionMatrixOrthoLH(orth_w, 3, 1, 100);
// Create target
target = smgr->addEmptySceneNode(0, 200);
target->setPosition(vector3df(0, 0, 0));
// Add rotational camera
pivot = smgr->addEmptySceneNode(target, 199);
camera[0] = smgr->addCameraSceneNode(NULL, vector3df(0, 0, -2), vector3df(0, 0, 0));
camera[0]->setParent(pivot);
pivot->setRotation(vector3df(25, -45, 0));
// Add Topdown camera
camera[1] = smgr->addCameraSceneNode(target, vector3df(0, 2, -0.01), vector3df(0, 0, 0));
camera[1]->setProjectionMatrix(projMat, true);
// Add front camera
camera[2] = smgr->addCameraSceneNode(target, vector3df(0, 0, -5), vector3df(0, 0, 0));
camera[2]->setProjectionMatrix(projMat, true);
// Add side camera
camera[3] = smgr->addCameraSceneNode(target, vector3df(5, 0, 0), vector3df(0, 0, 0));
camera[3]->setProjectionMatrix(projMat, true);
// Add Light
ILightSceneNode* light = smgr->addLightSceneNode(target, vector3df(25, 50, 0));
light->setLightType(ELT_POINT);
light->setRadius(2000);
// Add Plane
IMeshSceneNode* plane = smgr->addCubeSceneNode(1, 0, -1,
vector3df(0.5, -5.5, 0.5), vector3df(0, 0, 0),
vector3df(10, 10, 10));
plane->setMaterialTexture(0, driver->getTexture("media/texture_terrain.png"));
plane->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
plane->getMaterial(0).getTextureMatrix(0).setTextureScale(10, 10);
// Add sky box
scene::IMeshSceneNode* skybox = smgr->addCubeSceneNode(50);
skybox->setMaterialTexture(0, driver->getTexture("media/sky.jpg"));
skybox->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
skybox->setMaterialFlag(video::EMF_LIGHTING, false);
smgr->getMeshManipulator()->flipSurfaces(skybox->getMesh());
state->plane_tri = smgr->createOctreeTriangleSelector(skybox->getMesh(), skybox);
}
示例3: main
int main()
{
MyEventReceiver receiver;
IrrlichtDevice* device = createDevice(video::EDT_OPENGL,
core::dimension2d<u32>(640, 480), 16, false, false, false, &receiver);
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
smgr->addLightSceneNode(0,vector3df(50,50,50));
ICameraSceneNode *camera = smgr->addCameraSceneNode();
IMeshSceneNode *node = smgr->addCubeSceneNode();
node->setPosition(vector3df(0,75,0));
camera->setTarget(vector3df(0,1,0));
smgr->getMeshManipulator()->setVertexColors(node->getMesh(), SColor(0,0,255,255));
smgr->addLightSceneNode();
while(device->run()){
if(receiver.IsKeyDown(irr::KEY_LEFT)){
node->setPosition(node->getPosition()+vector3df(0,0,-0.1));
}
else if(receiver.IsKeyDown(irr::KEY_RIGHT)){
node->setPosition(node->getPosition()+vector3df(0,0,0.1));
}
else if(receiver.IsKeyDown(irr::KEY_SPACE)){
}
driver->beginScene(true, true, SColor(123,100,100,100));
smgr->drawAll();
driver->endScene();
}
return 0;
}
示例4: main
int main()
{
IrrlichtDevice *device =
createDevice( video::EDT_BURNINGSVIDEO, dimension2d<u32>(640, 480), 16,
false, false, false, 0);
if (!device) return 1;
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
// Add Light to the Scene
ILightSceneNode *light = smgr->addLightSceneNode( 0, vector3df() );
light->getLightData().AmbientColor = SColorf( 0.2f, 0.2f, 0.2f );
light->getLightData().SpecularColor = SColorf( 1.0f, 1.0f, 1.0f );
light->getLightData().DiffuseColor = SColorf( 0.8f, 0.8f, 0.8f );
light->setLightType( ELT_DIRECTIONAL );
light->setRotation( vector3df( 45.0f, 45.0f, 0.0f ));
smgr->setAmbientLight( SColorf( 0.2f, 0.2f, 0.2f ));
// scene::IMeshSceneNode* node = smgr->addCubeSceneNode(20);
// if (node){
// node->setMaterialFlag(EMF_LIGHTING, false);
// smgr->getMeshManipulator()->setVertexColors(node->getMesh(),SColor(250,250,0,0));
// node->setPosition(core::vector3df(0,0,0) );
// node->setVisible(false);
// }
smgr->addCameraSceneNode(0, vector3df(0,0,-50), vector3df(0,0,0));
while(device->run())
{
core::aabbox3df box;
box.MinEdge.set(vector3df(-100,-100,-100));
box.MaxEdge.set(vector3df(100,100,100));
driver->beginScene(true, true, SColor(250, 100, 150, 150));
smgr->drawAll();
guienv->drawAll();
criaGizmosBicos(driver);
// criaRegiaAnalise(box, driver);
driver->endScene();
}
device->drop();
return 0;
}
示例5: main
/* Ohjelman aloituspiste */
int main( int argc, char* argv[]) {
//Alustetaan irrlicht
device = createDevice(EDT_BURNINGSVIDEO, dimension2d<u32>(1024, 768), 16,
false, false, false, 0);
//ikkunan otsikko
device->setWindowCaption(L"Dungeon.");
//videoajuri ja scenemanager
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
//lisätään kamera
smgr->addCameraSceneNode(0, vector3df(10,30,-5), vector3df(0,0,0));
//tilekartta
Tile map = Tile(smgr);
//lisätään valoa
ILightSceneNode* light1 = smgr->addLightSceneNode(0, core::vector3df(0,5,0), video::SColorf(0.5f, 1.0f, 0.5f, 0.0f), 800.0f);
/* Luodaan uusi gridi ja alustetaan se */
Generator grid;
grid.initialize();
grid.generateDungeon();
cout << "Luolasto alustettu" << endl;
//pääsilmukka pyörii niin kauan kun ikkuna on auki
while(device->run()) {
//aloitetaan scenen piirtäminen ja täytetään ruutu valitulla värillä
if(driver->beginScene(true, true, SColor(255,100,101,140))) {
//piirretään objektit
smgr->drawAll();
//Lopetetaan scenen käsittely tältä kierrokselta
driver->endScene();
} else { std::cout << "Could not begin scene." << std::endl; }
}
//heitetään pois kaikki mitä on ladattu
device->drop();
return 0;
}
示例6: initScene
void CIrrWindow::initScene()
{
IVideoDriver* driver = m_driver;
IrrlichtDevice* device = m_device;
ISceneManager* smgr = m_smgr;
// create texture manager
CTextureManager::createGetInstance();
// create design camera
m_designCamera = new CGameCamera();
m_designCamera->setName( L"Design camera" );
m_designCamera->setTarget(core::vector3df(0,0,0));
m_designCamera->setPosition( core::vector3df(-400, 200, -400) );
// set active camera
getIView()->setActiveCamera( m_designCamera );
// add oxyz plane node
CGameOxyzSceneNode *oxyPlane = new CGameOxyzSceneNode( smgr->getRootSceneNode(), smgr, 1 );
oxyPlane->drop();
// add light
ISceneNode* pNode = smgr->addEmptySceneNode();
// default light
ILightSceneNode *light = smgr->addLightSceneNode( pNode, core::vector3df(0, 0, 0) );
light->setLightType( video::ELT_DIRECTIONAL );
// add demo particle
m_particleObject = new CGameObject();
CParticleComponent *particleComp = new CParticleComponent(m_particleObject);
particleComp->initParticle();
m_particleObject->m_components.push_back( particleComp );
}
示例7: LoadScene
void Editor::LoadScene()
{
IVideoDriver *driver = device->getVideoDriver();
ISceneManager *smgr = device->getSceneManager();
// Create target
target = smgr->addEmptySceneNode(0, 200);
target->setPosition(vector3df(0, 0, 0));
// Create cameras
pivot = smgr->addEmptySceneNode(target, 199);
pivot->setRotation(vector3df(25, -45, 0));
recreateCameras();
// Add Light
ILightSceneNode* light = smgr->addLightSceneNode(target, vector3df(25, 50, 0));
light->setLightType(ELT_POINT);
light->setRadius(2000);
// Add Plane
plane = smgr->addCubeSceneNode(1, 0, -1,
vector3df(0.5, -5.5, 0.5), vector3df(0, 0, 0),
vector3df(10, 10, 10));
plane->setMaterialTexture(0, driver->getTexture("media/texture_terrain.png"));
plane->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
plane->setMaterialFlag(video::EMF_LIGHTING, false);
plane->setMaterialFlag(video::EMF_BACK_FACE_CULLING, true);
plane->getMaterial(0).getTextureMatrix(0).setTextureScale(10, 10);
// Add sky box
scene::IMeshSceneNode* skybox = smgr->addCubeSceneNode(50);
skybox->setMaterialTexture(0, driver->getTexture("media/sky.jpg"));
skybox->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
skybox->setMaterialFlag(video::EMF_LIGHTING, false);
smgr->getMeshManipulator()->flipSurfaces(skybox->getMesh());
state->plane_tri = smgr->createOctreeTriangleSelector(skybox->getMesh(), skybox);
}
示例8: main
//.........这里部分代码省略.........
loadMap.Load(smgr, device, selector, plyrNode, anim, driver, Map_Africa);
currentMap = Map_Africa;
//loadMap.setCollisions(smgr, selector, plyrNode, anim);
if (loadMap.CollNode)
{
selector = smgr->createOctreeTriangleSelector(loadMap.CollNode->getMesh(), loadMap.CollNode, 32);
for (int i = 0; i < loadMap.CollNode->getMaterialCount(); i++)
{
loadMap.CollNode->getMaterial(i).NormalizeNormals = true;
}
loadMap.CollNode->setTriangleSelector(selector);
}
if (selector)
{
anim = smgr->createCollisionResponseAnimator(selector, plyrNode, vector3df(0.6f, 0.75f, 0.4f), core::vector3df(0.0f, -0.05f, 0.0f),
core::vector3df(0.0f, -0.725f, 0.0f));
plyrNode->addAnimator(anim);
}
ISceneCollisionManager* collMan = smgr->getSceneCollisionManager();
////////////// The Sun ////////////
ILightSceneNode *sun_node;
SLight sun_data;
ISceneNode *sun_billboard;
float sun_angle = 0;
video::SColorf Diffuse_Night = video::SColorf(0.0f, 0.0f, 0.0f, 1.0f);
video::SColorf Diffuse_Day = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
sun_node = smgr->addLightSceneNode();
sun_data.Direction = vector3df(0, 0, 0);
sun_data.Type = video::ELT_DIRECTIONAL;
sun_data.AmbientColor = video::SColorf(0.1f, 0.1f, 0.1f, 1);
sun_data.SpecularColor = video::SColorf(0, 0, 0, 0);
sun_data.DiffuseColor = Diffuse_Day;
sun_data.CastShadows = true;
sun_node->setLightData(sun_data);
sun_node->setPosition(vector3df(0, 0, 0));
sun_node->setRotation(vector3df(0, 0, 0));
sun_billboard = smgr->addBillboardSceneNode(sun_node, core::dimension2d<f32>(60, 60));
if (sun_billboard)
{
sun_billboard->setPosition(vector3df(0, 0, -100));
sun_billboard->setMaterialFlag(video::EMF_LIGHTING, false);
sun_billboard->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
sun_billboard->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
sun_billboard->setMaterialTexture(0, driver->getTexture("Assets/particlewhite.bmp"));
}
/////////// End ////////////
//------- candleLight -----//
ILightSceneNode *candleLight = smgr->addLightSceneNode();
SLight candleLight_data;
candleLight_data.Type = video::ELT_POINT;
candleLight_data.DiffuseColor = SColorf(1.0f, 0.546f, 0.016f, 1.0f);
candleLight_data.SpecularColor = video::SColorf(0, 0, 0, 0);
candleLight->setPosition(vector3df(2.43467f, 1.55795f, -3.94657));
candleLight_data.Radius = 1.5f;
candleLight->setLightData(candleLight_data);
//------- end -----//
示例9: main
int main(int argc, char **argv) {
BSPdungeon dun(50,50,5);
IrrlichtDevice *device =createDevice( video::EDT_OPENGL, dimension2d<u32>(1280,720), 16,false, false, false, 0);
if (!device)
return 1;
device->setWindowCaption(L"Pangolin Kwest");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
smgr->setAmbientLight(video::SColorf(0.1,0.1,0.1,1));
ILightSceneNode* mylight1 = smgr->addLightSceneNode( 0, core::vector3df(00,00,00), video::SColorf(0.3f,0.3f,0.3f), 30.0f, 1 );
//IGUIFont* myfont=guienv->getFont("./myfont.xml");
//if(myfont==0)exit(93);
//guienv->addMessageBox(L"Alertz!",L"You pangolin are been createrized. You totalleh ready to bash monstaz etc.!");
mylight1->enableCastShadow(true);
//guienv->addStaticText(L"Pangolin Kwest 3D",rect<s32>(10,10,260,22), true);
//-------------------------------------------
int x,y,z;
for(x=0;x<50;x++){
for(y=0;y<50;y++){
if(dun.map[x][y]==NIL){
for(z=0;z<3;z++){
ISceneNode* cueb=smgr->addCubeSceneNode(10);
cueb->setMaterialFlag(EMF_LIGHTING, true);
cueb->setMaterialTexture( 0, driver->getTexture("media/stdwall.jpg") );
// cueb->getMaterial(0).getTextureMatrix(0).setTextureTranslate(0.25,0.5);
// cueb->getMaterial(0).getTextureMatrix(0).setTextureScale(0.0625,0.0625);
cueb->setPosition(vector3df(x*10,z*10,y*10));
}
}
// ISceneNode* cueb=smgr->addCubeSceneNode(10);
// cueb->setMaterialFlag(EMF_LIGHTING, true);
// cueb->setMaterialTexture( 0, driver->getTexture("media/stdfloor.jpg") );
// cueb->setPosition(vector3df(x*10,-10,y*10));
ISceneNode* cueb=smgr->addCubeSceneNode(10);
cueb->setMaterialFlag(EMF_LIGHTING, true);
cueb->setMaterialTexture( 0, driver->getTexture("media/stdup.jpg") );
cueb->setPosition(vector3df(x*10,30,y*10));
}
}
ISceneNode* cueb=smgr->addCubeSceneNode(500);
cueb->setMaterialFlag(EMF_LIGHTING, true);
cueb->setMaterialTexture( 0, driver->getTexture("media/stdfloor.jpg") );
cueb->setPosition(vector3df(250,-255,250));
//cueb->getMaterial(0).getTextureMatrix(0).setTextureTranslate(0.25,0.5);
cueb->getMaterial(0).getTextureMatrix(0).setTextureScale(50,50);
//cueb->setScale(vector3df(0,-5,0));
//cueb->addshadowVolumeSceneNode();
//-------------------------------------------
int lastFPS;
//smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
ICameraSceneNode* mycam;
mycam=smgr->addCameraSceneNodeFPS(0,100.0f,0.025f);
mycam->setFOV(45);
mylight1->setParent(mycam);
while(device->run())
{
//mylight1->setPosition();
//mylight1->
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Pangolin Kwest 3D [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
//.........这里部分代码省略.........
示例10: main
int main(int argc, char* argv[])
{
// ask user for driver
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
if (driverType==video::EDT_COUNT)
return 1;
MyEventReceiver receiver;
IrrlichtDevice* device = createDevice(driverType,
core::dimension2du(800, 600), 32, false, false, false,
&receiver);
if(device == 0)
return 1;
IVideoDriver *driver = device->getVideoDriver();
ISceneManager *smgr = device->getSceneManager();
device->setWindowCaption(L"Irrlicht Example for SMesh usage.");
/*
Create the custom mesh and initialize with a heightmap
*/
TMesh mesh;
HeightMap hm = HeightMap(255, 255);
hm.generate(eggbox);
mesh.init(hm, 50.f, grey, driver);
// Add the mesh to the scene graph
IMeshSceneNode* meshnode = smgr -> addMeshSceneNode(mesh.Mesh);
meshnode->setMaterialFlag(video::EMF_BACK_FACE_CULLING, false);
// light is just for nice effects
ILightSceneNode *node = smgr->addLightSceneNode(0, vector3df(0,100,0),
SColorf(1.0f, 0.6f, 0.7f, 1.0f), 500.0f);
if (node)
{
node->getLightData().Attenuation.set(0.f, 1.f/500.f, 0.f);
ISceneNodeAnimator* anim = smgr->createFlyCircleAnimator(vector3df(0,150,0),250.0f);
if (anim)
{
node->addAnimator(anim);
anim->drop();
}
}
ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
if (camera)
{
camera->setPosition(vector3df(-20.f, 150.f, -20.f));
camera->setTarget(vector3df(200.f, -80.f, 150.f));
camera->setFarValue(20000.0f);
}
/*
Just a usual render loop with event handling. The custom mesh is
a usual part of the scene graph which gets rendered by drawAll.
*/
while(device->run())
{
if(!device->isWindowActive())
{
device->sleep(100);
continue;
}
if(receiver.IsKeyDown(irr::KEY_KEY_W))
{
meshnode->setMaterialFlag(video::EMF_WIREFRAME, !meshnode->getMaterial(0).Wireframe);
}
else if(receiver.IsKeyDown(irr::KEY_KEY_1))
{
hm.generate(eggbox);
mesh.init(hm, 50.f, grey, driver);
}
else if(receiver.IsKeyDown(irr::KEY_KEY_2))
{
hm.generate(moresine);
mesh.init(hm, 50.f, yellow, driver);
}
else if(receiver.IsKeyDown(irr::KEY_KEY_3))
{
hm.generate(justexp);
mesh.init(hm, 50.f, yellow, driver);
}
driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, SColor(0xff000000));
smgr->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
示例11: main
int main()
{
const int nRobots = 2;
//given robot numbers will be controlled by humans
vector<int> humanBrainIds;
//humanBrainIds.push_back(1);
//humanBrainIds.push_back(0);
//-- device ------------------------------------------------------------//
IrrlichtDevice* device;
device = createDevice(
EDT_OPENGL, //driverType
windowSize,
16, //bits
false,
false, //stencilbuffer
false, //vsync
NULL //receiver
);
//advanced device params
//SIrrlichtCreationParameters params;
//params.DeviceType = EIDT_CONSOLE;
//params.DriverType = EDT_OPENGL;
//params.WindowSize = windowSize;
//device = createDeviceEx(params);
if (device == 0)
return EXIT_FAILURE; // could not create selected driver.
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
//-- lights ------------------------------------------------------------//
//ambient light
//smgr->setAmbientLight( SColorf(1.0f,1.0f,1.0f,1.0f) );
//smgr->setAmbientLight( SColorf(.3f,.3f,.3f,1.0f) );
//diffusive light
SLight light_data;
light_data.AmbientColor = SColorf(.3,.3,.3);
//light_data.Attenuation = vector3df(.3,.3,.3); //Attenuation cte, linear quadratic TODO ??
light_data.DiffuseColor = SColorf(.0,.0,.0);
light_data.SpecularColor = SColorf(.0,.0,.0);
light_data.CastShadows = true;
light_data.Radius = 100.0f;
light_data.Type = ELT_DIRECTIONAL;
//ELT_POINT point light, it has a position in space and radiates light in all directions
//ELT_SPOT spot light, it has a position in space, a direction, and a limited cone of influence
//ELT_DIRECTIONAL directional light, coming from a direction from an infinite distance
ILightSceneNode* light = smgr->addLightSceneNode(0, core::vector3df(.5f,.0f,.5f));
light->setLightData(light_data);
//-- objects ------------------------------------------------------------//
IMesh* mesh;
ISceneNode * node;
float HEIGHT=1000.f, WIDTH=1.f;
//height between center/sky == height bottom/center
//large so that scene looks 2d on interactive test mode.
//on automatic mode, only middle pixel row is taken, so this does not matter
//outter boundary
//square
node = smgr->addCubeSceneNode(
2.f*WIDTH, // width
0, // parent
-1, // id
vector3df(0, 0, 0), // center
vector3df(0, 0, 0), // rotation
vector3df(1.0f, HEIGHT, 1.0f)*-1.f // scale. *-1 turns it inside out. to use both faces make two cubes.
);
//circle
//mesh = smgr->getGeometryCreator()->createCylinderMesh(
//1.f, //radius
//1., //length
//50, //tesselation
//SColor(0,0,0,255), //color
//false, //closeTop
//0.f //oblique
//);
//node = smgr->addMeshSceneNode(
//mesh,
//0, //ISceneNode * parent
//-1, //s32 id
//vector3df(0, -HEIGHT, 0), //const core::vector3df & position
//vector3df(0, 0, 0), //const core::vector3df & rotation
//vector3df(1.0f, 2.f*HEIGHT, 1.0f) //const core::vector3df & scale
//);
node->getMaterial(0).AmbientColor.set(0,0,0,0);
node->getMaterial(0).DiffuseColor.set(0,0,0,0);
//node->getMaterial(0).SpecularColor.set(255,255,255,255);
//node->getMaterial(0).Shininess = 20.0f;
//node->getMaterial(0).EmissiveColor.set(0,0,0,0);
//.........这里部分代码省略.........
示例12: main
//.........这里部分代码省略.........
user interface environment, so that we do not always have to write
device->getVideoDriver(), device->getSceneManager(), or
device->getGUIEnvironment().
*/
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
/*
We add a hello world label to the window, using the GUI environment.
The text is placed at the position (10,10) as top left corner and
(260,22) as lower right corner.
*/
guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
rect<s32>(10,10,260,22), true);
/*
To show something interesting, we load a Quake 2 model and display it.
We only have to get the Mesh from the Scene Manager with getMesh() and add
a SceneNode to display the mesh with addAnimatedMeshSceneNode(). We
check the return value of getMesh() to become aware of loading problems
and other errors.
Instead of writing the filename sydney.md2, it would also be possible
to load a Maya object file (.obj), a complete Quake3 map (.bsp) or any
other supported file format. By the way, that cool Quake 2 model
called sydney was modelled by Brian Collins.
*/
IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
if (!mesh)
{
device->drop();
return 1;
}
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
/*
To let the mesh look a little bit nicer, we change its material. We
disable lighting because we do not have a dynamic light in here, and
the mesh would be totally black otherwise. Then we set the frame loop,
such that the predefined STAND animation is used. And last, we apply a
texture to the mesh. Without it the mesh would be drawn using only a
color.
*/
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, true);
node->setMD2Animation(scene::EMAT_RUN);
node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") );
node->setDebugDataVisible(EDS_BBOX_BUFFERS | EDS_NORMALS);
}
/*
To look at the mesh, we place a camera into 3d space at the position
(0, 30, -40). The camera looks from there to (0,5,0), which is
approximately the place where our md2 model is.
*/
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
smgr->addLightSceneNode();
/*
Ok, now we have set up the scene, lets draw everything: We run the
device in a while() loop, until the device does not want to run any
more. This would be when the user closes the window or presses ALT+F4
(or whatever keycode closes a window).
*/
while(device->run())
{
/*
Anything can be drawn between a beginScene() and an endScene()
call. The beginScene() call clears the screen with a color and
the depth buffer, if desired. Then we let the Scene Manager and
the GUI Environment draw their content. With the endScene()
call everything is presented on the screen.
*/
driver->beginScene(true, true, SColor(255,100,101,140));
// std::cout<<smgr->getDebugName()<<std::endl;
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
/*
After we are done with the render loop, we have to delete the Irrlicht
Device created before with createDevice(). In the Irrlicht Engine, you
have to delete all objects you created with a method or function which
starts with 'create'. The object is simply deleted by calling ->drop().
See the documentation at irr::IReferenceCounted::drop() for more
information.
*/
device->drop();
return 0;
}
示例13: main
int main()
{
// create device
EventHandler receiver;
Init();
Output();
ISceneNode* objects [MAX_OBJECTS];
IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<u32>(ResX, ResY), 32, fullscreen, false, vsync, &receiver);
receiver.device = device;
if (!device)
return 1;
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
HMDDescriptor HMD;
// Parameters from the Oculus Rift DK1
HMD.hResolution = ResX;
HMD.vResolution = ResY;
HMD.hScreenSize = 0.14976;
HMD.vScreenSize = 0.0936;
HMD.interpupillaryDistance = 0.064;
HMD.lensSeparationDistance = 0.064;
HMD.eyeToScreenDistance = 0.041;
HMD.distortionK[0] = 1.0;
HMD.distortionK[1] = 0.22;
HMD.distortionK[2] = 0.24;
HMD.distortionK[3] = 0.0;
HMDStereoRender renderer(device, HMD, 10);
#ifdef OCCULUS
ICameraSceneNode* camera = smgr->addCameraSceneNode();
camera->bindTargetAndRotation(false);
camera->setTarget(vector3df(1,0,0));
#else
ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
#endif
device->getCursorControl()->setVisible(false);
// load a faerie
IAnimatedMesh* faerie = smgr->getMesh("media/faerie.md2");
IAnimatedMeshSceneNode* faerieNode = smgr->addAnimatedMeshSceneNode(faerie);
faerieNode->setMaterialTexture(0, driver->getTexture("media/faerie2.bmp"));
faerieNode->setMaterialFlag(EMF_LIGHTING, false);
faerieNode->setPosition(vector3df(40,190,-1030));
faerieNode->setRotation(vector3df(0,-90,0));
faerieNode->setMD2Animation(EMAT_SALUTE);
// load a dwarf
IAnimatedMesh* dwarf = smgr->getMesh("media/dwarf.x");
IAnimatedMeshSceneNode* dwarfNode = smgr->addAnimatedMeshSceneNode(dwarf);
dwarfNode->setPosition(vector3df(40,-25,20));
Level currentLevel(device);
currentLevel.makeLevel(0);
smgr->setAmbientLight(video::SColorf(0.1,0.1,0.1,1));
ILightSceneNode* light1 = smgr->addLightSceneNode( camera , vector3df(0,0,0), video::SColorf(0.3f,0.4f,0.4f), 80.0f, 1 );
vector3df pos = vector3df(0,0,0);
//naplníme tunel pøekážkama
srand (time(NULL));
/* generate secret number between 1 and 10: */
for(int i = 0; i < MAX_OBJECTS; i++){
objects[i] = smgr->addCubeSceneNode(2);
objects[i]->setMaterialFlag(EMF_LIGHTING, false);
objects[i]->setPosition( vector3df( (rand() % 30) - 5, (rand() % 30) - 5, rand() % 80) );
}
//device->setInputReceivingSceneManager(smgr);
//použivane pro
vector3df tempRot;
irr::core::quaternion tempQ;
irr::core::matrix4 tempM;
float round = 0;
while(device->run())
{
round += 0.01;
driver->beginScene(true, true, SColor(255,100,101,140));
for(int i = 0; i < MAX_OBJECTS; i++){
//.........这里部分代码省略.........
示例14: main
int main()
{
/* shadowDimen = dimension2du(1024,1024);
shadowDimen = dimension2du(2048,2048);
shadowDimen = dimension2du(4096,4096);
shadowDimen = dimension2du(2048,2048);
filterType = EFT_NONE;
filterType = EFT_4PCF;
filterType = EFT_8PCF;
filterType = EFT_4PCF;
*/
dimension2du shadowDimen = dimension2du(1024,1024);
E_FILTER_TYPE filterType = EFT_4PCF;
filterType = EFT_NONE;
////
IrrlichtDevice* device = createDevice(EDT_OPENGL,dimension2du(800,600),32);
ISceneManager* smgr = device->getSceneManager();
IVideoDriver* driver = device->getVideoDriver();
ICameraSceneNode* cam = smgr->addCameraSceneNodeFPS(0,100,.5);
cam->setPosition(vector3df(0,10,0));
// Create the effect handler, passing the device and RTT size (as a dimension2d) .
effectHandler* effect = new effectHandler(device,shadowDimen);
ITerrainSceneNode* terrain = smgr->addTerrainSceneNode("media/terrain.bmp",0,-1,vector3df(0,0,0),vector3df(0,0,0),vector3df(1,1,1),SColor(255,255,255,255),1,ETPS_33);
terrain->setMaterialTexture(0,driver->getTexture("media/terrain.jpg"));
terrain->setMaterialTexture(1, driver->getTexture("media/detailmap.jpg"));
terrain->scaleTexture(1,10);
terrain->setScale(core::vector3df(4, 0.01f, 4));
terrain->setPosition(vector3df(-120,-1.5f,-120));
terrain->setMaterialType(EMT_DETAIL_MAP);
// Make the terrain recieve a shadow with the specified filter type.
// (NOTE: 12PCF is only available in Direct3D9, all others work with OpenGL)
effect->addShadowToNode(terrain,filterType);
IAnimatedMeshSceneNode* sydney;
IAnimatedMesh* sydneymesh = smgr->getMesh("media/dwarf.x");
for(int g = 0;g < 1;g++)
{
for(int v = 0;v < 3;v++)
{
sydney = smgr->addAnimatedMeshSceneNode(sydneymesh);
sydney->setScale(vector3df(0.05f,0.05f,0.05f));
sydney->setPosition(vector3df(g * 4,0.5f,v * 4));
sydney->setMaterialFlag(EMF_NORMALIZE_NORMALS,true);
sydney->setAutomaticCulling(EAC_FRUSTUM_BOX);
sydney->setMaterialType(EMT_SOLID);
// Add the nodes to the depth pass so that they cast a shadow.
effect->addNodeToDepthPass(sydney);
}
}
effect->getLightCamera()->addAnimator(smgr->createFlyCircleAnimator(sydney->getPosition() + vector3df(0,15,0),25,0.0002f));
effect->getLightCamera()->setNearValue(5);
effect->setMaxShadowDistanceFromLight(120);
smgr->addLightSceneNode(effect->getLightCamera());
MyEventReceiver receiver(cam);
device->setEventReceiver(&receiver);
// Parent a sphere to the light camera so we can see its position.
smgr->addSphereSceneNode(1,8,effect->getLightCamera())->setMaterialFlag(EMF_LIGHTING,false);
while(device->run())
{
wchar_t tmp[255];
swprintf(tmp,255,L"Shadow Map Demo (FPS: %d)",driver->getFPS());
device->setWindowCaption(tmp);
driver->beginScene(true,true,SColor(0,0,0,0));
// Point the light camera at one of the nodes as it rotates around them.
effect->setLightTarget(sydney->getPosition());
// Update the effect handler, remember to always do this BEFORE smgr->drawAll and AFTER beginscene!
effect->update();
smgr->drawAll();
// If user wishes we can display the shadow map to the screen. (May not work in OpenGL)
//.........这里部分代码省略.........
示例15: main
int main(int argc, char** argv) {
CustomEventReceiver receiver;
IrrlichtDevice *device = createDevice( video::EDT_OPENGL, dimension2d<u32>(800, 600), 16, false, false, false, &receiver);
if (!device) {
return EXIT_FAILURE;
}
device->setWindowCaption(L"Solar System Simulator");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* sceneManager = device->getSceneManager();
scene::ISceneCollisionManager* collisionManager= sceneManager->getSceneCollisionManager();
IGUIEnvironment* guiEnv = device->getGUIEnvironment();
guiEnv->addStaticText(L"Click on a planet to attach the camera to it", rect<s32>(10,10,260,22), false);
sf::SoundBuffer buffer;
if (buffer.loadFromFile(currentPath() + "/sounds/burning.aif")) {
sf::Listener::setPosition(0, 0,0);
sf::Sound sound;
sound.setBuffer(buffer);
sound.setPosition(0, 0, 0);
sound.setLoop(true);
sound.play();
}
const char* spaceTexturePath = ( currentPath() + "/textures/space.jpg" ).c_str();
video::ITexture* space = driver->getTexture(spaceTexturePath);
scene::ISceneNode* skybox = sceneManager->addSkyBoxSceneNode(space, space, space, space, space, space);
sceneManager->addLightSceneNode(0, vector3df(0, 0, -50), video::SColorf(1.0f, 1.0f, 1.0f), 50.0f, 1001);
PlanetFactory planetFactory(sceneManager, driver);
Planet sun = planetFactory.create(PlanetId::Sun);
Planet earth = planetFactory.create(PlanetId::Earth);
Planet pluto = planetFactory.create(PlanetId::Pluto);
Planet jupiter = planetFactory.create(PlanetId::Jupiter);
Planet uranus = planetFactory.create(PlanetId::Uranus);
Planet neptune = planetFactory.create(PlanetId::Neptune);
vector<Planet> planets = { sun, planetFactory.create(PlanetId::Mercury) };
planets.push_back(planetFactory.create(PlanetId::Venus));
planets.push_back(earth);
planets.push_back(planetFactory.create(PlanetId::Mars));
planets.push_back(jupiter);
planets.push_back(planetFactory.create(PlanetId::Saturn));
planets.push_back(uranus);
planets.push_back(neptune);
planets.push_back(pluto);
ICameraSceneNode* camera = sceneManager->addCameraSceneNode(0, vector3df(0,0,40), vector3df(0,0,0));
rect<s32> mainCameraViewPortRect(0, 0, 800, 600);
ICameraSceneNode* topViewCamera = sceneManager->addCameraSceneNode(0, vector3df(0,50,0), vector3df(0,0,0));
sceneManager->setAmbientLight(video::SColorf(255.0,255.0,255.0));
ISceneNode* selectedNode = sun.node;
while(device->run()) {
if(receiver.GetMouseState().LeftButtonDown) {
position2di mousepos = receiver.GetMouseState().Position;
line3df ray = sceneManager->getSceneCollisionManager()->getRayFromScreenCoordinates( mousepos, camera);
vector3df intersection;
triangle3df tri;
for(Planet& planet : planets) {
ITriangleSelector* wselector = sceneManager->createTriangleSelectorFromBoundingBox(planet.node);
if (collisionManager->getCollisionPoint(ray, wselector, intersection, tri, planet.node)) {
selectedNode = planet.node;
}
wselector->drop();
}
}
camera->setTarget(selectedNode->getAbsolutePosition());
skybox->setVisible(true);
driver->setViewPort(mainCameraViewPortRect);
driver->beginScene(true, true, SColor(255,100,101,140));
sceneManager->setActiveCamera(camera);
sceneManager->drawAll();
guiEnv->drawAll();
driver->setViewPort(rect<s32>(0, 380, 200, 600));
driver->draw2DRectangle(SColor(100,0,0,190), mainCameraViewPortRect);
skybox->setVisible(false);
sceneManager->setActiveCamera(topViewCamera);
sceneManager->drawAll();
driver->endScene();
}
device->drop();
return EXIT_SUCCESS;
}