≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Mesh-Mesh collisions?
Posted by:
(you are not logged in)
Enter the missing letter in: "Internatio?al"
(you are not logged in)
Text:
[quote][b]Mike[/b] wrote: 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: [code] MySceneNode = function(engine) { var node=new CL3D.MeshSceneNode(); node.setMesh(mesh1); node.DoesCollision=true; node.CollidesWithWorld=true; scene.getRootSceneNode().addChild(node) node.Pos.X=-10; node.Pos.Z=-10; node.refreshCollision(); return node }[/code] [code]CL3D.SceneNode.prototype.refreshCollision = function () { var o = this.getAnimatorOfType('collisionresponse'); this.recalculateBoundingBox(); var r = this.Box.getExtent().multiplyWithScal(0.5); if (o!=null) { this.addAnimator(new CL3D.AnimatorCollisionResponse(r, o.getGravity(), new CL3D.Vect3d(0,0,0), o.getWorld())); this.removeAnimator(o); } else this.addAnimator(new CL3D.AnimatorCollisionResponse(r, new CL3D.Vect3d(0,-10,0), new CL3D.Vect3d(0,0,0), scene.getCollisionGeometry())); return null }; CL3D.SceneNode.prototype.recalculateBoundingBox = function () { this.Box=new CL3D.Box3d(); this.Box.reset(0, 0, 0); var v=Array(); var m=this.getMesh().MeshBuffers; if (this.getMesh().MeshBuffers.length + this.Children.length > 0) { for (var i=0; i<m.length; i=i+1) { m[i].recalculateBoundingBox(); v.push(m[i].Box.MinEdge); v.push(m[i].Box.MaxEdge); } if (this.Children){ for (var i=0; i<this.Children.length; ++i){ this.Children[i].recalculateBoundingBox(); v.push(this.Children[i].getTransformedBoundingBox().MinEdge); v.push(this.Children[i].getTransformedBoundingBox().MaxEdge); } } this.Box.MinEdge = v[0]; this.Box.MaxEdge = v[1]; for (var i=2; i<v.length; ++i) { this.Box.addInternalPointByVector(v[i]); } } };[/code][/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Image
[img]http://www.example.com/image.jpg[/img]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons
Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact