When a bullet fired into the barrel, world.contactTest unable to detect collisions.
Please watch a video:
tudou.com/programs/view/vMrw8D4xpt4/
In this video, there are a number of bullets fired into the barrel, and the barrel has also undergone a move, but did not trigger an explosion by world.contactTes .
When I fired, will be added a NodePath into self.bullet list .
def on_click(self):
shape = BulletCylinderShape(0.006, 0.02, YUp)
node = BulletRigidBodyNode('cylinder')
node.setMass(0.02)
node.addShape(shape)
node.setCcdMotionThreshold(1e-7)
node.setCcdSweptSphereRadius(0.01)
node.setLinearVelo ... # Calculating the direction of the bullet, the bullet speed of 247m/s.
np = render.attachNewNode(node)
...
self.world.attachRigidBody(node)
...
self.bullet.append(np) # Add a bullet into self.bullet list.
Here, each frame is checked Collision:
def update(self, task):
self.world.doPhysics(globalClock.getDt(), 50, 0.001)
for np in self.bullet:
result = self.world.contactTest(np.node())
for contact in result.getContacts():
mpoint = contact.getManifoldPoint()
e = loader.loadModel('textures/explosion')
e.setPos(mpoint.getPositionWorldOnA()+(0,0,-0.6))
e.setBillboardPointEye()
e.reparentTo(render)
taskMgr.doMethodLater(1.6 ,e.detachNode,'Remove explosion',extraArgs = [])
return task.cont
vorticity
###############################################################################################
I might ask a question:
I used “egg-texture-cards” panda3d.org/manual/index.php … _Animation make explosion, this is my explosion.egg file:
<Comment> {
"egg-texture-cards -o explosion.egg -fps 30 AnimatedExplosion_ME01.png AnimatedExplosion_ME02.png Ani ..."
}
<Texture> AnimatedExplosion_ME50 {
AnimatedExplosion_ME50.png
}
<Texture> AnimatedExplosion_ME49 {
AnimatedExplosion_ME49.png
}
...
...
...
<Texture> AnimatedExplosion_ME02 {
AnimatedExplosion_ME02.png
}
<Texture> AnimatedExplosion_ME01 {
AnimatedExplosion_ME01.png
}
<Material> explosion {
<Scalar> emitr { 1.00 }
<Scalar> emitg { 1.00 }
<Scalar> emitb { 1.00 }
}
<Group> {
<Switch> { 1 }
<Scalar> fps { 30 }
<VertexPool> vpool {
<Vertex> 0 {
-2 4 1
<UV> { 0 1 }
}
<Vertex> 1 {
-2 0 1
<UV> { 0 0 }
}
<Vertex> 2 {
2 0 1
<UV> { 1 0 }
}
<Vertex> 3 {
2 4 1
<UV> { 1 1 }
}
}
<Group> AnimatedExplosion_ME01 {
<Polygon> {
<RGBA> { 1 1 1 1 }
<TRef> { AnimatedExplosion_ME01 }
<MRef> { explosion }
<VertexRef> { 0 1 2 3 <Ref> { vpool } }
}
}
...
...
...
<Group> AnimatedExplosion_ME50 {
<Polygon> {
<RGBA> { 1 1 1 1 }
<TRef> { AnimatedExplosion_ME50 }
<VertexRef> { 0 1 2 3 <Ref> { vpool } }
}
}
}
But when I load it and reparent to render, It is not necessarily from the first frame playback. So, when a explosion, the explosion effect maybe to the half, and then play from start to half.