getCurrentFrame ?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
cyberbobjr
Posts: 64
Joined: Mon Sep 08, 2003 8:21 am
Location: Paris, France

getCurrentFrame ?

Post by cyberbobjr »

Hi,
I've found a very good solution for damage collision ! :D
It's a mix of :
getSceneNodeFromCameraBB
createTriangleSelector
getMesh

I explain how i do that :
first, for speed, i do a getSceneNodeFromCameraBB for gettin the node under the camera's target (this function works with BoundBox of the mesh).

After, for seeing if the mesh is *really* under the camera's target, i'll do this (assume that faerie is a animatedmesh and node the animatedscenenode, and targetshoot the camera's target):

Code: Select all

meshSelector=smgr->createTriangleSelector(faerie->getMesh(40),node);
node->setTriangleSelector(meshSelector);
meshSelector->drop();
// TEST MORE ACCURATE
if (smgr->getSceneCollisionManager()->getCollisionPoint(targetShoot,meshSelector,inPoint,inTriangle))
	std::cerr<<"BODY SHOOT !"<<std::endl;
And this is works ! :)

But you'll see just one problem, a really little problem :(
I want to replace the faerie->getMesh(40) (an arbitrary value) with the real number of frame played at this moment, a function which be named by example getCurrentFrame ... How can i implement that ?

Thanks for your helps.
Regards.
cyb
cyberbobjr
Posts: 64
Joined: Mon Sep 08, 2003 8:21 am
Location: Paris, France

Post by cyberbobjr »

YES !!!!!
I've find it !!!! Yaouh ! :lol:
getFrameNr()
I've transformed this private inline function to public function, and now collision damage is working with animated mesh !!! :D :D :D

This is my final code :

Code: Select all

if ((SelectionNode=device->getSceneManager()->getSceneCollisionManager()->getSceneNodeFromCameraBB (camera,-1))!=0)
{
	if (SelectionNode->getID()==2)
	{
		meshSelector=smgr->createTriangleSelector(faerie->getMesh(node->getFrameNr()),node);
		node->setTriangleSelector(meshSelector);
		meshSelector->drop();
		// TEST MORE ACCURATE
		if (smgr->getSceneCollisionManager()->getCollisionPoint(targetShoot,meshSelector,inPoint,inTriangle))
			std::cerr<<"BODY SHOOT !"<<std::endl;
	}
}
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Cool! I'll add a getCurrentFrame() to the SceneNode then. :)
Gorgon Zola
Posts: 118
Joined: Thu Sep 18, 2003 10:05 pm
Location: switzerland

Post by Gorgon Zola »

Hi
I know this is a rather old thread but i didn't want to start a new one for this.

Is there an easy way to find the currently played animation number with its boundaries (start, end) from an animated scene node?

I found a function for anim-boundaries in IAnimatedMeshMD2,
but i cant find the function for finding the current animation number.
I'm looking for something like:

Code: Select all

 EMD2_ANIMATION_TYPE getCurrentMD2Animation(int& outStart, int& outEnd, int& outFPS);
I would like to be able to find out if the current animation has ended or not
to be able to set a new animation at the correct time.

any ideas, how to accomplish this?

thanks
GorgonZola
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

( Sorry to bring a little off above post )

On a simular subject, is there a way of counting the number of animations that have repeated? I want to do a turn based game and so need to have a count of how many walk or run animations have passed to work out time units.
Gorgon Zola
Posts: 118
Joined: Thu Sep 18, 2003 10:05 pm
Location: switzerland

Post by Gorgon Zola »

maybe a animation trigger/callback would be a good idea to integrate
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

Thanx, I'll check it out ( sorry for hijacking the thread :D )
Post Reply