AS3 DAE增强现实PaperVision 3D [英] AS3 DAE Augmented Reality PaperVision 3D

查看:324
本文介绍了AS3 DAE增强现实PaperVision 3D的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在玩增强现实最近(和有很多乐趣与它太!!)我已经能够创建PaperVision元(立方体,圆柱体,圆锥体等。并与他们的工作),但添加DAE模型被证明是虚假的!

I have been playing with Augmented Reality recently (and having lots of fun with it too!!) I have been able to create PaperVision primitives (cube, cylinder, cone, etc.. and work with them) But adding a DAE model is proving to be illusive!

var cubeMaterialList:MaterialsList = new MaterialsList( { all: new FlatShadeMaterial(light, 0x0099FF, 0x0066AA) } );

            var cube:Cube = new Cube(cubeMaterialList,
                                     30,
                                     30,
                                     30);

            cube.z += 15;

            mainContainer.addChild(cube);

这一切工作正常!

我用这导入/尝试导入的DAE!

I am using this to import/attempt to import a dae!

private var mCollada:Collada;
private var universe:DisplayObject3D;
mCollada = new Collada("sample.dae");
universe = new DisplayObject3D();
universe.addChild(mCollada);
        mainContainer.addChild(universe);

我已经使用导入的DAE到非增强现实PaperVision项目,这种方法和它的作品一种享受!所以,只是想知道如果任何人有任何运气在导入的DAE与AR!

I have used this method of importing DAEs into a non-Augmented Reality PaperVision projects and it works a treat! So just wondering if anyone had any luck at importing DAEs with AR!

推荐答案

点击此处查看所需的进口和工作演示视频。

我注意到你正在使用的Collada类,相对于DAE,阶级,两者扮演一个有点不同的显示在视频的Abobe。

I notice that you are using the Collada Class, as opposed to the DAE, class, which both act a bit differently as is displayed in the video abobe.

同样重要的是要注意,你很可能被正确这样做的,存在与模型或可能甚至纹理的问题。如果纹理没有加载,你应该立即从控制台知道。尝试创建一个ColorMaterial并创建一个MaterialsList对象设置所有属性设置为您创建的ColorMaterial。最后的名单传给了的Collada或DAE类通过实例化或负载的方法的实例。另外,还要确保相机不放大关闭,可能离开其背后的3D对象。最后,随着规模的发挥,并非所有型号都在相同的比例,并使用Collada的类,而不是DAE,似乎吹模型了相当多的如上面的视频链接。

It is also important to note that you may very well be doing this correctly and that there is a problem with the model or possibly even the texture. If the texture isn't loading you should know immediately from the console. Try creating a ColorMaterial and create a MaterialsList object setting the "all" property to the ColorMaterial you created. Finally pass the list to the instantiation of Collada or DAE Classes through the instantiation or load method. Also make sure that the camera isn't zoomed in to close, possibly leaving the 3D Object behind it. Finally play with the scale, not all models come in at the same scale, and using Collada class, as opposed to DAE, seems to blow the model up considerable as shown in the video link above.

我有很多时间与FlarToolkit / Papervision3D的/ Collada的合作伙伴关系,最近在preparations的托尼霍克第十一网站播放。

I have had a lot of time to play with the FlarToolkit / Papervision3D / Collada partnership lately in preparations for the Tony Hawk XI website.

  • 在一个IDE,我用FlashDevelop3 RC2,但Flex Builder中或您选择的IDE将工作。
  • 在Papervision3D的2.0 Whiteshark,(最新版本)
  • 的Flex 3.3 SDK
  • 耐心
  • 使用谷歌3D模型库我的COLLADA文件。
  • 下一步采取.skp的SketchUp文件到谷歌Sketchup的。
  • 确保SketchUp的窗口具有焦点和命中CTRL和A在同一时间。 (全选)
  • 头高达编辑,再往下拉列表的底部,它通常会说你有多少组选择。
  • 选择爆炸。
  • 重复,直到你能不能爆炸了。 (如果您使用的是低多边形模型像你应该,这不应该需要很长时间。)
  • CTRL + A再次选择所有。
  • 转到文件>导出> 3D模型并选择.dae//如果你没有自己的SketchUp中.dae扩展不可用,查找工作围绕:)(本质上.dae被包裹在.skp
  • 您现在有一个.dae文件,并使用相同的确切名称的文件夹,带有纹理有关该模型在其内部。
  • Use Google 3D Warehouse for my Collada files.
  • Next take the ".skp" sketchup file into Google Sketchup.
  • Make sure the sketchup window has focus and hit CTRL and A at the same time. (Select all)
  • Head up to edit, and go down to the bottom of the drop-down list where it will typically say how many groups you have selected.
  • Choose explode.
  • Repeat until you cannot explode any more. (If you are using low-poly models like you are supposed to, this shouldn't take long.)
  • CTRL + A to select all again.
  • Goto File > Export > 3D Model and choose ".dae" //If you do not own Sketchup the .dae extension is not available, lookup the work around :) (Essentially the .dae is wrapped in the ".skp"
  • You will now have a .dae file, and a folder with the same EXACT name, with textures pertaining to the model inside of it.
package 
{
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.media.Camera;
    import flash.media.Video;
    import flash.utils.ByteArray;
    import org.libspark.flartoolkit.core.FLARCode;
    import org.libspark.flartoolkit.core.param.FLARParam;
    import org.libspark.flartoolkit.core.raster.rgb.FLARRgbRaster_BitmapData;
    import org.libspark.flartoolkit.core.transmat.FLARTransMat;
    import org.libspark.flartoolkit.core.transmat.FLARTransMatResult;
    import org.libspark.flartoolkit.detector.FLARSingleMarkerDetector;
    import org.libspark.flartoolkit.pv3d.FLARBaseNode;
    import org.libspark.flartoolkit.pv3d.FLARCamera3D;
    import org.papervision3d.cameras.Camera3D;
    import org.papervision3d.render.LazyRenderEngine;
    import org.papervision3d.scenes.Scene3D;
    import org.papervision3d.view.Viewport3D;
    import org.papervision3d.objects.parsers.Collada;
    import org.papervision3d.objects.parsers.DAE;
/**
 * ...
 * @author Brian Hodge
 */
public class Main extends Sprite 
{
	[Embed(source="../lib/camera_para.dat", mimeType="application/octet-stream")]
	private var CameraParameters:Class;

	[Embed(source="../lib/collada.pat", mimeType="application/octet-stream")]
	private var MarkerPattern:Class;

	private var cameraParameters:FLARParam;
	private var markerPattern:FLARCode;
	private var raster:FLARRgbRaster_BitmapData;
	private var detector:FLARSingleMarkerDetector;

	private var cam:Camera;
	private var vid:Video;
	private var capture:BitmapData;

	private var cam3D:FLARCamera3D;
	private var scene3D:Scene3D;
	private var viewPort:Viewport3D;
	private var mainContainer:FLARBaseNode;
	private var renderer:LazyRenderEngine;

	private var trans:FLARTransMatResult;
	private var prevSet:Boolean = false;
	private var prevZ:Number = 0;

	private var _collada:Collada;
	private var _dae:DAE;

	public function Main():void 
	{
		cameraParameters = new FLARParam();
		cameraParameters.loadARParam(new CameraParameters() as ByteArray);

		markerPattern = new FLARCode(16, 16);
		markerPattern.loadARPatt(new MarkerPattern());

		cam = Camera.getCamera();
		cam.setMode(640, 480, 30);

		vid = new Video();
		vid.width = 640;
		vid.height = 480;
		vid.attachCamera(cam);
		addChild(vid);

		capture = new BitmapData(vid.width, vid.height, false, 0x0);
		capture.draw(vid);

		raster = new FLARRgbRaster_BitmapData(capture);
		detector = new FLARSingleMarkerDetector(cameraParameters, markerPattern, 80);

		cam3D = new FLARCamera3D(cameraParameters);

		scene3D = new Scene3D();

		mainContainer = new FLARBaseNode();
		scene3D.addChild(mainContainer);

		viewPort = new Viewport3D(vid.width, vid.height);
		viewPort.scaleX = viewPort.scaleY = 2;
		addChild(viewPort);

		renderer = new LazyRenderEngine(scene3D, cam3D, viewPort);

		_dae = new DAE();
		_dae.load("assets/dae/apc.dae");
		_dae.rotationZ -= 90;
		mainContainer.addChild(_dae);

		/*
		_collada = new Collada("assets/dae/apc.dae");
		_collada.scale = 0.05;
		_collada.rotationZ -= 90;
		mainContainer.addChild(_collada);
		*/

		trans = new FLARTransMatResult();

		this.addEventListener(Event.ENTER_FRAME, mainEnter);
	}
	private function mainEnter(e:Event):void 
	{
		capture.draw(vid);

		if (detector.detectMarkerLite(raster, 80) && detector.getConfidence() > 0.5)
		{
			detector.getTransformMatrix(trans);

			mainContainer.setTransformMatrix(trans);
			mainContainer.visible = true;
			renderer.render();
		}
		else
		{
			mainContainer.visible = false;
			renderer.render();
		}
	}
}

}

我希望这一切可以帮助你,我建议你只是不停摆弄它,并保持它熟悉自己。

Hopefully all this helps you, I suggest you just keep playing with it and keep familiarizing yourself with it.

布赖恩·霍奇 blog.hodgedev.com hodgedev.com

这篇关于AS3 DAE增强现实PaperVision 3D的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆