[SOLVED]Colliding bodies. + new problem

JKFOZZY

20-12-2010 17:28:42

Hi,

I try to make a program so that i could shoot a barrel at a few cubes. When a cube is hit by a barrel i wan't to let the cube be invisible. I've taked a look at this link. https://www.ogre3d.org/addonforums/viewtopic.php?f=6&t=13034&p=73062&hilit=setContactCallback#p73062. But i think i do something wrong.

Here is my MyCallback.h code.:

#ifndef __MYCALLBACK_H_
#define __MYCALLBACK_H_

#include "NxOgre.h"

class MyCallback : public NxOgre::Callback
{
public:
MyCallback(void);
~MyCallback(void);

void onContact(const NxOgre::ContactPair& pair);
};

#endif



MyCallback.cpp .:


#include "MyCallback.h"

MyCallback::MyCallback(void)
{
}

MyCallback::~MyCallback(void)
{
}

void MyCallback::onContact(const NxOgre::ContactPair& pair)
{
//do something
}


Add the callback to the cubes.


for(std::vector<std::vector<std::vector<Kubus*>>>::iterator itr=cubes3D.begin(); itr < cubes3D.end(); itr++)
{
for(std::vector<std::vector<Kubus*>>::iterator jtr=(*itr).begin(); jtr < (*itr).end(); jtr++)
{
for(std::vector<Kubus*>::iterator ktr=(*jtr).begin(); ktr < (*jtr).begin(); ktr++)
{
(*ktr)->getBody()->setContactCallback(m_Callback);
}
}
}


add the callback to the barrels
for(int i=0; i < 10; i++)
{
Barrel* b=new Barrel(m_RenderSystem);
b->getBody()->setContactCallback(m_MyCallback);
m_Barrels.push_back(b);
}


set the actor flags
for(std::vector<Barrel*>::iterator itr=barrels.begin(); itr < barrels.end(); itr++)
{
for(std::vector<std::vector<std::vector<Kubus*>>>::iterator jtr=cubes3D.begin(); jtr < cubes3D.end(); jtr++)
{
for(std::vector<std::vector<Kubus*>>::iterator ktr=(*jtr).begin(); ktr < (*jtr).end(); ktr++)
{
for(std::vector<Kubus*>::iterator ltr=(*ktr).begin(); ltr < (*ktr).end(); ltr++)
{
m_Scene->setActorFlags((*itr)->getBody(), (*ltr)->getBody(), NxOgre::Enums::ContactPairFlags_All);
}
}
}
}


Thnx,
JKFOZZY.

JKFOZZY

22-12-2010 12:27:56

anyone? :oops: :D

JKFOZZY

22-12-2010 14:33:43

Hi,

I intergrated Visual Debugger in my project. I see something weirds. Maybe anyone understand why i get this result. Maybe this result causes that my collision detetection doesn't work.

In my project you see a big wall. This big wall is made of little cubes, Every cube is a body. Also in my project i have multiple barrels. I want that those barrels could colide with the big wall of cubes. The barrels are also body´s.

Here are some screenshots with Visual Debugger enabled. You will see that two objects have a bounding box etc enabled. The strange thing is i never created a object on one of the two object their location.[attachment=1]screenshot12222010_151801804.jpg[/attachment][attachment=0]screenshot12222010_151757522.jpg[/attachment]

Thnx,
JKFOZZY.

JKFOZZY

23-12-2010 11:16:52

could somebody help me? Thnx. :D

JKFOZZY

24-12-2010 13:22:47

Hi,

I fixed this problem.

I needed to add mWorld->advance(evt.timeSinceLastFrame); :lol:

Now i have another issue. It is realy strange.

I've created 64 kinematic body's. When i comment the line "mWorld->advance(evt.timeSinceLastFrame);" out. I see my cubes(the kinematic body's) positioned correctly. When i have the line of code 'enabled' al the 64 cubes go to the same position.

From those cube i want to make one big cube. 4x4x4.

Here are a few screenies with and without that line of code enabled.
Enabled.
[attachment=1]screenshot12242010_141800102.jpg[/attachment]

[attachment=1]screenshot12242010_141800102.jpg[/attachment]
Dissabled.

Could anybody help me please :D