Si que puede simular 3d dentro de flash, mis conocimientos dan hasta aqui, pero lo posteo para mostrar:
Torno 3d: Como el Lathe de 3d Studio max, creas un Spline que luego es llevado por el eje a 360 grados creando la silueta 3d.
Esto lo hace rendereando los puntos que conforman la spline en una circunsferencia dada por los EjeX, EjeY y sus radios. Espero le guste:
Código :
//VARIABLES DE POSICION
//VARIABLES EJES
ejeX = 150;
ejeY = 10;
MovieClip.prototype.rotateXY = function(s, xo, a, yo, zo, eX, eY) {
this.a = a;
this.speed = s;
this.camara = 300;
this.radioX = eX;
this.radioY = eY;
this.xo = xo;
this.yo = yo;
this.zo = zo;
this.onEnterFrame = function() {
this._x = this.xo+this.radioX*Math.sin(this.a);
this._y = this.yo+this.radioY*Math.cos(this.a);
this.z = this.z0;
this.pers = this.camara/(this.z+this.camara);
this._x *= this.pers;
this._y *= this.pers;
this.a>=6.3 ? (id1.removeMovieClip(), _root.onEnterFrame=null, this.removeMovieClip()) : this.a += this.speed;
};
};
render = false;
onMouseDown = function () {
render ? clean() : null;
a++;
attachMovie("id", "id"+a, a, {_x:_xmouse, _y:_ymouse});
};
clean = function () {
render = false;
_root.clear();
a = 0;
};
lathe = function (s) {
render = true;
for (var i = 2; i<=a; i++) {
eval("id"+i).rotateXY(s, id1._x, 0, eval("id"+i)._y, 0, id1._x-(eval("id"+i)._x), ejeY);
}
_root.onEnterFrame = function() {
this.lineStyle(1, 0, 10);
this.moveTo(id1._x, id1._y);
for (var i = 2; i<=a; i++) {
this.lineTo(eval("id"+i)._x, eval("id"+i)._Y);
}
};
};
Cubo 3d:
Código :
//VARIABLES DE POSICION
x = 250;
y = 100;
y2 = 300;
//VARIABLES EJES
ejeX = 150;
ejeY = 30;
//VARIABLES COLOR
ColorCaras = 0x666666;
//VARIABLES ALPHA CARAS
transp = 40;
velocidad = 0.1;
//FIN VARIABLES
//CUBO CODE
MovieClip.prototype.rotateXY = function(s, xo, a, yo, zo, eX, eY) {
this.a = a;
this.speed = s;
this.camara = 300;
this.radioX = eX;
this.radioY = eY;
this.xo = xo;
this.yo = yo;
this.zo = zo;
this.onEnterFrame = function() {
this._x = this.xo+this.radioX*Math.sin(this.a);
this._y = this.yo+this.radioY*Math.cos(this.a);
this.z = this.z0;
this.pers = this.camara/(this.z+this.camara);
this._x *= this.pers;
this._y *= this.pers;
this.a += this.speed;
};
};
makeFace = function (mc1, mc2, mc3, mc4, col, i) {
this.createEmptyMovieClip("cont"+i, i*100);
this["cont"+i].beginFill(col, transp);
this["cont"+i].lineStyle(0, 0, 10);
this["cont"+i].moveTo(mc1._x, mc1._y);
this["cont"+i].lineTo(mc2._x, mc2._y);
this["cont"+i].lineTo(mc3._x, mc3._y);
this["cont"+i].lineTo(mc4._x, mc4._y);
this["cont"+i].lineTo(mc1._x, mc1._y);
this["cont"+i].endFill();
};
//FIN CUBO CODE
ball1.rotateXY(velocidad, x, 0, y, 0, ejeX, ejeY);
ball2.rotateXY(velocidad, x, Math.PI/2, y, 0, ejeX, ejeY);
ball3.rotateXY(velocidad, x, Math.PI, y, 0, ejeX, ejeY);
ball4.rotateXY(velocidad, x, Math.PI*3/2, y, 0, ejeX, ejeY);
ball5.rotateXY(velocidad, x, 0, y2, 0, ejeX, ejeY);
ball6.rotateXY(velocidad, x, Math.PI/2, y2, 0, ejeX, ejeY);
ball7.rotateXY(velocidad, x, Math.PI, y2, 0, ejeX, ejeY);
ball8.rotateXY(velocidad, x, Math.PI*3/2, y2, 0, ejeX, ejeY);
onEnterFrame = function () {
makeFace(ball2, ball1, ball4, ball3, ColorCaras, 1);
makeFace(ball1, ball2, ball3, ball4, ColorCaras, 2);
makeFace(ball1, ball5, ball8, ball4, ColorCaras, 3);
makeFace(ball2, ball6, ball7, ball3, ColorCaras, 4);
makeFace(ball4, ball3, ball7, ball8, ColorCaras, 5);
makeFace(ball1, ball5, ball6, ball2, ColorCaras, 6);
};
Cilindro 3d:
Código :
MovieClip.prototype.rotateXY = function(s, xo, a, yo, zo) {
this.a = a;
this.speed = s;
this.camara = 300;
this.radio =100
this.xo = xo;
this.yo = yo;
this.zo = zo;
this.onEnterFrame = function() {
this._x = this.xo+this.radio*Math.cos(this.a);
this._y = this.yo+this.radio*Math.sin(this.a);
this.z = 150;
this.pers = this.camara/(this.z+this.camara);
this._x *= this.pers;
this._y *= this.pers;
this.a += this.speed;
};
this.onMouseUp = function() {
this.onEnterFrame = function() {
this._x = this.xo+this.radio*Math.cos(this.a);
this._y = this.yo+this.radio*Math.sin(this.a);
this.z = this.z0+this.radio*Math.sin(this.a);
this.pers = this.camara/(this.z+this.camara);
this._x *= this.pers;
this._y *= this.pers;
this.a += this.speed;
};
};
this.onMouseDown = function() {
this.onEnterFrame = null;
};
};
makeFace = function (mc1, mc2, mc3, mc4, col) {
this.beginFill(col, 10);
this.lineStyle(0);
this.moveTo(mc1._x, mc1._y);
this.lineTo(mc2._x, mc2._y);
this.lineTo(mc3._x, mc3._y);
this.lineTo(mc4._x, mc4._y);
this.lineTo(mc1._x, mc1._y);
this.endFill();
};
for (var i = 1; i<39; i++) {
node = this.attachMovie("node", "ball"+i, i*10);
node.rotateXY(0.05, 150, ang += 50, 150, 150);
node._alpha = 0;
}
ang = 0;
for (var i = 39; i<(39*2); i++) {
node = this.attachMovie("node", "ball"+i, i*10);
this["ball"+i].rotateXY(0.05, 150, ang += 50, 300, 150);
node._alpha = 0;
}
delete ang;
end = 40;
init = 1;
inc = 1;
onEnterFrame = function () {
this.clear();
for (var i = 0; i<30; i++) {
makeFace(this["ball"+(init+(inc*i))], this["ball"+(init+((inc*i)+1))], this["ball"+(end+(inc*i))], this["ball"+(end+(inc*(i-1)))], 0);
}
};
Espiral 3d Customizada:Con interaccion del mouse en direccion y altura:
Código :
MovieClip.prototype.rotateXY = function(s, xo, a, yo, zo, r) {
this.turn = true;
this.a = a;
this.speed = s;
this.camara = 600;
this.radio = r;
this.xo = xo;
this.yo = yo;
this.zo = zo;
this.onEnterFrame = function() {
this._x = this.xo+this.radio*Math.cos(this.a);
this._y = this.yo+this.radio*Math.sin(this.a);
this.a += this.speed;
};
_root.onMouseMove = function() {
_root._xmouse-oldX>0 ? der=1 : der=-1;
oldX = _root._xmouse;
_root._ymouse-oldY>0 ? up=1 : up=-1;
oldY = _root._ymouse;
};
this.onMouseUp = function() {
this.onEnterFrame = null;
this.gotoAndStop(2);
if (this.turn) {
this.turn = false;
this.onEnterFrame = function() {
this._x = this.xo+this.radio*Math.cos(this.a);
this._y = this.yo+this.radio*Math.sin(this.b);
this.z = this.z0+this.radio*Math.sin(this.a);
this.pers = this.camara/(this.z+this.camara);
this._x *= this.pers;
this._y *= this.pers;
this._alpha = this.pers*50;
this._xscale = this._yscale=this.pers*100;
this.a += this.speed*der;
this.b += this.speed*up;
};
} else {
this.gotoAndStop(1);
this.turn = true;
this._xscale = this._yscale=100;
this._alpha = 100;
this.onEnterFrame = function() {
this._x = this.xo+this.radio*Math.cos(this.a);
this._y = this.yo+this.radio*Math.sin(this.a);
this.a += this.speed;
};
}
};
};
for (var i = 1; i<15; i++) {
for (var j = 1; j<15; j++) {
node = this.attachMovie("node", "ball"+i+"_"+j, d++);
node.rotateXY(0.05, 250, ang += 50, 200, 100, rad += 2);
}
}
Engine para la coordenada Z:
Código :
MovieClip.prototype.z = function(z) {
this.x = this._x;
this.y = this._y;
this.z = z;
this.camara = 300;
this.pers = this.camara/(this.z+this.camara);
this._x *= this.pers;
this._y *= this.pers;
this._xscale = this._yscale=this.pers*100;
};
makeFace = function (mc1, mc2, mc3, mc4, col, i) {
this.createEmptyMovieClip("cont"+i, i*100);
this["cont"+i].beginFill(col, 20);
this["cont"+i].lineStyle(1, 0, 50);
this["cont"+i].moveTo(mc1._x, mc1._y);
this["cont"+i].lineTo(mc2._x, mc2._y);
this["cont"+i].lineTo(mc3._x, mc3._y);
this["cont"+i].lineTo(mc4._x, mc4._y);
this["cont"+i].lineTo(mc1._x, mc1._y);
this["cont"+i].endFill();
};
for (var i = 0; i<12; i++) {
dot = attachMovie("id", "id"+i, i*10, {_x:150, _y:150});
dot.z(100*i);
}
for (var i = 4; i<8; i++) {
dot = attachMovie("id", "id"+i, i*10, {_x:600, _y:150});
dot.z(100*(i-4));
}
for (var i = 8; i<12; i++) {
dot = attachMovie("id", "id"+i, i*10, {_x:150, _y:450});
dot.z(100*(i-8));
}
for (var i = 12; i<16; i++) {
dot = attachMovie("id", "id"+i, i*10, {_x:600, _y:450});
dot.z(100*(i-12));
}
makeFace(eval("id0"), eval("id8"), eval("id12"), eval("id4"), 0, 1000);
makeFace(eval("id1"), eval("id9"), eval("id13"), eval("id5"), 0, 1001);
makeFace(eval("id2"), eval("id10"), eval("id14"), eval("id6"), 0, 1002);
makeFace(eval("id3"), eval("id11"), eval("id15"), eval("id7"), 0, 1003);
makeFace(eval("id0"), eval("id1"), eval("id2"), eval("id3"), 0, 1004);
makeFace(eval("id4"), eval("id5"), eval("id6"), eval("id7"), 0, 1005);
makeFace(eval("id8"), eval("id9"), eval("id10"), eval("id11"), 0, 1006);
makeFace(eval("id12"), eval("id13"), eval("id14"), eval("id15"), 0, 1007);
Espirografo 3d :
Código :
//VARIABLES DE POSICION
//VARIABLES EJES
ejeX = 150;
ejeY = 10;
MovieClip.prototype.rotateXY = function(s, xo, a, yo, zo, eX, eY) {
this.a = a;
this.speed = s;
this.camara = 300;
this.radioX = eX;
this.radioY = eY;
this.xo = xo;
this.yo = yo;
this.zo = zo;
this.onEnterFrame = function() {
this._x = this.xo+this.radioX*Math.sin(this.a);
this._y = this.yo+this.radioY*Math.cos(this.a);
this.z = this.z0;
this.pers = this.camara/(this.z+this.camara);
this._x *= this.pers;
this._y *= this.pers;
this.a>=20 ? (id1.removeMovieClip(), _root.onEnterFrame=null, this.removeMovieClip()) : this.a += this.speed;
this.radioX += s*3;
this.radioY += s*10;
};
};
render = false;
onMouseDown = function () {
render ? clean() : null;
a++;
attachMovie("id", "id"+a, a, {_x:_xmouse, _y:_ymouse});
};
clean = function () {
render = false;
_root.clear();
a = 0;
};
lathe = function (s) {
render = true;
for (var i = 2; i<=a; i++) {
eval("id"+i).rotateXY(s, id1._x, 0, eval("id"+i)._y, 0, id1._x-(eval("id"+i)._x), ejeY);
}
_root.onEnterFrame = function() {
this.lineStyle(1, random(0xff000), 5);
this.moveTo(id1._x, id1._y);
for (var i = 2; i<=a; i++) {
this.lineTo(eval("id"+i)._x, eval("id"+i)._Y);
}
};
};
3d Aleatorio:
Código :
MovieClip.prototype.rotateXY = function(s, xo, a, yo, zo) {
this.a = a;
this.speed = s;
this.camara = 250;
this.radio = 100;
this.xo = xo;
this.yo = yo;
this.zo = zo;
this.onEnterFrame = function() {
this._x = this.xo+this.radio*Math.cos(this.a);
this._y = this.yo+this.radio*Math.sin(this.a);
this.z = this.z0+this.radio*Math.sin(this.a);
this.pers = this.camara/(this.z+this.camara);
this._x *= this.pers;
this._y *= this.pers;
this.a += this.speed;
};
this.onMouseUp = function() {
this.onEnterFrame = function() {
this._x = this.xo+this.radio*Math.cos(this.a);
this._y = this.yo+this.radio*Math.sin(this.a);
this.z = this.z0+this.radio*Math.sin(this.a);
this.pers = this.camara/(this.z+this.camara);
this._x *= this.pers;
this._y *= this.pers;
this.a += this.speed;
};
};
this.onMouseDown = function() {
this.onEnterFrame = null;
};
};
makeFace = function (mc1, mc2, mc3, mc4, col) {
this.beginFill(col, 10);
this.moveTo(mc1._x, mc1._y);
this.lineTo(mc2._x, mc2._y);
this.lineTo(mc3._x, mc3._y);
this.lineTo(mc4._x, mc4._y);
this.lineTo(mc1._x, mc1._y);
this.endFill();
};
ang = random(180);
for (var i = 1; i<5; i++) {
node = this.attachMovie("node", "ball"+i, i*10);
node.rotateXY(0.1, 150, ang += 20, 150, 150);
node._alpha = 0;
}
ang = random(360)+180;
for (var i = 5; i<9; i++) {
node = this.attachMovie("node", "ball"+i, i*10);
this["ball"+i].rotateXY(0.1, 150, ang += 20, 300, 150);
node._alpha = 0;
}
delete ang;
onEnterFrame = function () {
this.clear();
makeFace(ball1, ball2, ball3, ball4, 0x66666);
makeFace(ball1, ball5, ball8, ball4, 0x99999);
makeFace(ball2, ball6, ball7, ball3, 0);
makeFace(ball4, ball3, ball7, ball8, 0x333333);
makeFace(ball1, ball5, ball6, ball2, 0x222222);
makeFace(ball2, ball1, ball4, ball3, 0x444444);
};
Estas aplicaciones son hermosas pero me llevaron mucho tiempo y son muy precarias. Solo las uso para interactividades complejas o efectos sobre fotos por ejemplo, ya que pueda utilizarlo sobre mascaras y demas, esos efectos armarlos sobre 3d Studio, Plasma, o Swift no los podrias armar
Espero que le sirvan a alguien los codes y si alguien quiere emprolijarlos sientase libre que son codigos medios desordenados por su naturaleza matematica solo me concentre en ellos.
Salu2, Hernan . -