|
|
最近更新:
●
wan925446570阁下在 讨论区里
回复“怎么配置away3d 4.0运行环境啊?...”(15:12:45)
●
wan925446570阁下在 讨论区里
回复“怎么配置away3d 4.0运行环境啊?...”(10:01:38)
●
DDM君阁下在 讨论区里
回复“怎么配置away3d 4.0运行环境啊?...”(19:07:43)
|
|
|
浏览主题:问个基础的问题;
问个基础的问题;
中华 (2009-10-17 17:06:26)
d = 700; var homeRx = 0; var homeRy = 0; var homeRz = 0; var groundRx = 0; var groundRy = 0; var groundRz = 0; centerX = Stage.width/2; centerY = Stage.height/2; xObj = [70, -70, -70, 70, 70, -70, -70, 70, 75, -75, -75, 75, 75, -75, -75, 75, 120, -120, 120, -120]; yObj = [-50, -50, 50, 50, -50, -50, 50, 50, -50, -50, 50, 50, -50, -50, 50, 50, 50, 50, 50, 50]; zObj = [-50, -50, -50, -50, 50, 50, 50, 50, -55, -55, -55, -55, 55, 55, 55, 55]; groundX = [100, -100, -100, 100]; groundY = [50, 50, 50, 50]; groundZ = [-100, -100, 100, 100]; function TD(x, y, z, rotx, roty, rotz) { var sx = Math.sin(rotx); var cx = Math.cos(rotx); var sy = Math.sin(roty); var cy = Math.cos(roty); var sz = Math.sin(rotz); var cz = Math.cos(rotz); var xy, xz, yx, yz, zx, zy, ratio; xy = cx*y-sx*z; xz = sx*y+cx*z; yz = cy*xz-sy*x; yx = sy*xz+cy*x; zx = cz*yx-sz*xy; zy = sz*yx+cz*xy; var zfactor = _root.d/(_root.d+yz); x2 = zx*zfactor; y2 = zy*zfactor; return [x2, y2]; } function homeProject() { if (this.z-zoff<40) { this._visible = false; } else { this._visible = true; A1 = TD(this.x, this.y, this.z, _root.homeRx, _root.homeRy, _root.homeRz); this._x = A1[0]+centerX; this._y = A1[1]+centerY; } } function groundProject() { if (this.z-zoff<40) { this._visible = false; } else { this._visible = true; A1 = TD(this.x, this.y, this.z, _root.groundRx, _root.groundRy, _root.groundRz); this._x = A1[0]+centerX; this._y = A1[1]+centerY; } } _root.createEmptyMovieClip("home_mc",100); _root.createEmptyMovieClip("ground_mc",99); for (var i = 0; i var nm = "sphere"+(i-(-1)); _root.home_mc.attachMovie("sphere",nm,i); _root.home_mc[nm].x = xObj[i]; _root.home_mc[nm].y = yObj[i]; _root.home_mc[nm].z = zObj[i]; _root.home_mc[nm].onEnterFrame = homeProject; if (i<4) { _root.ground_mc.attachMovie("sphere",nm,i); _root.ground_mc[nm].x = groundX[i]; _root.ground_mc[nm].y = groundY[i]; _root.ground_mc[nm].z = groundZ[i]; _root.ground_mc[nm].onEnterFrame = groundProject; } } _root.home_mc.onEnterFrame = function() { if (Key.isDown(Key.LEFT)) { _root.homeRy += 0.1; } if (Key.isDown(Key.RIGHT)) { _root.homeRy -= 0.1; } if (Key.isDown(Key.UP)) { _root.homeRx += 0.1; } if (Key.isDown(Key.DOWN)) { _root.homeRx -= 0.1; } this.clear(); var fangzi_col = 0xFFFCE6; var fangzi_alpha = 30; this.lineStyle(1,0xC7C196,50); //内层 //前面 this.beginFill(fangzi_col,fangzi_alpha); this.moveTo(this.sphere1._x,this.sphere1._y); this.lineTo(this.sphere2._x,this.sphere2._y); this.lineTo(this.sphere3._x,this.sphere3._y); this.lineTo(this.sphere4._x,this.sphere4._y); this.lineTo(this.sphere1._x,this.sphere1._y); this.endFill(); //后面 this.beginFill(fangzi_col,fangzi_alpha); this.moveTo(this.sphere5._x,this.sphere5._y); this.lineTo(this.sphere6._x,this.sphere6._y); this.lineTo(this.sphere7._x,this.sphere7._y); this.lineTo(this.sphere8._x,this.sphere8._y); this.lineTo(this.sphere5._x,this.sphere5._y); this.endFill(); //右面 this.beginFill(fangzi_col,fangzi_alpha); this.moveTo(this.sphere1._x,this.sphere1._y); this.lineTo(this.sphere4._x,this.sphere4._y); this.lineTo(this.sphere8._x,this.sphere8._y); this.lineTo(this.sphere5._x,this.sphere5._y); this.lineTo(this.sphere1._x,this.sphere1._y); this.endFill(); //左面 this.beginFill(fangzi_col,fangzi_alpha); this.moveTo(this.sphere2._x,this.sphere2._y); this.lineTo(this.sphere3._x,this.sphere3._y); this.lineTo(this.sphere7._x,this.sphere7._y); this.lineTo(this.sphere6._x,this.sphere6._y); this.lineTo(this.sphere2._x,this.sphere2._y); this.endFill(); //外层 //前面 this.beginFill(fangzi_col,fangzi_alpha); this.moveTo(this.sphere9._x,this.sphere9._y); this.lineTo(this.sphere10._x,this.sphere10._y); this.lineTo(this.sphere11._x,this.sphere11._y); this.lineTo(this.sphere12._x,this.sphere12._y); this.lineTo(this.sphere9._x,this.sphere9._y); this.endFill(); //后面 this.beginFill(fangzi_col,fangzi_alpha); this.moveTo(this.sphere13._x,this.sphere13._y); this.lineTo(this.sphere14._x,this.sphere14._y); this.lineTo(this.sphere15._x,this.sphere15._y); this.lineTo(this.sphere16._x,this.sphere16._y); this.lineTo(this.sphere13._x,this.sphere13._y); this.endFill(); //右面 this.beginFill(fangzi_col,fangzi_alpha); this.moveTo(this.sphere9._x,this.sphere9._y); this.lineTo(this.sphere12._x,this.sphere12._y); this.lineTo(this.sphere16._x,this.sphere16._y); this.lineTo(this.sphere13._x,this.sphere13._y); this.lineTo(this.sphere9._x,this.sphere9._y); this.endFill(); //左面 this.beginFill(fangzi_col,fangzi_alpha); this.moveTo(this.sphere10._x,this.sphere10._y); this.lineTo(this.sphere11._x,this.sphere11._y); this.lineTo(this.sphere15._x,this.sphere15._y); this.lineTo(this.sphere14._x,this.sphere14._y); this.lineTo(this.sphere10._x,this.sphere10._y); this.endFill(); //底面 this.beginFill(fangzi_col,fangzi_alpha); this.moveTo(this.sphere9._x,this.sphere9._y); this.lineTo(this.sphere10._x,this.sphere10._y); this.lineTo(this.sphere14._x,this.sphere14._y); this.lineTo(this.sphere13._x,this.sphere13._y); this.lineTo(this.sphere9._x,this.sphere9._y); this.endFill(); var dimian_col = 0x22AA00; var dimian_alpha = 100; _root.ground_mc.lineStyle(1,0x22AA00,0); _root.ground_mc.beginFill(dimian_col,dimian_alpha); _root.ground_mc.moveTo(_root.ground_mc.sphere1._x,_root.ground_mc.sphere1._y); _root.ground_mc.lineTo(_root.ground_mc.sphere2._x,_root.ground_mc.sphere2._y); _root.ground_mc.lineTo(_root.ground_mc.sphere3._x,_root.ground_mc.sphere3._y); _root.ground_mc.lineTo(_root.ground_mc.sphere4._x,_root.ground_mc.sphere4._y); _root.ground_mc.lineTo(_root.ground_mc.sphere1._x,_root.ground_mc.sphere1._y); _root.ground_mc.endFill(); }; 用这样的方式也可以制作出一个3d的图形; 而3d引擎累里面有一大堆的东西;都不知道有什么用。很想了解基础3d引擎到底是基于什么样的基础,各个类之间的一些联系。
|
|