Papervision3D Collada to WOWPolygon

I didnt know what to do. It was the first time I've ever used physics
I decide to use WOWEngine.First I Made WSphere and WPlane collide. Then I rendered them as Pv3D SPhere and Pv3D Plane following this tutorial. I felt happy and almighty !
For my next trick, I wanted to make a complex ground using collada file. I searched the interwebs, found the right class to use : WOWPolygon , but not really of use of Papervision3D.
After a day of try , I finally got a result.
Here is the swf in action
This is a way to create WOWPolygon from Papervision3D DisplayObject3D :
Thanx to Daniele from Milan for his/her update.
- //Retrieving the "ground" of the collada, it's called "pPlane1" in my .dae source;
- var ground:DisplayObject3D = Levels.getChildByName("pPlane1" , true);
- ground.material.doubleSided = true;
- //For each face of the ground;
- for (var i:int = 0; i < ground.geometry.faces.length; i++)
- {
- //store the currentface as Triangle3D;
- var tri:Triangle3D = ground.geometry.faces[i];
- var VertArray:Array = new Array();
- //for each vertice of the face;
- for (var u:int = 0; u < tri.vertices.length; u++)
- {
- //Store the currentVertice;
- var Vert:Vertex3D = tri.vertices[u];
- //Convert it to a WOW Vertrex (invert axis);
- /**********************
- * UPDATE FROM DANIELE
- **********************/
- var n:Number3D = new Number3D(Vert.x,Vert.y,Vert.z);
- Matrix3D.multiplyVector4x4(tri.instance.transform,n);
- var VerticesNow:WVertex = new WVertex( -(ground.x + n.x) , -(ground.y + n.y) , -(ground.z + n.z));
- //And push the WVertex to the VerticesArray;
- VertArray.push(VerticesNow);
- //Three following lines are optionnally , just display a cube in each WVertice to show you the differents between Papervision and WOW axis;
- var cub:Cube = new Cube(new MaterialsList( { all:new WireframeMaterial(0xff9900) } ) , 50, 50, 50);
- cub.x = VerticesNow.x , cub.y = VerticesNow.y , cub.z = VerticesNow.z;
- _rootNode.addChild(cub);
- }
- //Now create a WOWPolygon with VertArray;
- var Poly:WOWPolygon = new WOWPolygon(VertArray[2] , VertArray[1] , VertArray[0]);
- //Property of a WOWParticle
- Poly.fixed = true;
- Poly.collidable = true;
- Poly.elasticity = 0.5;
- Poly.friction = 0.02;
- //Add the Poly to the physical Engine;
- wowEngine.addParticle(Poly);
- //We can Add Collision Function if we need;
- //Poly.activCollisionEvent(Bouncing);
- }
4 comments about this entry