IrrNewt irrlicht\newton framework >> SVN access

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Post Reply
Eugenik
Posts: 6
Joined: Mon Jan 29, 2007 4:58 am
Location: Russia, Sibiria, Novosibirsk

white tiger

Post by Eugenik »

Thanks, but you have not understood me. I understand as works getCollisionPoints (). I receive a file and I can work in him both with the first and with the tenth enemy. A problem that points of collisions with some enemies will not be worn out in this file as though they do not exist. I need to understand as about these to struggle.

By the way I tried to use getCollisionFirstPoint () and collisions with opponents are not checked. Collision with a wall is checked only. So I apply physics on enemies (if it matters).

//Тела ботов
newton::SBody BotBodyData[500];
for(int q=0; q<botNum-1; q++)
{
BotBodyData[q].Node=botnode[q];
BotBodyData[q].Mesh=bot[q]->getMesh(0);
BotBodyData[q].Mass=botMass;

rigel2_p_node[q]=p_world->createCharacterController(
p_world->createBody(BotBodyData[q]));
}

irr::newton::IMaterial* rigel2_material[500];

for(int q=0; q<botNum-1; q++)
{rigel2_material[q]=p_world->createMaterial();}

for(int q=0; q<botNum-1; q++)
{
rigel2_p_node[q]->setMaterial(rigel2_material[q]);}


I am sorry for a code in bad style
FriendlyWarlord
Posts: 58
Joined: Thu Apr 06, 2006 11:54 pm

Post by FriendlyWarlord »

Sorry to interrupt, but I have a quick and non-urgent question (and I'm pretty new to Newton).

Can IrrNewt (or Newton, for that matter) easily make certain bodies go through certain other bodies, but not others? For example, can I have an invisible cylinder that collides with level geometry to control the player, but everything else goes through this cylinder as if it does not exist? Or do you need to use some completely different collision method to do that? Sorry if it sounds like I don't know what I'm talking about... I probably don't =p

Looks very likely that I'll be using IrrNewt anyway. Thanks in advance ^^
=D
Eugenik
Posts: 6
Joined: Mon Jan 29, 2007 4:58 am
Location: Russia, Sibiria, Novosibirsk

Post by Eugenik »

I am very weak in English and consequently is compelled to speak with you through the translator. It similar also is the reason of difficulties in understanding. And probably my words sound not absolutely correctly (not as should be in English language) for you. It is very awkward to me to force to assort you it.

For a level and for enemies I created a physical body equally. Distinction only in creation of sites of a stage for a level

mapnode = sm-> addOctTreeSceneNode (map-> getMesh (0));
And for the enemy
botnode [q] = sm-> addAnimatedMeshSceneNode (bot [q]);

It occurs when I use getCollisionPoints (). I have made as well as in example.
For example on a way three enemies. Sometimes all is normal. That is points of collision with all three get in a file. And sometimes it happens that for example the first enemy is not taken into account and in a file two will be worn out only standing up for by it. And the next second all again is normal. I do not understand why so occurs.

It occurs when I use getCollisionFirstPoint ()
Almost always the point of collision is defined only with a map and very seldom she is defined on whom that from enemies. And very much often not on first of them.

I would accept a method getCollisionFirstPoint () better. If it is not difficult for you, set please a small example of this method. I have in view of an initial code.
VERY MUCH FOR IT I SHALL BE GRATEFUL!
white tiger
Posts: 269
Joined: Tue Oct 31, 2006 3:24 pm
Contact:

Post by white tiger »

@FriendlyWarlord:
Can IrrNewt (or Newton, for that matter) easily make certain bodies go through certain other bodies, but not others
yes. For example there are body1,body2, body3. We want that body1 collide with body2 but go trought body3. To do that simply create 3 materials for every body (material1->body1 exc...). Then simply call

material1->setCollidable(material3,false); //go trought all bodies with material3

material1->setCollidable(material2,true); //collide with all bodies with material2 as material

This last string is unecessary because the default value is true. So if you write it or comment it change nothing.
white tiger
Posts: 269
Joined: Tue Oct 31, 2006 3:24 pm
Contact:

Post by white tiger »

@Eugenik:

Code: Select all

I would accept a method getCollisionFirstPoint () better.
getCollisionFirstPoint() get the first point retrieved from newton. As you can see here this point may not coincide with the nearest (' closest ' is the tecnical term) point from line start. So getFirstCollisionPoint some times retrieve the closest point from line start some times not.

If you want to get always the closest collision point from line start you need a function called 'getCollisionFirstPointEx' wich will be in the next release. If you can't waint here are the getCollisionFirstPointEx code, use this instead of getCollisionFirstPoint and tell me if this solve the problem. To compile this code you need newton:

Code: Select all

//---------------------------------------------------------------------------
//---------------------------------------------------------------------------

irr::newton::SIntersectionPoint internal_intersect_point;

dFloat IrrNewt_FirstCollisionPointNewtonWorldRayFilterCallback (
	const NewtonBody* body,
	const dFloat* hitNormal,
	int collisionID, 
	void* userData,
	dFloat intersetParam) {
	
	if(intersetParam<internal_intersect_point.parametric_value) {

	irr::newton::IBody* this_body=(irr::newton::IBody*)NewtonBodyGetUserData(body);

	internal_intersect_point.parametric_value=intersetParam;
	internal_intersect_point.body=this_body;

	}//	if(intersetParam<internal_intersect_point.parametric_value) {

	return intersetParam;
}

unsigned IrrNewt_FirstCollisionPointNewtonWorldRayPrefilterCallback(
	const NewtonBody* body, 
	const NewtonCollision* collision,
	void* userData) {

	return 1;
}

//---------HERE ARE THE FUNCTION----------------------------

irr::newton::SIntersectionPoint irr::newton::ICollisionManager::getCollisionFirstPointEx(
		 irr::core::line3d<irr::f32> line) {

	line.start*=IrrToNewton;
	line.end*=IrrToNewton;

	internal_intersect_point.parametric_value=1.0f;

	int user_data=1;

	float line_start_array[3],line_end_array[3];
	irr::newton::Hidden::Vector3dfFillArray(line.start,line_start_array);
	irr::newton::Hidden::Vector3dfFillArray(line.end,line_end_array);

	NewtonWorldRayCast(
		this->n_world,
		line_start_array,
		line_end_array,
		IrrNewt_FirstCollisionPointNewtonWorldRayFilterCallback,
		(void*)&user_data,//user data
		IrrNewt_FirstCollisionPointNewtonWorldRayPrefilterCallback//prefilter
		);

	//calculate out point
	if(internal_intersect_point.body!=NULL) {
		irr::core::vector3df out=line.start + internal_intersect_point.parametric_value*(line.end - line.start);
		out*=NewtonToIrr;
		internal_intersect_point.point=out;
	}

	return internal_intersect_point;
}
-----------------------------------------------------------------------------

i've got a suggestion. with this code:
for(int q=0; q<botNum-1; q++)
{rigel2_material[q]=p_world->createMaterial();}

for(int q=0; q<botNum-1; q++)
{
rigel2_p_node[q]->setMaterial(rigel2_material[q]);}
you set different materials to every enemie. For example in your game 2 enemies have two materials. If you want you can set the same material to different bodies. For example:

Code: Select all

rigel2_material=p_world->createMaterial();

for(int q=0; q<botNum-1; q++) 
{rigel2_p_node[q]->setMaterial(rigel2_material);}
 
arnir
Competition winner
Posts: 154
Joined: Sat Jan 20, 2007 4:36 pm
Location: Czech Republic

Post by arnir »

i can´t compile car.cpp
here is same errors
Image
white tiger
Posts: 269
Joined: Tue Oct 31, 2006 3:24 pm
Contact:

Post by white tiger »

in your image there is writen "newton.h no such file or directory". This mean that you need to download newton SDK from http://www.newtongamedynamics.com
arnir
Competition winner
Posts: 154
Joined: Sat Jan 20, 2007 4:36 pm
Location: Czech Republic

Post by arnir »

thanks
newton.h wasn't in irrnewt Download
programmer is bad designer
designer is bad programmer
Warren
Posts: 60
Joined: Fri Jul 07, 2006 11:41 pm
Location: Santiago De Compostela, Spain

Post by Warren »

Hi,
I got the same errors than arnir.
I´d download the Newton SDK, but i still get the following errors:

First i had to put a new line at the end of each IrrNewt file. ok, solved.

Then the compiler returns me some no-matching calling to SPosRot constructor at:

Code: Select all

struct STire{
			STire():Pin(irr::core::vector3df(0,0,1.0f)),Mass(1.0f),
				SuspensionShock(30.0f),SuspensionSpring(200.0f),SuspensionLength(1.2f),
				BodyOffsetFromSceneNode(irr::newton::SPosRot()),
				Node(NULL),Width(UNDEFINED_PARAMETER),Radius(UNDEFINED_PARAMETER) {}
Node(NULL),Width(UNDEFINED_PARAMETER),Radius(UNDEFINED_PARAMETER)

and

Code: Select all

struct SCar {
			SCar():TiresPin(irr::core::vector3df(0,0,1.0f)),UpVector(core::vector3df(0,1,0)),
				TiresMass(1.0f),TiresOffsetFromChassis(core::vector3df()),
				SuspensionShock(30.0f),SuspensionSpring(200.0f),SuspensionLength(1.2f),
				TiresBodyOffsetFromSceneNode(irr::newton::SPosRot()),ChassisBody(NULL),
				TireNodeFR(NULL),TireNodeFL(NULL),TireNodeBR(NULL),TireNodeBL(NULL),
				TiresWidth(UNDEFINED_PARAMETER),TiresRadius(UNDEFINED_PARAMETER){}

TiresWidth(UNDEFINED_PARAMETER),TiresRadius(UNDEFINED_PARAMETER){}



I´m using dev-cpp.
I have included the irrNewt directory and the Newton.h.
And linked irrNewt.lib

some help? please

Tnx in advance!
------------------------------------------------
Irrlicht Ussers Map
Join now!!
http://www.frappr.com/irrlichtusers
white tiger
Posts: 269
Joined: Tue Oct 31, 2006 3:24 pm
Contact:

Post by white tiger »

i will download dev cpp and try to compile irrnewt. Thanks for the segnalation
Warren
Posts: 60
Joined: Fri Jul 07, 2006 11:41 pm
Location: Santiago De Compostela, Spain

Post by Warren »

irrnewt 0.2/include/structures.hpp:170: error: no matching function for call to `irr::newton::SPosRot::SPosRot(irr::newton::SPosRot)'
irrnewt 0.2/include/pos_rot.hpp:31: note: candidates are: irr::newton::SPosRot::SPosRot(irr::newton::SPosRot&)
irrnewt 0.2/include/pos_rot.hpp:27: note: irr::newton::SPosRot::SPosRot(irr::core::vector3df, irr::core::vector3df)
irrnewt 0.2/include/pos_rot.hpp:22: note: irr::newton::SPosRot::SPosRot()



I solved the compile errors deleting at car struct and tire struct:

BodyOffsetFromSceneNode(irr::newton::SPosRot()) ==> BodyOffsetFromSceneNode()

But i dont know what it could causes...

Anyway, after that i got link problems

Newbie question: is Dev-cpp able to link .lib files or it only uses .a libs???
------------------------------------------------
Irrlicht Ussers Map
Join now!!
http://www.frappr.com/irrlichtusers
white tiger
Posts: 269
Joined: Tue Oct 31, 2006 3:24 pm
Contact:

Post by white tiger »

to solve that problem the correct way is to change

irr::newton::SPosRot::SPosRot(irr::newton::SPosRot&)

to making it a real copy constructor:

irr::newton::SPosRot::SPosRot(const irr::newton::SPosRot& p)

and the problem will disappear. also "no new line at the end of file" is a warning, not an error
Anyway, after that i got link problems

Newbie question: is Dev-cpp able to link .lib files or it only uses .a libs???
.lib in the zip is for microsoft visual studio. to use irrnewt with gcc (the compiler of dev cpp) you need to recompile it and produce your .a file. unfortunately i have downloaded dev cpp but when I try to recompile irrnewt the compiler crash (segmentation fault) (the compiler crash, not irrnewt) when it process class IMaterialPairAndContact. because this class use multiple inheritance i think that this is the problem. i will try to solve the problem

IBody::setScale() now working
Eugenik
Posts: 6
Joined: Mon Jan 29, 2007 4:58 am
Location: Russia, Sibiria, Novosibirsk

white tiger

Post by Eugenik »

Thanks! Certainly I can wait the following version of your cursor.
When approximately it will be ready?

And still a question! When I put for enemies EBT_TREE that points of collisions correctly are. But on enemies why that does not operate a gravity.
They are not shifted with the help setVelocity (). Why so?
white tiger
Posts: 269
Joined: Tue Oct 31, 2006 3:24 pm
Contact:

Post by white tiger »

And still a question! When I put for enemies EBT_TREE that points of collisions correctly are. But on enemies why that does not operate a gravity.
They are not shifted with the help setVelocity (). Why so?
EBT_TREE object have infinite mass and you can't change the mass for that object. if you want precise collision detection with movement try EBT_CONVEX_HULL, but this is highly unreccomanded because make your game slower. a box or a cylinder or any primitive collision would bettere and work with getCollisionPointEx
white tiger
Posts: 269
Joined: Tue Oct 31, 2006 3:24 pm
Contact:

Post by white tiger »

i have ported irrnewt and its examples on mingw (dev c++'s compiler) with dynamic linking :D i have also created a .dev project file
Post Reply