Hi all
I have got shooting to work (finally) and have a small problem (two actually, this post focuses on one).
The collision with the main ground mesh (from irr) is working fine now, but I am trying to add another collision detection with a standard 3ds mesh. I have added the object and everything, I just don't have the correct code for this. I have also tried adding another triangle selector (using this mesh only) and putting it in this code:
// get intersection point with map
if (smgr->getSceneCollisionManager()->getCollisionPoint(
line, *triangleselector*, end, triangle))
{
//Do stuff here if collision is met
}
But changing it to work with my other 3d object. This does not seem to work, as any code passed does not seem to work. What have I done wrong here? I am using exact code from the demo tutorial with shooting.
All I am aiming to do is make my sphere change colour when hit by a bullet.
Shooting (from demo) collisions
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Mmm, not necessarily. Using getCollisionPoint() with a meta triangle selector wouldn't tell you which scene node was hit, which is a limitation that I intend to address after 1.5 is cut.JP wrote:You want to use a IMetaTriangleSelector instead of a ITriangleSelector.
The code posted looks reasonable, but it really depends on how you're creating the triangle selector. We'll need to see that code. If you're loading a 3ds mesh, then it should be something like:
Code: Select all
IAnimatedMesh * animatedMesh = smgr->getMesh("your_mesh.3ds");
IAnimatedMeshSceneNode * node = smgr->addAnimatedMeshSceneNode(animatedMesh);
// Note: we need to get an IMesh from the IAnimatedMesh
ITriangleSelector triangleSelector = smgr->createTriangleSelector(animatedMesh->getMesh(0), node);
//...
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Ahh yes, my bad for not paying attention to the requirements
I guess in that case you'd kinda have to check each triangle selector of interest individually...
Although aren't you using a physics engine jhend60? in which case you might be better off using functions from that rather than creating extra triangle selectors to do it within irrlilcht.
I guess in that case you'd kinda have to check each triangle selector of interest individually...
Although aren't you using a physics engine jhend60? in which case you might be better off using functions from that rather than creating extra triangle selectors to do it within irrlilcht.
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Indeed, which is pretty sub-optimal. You'll really want to do a ray/BB test on each node before doing the triangle selector check.JP wrote:I guess in that case you'd kinda have to check each triangle selector of interest individually...
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
ok
I have decided to use the irrlicht basic collision detections as Newton got a little bit bulky. I am using simple collision detection from irrlicht, and have used pretty much exact code from the demo. I think I must use collision detection with the LINE formed by the shooting function, instead of the bullet itself. I already have collision with the ground mesh and the bullet working, but cannot seem to replicate this effect on another object.