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.
Guest
Post
by Guest » Wed Jul 07, 2004 8:52 am
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
LordNaikon
Posts: 164 Joined: Wed May 05, 2004 5:34 pm
Location: Germany Berlin
Contact:
Post
by LordNaikon » Wed Jul 07, 2004 9:47 am
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
Last edited by
LordNaikon on Wed Jul 07, 2004 9:56 am, edited 1 time in total.
q|^.^|p beeing every time friendly to everyone
sys: 2500+Barton 512MB 6600GT WinXP
Guest
Post
by Guest » Wed Jul 07, 2004 9:55 am
It works! Thanks
LordNaikon
Posts: 164 Joined: Wed May 05, 2004 5:34 pm
Location: Germany Berlin
Contact:
Post
by LordNaikon » Wed Jul 07, 2004 9:57 am
everytime again
q|^.^|p beeing every time friendly to everyone
sys: 2500+Barton 512MB 6600GT WinXP
Endar
Posts: 145 Joined: Mon Jun 14, 2004 7:59 am
Post
by Endar » Wed Jul 07, 2004 11:00 am
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.
"The reputation of a thousand years may be determined by the conduct of one hour."
-Japanese Proverb
warui
Posts: 232 Joined: Wed Apr 14, 2004 12:06 pm
Location: Lodz, Poland
Contact:
Post
by warui » Wed Jul 07, 2004 11:16 am
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));
Endar
Posts: 145 Joined: Mon Jun 14, 2004 7:59 am
Post
by Endar » Wed Jul 07, 2004 11:48 am
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
)
"The reputation of a thousand years may be determined by the conduct of one hour."
-Japanese Proverb
Electron
Posts: 874 Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA
Post
by Electron » Wed Jul 07, 2004 12:52 pm
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
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Guest
Post
by Guest » Thu Jul 08, 2004 10:58 am
Thanks to all,
I have one more question to LordNaikom: where did You get that shotgun? Any links?
LordNaikon
Posts: 164 Joined: Wed May 05, 2004 5:34 pm
Location: Germany Berlin
Contact:
Post
by LordNaikon » Thu Jul 08, 2004 8:47 pm
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.
q|^.^|p beeing every time friendly to everyone
sys: 2500+Barton 512MB 6600GT WinXP
Th3one
Posts: 17 Joined: Fri Nov 25, 2005 11:43 am
Post
by Th3one » Sun Nov 27, 2005 12:08 am
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);
Guest
Post
by Guest » Sun Nov 27, 2005 1:06 am
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!
independentCreations
Posts: 24 Joined: Fri Oct 28, 2005 10:05 am
Location: Gold Coast, QLD, Australia
Post
by independentCreations » Sun Nov 27, 2005 7:24 am
must of went diggin for that 1 th3one, year and a half. i hope guest solved this allready
"do it, do it now"
Th3one
Posts: 17 Joined: Fri Nov 25, 2005 11:43 am
Post
by Th3one » Sun Nov 27, 2005 12:32 pm
hehe yea...but surely it'll help the likes of me that were searching for the solution
magisterrivus
Posts: 33 Joined: Sat Aug 05, 2006 9:46 pm
Post
by magisterrivus » Thu Aug 17, 2006 6:11 pm
A little addition to this 2yrs old code
Code: Select all
crosshair->setMaterialFlag(video::EMF_ZBUFFER, false);
under construction