![]() |
|
||||||||||
|
|||||
|
Регистрация: Apr 2003
Адрес: DC
Сообщений: 4,489
|
insertSorting = function (a, lb, ub) {
for (i=lb+1; i<=ub; i++) { t = a[i].z; temp = a[i].i; for (j=i-1; j>=lb && (a[j].z>t); j--) { a[j+1].z = a[j].z; a[j+1].i = a[j].i; } a[j+1].z = t; a[j+1].i = temp; } return (a); }; sort = function () { sortedArr = new Array(); for (var i = 0; i<=faces; i++) { sortedArr[i] = new Object(); sortedArr[i].z = f[i].zindex(); sortedArr[i].i = i; } sortedArr = insertSorting(sortedArr, 0, faces); for (var i = 0; i<=faces; i++) { f[sortedArr[faces-i].i].fill(); } }; vertex = function (x, y, z) { this.x = x; this.y = y; this.z = z; }; vertex.prototype.rotateXY = function(sinX, cosX, sinY, cosY) { //rotation around of axes X and Y var yp = this.y*cosY-this.z*sinY; var zp = this.y*sinY+this.z*cosY; var xp = this.x*cosX+zp*sinX; var zp = -this.x*sinX+zp*cosX; this.x = xp; this.y = yp; this.z = zp; }; vertex.prototype.perspective = function() { //calculation 3d to 2d var perRatio = 1/(this.z/dist+1); this.rx = cnx+this.x*perRatio; this.ry = cny+this.y*perRatio; }; face = function (c, d, a) { // dimension of the face this.d = d; this.c = c; // array of the vertexs included in the face this.a = a; }; face.prototype.draw = function() { shadow = 0; for (var i = 0; i<=this.d; i++) { shadow += (-v[this.a[i]].rx+v[this.a[i]].ry); } shadow = 140+shadow/(this.d+2); _root.lineStyle(0, 0x000000, 100); _root.beginFill(shadow << 16 | shadow << 8 | shadow << 0, 100); _root.moveTo(v[this.a[0]].rx, v[this.a[0]].ry); for (var i = 1; i<=(this.d); i++) { _root.lineTo(v[this.a[i]].rx, v[this.a[i]].ry, v[this.a[i+1]].rx, v[this.a[i+1]].ry); } _root.endFill(); }; face.prototype.fill = function() { var vis = ((v[this.a[1]].rx-v[this.a[0]].rx)*(v[this.a[2]].ry-v[this.a[0]].ry)-(v[this.a[1]].ry-v[this.a[0]].ry)*(v[this.a[2]].rx-v[this.a[0]].rx)); if ((this.c+2)%2) { vis *= -1; } if (vis>=0) { this.draw(); } delete vis; }; face.prototype.zindex = function() { var zindex = 0; for (var i = 0; i<=this.d; i++) { zindex += v[this.a[i]].z; } return (Math.round(zindex)); delete zindex; }; _root.onLoad = function() { cnx = 250; cny = 250; dist = 200; var radius = 100; var width = 50; rad = Math.PI/180; preRad = rad/25; // initialization of the vertexs & build star v = new Array(); var ang = (360/10)*rad; for (var i = 0; i<=19; i += 2) { var angle = ang*i; var width = (i == 10) ? -width : width; v[i+1] = new vertex(Math.cos(angle)*radius*0.5, Math.sin(angle)*radius*0.5, width); v[i] = new vertex(Math.cos(angle)*radius, Math.sin(angle)*radius, width); } // initialization of the faces f = new Array(); f[0] = new face(0, 9, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); f[1] = new face(1, 9, [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]); f[2] = new face(0, 3, [0, 1, 11, 10]); f[3] = new face(0, 3, [1, 2, 12, 11]); f[4] = new face(0, 3, [2, 3, 13, 12]); f[5] = new face(0, 3, [3, 4, 14, 13]); f[6] = new face(0, 3, [4, 5, 15, 14]); f[7] = new face(0, 3, [5, 6, 16, 15]); f[8] = new face(0, 3, [6, 7, 17, 16]); f[9] = new face(0, 3, [7, 8, 18, 17]); f[10] = new face(0, 3, [8, 9, 19, 18]); f[11] = new face(0, 3, [9, 0, 10, 19]); // ---------------------------------- faces = f.length-1; amount = v.length-1; // --------------- delete radius, width, ang, angle; }; // #################################################### // -- 3D STAR + REAL Z SORTING // -- © 2002-2003 Grigory Ryabov. // -- http://www.flash.plux.ru // #################################################### _root.onEnterFrame = function() { var xa = -(cnx-_ymouse)*preRad; var ya = (cny-_xmouse)*preRad; var sinY = Math.sin(ya); var cosY = Math.cos(ya); var sinX = Math.sin(xa); var cosX = Math.cos(xa); for (var i = 0; i<=amount; i++) { v[i].rotateXY(sinY, cosY, sinX, cosX); v[i].perspective(); } _root.clear(); sort(); }; stop();
__________________
flash/flex/unity |
|
|||||
|
Регистрация: Apr 2003
Адрес: DC
Сообщений: 4,489
|
Кто не понял - Вставляете этот код в первый кадр Flash MX.
__________________
flash/flex/unity |
|
|||||
|
Bumble Bee
[+1 05.07.06]
|
nuran, все уже знают что ты можешь....!но я думаю, что уже всем надоело, что ты каждый исходник рекламируешь сдесь! и ждешь пока скажут:"Оооооо.....дааааааа......бомбааа!ваще!!!!!ты лучший!"!
я ничё не могу сказать против!круто!но только мож хватит на каждый сорс сюда сувать линк или код! ЗЫ:Вот и погоны тебе об этом буду напоминать.... ![]()
__________________
Portfolio |
|
|||||
|
Регистрация: Nov 2001
Адрес: spb.ru
Сообщений: 177
|
|
|
|||||
|
Регистрация: Apr 2003
Адрес: DC
Сообщений: 4,489
|
2 пушистик.
Да я ничего не жду. Я просто для flasher'ов выложил. Наоборот им не надо ни куда отсюда заходить, а сразу вставить этот код в flash и всё. Разве так хуже, чем дать прямую ссылку на исходник????
__________________
flash/flex/unity |
|
|||||
|
Регистрация: Apr 2003
Адрес: DC
Сообщений: 4,489
|
А кто его возьмёт?
Даже если я толково напишу, на 2000 строк, какая хрен разница его на flasher.ru не возьмут. Или я не прав? Мне просто влом. А что касается именно этого исходника, то есть маленькое пояснение по этому коду. Смотрите здесь: http://www.flash.plux.ru/html/rus/fl...dstarV2__X.htm Работающий эффект здесь: http://www.flash.plux.ru/html/rus/flash/3d/3dstar.htm Ещё одна версия здесь: http://www.flash.plux.ru/html/rus/flash/3d/3dstarV2.htm
__________________
flash/flex/unity |
|
|||||
|
Регистрация: Apr 2003
Адрес: DC
Сообщений: 4,489
|
insertSorting = function (a, lb, ub) {
for (i=lb+1; i<=ub; i++) { t = a[i].z; temp = a[i].i; for (j=i-1; j>=lb && (a[j].z>t); j--) { a[j+1].z = a[j].z; a[j+1].i = a[j].i; } a[j+1].z = t; a[j+1].i = temp; } return (a); }; sort = function () { sortedArr = new Array(); for (var i = 0; i<=faces; i++) { sortedArr[i] = new Object(); sortedArr[i].z = f[i].zindex(); sortedArr[i].i = i; } sortedArr = insertSorting(sortedArr, 0, faces); for (var i = 0; i<=faces; i++) { f[sortedArr[faces-i].i].fill(); } }; vertex = function (x, y, z) { this.x = x; this.y = y; this.z = z; }; vertex.prototype.rotateXY = function(sinX, cosX, sinY, cosY) { //rotation around of axes X and Y var yp = this.y*cosY-this.z*sinY; var zp = this.y*sinY+this.z*cosY; var xp = this.x*cosX+zp*sinX; var zp = -this.x*sinX+zp*cosX; this.x = xp; this.y = yp; this.z = zp; }; vertex.prototype.perspective = function() { //calculation 3d to 2d var perRatio = 1/(this.z/dist+1); this.rx = cnx+this.x*perRatio; this.ry = cny-this.y*perRatio; }; face = function (c, d, a) { // dimension of the face this.d = d; this.c = c; // array of the vertexs included in the face this.a = a; }; face.prototype.draw = function() { shadow = 0; for (var i = 0; i<=this.d; i++) { shadow += (-v[this.a[i]].rx+v[this.a[i]].ry); } shadow = 130+shadow/(this.d+this.d/2); _root.star.lineStyle(0, 0x000000, 100); _root.star.beginFill(shadow << 16 | shadow << 8 | shadow << 0, 100); _root.star.moveTo(v[this.a[0]].rx, v[this.a[0]].ry); for (var i = 1; i<=(this.d); i++) { _root.star.lineTo(v[this.a[i]].rx, v[this.a[i]].ry, v[this.a[i+1]].rx, v[this.a[i+1]].ry); } _root.star.endFill(); }; face.prototype.fill = function() { var vis = ((v[this.a[1]].rx-v[this.a[0]].rx)*(v[this.a[2]].ry-v[this.a[0]].ry)-(v[this.a[1]].ry-v[this.a[0]].ry)*(v[this.a[2]].rx-v[this.a[0]].rx)); if ((this.c+2)%2) { vis *= -1; } if (vis>=0) { this.draw(); } delete vis; }; face.prototype.zindex = function() { var zindex = 0; for (var i = 0; i<=this.d; i++) { zindex += v[this.a[i]].z; } return (Math.round(zindex)); delete zindex; }; _root.onLoad = function() { _root.createEmptyMovieClip("star", 1); _root.star.onEnterFrame = function() { this._x += this._xmouse/10; this._y += this._ymouse/10; }; cnx = 0; cny = 0; dist = 200; var radius = 100; var width = 50; rad = Math.PI/180; preRad = rad/25; // initialization of the vertexs & build star v = new Array(); var ang = (360/10)*rad; for (var i = 0; i<=19; i += 2) { var angle = ang*i; var width = (i == 10) ? -width : width; v[i+1] = new vertex(Math.cos(angle)*radius*0.5, Math.sin(angle)*radius*0.5, width); v[i] = new vertex(Math.cos(angle)*radius, Math.sin(angle)*radius, width); } // initialization of the faces f = new Array(); f[0] = new face(1, 9, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); f[1] = new face(0, 9, [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]); f[2] = new face(1, 3, [0, 1, 11, 10]); f[3] = new face(1, 3, [1, 2, 12, 11]); f[4] = new face(1, 3, [2, 3, 13, 12]); f[5] = new face(1, 3, [3, 4, 14, 13]); f[6] = new face(1, 3, [4, 5, 15, 14]); f[7] = new face(1, 3, [5, 6, 16, 15]); f[8] = new face(1, 3, [6, 7, 17, 16]); f[9] = new face(1, 3, [7, 8, 18, 17]); f[10] = new face(1, 3, [8, 9, 19, 18]); f[11] = new face(1, 3, [9, 0, 10, 19]); // ---------------------------------- faces = f.length-1; amount = v.length-1; // --------------- delete radius, width, ang, angle; }; // #################################################### // -- 3D STAR V2 + REAL Z SORTING // -- © 2002-2003 Grigory Ryabov. // -- http://www.flash.plux.ru // #################################################### _root.onEnterFrame = function() { var xa = (cny-star._ymouse*2)*preRad; var ya = (cnx-star._xmouse*2)*preRad; var sinY = Math.sin(ya); var cosY = Math.cos(ya); var sinX = Math.sin(xa); var cosX = Math.cos(xa); for (var i = 0; i<=amount; i++) { v[i].rotateXY(sinY, cosY, sinX, cosX); v[i].perspective(); } _root.star.clear(); sort(); }; stop();
__________________
flash/flex/unity |
![]() |
Часовой пояс GMT +4, время: 05:26. |
|
|
« Предыдущая тема | Следующая тема » |
|
|