本文整理汇总了C++中ISceneManager类的典型用法代码示例。如果您正苦于以下问题:C++ ISceneManager类的具体用法?C++ ISceneManager怎么用?C++ ISceneManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ISceneManager类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
void StateTemp::Init()
{
SKeyMap aKeyMap[5];
aKeyMap[0].Action = EKA_MOVE_FORWARD;
aKeyMap[0].KeyCode = KEY_KEY_W;
aKeyMap[1].Action = EKA_MOVE_BACKWARD;
aKeyMap[1].KeyCode = KEY_KEY_S;
aKeyMap[2].Action = EKA_STRAFE_LEFT;
aKeyMap[2].KeyCode = KEY_KEY_A;
aKeyMap[3].Action = EKA_STRAFE_RIGHT;
aKeyMap[3].KeyCode = KEY_KEY_D;
aKeyMap[4].Action = EKA_JUMP_UP;
aKeyMap[4].KeyCode = KEY_SPACE;
m_pCamera = Irrdevice::GetInstance()->GetSceneManager()->addCameraSceneNodeFPS(NULL, 50.f, 0.1f, -1, aKeyMap, 9, FALSE, 2.f);
m_pNetworkControl = NetworkManager::getInstance()->GetNetworkControler();
m_pCamera->setPosition(vector3df(20,2000,20));
ISceneManager * smgr = Irrdevice::GetInstance()->GetSceneManager();
IVideoDriver * driver = Irrdevice::GetInstance()->GetVideoDriver();
m_MyId = -1;
m_OhterId = -1;
///////////////////////////여기서 부터 테스트
IAnimatedMesh * Terrain = smgr->getMesh("media/test.X");
m_pTerrain = new TerrainObject();
m_pTerrain->Init(smgr,Terrain);
m_pNinja = new UnitObject();
IAnimatedMesh* mesh = smgr->getMesh("media/ninja.b3d");
m_pNinja->init(smgr,mesh,NULL,1);
m_pMe = new Player();
m_pMe->Init(m_pNinja,m_pTerrain->GetTriangleSelecter());
m_pNinja2 = new UnitObject();
m_pNinja2->init(smgr,mesh,NULL,2);
m_pYou = new Player();
m_pYou->Init(m_pNinja2,m_pTerrain->GetTriangleSelecter());
m_pMe->AddPlayerTriangleSelecter(m_pYou);
m_pYou->AddPlayerTriangleSelecter(m_pMe);
m_pMe->SetPosition(vector3df(50,2100,50));
m_pYou->SetPosition(vector3df(-50,2100,-50));
//m_pMe->SetActiveCamera();
//커맨드패턴.. -_-;
//m_pUserConnect = CommandFactory::CreateUserConnectCommand(Irrdevice::GetInstance(),m_pNetworkControl,NULL);
for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
KeyIsDown[i] = false;
//Packet p(WELCOME_ACK,0);
//m_pNetworkControl->SendClientToPacket(p);
}
示例2: main
int main()
{
IDevice* device = gf::createDevice(EDT_DIRECT3D11, 800, 600);
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->createSceneManager();
IResourceGroupManager* resourceGroupManager = driver->getResourceGroupManager();
resourceGroupManager->init("Resources.cfg");
ITimer* timer = device->getTimer();
timer->reset();
ITextureManager* textureManager = ITextureManager::getInstance();
IShaderManager* shaderMgr = driver->getShaderManager();
IShader* shader = shaderMgr->load(EST_COMPUTE_SHADER, "matmul.hlsl", "cs_main");
const u32 dimension = 512;
const u32 sq_dimension = dimension * dimension;
std::vector<f32> A(sq_dimension);
std::vector<f32> B(sq_dimension);
std::vector<f32> C(sq_dimension);
std::vector<f32> D(sq_dimension);
// init data
for (u32 i = 0; i < sq_dimension; i++)
{
A[i] = math::RandomFloat(0, 10.0f);
B[i] = math::RandomFloat(0, 10.0f);
}
f32 start_time, end_time;
start_time = timer->getTime();
// store the right answers to D
for (u32 i = 0; i < dimension; i++)
{
for (u32 j = 0; j < dimension; j++)
{
f32 sum = 0;
for (u32 k = 0; k < dimension; k++)
{
sum += A[i * dimension + k] * B[k * dimension + j];
}
D[i * dimension + j] = sum;
}
}
end_time = timer->getTime();
printf("The computation time by CPU: %fs\n", end_time - start_time);
start_time = timer->getTime();
ITexture* inputTexture1 = textureManager->createTexture2D("input1", dimension, dimension,
ETBT_SHADER_RESOURCE, &A[0], 1, EGF_R32_FLOAT, 0);
ITexture* inputTexture2 = textureManager->createTexture2D("input2", dimension, dimension,
ETBT_SHADER_RESOURCE, &B[0], 1, EGF_R32_FLOAT, 0);
ITexture* outputTexture = textureManager->createTexture2D("output", dimension, dimension,
ETBT_UNORDERED_ACCESS, nullptr, 1, EGF_R32_FLOAT, 0);
ITexture* copyTexture = textureManager->createTexture2D("copy", dimension, dimension,
ETBT_CPU_ACCESS_READ, nullptr, 1, EGF_R32_FLOAT, 0);
shader->setTexture("gInputA", inputTexture1);
shader->setTexture("gInputB", inputTexture2);
shader->setTexture("gOutput", outputTexture);
u32 blockNum = dimension / 8;
if (blockNum * 8 != dimension)
blockNum++;
driver->runComputeShader(shader, blockNum, blockNum, 1);
//driver->resetRWTextures();
//driver->resetTextures();
outputTexture->copyDataToAnotherTexture(copyTexture);
STextureData outputData;
copyTexture->lock(ETLT_READ, &outputData);
u8* data = (u8*)outputData.Data;
for (u32 i = 0; i < dimension; i++)
{
// copy each row.
memcpy(&C[i * dimension], data + outputData.RowPitch * i, dimension * sizeof(f32));
}
copyTexture->unlock();
end_time = timer->getTime();
printf("The computation time by GPU: %fs\n", end_time - start_time);
for (u32 i = 0; i < sq_dimension; i++)
{
assert(math::FloatEqual(C[i], D[i]));
}
// destory textures.
if (!textureManager->destroy(inputTexture1))
printf("Destory texture failed!");
if (!textureManager->destroy(inputTexture2))
//.........这里部分代码省略.........
示例3: testGeometryCreator
/** Tests that the geometry creator does what it says it does. */
bool testGeometryCreator(void)
{
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO,
core::dimension2du(160,120), 32);
if (!device)
return false;
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
(void)smgr->addCameraSceneNode(0, vector3df(0, 0, -50));
const IGeometryCreator * geom = smgr->getGeometryCreator();
ITexture * wall = driver->getTexture("../media/wall.bmp");
SMaterial material;
material.Lighting = false;
material.TextureLayer[0].Texture = wall;
IMeshSceneNode * node = smgr->addMeshSceneNode(
geom->createHillPlaneMesh(dimension2df(10, 5), dimension2du(5, 5),
&material, 10, dimension2df(2, 2), dimension2df(3, 3)), 0, -1,
vector3df(0, 10, 0), vector3df(-60, 0, 0));
node = smgr->addMeshSceneNode(geom->createArrowMesh(4, 8, 10, 6, 3, 6,
SColor(255, 255, 0, 0), SColor(255, 0, 255, 0)),
0, -1, vector3df(-10, -20, 0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node = smgr->addMeshSceneNode(geom->createConeMesh(5.f, 10.f, 16), 0, -1, vector3df(-35, -20, 0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
node = smgr->addMeshSceneNode(geom->createCubeMesh(), 0, -1, vector3df(-20, -20, 0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
node = smgr->addMeshSceneNode(geom->createCylinderMesh(3, 10, 16), 0, -1, vector3df(0, -20, 10), core::vector3df(45,0,0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
node = smgr->addMeshSceneNode(geom->createSphereMesh(), 0, -1, vector3df(10, -15, 0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
node = smgr->addMeshSceneNode(geom->createVolumeLightMesh(), 0, -1, vector3df(20, -20, -10));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
node->setScale(core::vector3df(4.f,4.f,4.f));
bool result = false;
device->run();
if (driver->beginScene(true, true, video::SColor(0, 80, 80, 80)))
{
smgr->drawAll();
driver->endScene();
result = takeScreenshotAndCompareAgainstReference(driver, "-testGeometryCreator.png", 99.999f);
}
device->drop();
return result;
}
示例4: 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;
}
示例5: main
int main()
{
int d = 1;
GF_PRINT_CONSOLE_INFO("Hello:%d\n", d);
SDeviceContextSettings settings;
settings.MultiSamplingCount = 4;
settings.MultiSamplingQuality = 32;
IDevice* device = createDevice(EDT_DIRECT3D11, 800, 600, EWS_NONE, true, settings);
IVideoDriver* driver = device->getVideoDriver();
IShaderManager* shaderManager = driver->getShaderManager();
IInputLayoutManager* inputlayoutManager = driver->getInputLayoutManager();
IPipelineManager* pipelineMgr = driver->getPipelineManager();
IShader* vs = shaderManager->load(EST_VERTEX_SHADER, "color.hlsl", "ColorVertexShader");
IShader* ps = shaderManager->load(EST_PIXEL_SHADER, "PixelShader.hlsl", "ColorPixelShader");
std::vector<SInputLayoutElement> elements;
elements.resize(2);
elements[0].SemanticName = "POSITION";
elements[0].SemanticIndex = 0;
elements[0].Format = EGF_R32G32B32_FLOAT;
elements[0].Offset = 0;
elements[1].SemanticName = "COLOR";
elements[1].SemanticIndex = 0;
elements[1].Format = EGF_R32G32B32A32_FLOAT;
elements[1].Offset = 12;
IInputLayout* layout = inputlayoutManager->create(elements, vs);
IShader* shaders[2] = { vs, ps };
IPipeline* pipeline = pipelineMgr->create("color", shaders, 2, layout, EPT_TRIANGLELIST);
ISceneManager* smgr = device->getSceneManager();
Vertex vertices[3];
vertices[0] = Vertex(XMFLOAT3(-1.0f, -0.6f, 0.0f), XMFLOAT4(1.0f, 0.0f, 0.0f, 1.0f));
vertices[1] = Vertex(XMFLOAT3(0.0f, 0.6f, 0.0f), XMFLOAT4(0.0f, 1.0f, 0.0f, 1.0f));
vertices[2] = Vertex(XMFLOAT3(1.0f, -0.6f, 0.0f), XMFLOAT4(1.0f, 0.0f, 1.0f, 1.0f));
//IMesh* mesh = smgr->createSimpleMesh(&vertices, 3, sizeof(Vertex), nullptr, 0, 0);
IMesh* mesh = smgr->createCubeMesh();
IMeshNode* meshNode = smgr->addMeshNode(mesh, pipeline);
//CD3D11ShaderManager* s = new CD3D11ShaderManager(nullptr);
XMVECTOR eye = XMVectorSet(0.0f, 0.0f, -5.0f, 1.0f);
XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
XMVECTOR at = XMVectorZero();
XMMATRIX view = XMMatrixLookAtLH(eye, at, up);
XMMATRIX proj = XMMatrixPerspectiveFovLH(0.25f * 3.14f,
static_cast<float>(SCREEN_WIDTH) / static_cast<float>(SCREEN_HEIGHT),
1.0f, 1000.0f);
meshNode->translate(0, 0, 5.0f);
XMMATRIX world = meshNode->getAbsoluteTransformation();
//XMMATRIX world = XMMatrixIdentity();
pipeline->setMatrix("viewMatrix", reinterpret_cast<f32*>(&view));
pipeline->setMatrix("projectionMatrix", reinterpret_cast<f32*>(&proj));
SShaderAutoVariable var;
var.Type = ESAVT_WORLD_MATRIX;
var.ShaderType = EST_VERTEX_SHADER;
var.VariableName = "worldMatrix";
pipeline->addShaderAutoVariable(var);
std::cout << "Hello World" << std::endl;
ITimer* timer = device->createTimer();
timer->reset();
while (device->run())
{
const float clearColor[] = { 0.0f, 0.0f, 0.0f, 1.0f };
driver->beginScene(true, true, clearColor);
f32 dt = timer->tick();
//std::cout << dt << std::endl;
meshNode->setPosition(0, 0, -2.0f);
meshNode->yaw(1.0f * dt);
smgr->drawAll();
//XMMATRIX world = meshNode->getAbsoluteTransformation();
//pipeline->setMatrix("worldMatrix", reinterpret_cast<f32*>(&world));
driver->endScene();
}
return 0;
}
示例6: allKeysUp
void CSceneNodeAnimatorCameraFPS::animateNode(ISceneNode* node, UINT32 timeMs)
{
if (!node || node->getType() != ESNT_CAMERA)
return;
ICameraSceneNode* camera = static_cast<ICameraSceneNode*>(node);
if (firstUpdate)
{
camera->updateAbsolutePosition();
if (CursorControl)
{
CursorControl->setPosition(0.5f, 0.5f);
CursorPos = CenterCursor = CursorControl->getRelativePosition();
}
LastAnimationTime = timeMs;
firstUpdate = false;
}
// If the camera isn't the active camera, and receiving input, then don't process it.
if (!camera->isInputReceiverEnabled())
{
firstInput = true;
return;
}
if (firstInput)
{
allKeysUp();
firstInput = false;
}
ISceneManager * smgr = camera->getSceneManager();
if (smgr && smgr->getActiveCamera() != camera)
return;
// get time
FLOAT32 timeDiff = (FLOAT32)(timeMs - LastAnimationTime);
LastAnimationTime = timeMs;
// update position
Vector3 pos = camera->getPosition();
// Update rotation
Vector3 target = (camera->getTarget() - camera->getAbsolutePosition());
Vector3 relativeRotation = target.getHorizontalAngle();
if (CursorControl)
{
if (CursorPos != CenterCursor)
{
relativeRotation.y -= (0.5f - CursorPos.x) * RotateSpeed;
relativeRotation.x -= (0.5f - CursorPos.y) * RotateSpeed * MouseYDirection;
// X < MaxVerticalAngle or X > 360-MaxVerticalAngle
if (relativeRotation.x > MaxVerticalAngle * 2 &&
relativeRotation.x < 360.0f - MaxVerticalAngle)
{
relativeRotation.x = 360.0f - MaxVerticalAngle;
}
else
if (relativeRotation.x > MaxVerticalAngle &&
relativeRotation.x < 360.0f - MaxVerticalAngle)
{
relativeRotation.x = MaxVerticalAngle;
}
// Do the fix as normal, special case below
// reset cursor position to the centre of the window.
CursorControl->setPosition(0.5f, 0.5f);
CenterCursor = CursorControl->getRelativePosition();
// needed to avoid problems when the event receiver is disabled
CursorPos = CenterCursor;
}
// Special case, mouse is whipped outside of window before it can update.
IVideoDriver* driver = smgr->getVideoDriver();
Vector2 mousepos(UINT32(CursorControl->getPosition().x), UINT32(CursorControl->getPosition().y));
rect<UINT32> screenRect(0, 0, driver->getScreenSize().Width, driver->getScreenSize().Height);
// Only if we are moving outside quickly.
bool reset = !screenRect.isPointInside(mousepos);
if (reset)
{
// Force a reset.
CursorControl->setPosition(0.5f, 0.5f);
CenterCursor = CursorControl->getRelativePosition();
CursorPos = CenterCursor;
}
}
// set target
target.set(0, 0, Math::_max<Real>(1.f, pos.length()));
Vector3 movedir = target;
//.........这里部分代码省略.........
示例7: 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);
}
示例8: sceneNodeAnimator
/** Test functionality of the ISceneNodeAnimator implementations. */
bool sceneNodeAnimator(void)
{
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(160, 120));
assert_log(device);
if(!device)
return false;
ISceneManager * smgr = device->getSceneManager();
// Test the hasFinished() method.
ISceneNodeAnimatorCollisionResponse* collisionResponseAnimator
= smgr->createCollisionResponseAnimator(0, 0);
ISceneNodeAnimator* deleteAnimator = smgr->createDeleteAnimator(1);
ISceneNodeAnimator* flyCircleAnimator = smgr->createFlyCircleAnimator();
ISceneNodeAnimator* flyStraightAnimator
= smgr->createFlyStraightAnimator(vector3df(0, 0, 0), vector3df(0, 0, 0), 1, false);
ISceneNodeAnimator* flyStraightAnimatorLooping
= smgr->createFlyStraightAnimator(vector3df(0, 0, 0), vector3df(0, 0, 0), 1, true);
ISceneNodeAnimator* rotationAnimator = smgr->createRotationAnimator(vector3df(0, 0, 0));
array<vector3df> points;
points.push_back(vector3df(0, 0, 0));
points.push_back(vector3df(0, 0, 0));
ISceneNodeAnimator* followSplineAnimator = smgr->createFollowSplineAnimator(0, points, 1000.f);
array<video::ITexture*> textures;
textures.push_back(0);
textures.push_back(0);
ISceneNodeAnimator* textureAnimator = smgr->createTextureAnimator(textures, 1, false);
ISceneNodeAnimator* textureAnimatorLooping = smgr->createTextureAnimator(textures, 1, true);
bool result = true;
ISceneNode * deletedNode = smgr->addEmptySceneNode();
deletedNode->addAnimator(deleteAnimator);
ISceneNode * testNode = smgr->addEmptySceneNode();
testNode->addAnimator(collisionResponseAnimator);
testNode->addAnimator(deleteAnimator);
testNode->addAnimator(flyCircleAnimator);
testNode->addAnimator(flyStraightAnimator);
testNode->addAnimator(flyStraightAnimatorLooping);
testNode->addAnimator(rotationAnimator);
testNode->addAnimator(followSplineAnimator);
testNode->addAnimator(textureAnimator);
testNode->addAnimator(textureAnimatorLooping);
result &= !collisionResponseAnimator->hasFinished();
result &= !deleteAnimator->hasFinished();
result &= !flyCircleAnimator->hasFinished();
result &= !flyStraightAnimator->hasFinished();
result &= !flyStraightAnimatorLooping->hasFinished();
result &= !rotationAnimator->hasFinished();
result &= !followSplineAnimator->hasFinished();
result &= !textureAnimator->hasFinished();
result &= !textureAnimatorLooping->hasFinished();
device->run();
device->sleep(10);
device->run();
smgr->drawAll();
// These animators don't have an endpoint.
result &= !collisionResponseAnimator->hasFinished();
result &= !flyCircleAnimator->hasFinished();
result &= !rotationAnimator->hasFinished();
result &= !followSplineAnimator->hasFinished();
// These animators are looping and so can't finish.
result &= !flyStraightAnimatorLooping->hasFinished();
result &= !textureAnimatorLooping->hasFinished();
// These have an endpoint and have reached it.
result &= deleteAnimator->hasFinished();
result &= flyStraightAnimator->hasFinished();
result &= textureAnimator->hasFinished();
collisionResponseAnimator->drop();
deleteAnimator->drop();
flyCircleAnimator->drop();
flyStraightAnimator->drop();
flyStraightAnimatorLooping->drop();
rotationAnimator->drop();
followSplineAnimator->drop();
textureAnimator->drop();
textureAnimatorLooping->drop();
device->closeDevice();
device->run();
device->drop();
if(!result)
{
//.........这里部分代码省略.........
示例9: run
bool Editor::run(IrrlichtDevice* irr_device,Configuration* conf)
{
// Do Irrlicht Stuff
device = irr_device;
IVideoDriver *driver = device->getVideoDriver();
ISceneManager *smgr = device->getSceneManager();
IGUIEnvironment *guienv = device->getGUIEnvironment();
device->setEventReceiver(this);
device->setWindowCaption(L"Node Box Editor");
if (!conf->getBool("fullscreen")) {
device->setResizable(true);
}
// Project and state
Project *proj = new Project();
state = new EditorState(device, proj, conf);
// Menu State
state->menu = new MenuState(state);
// Add editor modes
state->AddMode(new NBEditor(state));
state->AddMode(new NodeEditor(state));
// Set up project
proj->AddNode(state, true, false);
// Load user interface
LoadScene();
state->SelectMode(0);
int LastX = driver->getScreenSize().Width;
if (!state->settings->getBool("hide_sidebar")) {
LastX -= 256;
}
int LastY = driver->getScreenSize().Height;
#ifdef _DEBUG
int lastFPS = -1;
#endif
bool dosleep = state->settings->getBool("use_sleep");
u32 last = std::clock();
double dtime = 0;
while (device->run()) {
if (state->NeedsClose()) {
device->closeDevice();
return true;
}
driver->beginScene(true, true, irr::video::SColor(255, 150, 150, 150));
int ResX = driver->getScreenSize().Width;
if (!state->settings->getBool("hide_sidebar"))
ResX -= 256;
int ResY = driver->getScreenSize().Height;
if (currentWindow == -1) {
// Draw Camera 0
if (camera[0]) {
smgr->setActiveCamera(camera[0]);
rect<s32> offset = rect<s32>(0, 0, ResX/2, ResY/2);
driver->setViewPort(offset);
smgr->drawAll();
if (state->Mode())
state->Mode()->viewportTick(VIEW_PERS, driver, offset);
}
// Draw Camera 1
if (camera[1]) {
smgr->setActiveCamera(camera[1]);
rect<s32> offset = rect<s32>(ResX/2, 0, ResX, ResY/2);
driver->setViewPort(offset);
smgr->drawAll();
if (state->Mode())
state->Mode()->viewportTick(VIEW_XZ, driver, offset);
}
// Draw Camera 2
if (camera[2]) {
smgr->setActiveCamera(camera[2]);
rect<s32> offset = rect<s32>(0, ResY/2, ResX/2, ResY);
driver->setViewPort(offset);
smgr->drawAll();
if (state->Mode())
state->Mode()->viewportTick(VIEW_XY, driver, offset);
}
// Draw Camera 3
if (camera[3]) {
smgr->setActiveCamera(camera[3]);
rect<s32> offset = rect<s32>(ResX/2, ResY/2, ResX, ResY);
driver->setViewPort(offset);
smgr->drawAll();
//.........这里部分代码省略.........
示例10: main
int main()
{
Input input;
IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D9, dimension2d<u32>(800, 600), 16, false, true, false, &input);
device->setWindowCaption(L"Seas of Gold");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
E_DRIVER_TYPE driverType = driverChoiceConsole();
EffectHandler *effect = new EffectHandler(device, driver->getScreenSize(), false, true);
E_FILTER_TYPE filterType = (E_FILTER_TYPE)core::clamp<u32>((u32)3 - '1', 0, 4);
int skyR = 30, skyG = 30, skyB = 70;
int timer = 0;
SColor sky = SColor(255, skyR, skyG, skyB);
float plPos_x = 0.0f, plPos_y = 0.0f, plPos_z = 0.0f;
bool updateCam = true;
bool menu1 = false;
int state = Main;
LoadMap loadMap;
Player player;
Interface playerInterface(driver);
ITriangleSelector* selector = 0;
ISceneNodeAnimator* anim = 0;
// Load the map scene
//loadMap.Load(smgr, device, Map_Africa);
//loadMap.Load(smgr, device, Map_India);
//loadMap.Load(smgr, device, selector, plyrNode, anim, Map_England);
IAnimatedMeshSceneNode* plyrNode = player.loadPlayerNode(device, smgr);
//plyrNode->setDebugDataVisible((scene::E_DEBUG_SCENE_TYPE)(plyrNode->isDebugDataVisible() ^ scene::EDS_BBOX));
ICameraSceneNode* camera = smgr->addCameraSceneNode(0, plyrNode->getPosition() + vector3df(0, 2, 2), vector3df(0, 0, 100));
loadMap.Load(smgr, device, selector, plyrNode, anim, Map_England);
//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 -----//
//.........这里部分代码省略.........
示例11: saveScene
// Tests save scene.
static bool saveScene(void)
{
IrrlichtDevice *device = createDevice( EDT_NULL, dimension2d<u32>(160, 120), 32);
assert_log(device);
if (!device)
return false;
ISceneManager * smgr = device->getSceneManager();
ISkinnedMesh* mesh = (ISkinnedMesh*)smgr->getMesh("../media/ninja.b3d");
if (!mesh)
return false;
IAnimatedMeshSceneNode* node1 = smgr->addAnimatedMeshSceneNode(mesh);
if (node1)
{
node1->setPosition(vector3df(-3, -3, 10));
node1->setMaterialFlag(EMF_LIGHTING, false);
node1->setAnimationSpeed(0.f);
node1->setCurrentFrame(10.f);
node1->setDebugDataVisible(irr::scene::EDS_BBOX_BUFFERS);
}
ISkinnedMesh* mesh2 = (ISkinnedMesh*)smgr->getMesh(device->getFileSystem()->getAbsolutePath("../media/dwarf.x"));
if (!mesh2)
return false;
IAnimatedMeshSceneNode* node2 = smgr->addAnimatedMeshSceneNode(mesh2);
if (node2)
{
node2->setPosition(vector3df(33, -93, 120));
node2->setMaterialFlag(EMF_LIGHTING, false);
node2->setAnimationSpeed(10.f);
node2->setCurrentFrame(2.f);
}
IAnimatedMeshSceneNode* node3 = smgr->addAnimatedMeshSceneNode(mesh2, node2);
if (node3)
{
node3->setPosition(vector3df(-88, -300, 150));
node3->setMaterialFlag(EMF_LIGHTING, false);
node3->setAnimationSpeed(0.f);
node3->setCurrentFrame(12.f);
}
smgr->addCameraSceneNode();
logTestString("Test scene.irr");
smgr->saveScene("results/scene.irr");
bool result = xmlCompareFiles(device->getFileSystem(), "results/scene.irr", "media/scene.irr");
logTestString("Test scene2.irr");
smgr->saveScene("results/scene2.irr", 0, node3);
result &= xmlCompareFiles(device->getFileSystem(), "results/scene2.irr", "media/scene2.irr");
device->closeDevice();
device->run();
device->drop();
return result;
}
示例12: main
int main(int argc, char* argv[])
{
// In CHRONO engine, The DLL_CreateGlobals() - DLL_DeleteGlobals(); pair is needed if
// global functions are needed.
DLL_CreateGlobals();
// Create the IRRLICHT context (device, etc.)
IrrlichtDevice* device = createDevice(video::EDT_DIRECT3D9, core::dimension2d<u32>(640, 480), 24, false, false, true);
if (device == 0)
{
GetLog() << "Cannot use DirectX - switch to OpenGL \n";
device = createDevice(video::EDT_OPENGL, core::dimension2d<u32>(640, 480));
if (!device) return 1;
}
device->setWindowCaption(L"SIMPLIEST example of integration of Chrono::Engine and Irrlicht");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* msceneManager = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
// Easy shortcuts to add logo, camera, lights and sky in Irrlicht scene:
ChIrrWizard::add_typical_Logo(device);
ChIrrWizard::add_typical_Sky(device);
ChIrrWizard::add_typical_Lights(device);
ChIrrWizard::add_typical_Camera(device, core::vector3df(0,0,-6));
//
// HERE YOU CREATE THE MECHANICAL SYSTEM OF CHRONO...
//
// 1- Create a ChronoENGINE physical system: all bodies and constraints
// will be handled by this ChSystem object.
ChSystem my_system;
// 2- Create the rigid bodies of the slider-crank mechanical system
// (a crank, a rod, a truss), maybe setting position/mass/inertias of
// their center of mass (COG) etc.
// ..the truss
ChSharedBodyPtr my_body_A(new ChBody);
my_system.AddBody(my_body_A);
my_body_A->SetBodyFixed(true); // truss does not move!
// ..the crank
ChSharedBodyPtr my_body_B(new ChBody);
my_system.AddBody(my_body_B);
my_body_B->SetPos(ChVector<>(1,0,0)); // position of COG of crank
// ..the rod
ChSharedBodyPtr my_body_C(new ChBody);
my_system.AddBody(my_body_C);
my_body_C->SetPos(ChVector<>(4,0,0)); // position of COG of rod
// 3- Create constraints: the mechanical joints between the
// rigid bodies.
// .. a revolute joint between crank and rod
ChSharedPtr<ChLinkLockRevolute> my_link_BC(new ChLinkLockRevolute);
my_link_BC->Initialize(my_body_B, my_body_C, ChCoordsys<>(ChVector<>(2,0,0)));
my_system.AddLink(my_link_BC);
// .. a slider joint between rod and truss
ChSharedPtr<ChLinkLockPointLine> my_link_CA(new ChLinkLockPointLine);
my_link_CA->Initialize(my_body_C, my_body_A, ChCoordsys<>(ChVector<>(6,0,0)));
my_system.AddLink(my_link_CA);
// .. an engine between crank and truss
ChSharedPtr<ChLinkEngine> my_link_AB(new ChLinkEngine);
my_link_AB->Initialize(my_body_A, my_body_B, ChCoordsys<>(ChVector<>(0,0,0)));
my_link_AB->Set_eng_mode(ChLinkEngine::ENG_MODE_SPEED);
if (ChFunction_Const* mfun = dynamic_cast<ChFunction_Const*>(my_link_AB->Get_spe_funct()))
mfun->Set_yconst(CH_C_PI); // speed w=3.145 rad/sec
my_system.AddLink(my_link_AB);
//
// THE SOFT-REAL-TIME CYCLE, SHOWING THE SIMULATION
//
// This will help choosing an integration step which matches the
// real-time step of the simulation..
ChRealtimeStepTimer m_realtime_timer;
bool removed = false;
while(device->run())
{
// Irrlicht must prepare frame to draw
driver->beginScene(true, true, SColor(255,140,161,192));
//.........这里部分代码省略.........
示例13: main
int main()
{
// ask user for driver
E_DRIVER_TYPE driverType = driverChoiceConsole();
if (driverType == EDT_COUNT)
return 1;
// create device
Myinput receiver;
//create a joystickInfo array to store joy buttons
array<SJoystickInfo> joystickInfo;
//Create an Irrlicht device to run our program with
IrrlichtDevice* device = createDevice(driverType, core::dimension2d<u32>(800, 720), 32, false, false, false, &receiver);
//If device failed.
if (device == 0)
return EXIT_FAILURE; // could not create selected driver.
//Create movement, **this would be changed to the world class later
movement movement(receiver, joystickInfo, device);
//Create a video display Driver
IVideoDriver* driver = device->getVideoDriver();
//Create a scene manager for the objects and camera
ISceneManager* smgr = device->getSceneManager();
// Create a level and load it in.
Level levelOne(device, driver, smgr);
levelOne.loadLevel();
//adds a camera to the scene
smgr->addCameraSceneNode(0, vector3df(0, 30, -40), vector3df(0, 5, 0));
//Detects plugged in joysticks.
movement.detectJoy();
//Testing out a FPS limit
u32 startTime;
u32 endTime;
u32 lockFPS = 1000 / 30; //Locks to 30 FPS; denominator = wanted FPS
//Main Game Loop
while (device->run())
{
startTime = device->getTimer()->getTime();
//Detect movement and inputs
movement.detectInput();
//Begins the scene for the player...displays all the things.
driver->beginScene(true, true, SColor(100, 70, 70, 70));
smgr->drawAll();
device->getGUIEnvironment()->drawAll();
driver->endScene();
endTime = device->getTimer()->getTime();
if ((endTime - startTime) < lockFPS)
device->sleep(lockFPS - (endTime - startTime));
}
device->drop();
return EXIT_SUCCESS;
}