纳金网
标题:
[PV3D专题]绘制一个立方体
[打印本页]
作者:
.
时间:
2013-3-21 15:28
标题:
[PV3D专题]绘制一个立方体
先导入两个个基本类:import org.papervision3d.view.BasicView; import org.papervision3d.objects.primitives.Cube;
这个类是其他四个类的合体:Scene3D,Viewport3D,Camera3D,BasicRenderEngine,聪明的人为何不直接用这个基本类代替这四个类呢?呵呵
package
{
import flash.display.Scene;
import flash.display.Sprite;
import flash.events.Event;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.view.BasicView;
/**
* ...
* @author 北飘草 ..欢迎和大家一起研究PV3D
*/
public class Main extends BasicView
{
private var colorlist:MaterialsList;
private var cube:Cube;
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
var red:ColorMaterial = new ColorMaterial(0xff0000);
var green:ColorMaterial = new ColorMaterial(0x00ff00);
var blue:ColorMaterial = new ColorMaterial(0x0000ff);
colorlist = new MaterialsList();
colorlist.addMaterial(red, "front")
colorlist.addMaterial(red, "back")
colorlist.addMaterial(blue, "left")
colorlist.addMaterial(blue ,"right")
colorlist.addMaterial(green, "bottom")
colorlist.addMaterial(green, "top")
cube=new Cube(colorlist,500,500,500)
scene.addChild(cube)
startRendering();
}
override protected function onRenderTick(e:Event=null):void
{
cube.localRotationY += 1;
cube.localRotationX+= 1;
super.onRenderTick()
}
}}
立方体的cube构造函数 第一个是MaterialsList
【来源:互联网】
更多精彩教程,尽在web3D纳金网http://www.narkii.com/college/
作者:
89684598
时间:
2014-2-22 15:49
谢谢分享
欢迎光临 纳金网 (http://c-www.narkii.com/club/)
Powered by Discuz! X2.5