splitscreen new stuff added!

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

your card is quite a good one. Consider perhaps a cpu upgrade. Although we should create stuff that runs on low end pcs, or better said, keeping low end pcs in mind. That's why they say you shouldn't develp stuff on a state-of-the-art pc, but a standard one.

I wish there were a way to optimize things even more so that they ran on any system but unfortunately, day by day, games and apps are more demanding on hardware specs leaving a big bunch of users out of the possibility to enjoy such games/apps.

Yesterday I loaded a more complex model, with a higher poly count and it really hogged my resources!!!

Image

so it's all relative. Now I got to create an optimized version of this model for the app to run better.
Image
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

BTW, I forgot to explain:

A 2d cartoon artist came to us with the need of turning his 2d cartoon into a 3d model in order to build a 4meter tall inflatable dummy. I modeled it and created a whole set of technical drawings for it, and as an extra, a nice walkthru in Irrlicht!!!



Image

Image
Image
angel80
Posts: 22
Joined: Mon Feb 07, 2005 1:37 pm
Location: Paris (France)

Post by angel80 »

hi afecelis,
I'm student, I'd like to programming a software for a virtual reality room, to do I need to programming a stereoscopic view (bigger screen spliting in 2, as the eyes) , I know how to do it in GLUT but Irrlicht don't use it. So can u post your code of spliting screen with irrlicht? please. It would be very helpfull for me.
Thank a lot
Franck
.: Franck :.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

hi Franck!

I used the same code from the splitscreen tutorial here:
http://irrlicht.sourceforge.net/tut009b.html

check it and see if it helps. I only added a few things but nothing in the graphic part, only some bool keys to toggle stuff on and off. Let me know if it helped and if you'd still need the code (since I think I lost that project in a hard drive break up )
:cry:

take care
angel80
Posts: 22
Joined: Mon Feb 07, 2005 1:37 pm
Location: Paris (France)

I succeded with the tutorial

Post by angel80 »

First, thank for your answer
Then I succeded to make the tutorial work,
Now I must compute to make the stereoscopic vision
Thank for your help
.: Franck :.
MikeR
Posts: 767
Joined: Sun Dec 26, 2004 4:03 pm
Location: Northern California USA
Contact:

Post by MikeR »

Wow, Al, that is a great demo. I especially like the fact that I could use "esc" to close the app. (beats unplugging my puter)
Would you post the code you used for the "esc" function?
If it exists in the real world, it can be created in 3d

Sys specs:
AMD 3700+ 64 processor
1.0 gb ram
e-Geforce 6600 graphics 256 mb onboard ram
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

@Franck and Mike: in case you may need any extra stuff: (ps. be careful if you get compiling errors, they will be due to the fact I'm using "My3d" files so you would need the "My3d" source and header as well. Just check the part of the bool keys (for esc):

Code: Select all

//Afecelis-Irrlicht SplitScreen-Example compiling with MSVC toolkit 2003 + the Relo IDE
//Copyright © 2004 Alvaro F. Celis "afecelis"
//Based on Max Winkel's splitscreen tutorial
//Using Zdimitor's My3d format and loader
//Music from the Gasoline demo by RECREATION : 'GASOLINE 2' : 2001, composed by Spector
 
/*  The Irrlicht Engine License
Copyright © 2002-2003 Nikolaus Gebhardt
 
This software is provided 'as-is', without any express or implied warranty. 
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, 
and to alter it and redistribute it freely, subject to the following restrictions:
1.The origin of this software must not be misrepresented; you must not claim that you wrote the original software. 
If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2.Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3.This notice may not be removed or altered from any source distribution.*/

//-----------------------------------------------------------------------------------------------//
//headers
#include <irrlicht.h>
#include <audiere.h>
#include <iostream>
#include <stdio.h>
#include <wchar.h>
#include <windows.h> 
#include "CMY3DMeshFileLoader.h"
 
//-----------------------------------------------------------------------------------------------//	
//Namespaces for the engine
using namespace irr;
using namespace audiere;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
 
#pragma comment(lib, "Irrlicht.lib")
#pragma comment (lib, "audiere.lib") 
 
ILogger* logger=NULL;
ICameraSceneNode *MayaCam, *NormalCam; 	
 
//-----------------------------------------------------------------------------------------------//	
//Resolution
#define ResX 800
#define ResY 600
#define fullScreen false
 
//-----------------------------------------------------------------------------------------------//	
//Use SplitScreen-cameras-wireframe?
//bool fullScreen = false;
bool SplitScreen = true;	
bool Mayacam = false;
bool Normalcam = false;
bool WireFrame = false;	
bool progDeath = false;
bool dark = false;
bool fog = false;	
bool particles = false;
 
//-----------------------------------------------------------------------------------------------//	
//cameras
ICameraSceneNode *camera[4] = {0,0,0,0}; 
 
//-----------------------------------------------------------------------------------------------//	
//added by jox: to make it available in the event receiver 
IrrlichtDevice *device;
 
//-----------------------------------------------------------------------------------------------//	
//Eventreceiver
class MyEventReceiver : public IEventReceiver 
{
public:
	virtual bool OnEvent(SEvent event)
	{
		//Esc to quit
		if (event.EventType == EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown){
    			switch(event.KeyInput.Key){
      			case KEY_ESCAPE:{
        			return progDeath = true;
      		}break;
			} 
  		return false;
		}	
		
		//Key P enables/disables Particles
		if (event.KeyInput.Key == KEY_KEY_P && event.KeyInput.PressedDown)
	 	{
	   	particles = !particles;
	   	return true;
	    	}			
		
		//Key S enables/disables SplitScreen
		if (event.KeyInput.Key == KEY_KEY_S && event.KeyInput.PressedDown)
	 	{
	   	SplitScreen = !SplitScreen;
	   	return true;
	    	}	
 
		//Key M enables Maya camera
   	if (event.KeyInput.Key == KEY_KEY_M && event.KeyInput.PressedDown)
    	{
      	camera[3] = MayaCam;
 
	  // jox: make cursor visible
	  		device->getCursorControl()->setVisible(true); 
      	return true;
       	} 
		
		//Key N enables fps cam
   	if (event.KeyInput.Key == KEY_KEY_N && event.KeyInput.PressedDown)
    	{
      	camera[3] = NormalCam;
 
	  // jox: make cursor invisible
      	device->getCursorControl()->setVisible(false);
      	return true;
       	} 
   	
		//Key W enables WireFrame
		if (event.KeyInput.Key == KEY_KEY_W && event.KeyInput.PressedDown)
	 	{
	   	WireFrame = !WireFrame;
	   	return true;
	    	}
	   
	   //Key L enables light
		if (event.KeyInput.Key == KEY_KEY_L && event.KeyInput.PressedDown)
	 	{
	   	dark = !dark;
	   	return true;
	    	}
	    	
	   //Key F enables fog
		if (event.KeyInput.Key == KEY_KEY_F && event.KeyInput.PressedDown)
	 	{
	   	fog = !fog;
	   	return true;
	    	}
 
		//Send all other events to camera4
	 	if (camera[3])
	 		camera[3]->OnEvent(event);
	 		return false;
	  		}	 	
		}; 
 
//-----------------------------------------------------------------------------------------------//	
//main function
int main()
{
	//Instance of the EventReceiver
	MyEventReceiver receiver;
 
//-----------------------------------------------------------------------------------------------//	
	//Initialize the engine
	device = createDevice(EDT_OPENGL,dimension2d<s32>(ResX,ResY),32,fullScreen,true,false,&receiver);
	ISceneManager* smgr = device->getSceneManager();
	IVideoDriver* driver = device->getVideoDriver();
	io::IFileSystem* fs = device->getFileSystem();
	logger = device->getLogger();  
	driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);	
	
//-----------------------------------------------------------------------------------------------//
	//initialize audio
	AudioDevicePtr audiereDevice;
	OutputStreamPtr stream;
	 
		audiereDevice = OpenDevice();
			if (!audiereDevice)
				return 1;
	 
		stream = OpenSound(audiereDevice.get(), "./data/murikka.mp3", true);
			if (!stream)
				return 2;
	 
	stream->setRepeat(true);
	stream->setVolume(1.0f); // 50% volume
	stream->play(); 	
 
//-----------------------------------------------------------------------------------------------//	   
	//add 3d model
	scene::IAnimatedMesh* sydneymesh = 0;
	sydneymesh = smgr->getMesh("./data/sydney.md2");
	smgr->getMeshManipulator()->makePlanarTextureMapping(sydneymesh->getMesh(0), 0.008f);
	 
	scene::IAnimatedMeshSceneNode* sydneynode = 0;
	sydneynode = smgr->addAnimatedMeshSceneNode(sydneymesh);
	sydneynode->setScale(vector3df(8,8,8));
	sydneynode->setPosition(core::vector3df(0,200,0));//1st=pos in x2nd=pos in y 3rd=pos in z
	sydneynode->setRotation(core::vector3df(0,0,0));	
	sydneynode->setMaterialTexture(0, driver->getTexture("./data/sydney.bmp"));
	sydneynode->setMaterialFlag(video::EMF_LIGHTING, true);	
	sydneynode->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); //makes it transparent
	sydneynode->getMaterial(0).EmissiveColor.set(0,0,255,0); //makes it emissive
	sydneynode->addShadowVolumeSceneNode();	
	smgr->setShadowColor(video::SColor(220,0,0,0));  
 
//-----------------------------------------------------------------------------------------------//
	//rotate animator for sydney
	scene::ISceneNodeAnimator* sydneyanim = 0;
	sydneyanim = smgr->createRotationAnimator(core::vector3df(0, -1, 0));
	sydneynode->addAnimator(sydneyanim);
	sydneyanim->drop();	
	 
//-----------------------------------------------------------------------------------------------//	
	//load room model using Zdimitor's My3d format and loader
	scene::IMeshLoader* my3dloader = 0;
	my3dloader = new scene::CMY3DMeshFileLoader(fs,driver,smgr);
	smgr->addExternalMeshLoader(my3dloader);
	 
	scene::IAnimatedMesh* mesh3d = 0;
	mesh3d = smgr->getMesh("./data/ind.my3d");
	 
	scene::ISceneNode* meshnode = 0;    
	meshnode = smgr->addOctTreeSceneNode(mesh3d->getMesh(0));
	meshnode->setMaterialFlag(video::EMF_LIGHTING, false);
	//meshnode->setMaterialFlag(video::EMF_WIREFRAME,true);
	//meshnode->setMaterialType(video::EMT_SPHERE_MAP);	
	//meshnode->setMaterialType(video::EMT_LIGHTMAP_LIGHTING); //bsp affected by dynamic lights
	//meshnode->setMaterialType(video::EMT_SOLID); //shows only bsp	
	meshnode->setScale( irr::core::vector3df(5,5,5));
	meshnode->setRotation( irr::core::vector3df(0,0,0));
	//meshnode->setMaterialFlag(EMF_FOG_ENABLE,true); //enables fog
	//driver->setFog(SColor(0,0,125,0),true, 0,4000); //fog color-final values= amount of fog, distance

//-----------------------------------------------------------------------------------------------//	
	// create particle system
	scene::IParticleSystemSceneNode* ps = 0;		
	ps = smgr->addParticleSystemSceneNode(false);
	ps->setMaterialFlag(video::EMF_LIGHTING, false);
	ps->setPosition(core::vector3df(-100,550,250));
	ps->setScale(core::vector3df(5,5,5));
	ps->setParticleSize(core::dimension2d<f32>(20,20));
	ps->setMaterialTexture(0, driver->getTexture("./sprites/particle_white.bmp"));
	ps->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);
	
	scene::IParticleEmitter* emb = 0;
	emb = ps->createBoxEmitter(core::aabbox3d<f32>(-7.00f,0.00f,-7.00f,7.00f,1.00f,7.00f),
				core::vector3df(0.00f,0.03f,0.00f),100,250,
				video::SColor(0,0,255,100), 
				video::SColor(0,255,255,100),1000,2000,0);
	ps->setEmitter(emb);	
	emb->drop();
		
	scene::IParticleAffector* paf = 0;
	paf = ps->createFadeOutParticleAffector(video::SColor(0,0,0,0),1000);
	ps->addAffector(paf);
	paf->drop();
	
	scene::IParticleAffector* pgaf = 0;
	pgaf = ps->createGravityAffector(core::vector3df(0.15f,0.11f,0.00f),1000);	
	ps->addAffector(pgaf);
	pgaf->drop();

//___________________________________________________________________________________________________//
	// create light with animator	
	scene::ILightSceneNode* lightnode = 0;
	lightnode = smgr->addLightSceneNode(0, core::vector3df(0,0,0),
	video::SColorf(1.0f, 0.6f, 0.7f, 1.0f), 700.0f);
	scene::ISceneNodeAnimator* lightanim = 0;
	lightanim = smgr->createFlyCircleAnimator (core::vector3df(0,450,0),250.0f);//sets position as well
	lightnode->addAnimator(lightanim);
	lightanim->drop();
 
//___________________________________________________________________________________________________//	
	// attach billboard to light
	scene::IBillboardSceneNode* lightbill = 0;
	lightbill = smgr->addBillboardSceneNode(lightnode, core::dimension2d<f32>(150, 150));
	lightbill->setMaterialFlag(video::EMF_LIGHTING, false);
	lightbill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
	lightbill->setMaterialTexture(0, driver->getTexture("./sprites/23.bmp"));
	//lightbill->setPosition(core::vector3df(-200,70,-70));

//-----------------------------------------------------------------------------------------------//	 
//Create 3 fixed and one user-controlled cameras
	//Front
	camera[0] = smgr->addCameraSceneNode(0,vector3df(500,200,0),vector3df(0,0,0));
	camera[0]->setTarget(core::vector3df(0,200,0));
 
	//Top
	camera[1] = smgr->addCameraSceneNode(0,vector3df(0,700,0),vector3df(0,0,0));
	//Left
	camera[2] = smgr->addCameraSceneNode(0,vector3df(0,250,500),vector3df(0,0,0));
 
	//User-controlled
	camera[3] = smgr->addCameraSceneNodeFPS();
	camera[3]->setPosition(core::vector3df(-2000,200,0));
	camera[3]->setRotation(core::vector3df(0,90,0));
	camera[3]->setFarValue (50000.0f) ;
	camera[3]->setFOV(1.1f);
	camera[3]->setTarget(core::vector3df(-2000,200,0));	  
 
//-----------------------------------------------------------------------------------------------//	  
	//Hide mouse
	device->getCursorControl()->setVisible(false);
	
//-----------------------------------------------------------------------------------------------//	
	//select image-color for transparency
	video::ITexture* images = driver->getTexture("./data/2dbkg.bmp");
	driver->makeColorKeyTexture(images, core::position2d<s32>(0,0));
 
//-----------------------------------------------------------------------------------------------//	
//We want to count the fps
	int lastFPS = -1; 
 
	// jox: adjusted the settings a bit:
	MayaCam = smgr->addCameraSceneNodeMaya(0, -500.0f, 2000.0f, 1000.0f);
	MayaCam->setFarValue (50000.0f) ;	
 
	NormalCam = smgr->addCameraSceneNodeFPS();
	NormalCam->setPosition(core::vector3df(-2000,200,0));
	NormalCam->setRotation(core::vector3df(0,90,0));
	NormalCam->setFarValue (50000.0f);
	NormalCam->setFOV(1.1f);
	NormalCam->setTarget(core::vector3df(-2000,200,0));
	
	progDeath = false;
	
	dark = false;
	
	fog = true; 
	
	particles = true;
	
//While....	
	while(device->run()) 
	{
		//Set the viewpoint to the whole screen and begin scene
		driver->setViewPort(rect<s32>(0,0,ResX,ResY));
		driver->beginScene(true,true,SColor(0,90,90,90));//0,r,g,b
 
//-----------------------------------------------------------------------------------------------//		
	//If SplitScreen is used
	if (SplitScreen) 
	{
		
//-----------------------------------------------------------------------------------------------// 
		//Activate camera1
		smgr->setActiveCamera(camera[0]);
		//Set viewpoint to the first quarter (left top)
		driver->setViewPort(rect<s32>(0,0,ResX/2,ResY/2));
		//Draw scene
		smgr->drawAll();
		
//-----------------------------------------------------------------------------------------------// 
		// draw logo
	   driver->draw2DImage(images, core::position2d<s32>(650,550),
		core::rect<s32>(323,87,442,118)); 
		
//-----------------------------------------------------------------------------------------------//	
		//Activate camera2
		smgr->setActiveCamera(camera[1]);
		//Set viewpoint to the second quarter (right top)
		driver->setViewPort(rect<s32>(ResX/2,0,ResX,ResY/2));
		//Draw scene
		smgr->drawAll();
		
//-----------------------------------------------------------------------------------------------// 
		// draw logo
	   driver->draw2DImage(images, core::position2d<s32>(650,550),
		core::rect<s32>(323,87,442,118));  
		
//-----------------------------------------------------------------------------------------------//	
		//Activate camera3
		smgr->setActiveCamera(camera[2]);
		//Set viewpoint to the third quarter (left bottom)
		driver->setViewPort(rect<s32>(0,ResY/2,ResX/2,ResY));
		//Draw scene
		smgr->drawAll();		

//-----------------------------------------------------------------------------------------------// 
		// draw logo
	   driver->draw2DImage(images, core::position2d<s32>(650,550),
		core::rect<s32>(323,87,442,118));  
		
//-----------------------------------------------------------------------------------------------//	
		//Set viewport the last quarter (right bottom)
		driver->setViewPort(rect<s32>(ResX/2,ResY/2,ResX,ResY));
	}
	
//-----------------------------------------------------------------------------------------------//	
		//Activate camera4
		smgr->setActiveCamera(camera[3]);
		//Draw scene
		smgr->drawAll();
		
//-----------------------------------------------------------------------------------------------// 
		// draw logo
	   driver->draw2DImage(images, core::position2d<s32>(650,550),
		core::rect<s32>(323,87,442,118));  
		  		
//-----------------------------------------------------------------------------------------------//
 		// end scene
		driver->endScene();
		
//-----------------------------------------------------------------------------------------------//	
		//If Maya is used
		if (Mayacam) 
		//maya cam
		camera[3] = MayaCam;		
//-----------------------------------------------------------------------------------------------//	
		//If Normalcam is used
		if (Normalcam)
		//Normalcam
		camera[3] = NormalCam;		 
//-----------------------------------------------------------------------------------------------//	
		//Render in wireframe
		meshnode->setMaterialFlag(video::EMF_WIREFRAME,WireFrame); 
		sydneynode->setMaterialFlag(video::EMF_WIREFRAME,WireFrame); 
	
//-----------------------------------------------------------------------------------------------//		
		// Light on/off
		meshnode->setMaterialFlag(video::EMF_LIGHTING, dark);
		
//-----------------------------------------------------------------------------------------------//		
		// fog on/off
		meshnode->setMaterialFlag(video::EMF_FOG_ENABLE, fog);
		driver->setFog(SColor(0,0,125,0),true, 0,4000);
		
//-----------------------------------------------------------------------------------------------//		
		// particles on/off
		ps->setVisible(particles);		

//-----------------------------------------------------------------------------------------------//		
		// If Esc is used
		if(progDeath)
			{
	   		device->closeDevice(); 
      	}
 
//-----------------------------------------------------------------------------------------------//		    
	//Get and show fps
	if (driver->getFPS() != lastFPS) 
	{
	   lastFPS = driver->getFPS();
	   wchar_t tmp[1024];
	   swprintf(tmp,1024,L"Afecelis-Splitscreen Demo (FPS: %d)",lastFPS);
	   device->setWindowCaption(tmp);
	   }
	}
 
//-----------------------------------------------------------------------------------------------//	
  	 //Delete device
	device->drop(); 
	return 0;
	}
please forgive my coding sloppiness!!!! :oops:
MikeR
Posts: 767
Joined: Sun Dec 26, 2004 4:03 pm
Location: Northern California USA
Contact:

Post by MikeR »

Wow, that 1 post answered a lot of questions. :oops:
Thankyou. :)
If it exists in the real world, it can be created in 3d

Sys specs:
AMD 3700+ 64 processor
1.0 gb ram
e-Geforce 6600 graphics 256 mb onboard ram
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

really? well I'm glad it helped!!! It's sorta like my "Irrlicht" newbie graduation project, lol :D :D :D

too bad I haven't had much time to extend my knowledge because of real-life work (nor to write any new tuts), but I'm sure I'll catch up sometime...soon...I hope... prolly this year.


lol

the best part is that many people in the community helped me out with it; that's another thing I love about Irlicht.

take care
MikeR
Posts: 767
Joined: Sun Dec 26, 2004 4:03 pm
Location: Northern California USA
Contact:

Post by MikeR »

I know about the time thing...I'm working 100+ hours a week at my "day" job, so haven't had any time at all to work with irrlicht. :(
I have been reading about C++ tho, so at least my day isn't totally wasted. :lol:
If it exists in the real world, it can be created in 3d

Sys specs:
AMD 3700+ 64 processor
1.0 gb ram
e-Geforce 6600 graphics 256 mb onboard ram
angel80
Posts: 22
Joined: Mon Feb 07, 2005 1:37 pm
Location: Paris (France)

About cameras

Post by angel80 »

Hi, it's angel80 again
I would like to know if it possible to make a splitscreen with 2 FPS cameras which move together, I'd like to make a stereoscopic camera for the virtual reality room
And thank for your code afecelis
.: Franck :.
Post Reply