本文整理汇总了C++中ISceneManager::addCameraSceneNode方法的典型用法代码示例。如果您正苦于以下问题:C++ ISceneManager::addCameraSceneNode方法的具体用法?C++ ISceneManager::addCameraSceneNode怎么用?C++ ISceneManager::addCameraSceneNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISceneManager
的用法示例。
在下文中一共展示了ISceneManager::addCameraSceneNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: runTestWithDriver
static bool runTestWithDriver(E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device = createDevice( driverType, dimension2d<s32>(640, 480));
if (!device)
return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
IVideoDriver* driver = device->getVideoDriver();
ISceneManager * smgr = device->getSceneManager();
// Draw a cube to check that the pixels' alpha is working.
ISceneNode * cube = smgr->addCubeSceneNode(50.f, 0, -1, vector3df(0, 0, 60));
cube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp"));
cube->setMaterialFlag(video::EMF_LIGHTING, false);
(void)smgr->addCameraSceneNode();
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
// Test for offscreen values as well as onscreen.
for(s32 x = -10; x < 650; ++x)
{
s32 y = 480 * x / 640;
driver->drawPixel((u32)x, (u32)y, SColor(255, 255 * x / 640, 255 * (640 - x) / 640, 0));
y = 480 - y;
driver->drawPixel((u32)x, (u32)y, SColor(255 * x / 640, 0, 255, 255));
}
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-drawPixel.jpg");
device->drop();
return result;
}
示例4: burningsVideo
/** Tests the Burning Video driver */
bool burningsVideo(void)
{
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO,
core::dimension2di(160,120), 32);
if (!device)
return false;
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
smgr->addCubeSceneNode(10.f, 0, -1, core::vector3df(0.f, 0.f, 20.f));
smgr->addCameraSceneNode();
// Test that ambient lighting works when there are no other lights in the scene
smgr->setAmbientLight(video::SColorf(.7f, .1f, .1f, 1.f));
bool result = false;
device->run();
if (driver->beginScene(true, true, video::SColor(0, 80, 80, 80)))
{
smgr->drawAll();
driver->endScene();
result = takeScreenshotAndCompareAgainstReference(driver, "-ambient-lighting.png", 100);
}
device->drop();
return result;
}
示例5: main
int main()
{
IrrlichtDevice* irrDevice = createDevice(EDT_OPENGL,dimension2d<s32>(800,600),32,false,false,false,0);
IVideoDriver* irrVideo = irrDevice->getVideoDriver();
ISceneManager* irrSceneMgr = irrDevice->getSceneManager();
TMovie* movie = new TMovie(irrDevice->getTimer());
movie->LoadMovie("Mymovie.avi");
irrVideo->setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false);
u32 w = movie->getMovieWidth();
u32 h = movie->getMovieHeight();
ITexture* movTxtr = irrVideo->addTexture(dimension2d<s32>(w<513?512:1024,h<513?512:1024),"imovie");
irrSceneMgr->addCameraSceneNode(0, vector3df(0,0,-20), vector3df(0,0,0));
CSampleSceneNode* myNode = new CSampleSceneNode(irrSceneMgr->getRootSceneNode(), irrSceneMgr, 666);
myNode->setMaterialTexture( 0, movTxtr);
myNode->drop();
ISceneNodeAnimator* anim = irrSceneMgr->createRotationAnimator(vector3df(0,0.1f,0));
myNode->addAnimator(anim);
anim->drop();
while(irrDevice->run())
{
irrVideo->beginScene(true, true, SColor(0,200,200,200));
if (movie->NextMovieFrame())
movie->DrawMovie(0,0,movTxtr);
irrSceneMgr->drawAll();
irrVideo->endScene();
}
irrDevice->drop();
return 0;
}
示例6: runTestWithDriver
/** The test loads a texture, renders it using draw2dimage, loads another
texture and renders the first one again. Due to the texture cache this
can lead to rendering of the second texture in second place. */
static bool runTestWithDriver(E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device = createDevice( driverType, dimension2d<s32>(160, 120), 32);
if (!device)
return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
IVideoDriver* driver = device->getVideoDriver();
ISceneManager * smgr = device->getSceneManager();
ITexture* tex1 = driver->getTexture("../media/wall.bmp");
(void)smgr->addCameraSceneNode();
driver->beginScene(true, true, SColor(255,100,101,140));
driver->draw2DImage(tex1, position2di(0,0));
driver->endScene();
driver->getTexture("../media/tools.png");
driver->beginScene(true, true, SColor(255,100,101,140));
driver->draw2DImage(tex1, position2di(0,0));
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-textureRenderStates.png", 100);
device->drop();
return result;
}
示例7: example_customscenenode
int example_customscenenode()
{
// create device
IrrlichtDevice *device = startup();
if (device == 0) return 1; // could not create selected driver.
// create engine and camera
EventReceiver_basic receiver(device);
device->setEventReceiver(&receiver);
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
smgr->addCameraSceneNode(0, vector3df(0, -40, 0), vector3df(0, 0, 0));
CSampleSceneNode *myNode = new CSampleSceneNode(smgr->getRootSceneNode(), smgr, 666);
ISceneNodeAnimator* anim = smgr->createRotationAnimator(vector3df(0.8f, 0, 0.8f));
if (anim) {
myNode->addAnimator(anim);
anim->drop();
anim = 0; // As I shouldn't refer to it again, ensure that I can't
}
myNode->drop();
myNode = 0; // As I shouldn't refer to it again, ensure that I can't
return run(device);
}
示例8: main
int main(int argc, char** argv)
{
IrrlichtDevice* device = createDevice(video::EDT_OPENGL, dimension2d<u32>(800, 600), 16, false, false, false, 0);
if (!device) {
return 1;
}
device->setWindowCaption(L"boxes");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IMeshSceneNode* cube = smgr->addCubeSceneNode();
smgr->addCameraSceneNode(0);
while (device->run()) {
driver->beginScene();
smgr->drawAll();
driver->endScene();
}
return 0;
}
示例9: main
int main()
{
IrrlichtDevice *device =
createDevice( video::EDT_OPENGL, dimension2d<u32>(800, 600));
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
smgr->addCameraSceneNode(0, vector3df(0,10,-10), vector3df(0,5,0));
IAnimatedMesh* mesh = smgr->getMesh("ninja.b3d");
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh);
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMaterialTexture( 0, driver->getTexture("nskinrd.jpg") );
node->setRotation(vector3df(0,180,0)); // let ninja be in front to us
node->setJointMode(EJUOR_CONTROL); // tell irrlicht that you want to control joint positions
IBoneSceneNode* bone = node->getJointNode("Joint10"); // create IBoneSceneNode and select the desired bone
while(device->run()) {
bone->setRotation(bone->getRotation() + vector3df(1,0,0)); // rotate bone
driver->beginScene();
smgr->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
示例10: testTransparentVertexAlphaMore
bool testTransparentVertexAlphaMore(E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device = createDevice(driverType, dimension2d<u32>(160, 120));
if (!device)
return true;
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
if (driver->getColorFormat() != video::ECF_A8R8G8B8)
{
device->closeDevice();
device->run();
device->drop();
return true;
}
logTestString("Testing driver %ls\n", driver->getName());
IAnimatedMesh* mesh = smgr->getMesh("../media/sydney.md2");
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
IMeshSceneNode* cube = smgr->addCubeSceneNode(10.0f,0,-1,vector3df(-5,3,-15));
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setFrameLoop(0, 310);
node->setMaterialTexture( 0, driver->getTexture("../media/sydney.bmp") );
}
if (cube)
{
cube->getMaterial(0).MaterialType = EMT_TRANSPARENT_VERTEX_ALPHA;
cube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp"));
cube->setMaterialFlag(EMF_LIGHTING, false);
smgr->getMeshManipulator()->setVertexColorAlpha(cube->getMesh(),128);
}
// second cube without texture
cube = smgr->addCubeSceneNode(10.0f,0,-1,vector3df(5,3,-15));
if (cube)
{
cube->getMaterial(0).MaterialType = EMT_TRANSPARENT_VERTEX_ALPHA;
cube->setMaterialFlag(EMF_LIGHTING, false);
smgr->getMeshManipulator()->setVertexColorAlpha(cube->getMesh(),128);
}
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
driver->beginScene(true, true, SColor(0,200,200,200));
smgr->drawAll();
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-transparentVertexAlphaChannelMore.png", 99.18f);
device->closeDevice();
device->run();
device->drop();
return result;
}
示例11: CreateCamera
void CreateCamera(int width, int height, vector3df position, vector3df target)
{
//Build camera
ISceneManager* sm = g_GameGraph->GetSceneManager();
WorldState* worldState =
static_cast<WorldState*> (g_GameGraph->GetWorldState());
HexMap* hm = worldState->GetCurrentMap();
if (NULL != sm)
{
if (NULL != hm)
{
ICameraSceneNode* orthoCam = sm->addCameraSceneNode(
sm->getRootSceneNode(), position, target);
matrix4 projMat;
projMat.buildProjectionMatrixOrthoLH(width, height, -5, 5);
orthoCam->setProjectionMatrix(projMat, true);
orthoCam->bindTargetAndRotation(true);
if (orthoCam->isOrthogonal())
{
CameraAnimator* cameraAnim = new CameraAnimator(position, width,
height, hm->GetMapDimensions().Height,
hm->GetMapDimensions().Width, worldState->GetHero(),
hm->GetCoordinateTranslator());
orthoCam->addAnimator(cameraAnim);
cameraAnim->drop();
cameraAnim = NULL;
if (width > height)
{
LOGI("Creating a landscape camera.");
landscapeCamera = orthoCam;
}
else
{
LOGI("Creating a portrait camera");
portraitCamera = orthoCam;
}
}
else
{
LOGE("The created camera is not orthoganol, something is wrong with the perspective matrix.");
}
}
else
{
LOGE("The hex map created in the WorldState is NULL.");
}
}
else
{
LOGE("The scene manager cannot be loaded from the device.");
}
}
示例12: b3dAnimation
/** Verify that two skinned animated mesh scene nodes can use different frames of the skinned mesh */
bool b3dAnimation(void)
{
// Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
IrrlichtDevice *device = createDevice( EDT_BURNINGSVIDEO, dimension2d<s32>(160, 120), 32);
assert(device);
if (!device)
return false;
IVideoDriver* driver = device->getVideoDriver();
ISceneManager * smgr = device->getSceneManager();
IAnimatedMesh* mesh = smgr->getMesh("../media/ninja.b3d");
IAnimatedMeshSceneNode* node1;
IAnimatedMeshSceneNode* node2;
assert(mesh);
bool result = false;
if(mesh)
{
node1 = smgr->addAnimatedMeshSceneNode(mesh);
assert(node1);
if(node1)
{
node1->setPosition(vector3df(-3, -3, 10));
node1->setMaterialFlag(EMF_LIGHTING, false);
node1->setAnimationSpeed(0.f);
}
node2 = smgr->addAnimatedMeshSceneNode(mesh);
assert(node2);
if(node2)
{
node2->setPosition(vector3df(3, -3, 10));
node2->setMaterialFlag(EMF_LIGHTING, false);
node2->setAnimationSpeed(0.f);
node2->setCurrentFrame(62.f);
}
(void)smgr->addCameraSceneNode();
// Just jump to the last frame since that's all we're interested in.
device->run();
driver->beginScene(true, true, SColor(255, 255, 255, 0));
smgr->drawAll();
driver->endScene();
result = takeScreenshotAndCompareAgainstReference(driver, "-b3dAnimation.png");
}
device->drop();
return result;
}
示例13: getIView
CGameCamera::CGameCamera()
{
m_targetObject = NULL;
m_objectType = CGameObject::CameraObject;
#ifdef GSEDITOR
m_cameraMesh = NULL;
#endif
ISceneManager *smgr = getIView()->getSceneMgr();
// save old camera
ICameraSceneNode *oldCam = smgr->getActiveCamera();
// create new camera
m_camera = smgr->addCameraSceneNode();
m_camera->setFOV( core::degToRad(60.0f) );
m_camera->setFarValue( 8000.0f );
m_camera->grab();
core::vector3df pos(0,0,0);
setPosition( pos );
core::vector3df target(1,0,0);
setTarget( target );
#ifdef GSEDITOR
CColladaMeshComponent *comp = new CColladaMeshComponent( this );
comp->loadFromFile( getIView()->getPath("data/editor/camera.dae") );
addComponent( comp );
setLighting( false );
m_cameraMesh = m_node;
m_cameraMesh->setVisible( true );
ITriangleSelector *selector = smgr->createTriangleSelectorFromBoundingBox( m_cameraMesh );
m_cameraMesh->setTriangleSelector(selector);
selector->drop();
#endif
// set camera node
m_node = m_camera;
// restore camera
smgr->setActiveCamera( oldCam );
m_animator = NULL;
#ifndef GSGAMEPLAY
setEditorCamera();
#else
setFreeCamera();
#endif
}
示例14: runTestWithDriver
//! Tests lightmaps under all drivers that support them
static bool runTestWithDriver(E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device = createDevice( driverType, dimension2d<u32>(160, 120), 32);
if (!device)
return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
IVideoDriver* driver = device->getVideoDriver();
ISceneManager * smgr = device->getSceneManager();
logTestString("Testing driver %ls\n", driver->getName());
if (driver->getDriverAttributes().getAttributeAsInt("MaxTextures")<2)
{
device->closeDevice();
device->run();
device->drop();
return true;
}
stabilizeScreenBackground(driver);
bool result = true;
bool added = device->getFileSystem()->addFileArchive("../media/map-20kdm2.pk3");
assert_log(added);
if(added)
{
ISceneNode * node = smgr->addOctreeSceneNode(smgr->getMesh("20kdm2.bsp")->getMesh(0), 0, -1, 1024);
assert_log(node);
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setPosition(core::vector3df(-1300,-820,-1249));
node->setScale(core::vector3df(1, 5, 1));
(void)smgr->addCameraSceneNode(0, core::vector3df(0,0,0), core::vector3df(40,100,30));
driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255,255,255,0));
smgr->drawAll();
driver->endScene();
result = takeScreenshotAndCompareAgainstReference(driver, "-lightmaps.png", 96);
}
}
device->closeDevice();
device->run();
device->drop();
return result;
}
示例15: loadScene
static bool loadScene(void)
{
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO,
core::dimension2du(160,120), 32);
if (!device)
return false;
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
// load scene from example, with correct relative path
device->getFileSystem()->changeWorkingDirectoryTo("results");
smgr->loadScene("../../media/example.irr");
smgr->addCameraSceneNode(0, core::vector3df(0,0,-50));
device->getFileSystem()->changeWorkingDirectoryTo("..");
bool result = false;
device->run();
device->getTimer()->setTime(666); // scene has animations and current scene seems to be saved at that time ... really - best result with just that number :-)
if (driver->beginScene(true, true, video::SColor(0, 80, 80, 80)))
{
smgr->drawAll();
driver->endScene();
// we need to be very sloppy, because the animators will produce a different
// start depending on the actual loading time. 97% seems to be safe, as removing
// an object produces values around 95%
result = takeScreenshotAndCompareAgainstReference(driver, "-loadScene.png", 97.4f);
if (!result)
logTestString("Rendering the loaded scene failed.\n");
}
ISceneNode* node = smgr->getSceneNodeFromId(128);
if (!node)
result=false;
else if (result) // only check if scene was correctly loaded
{
result &= (node->getChildren().size()==0);
if (!result)
logTestString("Node has an illegal child node.\n");
device->getSceneManager()->loadScene("results/scene2.irr", 0, node);
result &= (node->getChildren().size()!=0);
if (!result)
logTestString("Loading second scene as child failed.\n");
}
device->closeDevice();
device->run();
device->drop();
return result;
}