≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
createClone() problems - still
Posted by:
(you are not logged in)
Enter the missing letter in: "In?ernational"
(you are not logged in)
Text:
[quote][b]csp-games[/b] wrote: Okee dokee! Wow today things really work. I just managed to get collision working with a cloned mesh. Thanks to wild-master! His code at the end of a onL.o.a.d.ingComplete function: [code] // add a cube to test var cubenode = new CL3D.CubeSceneNode(); scene.getRootSceneNode().addChild(cubenode); var TriangleSelectorOfCubeNode = new CL3D.MeshTriangleSelector(cubenode.getMesh(), cubenode); MetaTriangleSelector = new CL3D.MetaTriangleSelector(); var colanimator = new CL3D.AnimatorCollisionResponse( new CL3D.Vect3d(6,12,6), // size of the player ellipsoid new CL3D.Vect3d(0,0,0), // position of the eye in the ellipsoid MetaTriangleSelector); colanimator.AffectedByGravity = false; cam.addAnimator(colanimator); var TriangleSelectorOfCubeNode = new CL3D.MeshTriangleSelector(cubenode.getMesh(), cubenode); MetaTriangleSelector.addSelector(TriangleSelectorOfCubeNode); [/code] worked right out of the box (didn't read it carefully enough the first time). Furthermore, by adding: cubenode.Visible=false; I can have an invisible collision cube and position it around an object with high polycount, which is preferable, performence-wise. However, the code also works with a cloned mesh, so here's the whole tree planting code: [code][b] var cam = scene.getActiveCamera(); var mytree=ccbGetSceneNodeFromName("my_pinetree1"); var myvec_old=mytree.getAbsolutePosition(); var myvec=cam.getAbsolutePosition(); var mytree2=mytree.createClone(scene.getRootSceneNode(),mytree.Id,mytree.Id+count_trees);// worked count_trees+=1; // that's a global, declared outside of any functions as "var count_trees=0"; myvec.Z-=40; myvec.Y=myvec_old.Y; mytree2.Pos=myvec; mytree2.updateAbsolutePosition(); //------- add collision handler for cloned mesh var TriangleSelectorOfCubeNode = new CL3D.MeshTriangleSelector(mytree2.getMesh(), mytree2); MetaTriangleSelector = new CL3D.MetaTriangleSelector(); var colanimator = new CL3D.AnimatorCollisionResponse( new CL3D.Vect3d(6,12,6), // size of the player ellipsoid new CL3D.Vect3d(0,12,0), // position of the eye in the ellipsoid MetaTriangleSelector); colanimator.AffectedByGravity = false; cam.addAnimator(colanimator); var TriangleSelectorOfCubeNode = new CL3D.MeshTriangleSelector(mytree2.getMesh(), mytree2); MetaTriangleSelector.addSelector(TriangleSelectorOfCubeNode); //---------- [/b][/code] What used to confuse me was that I had to set player ellipsoid. It appears the cam has an individual coll ellipsoid for each coll animator. I also had to set eyeheight to ellipsoid height to make it work. But as I said, I will rather use an invisible box for collision around the trees' stems - collision for all the leaf triangles seems silly (1000 rtis per tree, yet, no noticeable impact with about 10 trees with full mesh collision). Using mesh collision with a clone or a custom made mesh node is esp. interesting for the ground and walls. Horray![/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