shooting help (figuring it out myself)

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
Xenxe
Posts: 43
Joined: Sat Jan 26, 2008 9:54 pm
Location: U.S.A. Wasington

shooting help (figuring it out myself)

Post by Xenxe »

okay i need help figuring out how to make the bullet in my scene do what the fireball does in the demo (comes from camera hits a wall dissapears)
but whithout the particle effects

basicly i need to know how to set a straight line animator calculate the position from the camera to where im looking then create a formula to how long its going to be to get there so ive studied the demo but there are all these confusing variable and functions i dont know how to deal whith so if anyone can help me it would be greatly appreaciated

oh yeah heres the code im using:

Code: Select all

#include <irrlicht.h>
#include <irrklang.h>
#include <iostream>

using namespace irr;

#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif


int main()
{
	


	IrrlichtDevice *device =
		createDevice(video::EDT_DIRECT3D9, core::dimension2d<s32>(640, 480), 16, true);
		
	
	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();

	
	device->getFileSystem()->addZipFileArchive("../media/map-20kdm2.pk3");

	
	scene::IAnimatedMesh* q3levelmesh = smgr->getMesh("20kdm2.bsp");
	scene::ISceneNode* q3node = 0;

	scene::IAnimatedMesh* pistol = smgr->getMesh("../media/pistol.3ds");
	scene::ISceneNode* pistolnode = 0;

	if (q3levelmesh)
		q3node = smgr->addOctTreeSceneNode(q3levelmesh->getMesh(0));

	if (pistol)
		pistolnode = smgr->addOctTreeSceneNode(pistol->getMesh(0));
	
	scene::IAnimatedMesh* pbullet = smgr->getMesh("../media/pistol bullet.3ds");
	scene::ISceneNode* bulletnode = 0;

	if (pbullet)
		bulletnode = smgr->addOctTreeSceneNode(pbullet->getMesh(0));




	

	scene::ITriangleSelector* selector = 0;
	pistolnode->setPosition(core::vector3df(5,17,10));
	if (q3node)
	{		
		q3node->setPosition(core::vector3df(-1350,-140,-1410));

		selector = smgr->createOctTreeTriangleSelector(q3levelmesh->getMesh(0), q3node, 128);
		q3node->setTriangleSelector(selector);
	}


	
	scene::ICameraSceneNode* camera = 
		smgr->addCameraSceneNodeFPS(0, 100.0f, 300.0f, -1, 0, 0, true);
	camera->setPosition(core::vector3df(0,50,0));

	if (selector)
	{
		scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
			selector, camera, core::vector3df(30,50,30),
			core::vector3df(0,-3,0), 
			core::vector3df(0,50,0));
		selector->drop();
		camera->addAnimator(anim);
		anim->drop();
	}

	
	

	device->getCursorControl()->setVisible(false);

	scene::ISceneNode* selectedSceneNode = 0;
	scene::ISceneNode* lastSelectedSceneNode = 0;

	pistolnode->setParent(camera);
	
	int lastFPS = -1;

	while(device->run())
	if (device->isWindowActive())
	{
		
		driver->beginScene(true, true, 0);

		smgr->drawAll();
	
		driver->endScene();

		int fps = driver->getFPS();

		if (lastFPS != fps)
		{
		  core::stringw str = L"test[";
		  str += driver->getName();
		  str += "] FPS:";
		  str += fps;

		  device->setWindowCaption(str.c_str());
		  lastFPS = fps;
		}
	}

	device->drop();
	
	return 0;
}

Last edited by Xenxe on Mon Feb 04, 2008 2:23 am, edited 3 times in total.
who else here is 14?
But confused about many things.
(\__/)
(='.'=) world domination!!!
(")_(")
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Re: shooting help

Post by rogerborg »

Xenxe wrote:ive studied the demo but there are all these confusing variable and functions i dont know how to deal whith so if anyone can help me it would be greatly appreaciated
Uh... help you with what, exactly? Which part of it is giving you trouble?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Xenxe
Posts: 43
Joined: Sat Jan 26, 2008 9:54 pm
Location: U.S.A. Wasington

Post by Xenxe »

to make the pistol shoot the bulletss ive already loaded the pistol and the bullet into a node
who else here is 14?
But confused about many things.
(\__/)
(='.'=) world domination!!!
(")_(")
Xenxe
Posts: 43
Joined: Sat Jan 26, 2008 9:54 pm
Location: U.S.A. Wasington

Post by Xenxe »

anyone its been 45 minutes
who else here is 14?
But confused about many things.
(\__/)
(='.'=) world domination!!!
(")_(")
zeno60
Posts: 342
Joined: Sun May 21, 2006 2:48 am
Location: NC, USA
Contact:

Post by zeno60 »

Xenxe wrote:anyone its been 45 minutes
45 Minutes you could have spent looking at the CDemo.cpp in the examples /Demo folder. It contains the function used for the Irr-Demo: shoot() which does exactly that. You say you have loaded the bullet & pistol, so the code to move said bullet is in that cpp file. Commented reasonably with hardly cryptic variable names: (start & end, hmmm...what would those mean?).
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Xenxe wrote:anyone its been 45 minutes
If you really don't enjoy figuring out how to solve problems by yourself, then you're going to have a short and miserable career as a software developer, because that is what it is all about.

I'm done with you now.

Image
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Xenxe
Posts: 43
Joined: Sat Jan 26, 2008 9:54 pm
Location: U.S.A. Wasington

Post by Xenxe »

I studied the demo and i do try to solve my problems
Xenxe wrote: basicly i need to know how to set a straight line animator calculate the position from the camera to where im looking then create a formula to how long its going to be to get there so ive studied the demo but there are all these confusing variable and functions i dont know how to deal whith so if anyone can help me it would be greatly appreaciated
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=26074
Xenxe wrote:i at least try to solve my problems before i post them!!!
i came here for help so im sorry for all the questions im just trying to learn
rogerborg wrote: If you really don't enjoy figuring out how to solve problems by yourself, then you're going to have a short and miserable career as a software developer, because that is what it is all about.
and no, who does like problems, im bymyself in this game developer thing right now and i have no help but your own

so i come for help in my endevor not for problems

isnt that what this forums for

but your right i should try harder to solve my problem thats why im going to use newton i heard that it is pretty easy to intergrate whith irrlicht and the game will be better that way anyway
who else here is 14?
But confused about many things.
(\__/)
(='.'=) world domination!!!
(")_(")
zeno60
Posts: 342
Joined: Sun May 21, 2006 2:48 am
Location: NC, USA
Contact:

Post by zeno60 »

Xenxe wrote:but your right i should try harder to solve my problem thats why im going to use newton i heard that it is pretty easy to intergrate whith irrlicht and the game will be better that way anyway
Fair enough, just be warned that "Better" usually means more work on your part (And trust me, it will be with integrating Newton to your objects) and seeing as how you cannot understand the Demo.cpp I am not sure that adding more weight to your project is really going to solve your problem. I suggest going smaller, 2d pong/tetris remake perhaps? Or a simple demo of moving an object to understand how vectors and other 3d math concepts work. Good luck.

Build on previous knowledge, don't just try to learn all at once. To put in more global terms, walk before you run.
Xenxe
Posts: 43
Joined: Sat Jan 26, 2008 9:54 pm
Location: U.S.A. Wasington

Post by Xenxe »

your right newton is still hard i looked at that and then i thought OMG going back to irrlichts sytem

so ill work on this shooting thing for a few days

baby steps
who else here is 14?
But confused about many things.
(\__/)
(='.'=) world domination!!!
(")_(")
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Xenxe wrote:and no, who does like problems
I do, and I imagine that most other long-term hobbyist devs do as well. Why else would we be interested in helping to solve other peoples' problems? Believe me, it's not for the sparking repartée.

Please understand that I'm just trying to give you fair warning here about what you're getting into. Software engineering really is a process of iterative problem solving. It's just one problem after another, and there is no magic short-cut to avoid that. You can't be fed cookie-cutter solutions to each of your problems, because they are (or will soon become) unique to you.

If you don't actively enjoy the process of understanding and overcoming each and every one of those problems as they occur, then it's going to be a long and painful journey, and your chances of reaching a rewarding destination are remote.

Bear in mind that there are plenty of ways other than programming to contribute to a game project. Modelling, UI design, creating or modifying sound effects or music, testing: there are projects crying out for people to help in those areas.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Xenxe
Posts: 43
Joined: Sat Jan 26, 2008 9:54 pm
Location: U.S.A. Wasington

Post by Xenxe »

well i am a decent modeler whose models look like they were made 8 years ago thats at least decent right
who else here is 14?
But confused about many things.
(\__/)
(='.'=) world domination!!!
(")_(")
marrabld
Posts: 37
Joined: Wed Jul 11, 2007 9:16 am

Post by marrabld »

NOTE :: I am a beginner here as well but I think what everyone is trying to say is that its OK to have a problem and ask for help. But you must be specific about the problem and what you don't understand.

You have to show that you have a given it a decent go and that you have read, previous posts, tutorials etc.

Is this a fair comment guys?

If you just say I don't understand the demo, its too vague and too difficult to try and answer.

Ha Ha, Ill try keep this in mind when I post my next question now that I have opened my self up for criticism.

EDIT :: Read the How to ask questions the smart way in RogerBorgs footer. Its excellent.

----

NOTE :: some of you guys are a bit hard on noobs I think, this is the beginners help. If a question isn't asked very well maybe you should say as such rather than just blasting someone for being stupid (Now and then :) ).
Post Reply