第一个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;
分享到:
相关推荐
是我打包好的PV3D的SWC、AS文件和英文API,相信大家都会用到。
pv3d flash 3d源码 pv3d flash 3d源码 pv3d flash 3d源码
pv3D 导入DAE模型 有原文件pv3D 导入DAE模型 有原文件pv3D 导入DAE模型 有原文件pv3D 导入DAE模型 有原文件pv3D 导入DAE模型 有原文件pv3D 导入DAE模型 有原文件pv3D 导入DAE模型 有原文件
pv3d开发包,想学pv3d的朋友一定要下的工具包
PV3D是流行的Flash3D技术,该资料包含了很多PV3D的资料,主要是学习的文档,还包括源码。
pv3d简单全景,一个非常简单的pv3d全景图。
pv3d网上搜的资料 供大家享用吧,pv3d是一款很有用的3d引擎,非常厉害
本软件PV3D是一个很著名的Flash 3D免费开源引擎,功能很强大,效率也可以。官方网站是http://www.papervision3d.org/,源代码下载地址是http://code.google.com/p/papervision3d/。目前最新版本是2.0a(Greate White)...
使用PV3D编写的太阳系,同时添加了鼠标事件处理,当鼠标移动到地球的时候,地球会停止旋转,鼠标移开继续旋转
pv3d hlep 英文 chm格式 API帮助文档
PV3D官网的展示:海底世界http://www.papervision3d.org/
pv3d开发工具as3 编写的pv3d开发工具as3 编写的pv3d开发工具as3 编写的pv3d开发工具as3 编写的
flash as3 3D开发引擎pv3D
开源3d引擎 pv3d源文件(AS3.0版)及demo.rar 开源3d引擎 pv3d源文件(AS3.0版)及demo.rar
Papervision3D Essentials学习笔记
pv3d的类和部分simple和3d模型(包括md2,dae,xml格式)和贴图
PV3D-GreatWhite-DOC. chm格式的pv3d api说明。
examples in pv3d 关于pv3d安装,简单运用的各种小实例,适合初学者
每个摄像机都从DisplayObject3D继承x,y,z属性,我们可以让摄影机绕坐标轴进行旋转.不但如此,还可以像旋转DisplayObject3D实例那样对摄影机进行操作.尽管摄影机没有在屏幕上可见,我们依然有很多方法可以控制它.摄影机...
PV3D 3D 电子书展示平台源码PV3D 3D 电子书展示平台源码