Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
I'm trying to develop a simple demo in CL. Part of the functionality expected from it is adding meshes to the scene - that I can do, but I've ran into a difficulty with collisions between the inserted nodes (not a full-blown physics system, all I need is that the nodes stop each other's mvement.. The basic scene, with two cube nodes on a plane, was created in CopperCube. Those two objects can be moved and collide with each other when moved. Moved nodes collide with the pre-placed ones, but not with the ones added during the demo's operation. What am I missing or doing wrong? Here's the code I'm using to add a new node to the scene and add the collision response animator to it: MySceneNode = function(engine) CL3D.SceneNode.prototype.refreshCollision = function () { |
||||
|
This isn't supported, since this would need complex physics calculations between the objects - that's what a physics engine does. What you could do is to add a child object like a cube to each object, so that each object cannot move through each other, and this might work, but not perfectly. For stuff like that you'd need a real physics engine, and there is a reason they are so complicated and need a lot of CPU power. |
||||
|
I don't need perfect collisions, nor any physics simulation - if the objects were prevented from clipping each other's bounding box, it would be sufficient. The pre-placed cubes were showing the desired behavior, and the nodes added at run time (with same mesh) did not, what I was trying to understand was what caused the difference. Found it now: the collision world was set for the new nodes, but it was not reset when nodes were added, deleted or had their meshes changed. This mostly solves the problem (needs to be called after each of the above events): CL3D.CopperLicht.prototype.resetCollisionWorld(){ To fix the glitch with nodes retaining their old collision after setting new mesh, setMesh() has to be changed a bit: CL3D.MeshSceneNode.prototype.setMesh = function (a) { |
|