NewX3D V2.02更新
update info:
performance optimization.fps +20%
性能优化,速度提高20%
update info:
performance optimization.fps +20%
性能优化,速度提高20%
因为好多人说不会用引擎,而我也较忙,只能暂时先给demo补充一些中文说明供大家参考。我争取尽快补充文档。感谢大家对本引擎的支持。svn上面已经更新。
/**
* NewX3D
*
* AUTHOR: Ma Chao
* EMAIL: machaoii@263.net
* MSN: machaoii@hotmail.com
* QQ: 68552233
* _____________________________________________________________
* http://newx3d.cn/blog http://code.google.com/p/newx3d/
*
* Copyright 2008 Ma Chao
Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
{
import cn.newx.camera.Camera3D;
//import cn.newx.data.Vector4D;
import cn.newx.data.ZBuffer;
import cn.newx.geometry.DAE;
import cn.newx.materials.MaterialManager;
import cn.newx.render.NXZBufferRender;
import cn.newx.utils.FPS;
import flash.display.Sprite;
import flash.events.*;
import flash.geom.Vector3D;
//[SWF (width='400',height='400',backgroundColor='0x000000',frameRate='120')]
public class DAETest extends Sprite
{
//声明dae模型
private var dae:DAE;
//声明相机
private var cam:Camera3D;
//定义相机坐标x,y,z
private var cam_pos:Vector3D=new Vector3D(0,0,-50);
//定义相机朝向x,y,z
private var cam_dir:Vector3D=new Vector3D(0,0,20);
//声明显示模型的容器
private var sprite:Sprite;
//声明z缓冲
private var zbuffer:ZBuffer;
//声明材质管理器
private var mm:MaterialManager;
//声明渲染引擎
private var render:NXZBufferRender;
//下面几个都是让球按不同速度转的数据
private var r:int=0;
private var xsignal:int=1;
private var ysignal:int=1;
private var zsignal:int=1;
public function DAETest()
{
sprite=new Sprite();
this.addChild(sprite);
//初始化相机,参数分别为位置,朝向,视口宽度,视口高度
cam=new Camera3D(cam_pos, cam_dir, 400, 400);
//初始化z缓冲,参数为视口宽度,视口高度
zbuffer=new ZBuffer(400,400);
//初始化材质管理器
mm=new MaterialManager();
//初始化dae模型,参数为模型的路径
dae=new DAE(”texture/shuilei.dae”);
//设置材质文件路径(引擎自动识别材质文件名,只需要提供路径即可),默认为和swf在同一目录下。
dae.setMaterialFolder(”texture/”);
//连接相机(必须要有)
dae.attachCam(cam);
//连接材质管理器(必须要有)
dae.attachMaterialManager(mm);
//dae.singnal()是模型的事件发生器,这里表示模型加载完毕的事件。
dae.signal().addEventListener(Event.COMPLETE,doRender)
//载入模型
dae.load();
var fps:FPS=new FPS();
this.addChild(fps);
}
public function doRender(ev:Event):void{
//初始化渲染引擎,参数为dae模型,显示模型的容器,材质管理器,z缓冲,是否平滑处理。
render=new NXZBufferRender(dae,sprite,mm,zbuffer,cam,true);
this.addEventListener(Event.ENTER_FRAME,xxx);
}
private function xxx(ev:Event):void{
//var speed:int=Math.round(Math.random()*10);
//dae.getChildByName(”objpolySurface31″)。如果一个dae文件里面有多个模型,系统会把它们自动加载为dae的child。其中的name就是你在3dmax里面设置的几何体的name.
//这样可以让你轻松操作单个几何体。
dae.getChildByName(”objpolySurface31″).rotationY(5);
dae.getChildByName(”objpolySurface31″).rotationX(5);
dae.getChildByName(”objpolySurface31″).rotationZ(5);
if(dae.getChildByName(”objpolySurface31″).x>50){
xsignal=-1;
}
else if(dae.getChildByName(”objpolySurface31″).x<-50){
xsignal=1;
}
if(dae.getChildByName(”objpolySurface31″).y>50){
ysignal=-1;
}
else if(dae.getChildByName(”objpolySurface31″).y<-40){
ysignal=1;
}
if(dae.getChildByName(”objpolySurface31″).z>80){
zsignal=-1;
}
else if(dae.getChildByName(”objpolySurface31″).z<10){
zsignal=1;
}
dae.getChildByName(”objpolySurface31″).x+=xsignal;
dae.getChildByName(”objpolySurface31″).y+=ysignal;
dae.getChildByName(”objpolySurface31″).z+=zsignal;
//执行渲染
render.render();
}
}
}
忙死了,搞得文档和教程的发布都被拖延了,很多朋友肯定还不会用=.=(其实很简单,对关键方法说明一下马上就会用的)
老板要几个人在一个月里搞出一个sns,偶地神阿。。。。。
随时准备跑路,可怎么也得弄完了再跑,不能没上战场就当逃兵=。=如果哪位兄台有合适的工作希望能够推荐给我,十分感谢。
另外再公布一下newx3d的qq群 66938764,有问题暂时先用这个交流,唉,继续忙去了….
这次地举办地点离家很近hoho 估计写这篇文章的时候很多兄弟还没到家呢。
今天收获挺多的 尤其是flash3d和text render这两方面。
3d方面没有什么新消息,但是对以前的一些猜测得到官方证实,比如硬件加速目前支持的只是图形效果和视频。也就是说fp10在3d model方面仍然是大半软=。=虽然有些遗憾但是却有了更多的期待,毕竟我不认为adobe没有那个能力做真3d的实现,而是综合很多方面的考虑,比如跨平台兼容和plugin大小等等,用7yue的话就是要有取舍的做,而不是完全搬过来。不过当一切条件都成熟了自然就都水到渠成,敬请期待吧。
Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes