Crosshair help

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.
Gameswhiz
Posts: 10
Joined: Thu Jul 01, 2004 6:39 pm

Crosshair help

Post by Gameswhiz »

Hi,

This is my first post so be gentle.I am creating a little demo thing to see what I can do in irrlicht and I decided on a first person shooter where you just have one level, two guys and you control one and you shoot each other.I was thinking about the crosshair and I was wondering if I could use a billboard to make the crosshair? What do you think?
Thanks,

Alex
VPB
Posts: 36
Joined: Sat Apr 10, 2004 8:02 am

Post by VPB »

Why not just draw a 2Dpic in the middle, or where ever the crosshair is supposed to be 8)
Gameswhiz
Posts: 10
Joined: Thu Jul 01, 2004 6:39 pm

reply

Post by Gameswhiz »

So is there a way to change the cursor using a bitmap image like make it a + instead of an arrow or is this not possible? Also should I use a billboard for the weapon(s)?
bal
Posts: 829
Joined: Fri Jun 18, 2004 5:19 pm
Location: Geluwe, Belgium

Re: reply

Post by bal »

Gameswhiz wrote:So is there a way to change the cursor using a bitmap image like make it a + instead of an arrow or is this not possible? Also should I use a billboard for the weapon(s)?
3-4 days ago I asked exactly the same. You have to make your weapon child of the camera and then place it good.

Code: Select all

scene::ICameraSceneNode* camera = sm->addCameraSceneNodeFPS(); 
scene::IAnimatedMesh* weaponMesh;
scene::IAnimatedMeshSceneNode* weaponNode;
weaponMesh = sm->getMesh("ak47.x");  //Your Mesh is loaded here
weaponNode = sm->addAnimatedMeshSceneNode(weaponMesh, camera, -1);  //optionaly here, you could set the initial pos, rot, and scale in that order 

// Your animation speed may be different so play with the value
weaponNode->setAnimationSpeed(20);

// The next few lines are the ones that have to be hand 
// tweaked and you may not at first see your weapon.
// The values below reflect my weapon setting to see
// it in front of me. My weapon had to be rotated 180
// degrees as thats how I modeled it and didnt want
// to rerig it and reanimate it.
weaponNode->setScale(core::vector3df(14,14,14));
weaponNode->setPosition(core::vector3df(15,-10,30));
weaponNode->setRotation(core::vector3df(180,0,180)); 
A little note: creating a game is a lot harder than it seems, even a demo :)
Gameswhiz
Posts: 10
Joined: Thu Jul 01, 2004 6:39 pm

Reply

Post by Gameswhiz »

Thanks for that I'll be able to do it now.I guess I can have some fun now with my shotgun model and the homer simpson model I got from polycount heh.I'll see you guys around and thanks for the help.
Endar
Posts: 145
Joined: Mon Jun 14, 2004 7:59 am

Re: Reply

Post by Endar »

Gameswhiz wrote:Thanks for that I'll be able to do it now.I guess I can have some fun now with my shotgun model and the homer simpson model I got from polycount heh.I'll see you guys around and thanks for the help.
What file format is the shotgun model?
"The reputation of a thousand years may be determined by the conduct of one hour."
-Japanese Proverb
Gameswhiz
Posts: 10
Joined: Thu Jul 01, 2004 6:39 pm

reply

Post by Gameswhiz »

All the models that I use are in the md2 format.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

This is code I use to draw simple crosshair in my demo:

Code: Select all

driver->draw2DRectangle( irr::video::SColor(100,255,100,100), irr::core::rect<s32>(300,299,500,301) );
      driver->draw2DRectangle( irr::video::SColor(100,255,100,100), irr::core::rect<s32>(399,200,401,400) );
Gameswhiz
Posts: 10
Joined: Thu Jul 01, 2004 6:39 pm

Reply

Post by Gameswhiz »

Really is that all the code you needed to add? Just draw to rectangls? Seems too easy really.
l0calh05t
Posts: 68
Joined: Wed Apr 07, 2004 7:08 pm

Re: Reply

Post by l0calh05t »

Gameswhiz wrote:Really is that all the code you needed to add? Just draw to rectangls? Seems too easy really.
it is easy

for example for a new cursor:
core::position2d<s32> m = device->getCursorControl()->getPosition();
driver->draw2DImage (cursor, core::position2d<s32>(m.X,m.Y), core::rect<s32>(0,0,64,64), 0, video::SColor(255,255,255,255), true);

is pretty much all you need (of course you have to hide the original cursor and load a texture for cursor
Raw data for raw nerves

My main PC: Athlon XP 2800+, 512MB RAM, ATI Radeon 9700 Pro 128MB, Win2k SP4
My secondary PC: Pentium III 500 Mhz, 256MB RAM, TNT2 64, Gentoo Linux
warui
Posts: 232
Joined: Wed Apr 14, 2004 12:06 pm
Location: Lodz, Poland
Contact:

Re: Reply

Post by warui »

Gameswhiz wrote:Really is that all the code you needed to add? Just draw to rectangls? Seems too easy really.
If you find it too easy you can always do it in more complicated way ;)
Tomasz Nowakowski
Openoko - www.openoko.pl
Gameswhiz
Posts: 10
Joined: Thu Jul 01, 2004 6:39 pm

Post by Gameswhiz »

This is code I use to draw simple crosshair in my demo:

code:
--------------------------------------------------------------------------------
driver->draw2DRectangle( irr::video::SColor(100,255,100,100), irr::core::rect<s32>(300,299,500,301) );
driver->draw2DRectangle( irr::video::SColor(100,255,100,100), irr::core::rect<s32>(399,200,401,400) );
Hi, I got the crosshair in the middle using draw2DRectangle but how do I resize the rectangle? Also I am still have trouble rendering the gun infront of the camera all the time.I have created the node and loaded the mesh and texture but now what?
Gameswhiz
Posts: 10
Joined: Thu Jul 01, 2004 6:39 pm

re:

Post by Gameswhiz »

no one knows the answer? I really need this to get my project back on track.I just wanna know how to make a node the child of another node and how to change the size of a rectangle in the function draw2DRectangle().
Thanks,
Alex
bal
Posts: 829
Joined: Fri Jun 18, 2004 5:19 pm
Location: Geluwe, Belgium

Post by bal »

I learned this from other guys on this forum and they are so right: http://irrlicht.sourceforge.net/docu/index.html
Gameswhiz
Posts: 10
Joined: Thu Jul 01, 2004 6:39 pm

re:

Post by Gameswhiz »

Code: Select all

driver->draw2DLine(position2d<320>, position2d<330>);
It could be a dumb question but does anyone know what is wrong with that?
Post Reply