Laser beam instead of crosshair

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
XFactor
Posts: 39
Joined: Fri Jun 03, 2005 5:30 am

Post by XFactor »

@Midnight
That looks very good. Good Job!. But can you position it better or are you gonna make me do that on my own? :wink:


Thanks.
IRRLICHT ROCKS!!!!
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

LMFAO the idea was for you do use the "HOW" to do your own stuff..like any demo...

The position is set to a position relative to the camera...which is bad.
(it's bad for laser sights which would always point the same way)

Also it seems the camera spins and the laser doesn't hence "relative".

it needs alot of work..I think you can handle that I have alot of work to do.

plus I havent exactly figuared out how to make the position more lasersights like.

it would have to come from the position on the model and extend forward a certain distance... but how to get the position??

maybe line.end = line.start + 10000... uhh yeah something like that. 8)
XFactor(notlogged)

Post by XFactor(notlogged) »

Ok. Thx Midnight. Ill take it from here :D
Guest

Post by Guest »

i did nice work i hope one day i can grow up and write something like that...
:p lol good job
XFactor
Posts: 39
Joined: Fri Jun 03, 2005 5:30 am

New Aprroach

Post by XFactor »

I've been working on this for a while now. A friend has been helping me out and this is what we got:

Code: Select all

void CDemo::run()
{
	device = createDevice(driverType,
		core::dimension2d<s32>(1024, 728), 32, fullscreen, shadows, vsync, this);

	//stuff(code)
	
	device->getFileSystem()->addZipFileArchive("irrlicht.dat");
	device->getFileSystem()->addZipFileArchive("media/irrlicht.dat");
	device->getFileSystem()->addZipFileArchive("jof3dm2-pka.pk3");
	device->getFileSystem()->addZipFileArchive("media/jof3dm2-pka.pk3");

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

	wchar_t tmp[255];
	
	scene::ISceneManager* sm = device->getSceneManager();
	core::vector3df camL;
	core::vector3df camPosition;
	core::vector3df camTarget;
	f32 camFarValue;
	
	while(device->run() && driver)
	{
		if (device->isWindowActive())
		{
			// load next scene if necessary
			u32 now = device->getTimer()->getTime();
			if (now - sceneStartTime > timeForThisScene && timeForThisScene!=-1)
				switchToNextScene();

			createParticleImpacts();

			// draw everything

			driver->beginScene(true, true, backColor);
				
			smgr->drawAll();
			guienv->drawAll();

			// get line of camera
			camera = sm->getActiveCamera(); 
			if (camera) 
			{
				camPosition = camera->getAbsolutePosition(); 
				camTarget   = camera->getTarget();
				camFarValue = camera->getFarValue();
			}

			core::vector3df start = camPosition;
			core::vector3df end = (camTarget - start);
			core::vector3df enddir = end;
            enddir.normalize(); 
 
			start += enddir*15.0f;
			end = start + (enddir * camFarValue);

			matrix4 mat;
			driver->setTransform(ETS_WORLD,mat);
 	        driver->draw3DLine(start, end, SColor(255,100,100,200));

			driver->endScene();

			// write statistics

			swprintf(tmp, 255, L"%s fps:%d", driver->getName(),	driver->getFPS());

			statusText->setText(tmp);			
		}
	}

	device->drop();
}
But the laser is not drawn. Can you help me?

Thanks
IRRLICHT ROCKS!!!!
me = discreet

Post by me = discreet »

Its basically the code i wrote...
me = XFactor

Post by me = XFactor »

Where did you write that? I didnt see it. Also, can you help me fix it please? The line doesnt show. Thanks
XFactor (not logged)

Post by XFactor (not logged) »

bump
Skyclad Monkey
Posts: 3
Joined: Wed Oct 13, 2004 9:43 pm

Post by Skyclad Monkey »

Nice one Midnight.
Who are you that walks across the graves of giants at this late hour
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

oh sorry wow that was nearly a month ago...I'll try to jazz it up... ya know I need to do a 3rd person camera or something with a model and stuff...think I'll work on that a few days add in the laser on my own model or something. 8)
Post Reply