Page 1 of 3

weapon

Posted: Mon Dec 18, 2006 7:50 pm
by jimowns
hey
now i'm trying to add weapon intro my source code .
i maded a code to see my wapen .
but i add the code and i can see my weapon but not by me .
i 'm trying to make a weapon on my richt side so i can see it .
i add here my code .
but i realy dont know whats wrong in it .
( sorry for my bad english )

here is my own code

Code: Select all

IAnimatedMesh* player_mesh = smgr->getMesh("Guns/AK-47.md2");                             
IAnimatedMeshSceneNode* player_node = smgr->addAnimatedMeshSceneNode( player_mesh );

weapon_mesh->drop(); 
weapon_node->setScale(core::vector3df(0.25,0.25,0.25));

Posted: Mon Dec 18, 2006 9:21 pm
by JP
Don't drop the weapon mesh, you shouldn't do that unless you've called weapon_mesh->grab() and i doubt you'll want to be doing that yet. You can see in IUnknown in the API a little explanation on when to call drop and when not to i think. basically if your object has been created with a createXXX() function call you DON'T drop it, but if it's been created with an addXXX() function call then you DO drop it.

To solve your problem you just have to use weapon_mesh->setPosition(vector3df(x,y,z))

try small values for each of x y and z until you get the gun placed right, basically trial and error!

Posted: Mon Dec 18, 2006 9:41 pm
by jimowns
i did what you sayd but its keep dropping it

Code: Select all

IAnimatedMesh* weapon_mesh = smgr->getMesh("3Ddata/Guns/AK-47.md2");               
IAnimatedMeshSceneNode* weapon_node = smgr->addAnimatedMeshSceneNode(weapon_mesh); 

weapon_mesh->grab(); 
weapon_mesh->setPosition(core::vector3df(50,20,80));

Posted: Mon Dec 18, 2006 10:03 pm
by zeno60
grab() does not mean your player will physically grab the weapon. You are also setting the position of the mesh, you must set the position of the node.

IAnimatedMesh* weapon_mesh = smgr->getMesh("3Ddata/Guns/AK-47.md2");
IAnimatedMeshSceneNode* weapon_node = smgr->addAnimatedMeshSceneNode(weapon_mesh);

weapon_node->setParent(player_node);
weapon_node->setPosition(core::vector3df(*,*,*));
// * = your own values

Posted: Mon Dec 18, 2006 10:43 pm
by JP
Yeah that's my bad about telling you to set the position of the mesh! I wasn't thinking much whilst typing! But yeah you don't want to be calling grab i shouldn't think, there are times when you would want to but this isnt one of them and i guess in time you'll learn when you would need to, generally you just dont need to so just forget about it for now ;)

Posted: Tue Dec 19, 2006 12:14 pm
by jimowns
i tryd what zeno60 syad and its not working .

i testing other codes but i can't find it whats the probelm is .

Code: Select all

IAnimatedMesh* player_mesh = smgr->getMesh("3Ddata/Guns/test.md2");
IAnimatedMeshSceneNode* player_node = smgr->addAnimatedMeshSceneNode( player_mesh ); 

IAnimatedMesh* weapon_mesh = smgr->getMesh("3Ddata/Guns/weapon2.md2"); 
IAnimatedMeshSceneNode* weapon_node = smgr->addAnimatedMeshSceneNode(weapon_mesh); 

weapon_node->setParent(player_node); 
weapon_node->setPosition(core::vector3df(-200,-150,-150)); 

Posted: Tue Dec 19, 2006 12:32 pm
by JP
What's the problem you're having? the gun's not lining up with the player properly? Have you tried varying the position you set the gun to?

Posted: Tue Dec 19, 2006 12:42 pm
by jimowns
if a looks on the ground i see my weapon on the grond .
but if i move my weapon dont moving .

Posted: Tue Dec 19, 2006 4:06 pm
by jimowns
please can someone help me .
i try that code and its keep dropping my gun .

Posted: Tue Dec 19, 2006 5:00 pm
by zeno60
Are you trying to attach the gun to the player_node or to the camera? (Hint: I told you how to attach it to the player_node, you should be able to figure out, if you wanted to, how to attach it to the camera)

Use the search link on the forums and try searching for "attach and gun and camera."

Posted: Tue Dec 19, 2006 5:03 pm
by jimowns
normaly i'm trying to get my gun on my richt side of my screen .
like counter strike and more schooter games.

Posted: Wed Dec 20, 2006 6:01 pm
by blendermen
If somebody has problem with that:

http://irrwizard.sourceforge.net/wiki/i ... g_a_weapon


black on white

Posted: Wed Dec 20, 2006 6:45 pm
by jimowns
its giveing me so many errors

Code: Select all

------ Build started: Project: Project1, Configuration: Debug Win32 ------
Compiling...
game.cpp
.\game.cpp(89) : error C2065: 'pManager' : undeclared identifier
.\game.cpp(89) : error C2227: left of '->getDevice' must point to class/struct/union/generic type
        type is ''unknown-type''
.\game.cpp(89) : error C2227: left of '->getSceneManager' must point to class/struct/union/generic type
.\game.cpp(89) : error C2227: left of '->getMesh' must point to class/struct/union/generic type
.\game.cpp(90) : error C2227: left of '->getDevice' must point to class/struct/union/generic type
        type is ''unknown-type''
.\game.cpp(90) : error C2227: left of '->getSceneManager' must point to class/struct/union/generic type
.\game.cpp(90) : error C2227: left of '->addAnimatedMeshSceneNode' must point to class/struct/union/generic type
.\game.cpp(90) : error C2227: left of '->getSceneManager' must point to class/struct/union/generic type
        type is ''unknown-type''
.\game.cpp(90) : error C2227: left of '->getActiveCamera' must point to class/struct/union/generic type
.\game.cpp(93) : error C2227: left of '->getDevice' must point to class/struct/union/generic type
        type is ''unknown-type''
.\game.cpp(94) : error C2227: left of '->getVideoDriver' must point to class/struct/union/generic type
.\game.cpp(94) : error C2227: left of '->getTexture' must point to class/struct/union/generic type
.\game.cpp(98) : error C2227: left of '->getSceneManager' must point to class/struct/union/generic type
        type is ''unknown-type''
.\game.cpp(98) : error C2227: left of '->getActiveCamera' must point to class/struct/union/generic type
Build log was saved at "file://c:\Documents and Settings\Eigenaar\Bureaublad\Counter strike 9.0 my game\Project1\Debug\BuildLog.htm"
Project1 - 14 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Posted: Wed Dec 20, 2006 7:29 pm
by zeno60
You cannot copy and paste that code into your own project and expect it to work without knowing what it does, you really need to take some C++ lessons, these are all basic C++ problems you are facing.

Posted: Wed Dec 20, 2006 7:42 pm
by jimowns
i only can programming in Console , this is my first 1 week in irrlicht .
but is there not a tutorial for irrlicht ?