Problem with displaying custom mesh and MouseEvent3D

Software: Away3D 4.x

richard7854, Newbie
Posted: 26 June 2013 10:23 PM   Total Posts: 1

Hello,

I am new to Away3d v4.1 and I like it, but I have a problem. At start, look at this swf - http://ponozka.php5.cz/triangleProblem/ (you can change the rotation by pressing any key).As you can see, it should be a nice geosphere, but it isnt and some faces are strangely appearing and disappearing. I am creating the triangles from the array (it has positions of vertices in it). Each triangle is a separate mesh and is not connected to other triangles.
I dont really know how to set normals and tangents. Strange thing is, that whatever i fill them will any random numbers, it behaves the same. Even if i dont supply any normals/tangents and leave it to automatic, it behaves exactly the same.
Another issue is with Mouse events. Sometimes it reacts fine, sometimes the wrong mesh(triangle) dispatches the event and sometimes it doesnt occur at all. Just try to click a few triangles.

Source code is bellow:

sphere = new ObjectContainer3D()
   
material = new TextureMaterial(Cast.bitmapTexture(new Main.GulaText()), false)
   
faces = new Array()
   
facesDis = new Array()
   for (var 
i:int 0triangleData.length/9i++) {
     
var m:Number 5
     
var subGeo:SubGeometry = new SubGeometry()
     var 
verts:Vector.<Number> = new Vector.<Number>()
     var 
uvs:Vector.<Number>= new Vector.<Number>()
     var 
norms:Vector.<Number> = new Vector.<Number>()
     var 
tangs:Vector.<Number> = new Vector.<Number>()
     var 
indices:Vector.<uint> = new Vector.<uint>()
     for (var 
u:int 03u++) {
      
var v:Vertex = new Vertex(triangleData[u*3+9]/(m), triangleData[u*3+9+1]/(m), triangleData[u*3+9+2]/(m),u)//load from array
      
verts.push(v.xv.yv.z);
      
norms.push(Math.random()*200,Math.random()*200Math.random()*200)//does it have any effect ?
      
tangs.push(Math.random()*200,Math.random()*200,Math.random()*200)//no matter how I change auto settings bellow
     
}
     uvs
.push(00100.50.8660254037)//this works
     
indices.push(012)
     
subGeo.autoDeriveVertexNormals =true//??
     
subGeo.autoDeriveVertexTangents true//??
     
subGeo.useFaceWeights true//??
     
subGeo.updateVertexData(verts)
     
subGeo.updateIndexData(indices);
     
subGeo.updateUVData(uvs);
     
//subGeo.updateVertexNormalData(norms);
     //subGeo.updateVertexTangentData(tangs)
     
var geo:Geometry = new Geometry()
     
geo.addSubGeometry(subGeo)
     var 
mesh:Mesh = new Mesh(geomaterial)
     
mesh.mouseEnabled true
     mesh
.name i+""
     
sphere.addChild(mesh)
     
faces[i] mesh
     facesDis[i] 
false
   }
   addChild
(sphere)
   
sphere.mouseEnabled true
   sphere
.addEventListener(MouseEvent3D.MOUSE_DOWNonSphereMouseDown)//works only sometimes 
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X