Exemplo n.º 1
0
 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;
}
Exemplo n.º 2
0
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);
}
Exemplo n.º 3
0
/*
That's it. The Scene node is done. Now we simply have to start
the engine, create the scene node and a camera, and look at the result.
*/
int main()
{
	// create engine and camera

	IrrlichtDevice *device =
		createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640, 480), 16, false);

	device->setWindowCaption(L"Custom Scene Node - Irrlicht Engine Demo");

	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();

	smgr->addCameraSceneNode(0, core::vector3df(0,-40,0), core::vector3df(0,0,0));

	/*
	Create our scene node. Note that it is dropped (->drop()) instantly after 
	we create it. This is possible because the scene manager now takes
	care of it. This is not nessecary, it would also be possible to drop it
	at the end of the program.
	*/

	CSampleSceneNode *myNode = 
		new CSampleSceneNode(smgr->getRootSceneNode(), smgr, 666);

	myNode->drop();

	/*
	To animate something in this boring scene consisting only of one tetraeder,
	and to show, that you now can use your scene node like any other scene
	node in the engine, we add an animator to the scene node, which rotates
	the node a little bit.
	*/

	scene::ISceneNodeAnimator* anim = 
		smgr->createRotationAnimator(core::vector3df(0.8f, 0, 0.8f));

	myNode->addAnimator(anim);
	anim->drop();

	/* 
	Now draw everything and finish.
	*/

	while(device->run())
	{
		driver->beginScene(true, true, video::SColor(0,100,100,100));

		smgr->drawAll();

		driver->endScene();
	}

	device->drop();
	
	return 0;
}
Exemplo n.º 4
0
int main() 
{

	// driver type 
	video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D9;

	// create device 
	IrrlichtDevice *device = createDevice(driverType, core::dimension2d<u32>(640, 480), 16, false );

	if ( device == 0 ) 
	{
		return 1;
	}

	// create engine and camera 
	device->setWindowCaption(L"Custom Scene Node - Irrlicht Engine Demo ");

	video::IVideoDriver *driver = device->getVideoDriver();
	scene::ISceneManager *smgr  = device->getSceneManager();

	smgr->addCameraSceneNode(0, core::vector3df(0,-40,0), core::vector3df(0,0,0));


	CSampleSceneNode *myNode = new CSampleSceneNode(smgr->getRootSceneNode(), smgr, 666);

	scene::ISceneNodeAnimator *anim = smgr->createRotationAnimator(core::vector3df(0.8f, 0, 0.8f));
	if (anim) 
	{
		myNode->addAnimator(anim);
		anim->drop();
		anim  = 0; // ensure i can not refer to it again.
	}

	myNode->drop();
	myNode = 0; // ensure i can not refer to it again.

	// draw everything 
	u32 frames = 0;
	while (device->run())
	{
		driver->beginScene(true, true, video::SColor(0, 100, 100, 100));
		smgr->drawAll();

		driver->endScene();

		if (++frames==100)
		{
			core::stringw str = L"Irrlicht Engine [";
			str += driver->getName();
			str += L"] FPS: ";
			str += (s32)driver->getFPS();
			
			device->setWindowCaption(str.c_str());
			frames = 0;
		}
	}

	driver->drop();

	return 0;

}
Exemplo n.º 5
0
/*
That's it. The Scene node is done. Now we simply have to start
the engine, create the scene node and a camera, and look at the result.
*/
int main()
{
	// ask user for driver
	video::E_DRIVER_TYPE driverType=driverChoiceConsole();
	if (driverType==video::EDT_COUNT)
		return 1;

	// create device

	IrrlichtDevice *device = createDevice(driverType,
			core::dimension2d<u32>(640, 480), 16, false);
		
	if (device == 0)
		return 1; // could not create selected driver.

	// create engine and camera

	device->setWindowCaption(L"Custom Scene Node - Irrlicht Engine Demo");

	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();

	smgr->addCameraSceneNode(0, core::vector3df(0,-40,0), core::vector3df(0,0,0));

	/*
	Create our scene node. I don't check the result of calling new, as it
	should throw an exception rather than returning 0 on failure. Because
	the new node will create itself with a reference count of 1, and then
	will have another reference added by its parent scene node when it is
	added to the scene, I need to drop my reference to it. Best practice is
	to drop it only *after* I have finished using it, regardless of what
	the reference count of the object is after creation.
	*/
	CSampleSceneNode *myNode =
		new CSampleSceneNode(smgr->getRootSceneNode(), smgr, 666);

	/*
	To animate something in this boring scene consisting only of one
	tetraeder, and to show that you now can use your scene node like any
	other scene node in the engine, we add an animator to the scene node,
	which rotates the node a little bit.
	irr::scene::ISceneManager::createRotationAnimator() could return 0, so
	should be checked.
	*/
	scene::ISceneNodeAnimator* anim =
		smgr->createRotationAnimator(core::vector3df(0.8f, 0, 0.8f));

	if(anim)
	{
		myNode->addAnimator(anim);
		
		/*
		I'm done referring to anim, so must
		irr::IReferenceCounted::drop() this reference now because it
		was produced by a createFoo() function. As I shouldn't refer to
		it again, ensure that I can't by setting to 0.
		*/
		anim->drop();
		anim = 0;
	}

	/*
	I'm done with my CSampleSceneNode object, and so must drop my reference.
	This won't delete the object, yet, because it is still attached to the
	scene graph, which prevents the deletion until the graph is deleted or the
	custom scene node is removed from it.
	*/
	myNode->drop();
	myNode = 0; // As I shouldn't refer to it again, ensure that I can't

        Skybox skybox(smgr, driver);
	/*
	Now draw everything and finish.
	*/
	u32 frames=0;
	while(device->run())
	{
		driver->beginScene(true, true, video::SColor(0,100,100,100));

		smgr->drawAll();

		driver->endScene();
		if (++frames==100)
		{
			core::stringw str = L"Irrlicht Engine [";
			str += driver->getName();
			str += L"] FPS: ";
			str += (s32)driver->getFPS();

			device->setWindowCaption(str.c_str());
			frames=0;
		}
	}

	device->drop();
	
	return 0;
}
Exemplo n.º 6
0
/*
That's it. The Scene node is done. Now we simply have to start
the engine, create the scene node and a camera, and look at the result.
*/
int mainA(int npars,char*pars[])
{
	if(npars>1)
		{
		nsides=atoi(pars[1]);
		std::cout<<"parameter read - "<<nsides<<std::endl;
		}
	else
		nsides=1;


	// set the driver to open GL
		video::E_DRIVER_TYPE driverType=video::EDT_OPENGL;

	// create device

		IrrlichtDevice *device = createDevice(driverType,
				core::dimension2d<u32>(640, 480), 16, false);

		if (device == 0)
			return 1; // could not create selected driver.

	// create engine and camera

		device->setWindowCaption(L"Coaster Track Demo - Irrlicht");

		video::IVideoDriver* driver = device->getVideoDriver();
		scene::ISceneManager* smgr = device->getSceneManager();

		irr::scene::ICameraSceneNode*camera;
		#if 0
			camera=smgr->addCameraSceneNode(0, core::vector3df(0,-40,0), core::vector3df(0,0,0));
		#else
			SKeyMap keyMap[8];
			keyMap[0].Action = EKA_MOVE_FORWARD;
			keyMap[0].KeyCode = KEY_UP;
			keyMap[1].Action = EKA_MOVE_FORWARD;
			keyMap[1].KeyCode = KEY_KEY_W;

			keyMap[2].Action = EKA_MOVE_BACKWARD;
			keyMap[2].KeyCode = KEY_DOWN;
			keyMap[3].Action = EKA_MOVE_BACKWARD;
			keyMap[3].KeyCode = KEY_KEY_S;

			keyMap[4].Action = EKA_STRAFE_LEFT;
			keyMap[4].KeyCode = KEY_LEFT;
			keyMap[5].Action = EKA_STRAFE_LEFT;
			keyMap[5].KeyCode = KEY_KEY_A;

			keyMap[6].Action = EKA_STRAFE_RIGHT;
			keyMap[6].KeyCode = KEY_RIGHT;
			keyMap[7].Action = EKA_STRAFE_RIGHT;
			keyMap[7].KeyCode = KEY_KEY_D;
			camera = smgr->addCameraSceneNodeFPS(0, 100, 500, -1, keyMap, 8);
			#endif



	//initialize the control points
		core::vector3d<float> controlpts[4];
		core::vector3d<float> ups[4];
		#if 1
		controlpts[0]=core::vector3d<float>(0.0f,0.0f,0.0f);
		controlpts[1]=core::vector3d<float>(0.0f,0.0f,20.0f);
		controlpts[2]=core::vector3d<float>(0.0f,20.0f,20.0f);
		controlpts[3]=core::vector3d<float>(20.0f,20.0f,20.0f);
		#else
		controlpts[0]=core::vector3d<float>(20.0f,0.0f,0.0f);
		controlpts[1]=core::vector3d<float>(20.0f,10.0f,0.0f);
		controlpts[2]=core::vector3d<float>(10.0f,20.0f,0.0f);
		controlpts[3]=core::vector3d<float>(0.0f,20.0f,0.0f);
		#endif
		{
		int i=0;
		ups[i]=core::vector3d<float>(0,1,0);	ups[i].normalize();	i++;
		ups[i]=core::vector3d<float>(0,0,-1);	ups[i].normalize();	i++;
		ups[i]=core::vector3d<float>(1,0,0);	ups[i].normalize();	i++;
		ups[i]=core::vector3d<float>(0,-1,0);	ups[i].normalize();	i++;
		}


	//**********************************
	//set up the quaternion for rotation
	//**********************************
		float axisangle=45;	//angle of rotation in degrees
				////float axisangle=90/12;	//angle of rotation in degrees
		float axisradians=axisangle*3.1415927/180;
		float axishalfradians=axisradians/2;
		core::vector3df axis(0,1,0);
		axis.normalize();
		core::quaternion q;
		q.fromAngleAxis(axisradians,axis);
		q.W=-q.W;
		core::quaternion qinv=q;
		qinv.makeInverse();

	//set up the point quat
		core::quaternion qpoint(1,0,0,0);

	//do rotation sequence
		core::quaternion qfinal;
		qfinal=qinv*qpoint;
		qfinal=qfinal*q;	//this is the final step and gives you the rotated point

	//print the results of the custom axis rotation
		std::cout<<"******** Custom Axis Rotation ********"<<std::endl;
		std::cout<<"\tAxis: <"<<axis.X<<","<<axis.Y<<","<<axis.Z<<">"<<std::endl;
		std::cout<<"\tAngle(deg): "<<axisangle<<std::endl;
		std::cout<<"\tP: <"<<qpoint.X<<","<<qpoint.Y<<","<<qpoint.Z<<">"<<std::endl;
		std::cout<<"\tP': <"<<qfinal.X<<","<<qfinal.Y<<","<<qfinal.Z<<">"<<std::endl;
		std::cout<<"******** /Custom Axis Rotation ********"<<std::endl;

	/*
	Create our scene node. I don't check the result of calling new, as it
	should throw an exception rather than returning 0 on failure. Because
	the new node will create itself with a reference count of 1, and then
	will have another reference added by its parent scene node when it is
	added to the scene, I need to drop my reference to it. Best practice is
	to drop it only *after* I have finished using it, regardless of what
	the reference count of the object is after creation.
	*/
		CSampleSceneNode *myNode =
			new CSampleSceneNode(smgr->getRootSceneNode(), smgr, 666,controlpts,ups,4);

	/*
	To animate something in this boring scene consisting only of one
	tetraeder, and to show that you now can use your scene node like any
	other scene node in the engine, we add an animator to the scene node,
	which rotates the node a little bit.
	irr::scene::ISceneManager::createRotationAnimator() could return 0, so
	should be checked.
	*/
	scene::ISceneNodeAnimator* anim =
		smgr->createRotationAnimator(core::vector3df(0.0f, 0.0f, 0.0f));

	if(anim)
	{
		myNode->addAnimator(anim);

	/*
	I'm done referring to anim, so must
	irr::IReferenceCounted::drop() this reference now because it
	was produced by a createFoo() function. As I shouldn't refer to
	it again, ensure that I can't by setting to 0.
	*/
		anim->drop();
		anim = 0;
	}

	/*
	I'm done with my CSampleSceneNode object, and so must drop my reference.
	This won't delete the object, yet, because it is still attached to the
	scene graph, which prevents the deletion until the graph is deleted or the
	custom scene node is removed from it.
	*/
		myNode->drop();
		myNode = 0; // As I shouldn't refer to it again, ensure that I can't

	/*
	Now draw everything and finish.
	*/
		u32 frames=0;
		while(device->run())
		{
			driver->beginScene(true, true, video::SColor(0,100,100,100));

			smgr->drawAll();

			driver->endScene();
			if (++frames==100)
			{
				core::stringw str = L"Irrlicht Engine [";
				str += driver->getName();
				str += L"] FPS: ";
				str += (s32)driver->getFPS();

				device->setWindowCaption(str.c_str());
				frames=0;
			}
		}

		device->drop();

		return 0;
}