Page 18 of 31

Posted: Thu May 19, 2011 4:35 pm
by lazerblade
Alright, I'm still getting errors, although it doesn't look like any of them are because of missing Bullet libs. It's all stuff it should be finding in the standard library, but all of it is getting called from the IrrBullet files.

Posted: Fri May 20, 2011 6:25 am
by lazerblade
I've learned that taking out my IrrBullet references(except for the .h file) greatly reduces the number of errors I get. Don't know if that helps...

I've also tried compiling hello world and basic applications in my workspace, the standard libraries seem to be working fine.

Posted: Fri May 20, 2011 9:04 pm
by diho
What's the best way for using collision in irrbullet with an bsp map. I tried it with a normal Itriangleselector and with an IBvhTriangleMeshShape. But the cubes (code from example, hello world) just move throught the walls. :?

Posted: Sun May 22, 2011 7:31 am
by mataanjin
how do i use the collision callback with this?

i try to follow collision example, but it didn't give me the correct collision.

sometimes, even if 2 bodies didn't collide it tell me that 2 bodies has collide.

but, the collision response is correct though.

here is my collision handle code

Code: Select all

	for(u32 i=0; i < world->getNumManifolds(); i++)
    {
        ICollisionCallbackInformation *info = world->getCollisionCallback(i);
		
		ICollisionObject* obj1 = info->getBody0();
		ICollisionObject* obj2 = info->getBody1();
		
		if(obj1->getAttributes()->existsAttribute("RCCar") && obj2->getAttributes()->existsAttribute("wall"))
		{
			info->getContactPoint(0);
			u16 id = obj1->getAttributes()->getAttributeAsInt("id");
			switch(id)
			{
			case 1:
				if (car->dead(dT))
					input->setLayer(UTAMA);
				break;
			}
		}
		if(obj2->getAttributes()->existsAttribute("RCCar") && obj1->getAttributes()->existsAttribute("wall"))
		{
			u16 id = obj2->getAttributes()->getAttributeAsInt("id");
			switch(id)
			{
			case 1:
				if (car->dead(dT))
					std::cout<<"Mati"<<std::endl;
				break;
			}
		}
		if(obj2->getAttributes()->existsAttribute("RCCar") && obj1->getAttributes()->existsAttribute("RCCar"))
		{
			u16 id = obj1->getAttributes()->getAttributeAsInt("id");
			
			switch(id)
			{
			case 1:
				if (car->dead(dT))
					std::cout<<"Mati"<<std::endl;
				break;
			}
		}
	}
and my bodies creation code

Code: Select all

			IGImpactMeshShape *shape = new IGImpactMeshShape(body, smgr->getMesh("../Mesh/PickUpColl.3ds"), 1400);
			rBody = world->addRigidBody(shape);
			rBody->setActivationState(EAS_DISABLE_DEACTIVATION);
			vehicle = world->addRaycastVehicle(rBody);
			rBody->getAttributes()->addBool("RCCar", true);
			rBody->getAttributes()->addInt("id", id);

Code: Select all

			ICollisionShape *shape1 = new IBvhTriangleMeshShape(a, smgr->getMesh("../Mesh/FastTripCollW.3ds"), 0.0);
			shape1->setMargin(0.07f);

			wall = world->addRigidBody(shape1);
			wall->setCollisionFlags(ECF_STATIC_OBJECT);
			wall->getAttributes()->addBool("wall", true);
so what do i do wrong?

here is the pic.
Image
as you can see, the car didn't hit the wall. but the collision is reported.

Posted: Thu May 26, 2011 11:49 am
by cobra
mataanjin wrote:...
Hi mataanjin. Collisions are reported as soon as there is an AABB overlap. You have to check the distance of the collision (between actual shape geometry).

Code: Select all

SManifoldPoint& ICollisionCallbackInformation::getContactPoint(irr::u32 index)

irr::f32 SManifoldPoint::getDistance() const

Use:

Code: Select all

callbackInfo->getContactPoint(0).getDistance();

Posted: Thu May 26, 2011 12:49 pm
by mataanjin
@cobra

i have change to this

Code: Select all

	for(u32 i=0; i < world->getNumManifolds(); i++)
    {
        ICollisionCallbackInformation *info = world->getCollisionCallback(i);
		
		ICollisionObject* obj1 = info->getBody0();
		ICollisionObject* obj2 = info->getBody1();
		
		int numContacts = info->getPointer()->getNumContacts();

		if(info->getContactPoint(i).getDistance() < 0.01f && info->getContactPoint(i).getLifeTime() < 2.0f)
		{
			std::cout<<"kena "<<numContacts<<std::endl;
			if(obj1->getAttributes()->existsAttribute("RCCar") && obj2->getAttributes()->existsAttribute("wall"))
			{
				info->getContactPoint(0);
				u16 id = obj1->getAttributes()->getAttributeAsInt("id");
				switch(id)
				{
				case 1:
					if (car->dead(dT))
						input->setLayer(UTAMA);
					break;
				}
			}
			if(obj2->getAttributes()->existsAttribute("RCCar") && obj1->getAttributes()->existsAttribute("wall"))
			{
				u16 id = obj2->getAttributes()->getAttributeAsInt("id");
				switch(id)
				{
				case 1:
					if (car->dead(dT))
						std::cout<<"Mati"<<std::endl;
					break;
				}
			}
			if(obj2->getAttributes()->existsAttribute("RCCar") && obj1->getAttributes()->existsAttribute("RCCar"))
			{
				u16 id = obj1->getAttributes()->getAttributeAsInt("id");
			
				switch(id)
				{
				case 1:
					if (car->dead(dT))
						std::cout<<"Mati"<<std::endl;
					break;
				}
			}
		}
	}
still it report incorrectly.

how to check the actual shape geometry?

edit:
got it, i change my if to this

Code: Select all

if( abs(info->getContactPoint(i).getDistance()) < 0.1f && numContacts > 0)
at least it work :P

thanks

Program Crashing

Posted: Fri May 27, 2011 4:56 am
by MichaelR
Hello, I am new to Irrlicht and Bullet, but not C++.

I am trying to simply implement some of the HelloWorld functions into a simple little starting platform for me to learn more about game/graphic programming with. I can successfully compile and run the HelloWorld example and it works great. I wrote a basic framework class based on the example in HelloWorld. However, I am having issues getting it to successfully run. I compile with no problems, but it crashes before it even displays anything. Most of my code is very very similar to the HelloWorld example and I simply cannot find anything wrong with it to cause this kind of behavior.

If someone would look at my project (Code::Blocks) and give me some advice, I would be greatly appreciative.

You can download the project here: http://brokemeetscollege.com/projects/life-sim.zip

Re: Program Crashing

Posted: Fri May 27, 2011 7:54 am
by Xaryl
MichaelR wrote: Hello, I am new to Irrlicht and Bullet, but not C++.

Code: Select all

if(keys[KEY_ESCAPE]){
    break;
}
keys is never initialized.

And after you solve that, it still won't work as you expect, because you never registered your event receiver anywhere.

Posted: Fri May 27, 2011 5:57 pm
by soulless
Hi,

Could someone tell the proper way to move a character with keys and still respond correctly to collisions (stop against walls, climb slopes, etc.)???

It is not necessary any code, just an explanation.

I'm doing it in two ways, but both act the same, characters are going trough walls, basically I'm setting the translation of the node manually with a matrix4.

I tried applying impulse, characters get stuck in the floor, so no move (it moves just when is jumping), lower the friction to zero, nothing changes; then tried with linear velocity, but I got the same results.

I know this is not a problem about irrBullet (it is just me not knowing Bullet itself), but I ask here because in Bullet's forum most questions get never answers.

Re: Program Crashing

Posted: Fri May 27, 2011 6:00 pm
by MichaelR
Xaryl wrote:
MichaelR wrote: Hello, I am new to Irrlicht and Bullet, but not C++.

Code: Select all

if(keys[KEY_ESCAPE]){
    break;
}
keys is never initialized.

And after you solve that, it still won't work as you expect, because you never registered your event receiver anywhere.
Stupid mistake there, but I fixed it.

I re-structured the code a bit and I am now correctly registering the event receiver as far as I know. However, the program still crashes when registering the receiver... I have uploaded the updated version of the code. The debugger is telling me segfault in createIrrXMLReader in Irrlicht.dll.

http://brokemeetscollege.com/projects/life-sim.zip

Posted: Fri May 27, 2011 8:50 pm
by Barratator
Hello,
first of all: Sorry for my bad english Wink

I'm trying to use your irrBullet in my project (with Visual Studio 2010). In irrBullet 1.7 I can't find all required *.lib-Files, so I can't compile it.

When I'm trying to use irrBullet 1.7.1 there is only the file "irrBullet.lib" for VS2010, and a few libs for VS2008 - Both types aren't work for me.

When I use the 2010-irrBullet-lib i get a lots of errors with not resolved external symbols,...

Is that a known problem? What can I do to use irrBullet?


Btw...Nice Projekt! Smile


Thanks!

[I already sent it to cobra, but he didn't answered] :)

Re: Program Crashing

Posted: Fri May 27, 2011 10:16 pm
by Xaryl
MichaelR wrote: However, the program still crashes when registering the receiver... I have uploaded the updated version of the code. The debugger is telling me segfault in createIrrXMLReader in Irrlicht.dll.
Your codes compiled and I was able to quit with ESC and shoot the cubes with left mouse click.

Image

I am too lazy to scrutinise the lines one by one, and since I can't reproduce the crash, I will leave it here.

p.s. It was tested on a Linux and thus obviously not with the library files you provided.

Re: Program Crashing

Posted: Fri May 27, 2011 10:43 pm
by MichaelR
Xaryl wrote:
MichaelR wrote: However, the program still crashes when registering the receiver... I have uploaded the updated version of the code. The debugger is telling me segfault in createIrrXMLReader in Irrlicht.dll.
Your codes compiled and I was able to quit with ESC and shoot the cubes with left mouse click.

Image

I am too lazy to scrutinise the lines one by one, and since I can't reproduce the crash, I will leave it here.

p.s. It was tested on a Linux and thus obviously not with the library files you provided.
Hmm, I'll try rebuilding the libraries, thanks.

Update: Rebuild irrlicht and now it works great! Thank you for your help.

Posted: Sat May 28, 2011 8:31 am
by Rocko Bonaparte
Right now I have the player represented as a ninja on some ground. Generally I can move the ninja around with a joystick by applying a linear velocity. This works pretty well. What I can't figure out is how to spin the ninja around to face the direction being aimed at with the joystick. It looks like Bullet has taken over not only setting position, but also rotation.

I can apply spin through angular velocities or torque, but I can't anticipate the correct amount to apply since I don't necessarily know when the next frame and physics simulation is going to complete. So I'm at a bit of a loss as to how much velocity or force to apply. Once I'm within, say, 5 degrees either way of the angle I want I can have it curb all rotation, but getting there without dramatic overshoot or a slow undershoot is the problem.

Any ideas?

Posted: Sat May 28, 2011 7:14 pm
by d3jake
I think that the best route for this would be to sit and play with the physics values for your object. It took a bit of tweaking in my game, but I eventually achieved the effect that you're after.

I would recommend adjusting the amount of torque being applied, along with the rotational dampening.