Hello all,
Im new to this engine and C++, but would like to put a 3ds model gun in the engine. Can anyone explain how to do this?
Inserting models such as a weapon into irrlicht
-
- Posts: 22
- Joined: Wed Jun 08, 2005 2:44 pm
Code: Select all
//! Adds a weapon model to the Players camera
//! The weapon must be aligned manualy due to different model origins etc.
//! Staff (staff.ms3d): Scale(5,5,5), Position(40,-40,40), Rotation(10,0,0)
//! Sword (sword.md2) : Scale(5,5,5), Position(40,-40,40), Rotation(10,0,0)
//! Mace (mace.md2) : Scale(1,1,1), Position(10,-20,0), Rotation(10,180,-65)
void CGamePlayer::AddFPSWeapon(IrrlichtDevice* pDevice)
{
// load FPS weapon to Camera
m_pWeaponMesh = pDevice->getSceneManager()->getMesh("media/models/morning_star.md2");
irr::scene::IAnimatedMeshSceneNode* m_pWeaponNode;
irr::scene::IAnimatedMeshMD2* m_pMd2WepMesh = static_cast<irr::scene::IAnimatedMeshMD2*>(m_pWeaponMesh);
m_pWeaponNode = pDevice->getSceneManager()->addAnimatedMeshSceneNode( m_pMd2WepMesh, getCamera(), -1);
m_pWeaponNode->setMaterialFlag(video::EMF_LIGHTING, false);
m_pWeaponNode->setMD2Animation(scene::EMAT_STAND);
m_pWeaponNode->setAnimationSpeed(60);
m_pWeaponNode->setMaterialTexture(0, pDevice->getVideoDriver()->getTexture("media/models/morning_star.bmp"));
// manualy position model based on origin, scale etc
m_pWeaponNode->setScale(core::vector3df(1,1,1)); //1,1,1
m_pWeaponNode->setPosition(core::vector3df(10,-20, 0)); //20,-20,0
m_pWeaponNode->setRotation(core::vector3df(10,180,-65)); //10,180,-65
}
________
Honda VTR250 history
Last edited by area51 on Tue Feb 22, 2011 1:05 pm, edited 1 time in total.
I wish people would put more effort into learning something themselfs before posting on the forums... Game Design is an artform and a rather complex skill or set of skills to learn and do and alot of people seem to have the dark basic idea about it.
as though it were as simple to build a game as it is to play it.
I think alot of the more elite programmers and designers should think more clearly about who what when where and why they are helping.
Just think to yourself maybe you are creating your compatition.
good luck getting a model into Irrlicht btw it's not like there aren't 12 or more examples of how to do it if you know how to READ.
sigh...
as though it were as simple to build a game as it is to play it.
I think alot of the more elite programmers and designers should think more clearly about who what when where and why they are helping.
Just think to yourself maybe you are creating your compatition.
good luck getting a model into Irrlicht btw it's not like there aren't 12 or more examples of how to do it if you know how to READ.
sigh...
Ok Midnight that is it .... Stop flaming and being such a clever "game designer & programmer"! Your problem is that you think you have made many games before (maybe u have ?) and u think u are a "mega-great-hyper - pro designer and programmer?" . If you are okay, i am proud of you, but stop complaining about other noobs and people, and if someone is asking about for example -> gun node with camera, which was asked thousand times, just show this person some code and help. (i think newbies in irrlicht wouldn't even think of searching the forums; they are making the new thread in which we could help such noobs will show them how alive this forum is - maybe they want to check if they won't be alone here)
Or if you think that NO ONE should release any form of code , because it is STEALING a lot of your hard work, try being on NETRUAL position , because you are too nervous on that i think. Just don't bother about that my friend.
PS Remember that many people are too ambitious this times, and they think they can make a little game on 2 days without hearing the name o programming : "c++"... Only thing they dont have is patience ...
Or if you think that NO ONE should release any form of code , because it is STEALING a lot of your hard work, try being on NETRUAL position , because you are too nervous on that i think. Just don't bother about that my friend.
PS Remember that many people are too ambitious this times, and they think they can make a little game on 2 days without hearing the name o programming : "c++"... Only thing they dont have is patience ...
Last edited by dawasw on Thu Jun 30, 2005 6:31 pm, edited 1 time in total.
You will need to create a "Hello world" type file, yes.
Here is some code that can be inserted after the camera is added to the SceneManager in the "Hello World" or "Quake 3 Map" tutorial:
The original code was a function I created, and would need to be modified slightly to work.
If you can't see your weapon at first, then change the position and rotation parameters as it could be behind or above the camera.
________
Zx14 Vs Hayabusa
Here is some code that can be inserted after the camera is added to the SceneManager in the "Hello World" or "Quake 3 Map" tutorial:
Code: Select all
// load FPS weapon to Camera
irr::scene::IAnimatedMesh* m_pWeaponMesh = smgr->getMesh("sword.3ds");
irr::scene::IAnimatedMeshSceneNode* m_pWeaponNode;
m_pWeaponNode = smgr->addAnimatedMeshSceneNode( m_pWeaponMesh, smgr->getActiveCamera(), -1);
m_pWeaponNode->setMaterialFlag(video::EMF_LIGHTING, false);
m_pWeaponNode->setMaterialTexture(0, driver->getTexture("sword.bmp"));
m_pWeaponNode->setScale(core::vector3df(1,1,1));
m_pWeaponNode->setPosition(core::vector3df(10,-20, 0));
m_pWeaponNode->setRotation(core::vector3df(10,180,-65));
If you can't see your weapon at first, then change the position and rotation parameters as it could be behind or above the camera.
________
Zx14 Vs Hayabusa