Creating a face from vertices?

Software: Away3D 4.x

hlstriker, Newbie
Posted: 17 September 2011 08:27 PM   Total Posts: 1

I’m trying to create a face using vertices but have no clue how with Away3D 4. I found the tutorial below but apparently it’s all different now.

http://polygeek.com/3965_away3d_101-vector-shapes

Can someone please explain how I can do this in Away3D 4?

   

Avatar
Alejandro Santander, Administrator
Posted: 18 September 2011 02:00 AM   Total Posts: 414   [ # 1 ]

You can do something like this:

public class Triangle extends PrimitiveBase
{
    
private var _v0:Vector3D;
    private var 
_v1:Vector3D;
    private var 
_v2:Vector3D;
    private var 
_uv0:Vector3D;
    private var 
_uv1:Vector3D;
    private var 
_uv2:Vector3D;

    
// Define vertices in a clockwise manner.
    
public function Triangle(material:MaterialBasev0:Vector3Dv1:Vector3Dv2:Vector3D,
                                                    
uv0:Vector3D nulluv1:Vector3D nulluv2:Vector3D null)
    
{
        super
(material);

        
_v0 v0;
        
_v1 v1;
        
_v2 v2;
        
_uv0 uv0;
        
_uv1 uv1;
        
_uv2 uv2;
    
}

    override 
protected function buildGeometry(target:SubGeometry):void
    {
        
var rawVertices:Vector.<Number> = Vector.<Number>([_v0.x_v0.y_v0.z_v1.x_v1.y_v1.z_v2.x_v2.y_v2.z]);
        var 
rawIndices:Vector.<uint> = Vector.<uint>([012]);

        var 
d0:Vector3D _v1.subtract(_v0);
        var 
d1:Vector3D _v2.subtract(_v0);
        var 
rawTangents:Vector.<Number> = Vector.<Number>([000]);

        var 
normal:Vector3D d0.crossProduct(d1);
        
normal.normalize();
        var 
rawNormals:Vector.<Number> = Vector.<Number>([normal.xnormal.ynormal.znormal.xnormal.ynormal.znormal.xnormal.ynormal.z]);

        
target.updateVertexData(rawVertices);
        
target.updateIndexData(rawIndices);
        
target.updateVertexNormalData(rawNormals);
        
target.updateVertexTangentData(rawTangents);
    
}

    override 
protected function buildUVs(target:SubGeometry):void
    {
        
if(_uv0 && _uv1 && _uv2)
            var 
rawUvData:Vector.<Number> = Vector.<Number>([_uv0.x_uv0.y_uv1.x_uv1.y_uv2.x_uv2.y]);
    
}
}
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X