Hi Folks,

Hier was für die 3D - OOP Freaks. Einfach ins erste Frame.

PHP-Code:
cubeData = [{colour:0xff9900// Unten
            
Sides:[
                      {
x:-50y:50z:50}, // UL
                      
{x:-50y:50z:-50}, // OL
                      
{x:50y:50z:-50}, // OR
                      
{x:50y:50z:50// UR
                      
]},
            {
colour:0xff9900// Oben
            
Sides:[
                      {
x:-50y:-50z:-50}, // UL
                      
{x:-50y:-50z:50}, // OL
                      
{x:50y:-50z:50}, // OR
                      
{x:50y:-50z:-50// UR
                      
]},
            {
colour:0xff8800// Rechts
            
Sides:[
                      {
x:50y:-50z:50}, // OR
                      
{x:50y:50z:50}, // UR
                      
{x:50y:50z:-50}, // UL
                      
{x:50y:-50z:-50// OL
                      
]},
            {
colour:0xff8800// Links
            
Sides:[
                      {
x:-50y:-50z:-50}, // OR
                      
{x:-50y:50z:-50}, // UR
                      
{x:-50y:50z:50}, // UL
                      
{x:-50y:-50z:50// OL
                      
]},
            {
colour:0xffaa00// Vorne
            
Sides:[
                      {
x:-50y:50z:-50}, // UL
                      
{x:-50y:-50z:-50}, // OL
                      
{x:50y:-50z:-50}, // OR
                      
{x:50y:50z:-50// UR
                      
]},
            {
colour:0xffaa00// Hinten 
            
Sides:[
                      {
x:50y:50z:50}, // UL
                      
{x:50y:-50z:50}, // OL
                      
{x:-50y:-50z:50}, // OR
                      
{x:-50y:50z:50// UR
                      
]}
            ];
Objekt3d = function (data3d) {
    
this.data3d data3d;
    
this.move3d = function(xyz) {
        var 
0;
        while (
k<this.data3d.length) {
            var 
0;
            while (
i<this.data3d[k].Sides.length) {
                
this.data3d[k].Sides[i].this.data3d[k].Sides[i].x+x;
                
this.data3d[k].Sides[i].this.data3d[k].Sides[i].y+y;
                
this.data3d[k].Sides[i].this.data3d[k].Sides[i].z+z;
                
i++;
            }
            
k++;
        }
    };
    
this.scale3d = function(xyz) {
        var 
0;
        while (
k<this.data3d.length) {
            var 
0;
            while (
i<this.data3d[k].Sides.length) {
                
this.data3d[k].Sides[i].this.data3d[k].Sides[i].x*x;
                
this.data3d[k].Sides[i].this.data3d[k].Sides[i].y*y;
                
this.data3d[k].Sides[i].this.data3d[k].Sides[i].z*z;
                
i++;
            }
            
k++;
        }
    };
    
this.rotate3d = function(xaya) {
        var 
rad Math.PI/180;
        var 
px;
        var 
py;
        var 
pz;
        var 
sin_xa;
        var 
sin_ya;
        var 
cos_xa;
        var 
cos_ya;
        var 
tempz;
        var 
0;
        while (
k<this.data3d.length) {
            var 
0;
            while (
i<this.data3d[k].Sides.length) {
                
px this.data3d[k].Sides[i].x;
                
py this.data3d[k].Sides[i].y;
                
pz this.data3d[k].Sides[i].z;
                
cos_ya Math.cos(ya*rad);
                
sin_ya Math.sin(ya*rad);
                
cos_xa Math.cos(xa*rad);
                
sin_xa Math.sin(xa*rad);
                
tempz = (pz*cos_ya)-(px*sin_ya);
                
this.data3d[k].Sides[i].= (pz*sin_ya)+(px*cos_ya);
                
this.data3d[k].Sides[i].= (py*cos_xa)-(tempz*sin_xa);
                
this.data3d[k].Sides[i].= (py*sin_xa)+(tempz*cos_xa);
                
i++;
            }
            
k++;
        }
    };
};
Kamera3d = function (Objekt3ddistanceangleloc) {
    
this.Objekt3d Objekt3d;
    
this.distance distance;
    
this.angle angle;
    
this.loc loc;
    
this.mc this.create();
};
Kamera3d.prototype.create = function() {
    return (
this.loc.createEmptyMovieClip("camMC"+Stage.camNumStage.camNum++));
};
Kamera3d.prototype.render = function() {
    
this.mc.clear();
    var 
z;
    var 
pers;
    var 
sx;
    var 
sy;
    var 
tx;
    var 
ty;
    var 
polygon;
    var 
0;
    while (
k<this.Objekt3d.data3d.length) {
        
polygon = [];
        var 
0;
        while (
i<this.Objekt3d.data3d[k].Sides.length) {
            
this.Objekt3d.data3d[k].Sides[i].z+this.distance;
            
pers this.angle/z;
            
sx this.Objekt3d.data3d[k].Sides[i].x*pers;
            
sy this.Objekt3d.data3d[k].Sides[i].y*pers;
            
polygon.push({sx:sxsy:sy});
            
i++;
        }
        
= ((polygon[1].sx-polygon[0].sx)*(polygon[2].sy-polygon[0].sy))-((polygon[1].sy-polygon[0].sy)*(polygon[2].sx-polygon[0].sx));
        if (
z>0) {
            
this.mc.beginFill(this.Objekt3d.data3d[k].colourthis.Objekt3d.data3d[k].colour);
            
this.mc.moveTo(polygon[0].sxpolygon[0].sy);
            
this.mc.lineTo(polygon[1].sxpolygon[1].sy);
            
this.mc.lineTo(polygon[2].sxpolygon[2].sy);
            
this.mc.lineTo(polygon[3].sxpolygon[3].sy);
            
this.mc.lineTo(polygon[0].sxpolygon[0].sy);
        }
        
k++;
    }
};
Cube3d = new Objekt3d(cubeData);
Szene3D = new Kamera3d(Cube3d200400_root);
Szene3D.render();
Szene3D.mc._x 275;
Szene3D.mc._y 175;
_root.onEnterFrame = function() {
    
Cube3d.rotate3d((this._xmouse+100)/100, (this._ymouse+200)/100);
    
Szene3D.render();
}; 
Beispiel:
hier zur 3D Engine (Angina)

Be inspired

mfg
Matze K.