`
hereson
  • 浏览: 1430342 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

PV3D第一个测试文件

    博客分类:
  • Pv3d
阅读更多
第一个PV3D的测试文件:
这个实例是根据一个网站视频教程里学着做的,用来测试PV3D的环境,我在做完之后查了帮助文档,加上一些注释:
教程的网址是:http://www.gotoandlearn.com/

测试文档的源文件如下:
需要在库中加上一个(位图)元件并右击创建"链接名"为Icon才可以调试

//-----------------------------------------------------------------------------------------------------------------

//导入PV3D包
import org.papervision3d.cameras.*;//导入PV3D的3D相机   (Camera3D)
import org.papervision3d.objects.*;//导入PV3D对象包是   (Plane)
import org.papervision3d.scenes.*;//导入PV3D场景包       (Scene3D)
import org.papervision3d.materials.*;//导入PV3D材质包     (BitmapAssetMaterial 位图材质)
//------------------------------------------
var container:Sprite=new Sprite();//定义一个容器
container.x=stage.stageWidth*0.5;
container.y=stage.stageHeight*0.5;
addChild(container);//加入成为显示对像
//定义容器的位置以便把他加入到3D场景中
var sence:Scene3D=new Scene3D(container);//把容器转换成为3D场景
//------------帮助文件-----------------:
//The Scene3D class lets you create a scene where all objects are rendered in the same container.
//Scene3D类让你可以创建一个所在对像都可以演示的容器
//--------------------------------------------------------------------
var camera:Camera3D=new Camera3D();//定议一个3D相机
//------------帮助文件-----------------:
//The Camera3D class creates a camera that views the area around a target object.
//Camera3D类用来创建一个观看范围围绕目标对象的相机
//--------------------------------------------------------------------
camera.zoom=5;
//------------帮助文件-----------------:
//This value specifies the scale at which the 3D objects are rendered.
//用来设定目标对象的显示比例
//-------------------------------------------------------------------
var bam:BitmapAssetMaterial=new BitmapAssetMaterial("img");
//------------帮助文件-----------------:
//The BitmapAssetMaterial class creates a texture from a Bitmap library symbol.
//这个类根据位图库里的位图元件来创建一个材质
//-------------------------------------------------------------------
bam. oneSide = false;
//------------帮助文件-----------------:
//A Boolean value that indicates whether the faces are single sided
//定义是一个多面材质还是单面的
//-------------------------------------------------------------------
bam.smooth=true;
//------------帮助文件-----------------:
//A Boolean value that determines whether the BitmapData texture is smoothed when rendered.
//是否平滑
//-------------------------------------------------------------------
for (var i:uint=0; i<50; i++) {
var p:Plane=new Plane(bam,234,236,2,2);
//------------帮助文件-----------------:
//The Plane class lets you create and display flat rectangle objects.
//创建一个平面长方形
//参数:
//Plane () constructor
//public function Plane(material:MaterialObject3D = null,(材质)
//width:Number = 0, height:Number = 0,
//segmentsW:Number = 0(水平方向节点数),segmentsH:Number = 0(垂直方向节点数), initObject:Object = null)
//initObject参数不知道什么意思:
//An object that contains user defined properties with which to populate the newly created GeometryObject3D.
//-------------------------------------------------------------------
sence.addChild(p);//把平面添加到显示对像中
p.x=Math.random()*1000-50;
p.y=Math.random()*1000-50;
p.z=Math.random()*1000-50;
p.rotati.random()*360;
//------------帮助文件-----------------
//Specifies the rotation around the Y axis from its original orientation.
//定议围绕Y转旋转的角度
//-------------------------------------------------------------------
}

this.addEventListener(Event.ENTER_FRAME,domc);
function domc(e:Event):void
{
camera.x+=stage.mouseX-(stage.stageWidth*0.5);
//------------帮助文件-----------------
//An Number that sets the X coordinate of a object relative to the origin of its parent.
//定议相对于目标的X转的旋转角度(好像是这样)
//-------------------------------------------------------------------
camera.y+=stage.mouseY-(stage.stageHeight*0.5);
//------------帮助文件-----------------
//An Number that sets the Y coordinate of a object relative to the origin of its parent.
//定议相对于目标的Y转的旋转角度(好像是这样)
//-------------------------------------------------------------------
sence.renderCamera(camera);
//------------帮助文件-----------------
//Generates an image from the camera's point of view and the visible models of the scene.
//根据照相机拍到的场景中的可见模型部生图像
//-------------------------------------------------------------------
}

FLEX中应用有几个地方需要改动:
1.在flex project(AIR)中,由于主场景不是sprite而是WindowedApplication,所以不能使用addChild(sprite),必需把上面的var container:Sprite=new Sprite();//定义一个容器 改成 var container:UIComp UIComponent();//
其它的不变
2.在flex 里头,没有库元件这么一说(好像没有),所以在贴图的地方不能用BitmapAssetMaterial类,需要改成
BitmapFileMaterial(imgURL)
就是把原来调用库链接的方法直接调用外部文件的URL;
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics