Well i am having problem with collision detection in Irrlicht:
Well we got ISceneNodeAnimatorCollisionResponse which do automatic collision detection for a scene node.The problem is that i let me do collision detection with only one node. But i want to do collision detection (also Response similar to the above interface) for "a large number of nodes( high polygon nodes)".
Surely there is a ISceneCollisionManager for doing this but does not it is very inefficient to do the collision detection for all the scene nodes linearly. Because i might be some scene nodes are very far apart form player whish do not require detection.
Is there any way to efficiently do collision detection and also response (as ISceneNodeAnimatorCollisionResponse do) with large number of scene nodes.
Regards,
TH
Collision Detction nadn response with a number of Nodes
-
- Posts: 292
- Joined: Sun Mar 14, 2004 5:28 pm
- Location: Germany
- Contact:
lol, a joke, isn't it?TH wrote:I did not know there is a search feature in the forum too!
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
Ok guys this time serious!
Well i am trying to use the IMetaTriangleSelector, but rather moving around in the world i am "stucked" at one position . here is what i am doing can any body tell me is that the corrcet way to use IMetaTriangleSelector.
Also when i try to set the gravityDirectionAndSpeed to (0,-100,0) i fall done form my world floor!!!
plz help!
regards,
TH
PS: This time i have done the serachign and this question hasnot been not asked!
Well i am trying to use the IMetaTriangleSelector, but rather moving around in the world i am "stucked" at one position . here is what i am doing can any body tell me is that the corrcet way to use IMetaTriangleSelector.
Code: Select all
scene::ICameraSceneNode* camera = 0;
camera = smgr->addCameraSceneNodeFPS(0,100.0f,300.0f);
camera->setPosition(core::vector3df(10,50,10));
camera->setFarValue(500);
IMetaTriangleSelector* metaselector = smgr->createMetaTriangleSelector();
ISceneCollisionManager* collisionmanager = smgr->getSceneCollisionManager();
triangle3df outtri;
bool flag = false;
vector3df lastposition = camera->getPosition();
while(device->run())
{
driver->beginScene(true, true, video::SColor(0,100,100,100));
smgr->drawAll();
driver->endScene();
vector3df direction = (lastposition - camera->getPosition());
vector3df newposition =
collisionmanager->getCollisionResultPosition(metaselector,
camera->getPosition(),
core::vector3df30,50,30) ,direction,outtri,flag,0.000500,
core::vector3df(0,0,0)
);
lastposition = newposition;
camera->setPosition(newposition);
}
plz help!
regards,
TH
PS: This time i have done the serachign and this question hasnot been not asked!
You have to add all meshes needet for collision detection to the meta selector...
Use: addTriangleSelector(ITriangleSelector* toAdd)
Use: addTriangleSelector(ITriangleSelector* toAdd)
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Well i have been after trying for hours and hours and unable to do collision detection!
As Acki mention i have also this time used the addTriangleSelector() too! but still the user is stuck at one position.
Here what i am doing:
The two for loops add sence node for floor(a small horizontal quad) and a house alternatively.So i it makes a little urban town wih streets and house!
Please Help!
(Sorry the code listing is a little long)
TH
As Acki mention i have also this time used the addTriangleSelector() too! but still the user is stuck at one position.
Here what i am doing:
Code: Select all
if(housemesh == NULL)
{
return 0;
}
scene::IAnimatedMesh* floormesh = smgr->getMesh("data\\floor_patch.x");
if(floormesh == NULL)
{
return 0;
}
scene::ITriangleSelector* selector = 0;
IMetaTriangleSelector* metaselector = smgr->createMetaTriangleSelector();
bool flag = false;
for(int i = 0; i < 10; i++)
{
for(int j = 0; j < 10; j++)
{
if(flag == false)
{
node = smgr->addMeshSceneNode(floormesh->getMesh(0));
node->setPosition(core::vector3df(i*20,0,j*20));
node->setScale(core::vector3df(2.0,2.0,2.0));
selector = smgr->createTriangleSelector(floormesh->getMesh(0),node);
node->setTriangleSelector(selector);
metaselector->addTriangleSelector(selector);
selector->drop();
flag = !flag;
}
else
{
node = smgr->addMeshSceneNode(housemesh->getMesh(0));
node->setPosition(core::vector3df(i*20,0,j*20));
selector = smgr->createTriangleSelector(housemesh->getMesh(0),node);
node->setTriangleSelector(selector);
metaselector->addTriangleSelector(selector);
selector->drop();
flag = !flag;
}
}
}
smgr->addLightSceneNode(0,core::vector3df(100,10,100));
smgr->addLightSceneNode(0,core::vector3df(10,10,10));
scene::ICameraSceneNode* camera =
smgr->addCameraSceneNodeFPS(0,100.0f,300.0f);
camera->setPosition(core::vector3df(30,5,30));
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
metaselector, camera, core::vector3df(20,50,20),
core::vector3df(0,-100,0), 100.0f,
core::vector3df(0,50,0));
camera->addAnimator(anim);
anim->drop();
device->getCursorControl()->setVisible(false);
while(device->run())
{
driver->beginScene(true, true, video::SColor(0,100,100,100));
smgr->drawAll();
driver->endScene();
}
metaselector->drop();
device->drop();
Please Help!
(Sorry the code listing is a little long)
TH
Thanks Kande for the reply
i first also thought that i was placing the camera in the BB of some object. But i have tried changing the camera position and elipsoid raduis.
I have spent hours changing different parameter but useless.
I am sure it must be some stupid mistake! but can please any body point out the mistake.
regards,
TH
i first also thought that i was placing the camera in the BB of some object. But i have tried changing the camera position and elipsoid raduis.
I have spent hours changing different parameter but useless.
I am sure it must be some stupid mistake! but can please any body point out the mistake.
regards,
TH