How to add weapon mesh to camera?

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.
Post Reply
systat
Posts: 41
Joined: Mon Jan 07, 2008 8:01 pm

How to add weapon mesh to camera?

Post by systat »

How to add weapon mesh to camera?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

look up to the very top of this page and click 'Search' ;)

this question's been asked a lot so you're sure to find the solution :)
Image Image Image
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

set parent

Post by 3DModelerMan »

You can set the camera as the weapons parent, I think the code works like this.

Code: Select all

 node->setParent("another node");
I'm pretty sure it's something like that, you might have to play around with it a little, cause I'm not as good at programming as modeling.
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
systat
Posts: 41
Joined: Mon Jan 07, 2008 8:01 pm

Post by systat »

I found it, I don't know why this happens, and how to fix, please any help :)
When I look down in the terrain, the part of the weapon is getting inside the terrain.

Image
Last edited by systat on Tue Jul 15, 2008 5:34 pm, edited 1 time in total.
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

try this

Post by 3DModelerMan »

Try putting a colision response animator on the weapon like in the collision example.
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

Actually, disabling the Z-Buffer on the gun may be a better idea
systat
Posts: 41
Joined: Mon Jan 07, 2008 8:01 pm

Post by systat »

I disabled Z-Buffer, but gun now looks weird.
I will try some other way.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Maybe you disabled the wrong z-buffer setting? Because that would overwrite the gun (partially). You have to disable the zbuffer test.
systat
Posts: 41
Joined: Mon Jan 07, 2008 8:01 pm

Post by systat »

OHh, I use this code

Code: Select all

weaponMesh=smgr->getMesh("data/marine_rifle.3ds"); 
	weaponNode = smgr->addAnimatedMeshSceneNode( weaponMesh, camera, -1 );
	 weaponNode->setScale(core::vector3df(6,6,6));
	 weaponNode->setMaterialTexture(0,driver->getTexture("data/marine_rifle.png"));
	 weaponNode->setMaterialFlag(EMF_LIGHTING,false);
	 weaponNode->setMaterialFlag(EMF_ZBUFFER,false);
   weaponNode->setPosition(vector3df(30,-52,100));
   weaponNode->setRotation(vector3df(0, 180,0)); 
And this is how my gun looks with it :(

Image
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

How about just scaling your gun down and repositioning it closer to the camera so that it looks the same size but is actually small enough to not go through objects?
Image Image Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, correct setting but due to the many mesh buffers your gun has it's not looking as expected.
Post Reply