# Tough question concern 3d + uvt data

**URL:** <https://forum.kirupa.com/t/tough-question-concern-3d-uvt-data/280114>\
**Category:** Uncategorized\
**Created:** [January 22, 2009, 9:21pm UTC](https://forum.kirupa.com/t/tough-question-concern-3d-uvt-data/280114 "2009-01-22T21:21:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![smkirupa](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@smkirupa](https://forum.kirupa.com/u/smkirupa)\
**Post date:** [January 22, 2009, 9:21pm UTC](https://forum.kirupa.com/t/tough-question-concern-3d-uvt-data/280114/1 "2009-01-22T21:21:14Z")

</div>

I’m attempting to make a 3d, textured cube based off of Senocular’s write-up about 3d functions here:

[http://www.senocular.com/flash/tutorials/flash10drawingapi/](http://www.senocular.com/flash/tutorials/flash10drawingapi/)

I’ve got the whole thing going great except my UVT data, I’m still getting distortions when the cube rotates. Here is the code in question:

create planes:

```auto
var p:Vector.<Vector3D> = new Vector.<Vector3D>();
         
            for(var i:int = 0;i < points.length; i++) {
                var pt:Vector3D = matrix.transformVector(points*);
                pt.w = fov.focalLength / (fov.focalLength + pt.z);
                pt.project();
                p.push(pt);
            }
         
            var planes:Array = [
             [p[0], p[1], p[2], p[3]],
             [p[7], p[6], p[5], p[4]],
             [p[0], p[4], p[5], p[1]],
             [p[1], p[5], p[6], p[2]],
             [p[2], p[6], p[7], p[3]],
             [p[3], p[7], p[4], p[0]] ];

etc etc, this part is not the issue

drawPlane(plane);

```

drawPlane:

```auto

            graphics.beginBitmapFill(Model.instance.getBitmap("test"));

            var vertices:Vector.<Number> = new Vector.<Number>();
            vertices.push(p1.x,p1.y, p2.x,p2.y, p4.x,p4.y, p3.x,p3.y);
            var indices:Vector.<int> = new Vector.<int>();
            indices.push(0,1,2, 1,3,2);
            
            var fov:Number = fov.focalLength;
            var t1:Number = fov / (fov + p1.z);
            var t2:Number = fov / (fov + p2.z);
            var t3:Number = fov / (fov + p3.z);
            var t4:Number = fov / (fov + p4.z);
            
            graphics.drawTriangles(vertices,indices, Vector.<Number>(
                [0,0,t1, 1,0,t2, 0,1,t4, 1,1,t3]));

```

What am I doing wrong with my UVT?
