Page 1 of 1
Crosshair
Posted: Wed Jul 07, 2004 8:52 am
by Guest
Hello,
I'm new here and I have a question: how can I add a crosshair. Please send some code
PS: Please excuse my bad english
1024x768
Posted: Wed Jul 07, 2004 9:47 am
by LordNaikon
for a solution of 1024x768
Code: Select all
driver->draw2DRectangle( irr::video::SColor(100,100,200,100), irr::core::rect<s32>(511,372,513,378) ); //above
driver->draw2DRectangle( irr::video::SColor(100,100,200,100), irr::core::rect<s32>(518,383,524,385) ); //right
driver->draw2DRectangle( irr::video::SColor(100,100,200,100), irr::core::rect<s32>(511,390,513,396) ); //down
driver->draw2DRectangle( irr::video::SColor(100,100,200,100), irr::core::rect<s32>(500,383,506,385) ); //left
looks like this
Posted: Wed Jul 07, 2004 9:55 am
by Guest
It works! Thanks
Posted: Wed Jul 07, 2004 9:57 am
by LordNaikon
everytime again
Posted: Wed Jul 07, 2004 11:00 am
by Endar
What you could also do, because you have to account for other screen sizes, if you want the cross hair in the middle of the screen, you can do something like:
Code: Select all
irr::core::position2d<irr::f32> pos = Cursor->getRelativePosition();
// keep cursor in the middle of the screen
pos.X = 0.5f;
pos.Y = 0.5f;
Cursor->setPosition(pos);
This will position the cursor in the middle of the screen.
Posted: Wed Jul 07, 2004 11:16 am
by warui
Why you get position of a cursor and then overwrite it with new valuse. To keep cursor in the meedle of the screen this is sufficient:
Code: Select all
Cursor->setPosition(irr::core::position2d<irr::f32>(0.5f,0.5f));
Posted: Wed Jul 07, 2004 11:48 am
by Endar
Oh, yeah, okay. That does make more sense.
I was just changing someone else's code, which generally I do on a mostly line by line basis, because its occasionally hard to see where someone is going with it. (occasionally, but admitedly not in this case
)
Posted: Wed Jul 07, 2004 12:52 pm
by Electron
If you use a camera that traps the cursor, it may jump around a bit more than you'd want a crosshair to. I haven't actually tried it, so maybe it wouldn't be a problem, but the cursor with the irrlicht fps camera appears to jump around a bit
Posted: Thu Jul 08, 2004 10:58 am
by Guest
Thanks to all,
I have one more question to LordNaikom: where did You get that shotgun? Any links?
Posted: Thu Jul 08, 2004 8:47 pm
by LordNaikon
i know you would ask that question
, but i have to say i don't know where i get that shotgun sry. i am also searching of free model stuff all around.
Posted: Sun Nov 27, 2005 12:08 am
by Th3one
This'l add your crosshair no probs buddy....
Code: Select all
scene::ISceneNode* crosshair = 0;
crosshair = smgr->addBillboardSceneNode(crosshair,
core::dimension2d<f32>(10, 10));
crosshair->setMaterialFlag(video::EMF_LIGHTING, false);
crosshair->setMaterialTexture(0, driver->getTexture
("../../Textures/crosshair1.bmp"));
crosshair->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
crosshair->setPosition(core::vector3df(0,0,150));
camera->addChild(crosshair);
Posted: Sun Nov 27, 2005 1:06 am
by Guest
sorry mate but this thread is a _little_ old
(lets say 1,5 years) - the thread owner will have found the solution already after such a long time i guess
see you!
Posted: Sun Nov 27, 2005 7:24 am
by independentCreations
must of went diggin for that 1 th3one, year and a half. i hope guest solved this allready
Posted: Sun Nov 27, 2005 12:32 pm
by Th3one
hehe yea...but surely it'll help the likes of me that were searching for the solution
Posted: Thu Aug 17, 2006 6:11 pm
by magisterrivus
A little addition to this 2yrs old code
Code: Select all
crosshair->setMaterialFlag(video::EMF_ZBUFFER, false);