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 = 0; i < triangleData.length/9; i++) {
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 = 0; u < 3; u++) {
var v:Vertex = new Vertex(triangleData[u*3+i * 9]/(m), triangleData[u*3+i * 9+1]/(m), triangleData[u*3+i * 9+2]/(m),u)//load from array
verts.push(v.x, v.y, v.z);
norms.push(Math.random()*200,Math.random()*200, Math.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(0, 0, 1, 0, 0.5, 0.8660254037)//this works
indices.push(0, 1, 2)
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(geo, material)
mesh.mouseEnabled = true
mesh.name = i+""
sphere.addChild(mesh)
faces[i] = mesh
facesDis[i] = false
}
addChild(sphere)
sphere.mouseEnabled = true
sphere.addEventListener(MouseEvent3D.MOUSE_DOWN, onSphereMouseDown)//works only sometimes