I have a object of type DAE and want to do something like
animatedDae.setFrame(15);
Any ideas how to do that in PaperVision3D
animationcolladapapervision3d
I have a object of type DAE and want to do something like
animatedDae.setFrame(15);
Any ideas how to do that in PaperVision3D
Click here to view a video of the necessary imports and working demo on my site.
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.
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.
I have had a lot of time to play with the FlarToolkit / Papervision3D / Collada partnership lately in preparations for the Tony Hawk XI website.
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.
There is not other way you can set transparency. Setting a 3d object on a viewport layer is like giving it a sprite you can play with. If you have layering issues I suggest creating layers for you other content as well. Figure out what will be rendered above and bellow your DAE and make layers for them too, but stack them properly. Have a look at Andy Zupko's post on layering objects. useOwnContainer will make a layer, but you won't have much control over it.
here's some simple code to get you started. I'm using a BasicView, but you understand when I'm using the viewport.
var daeLayer:ViewportLayer = new ViewportLayer(basicView.viewport,null);
basicView.viewport.containerSprite.addLayer(daeLayer);
basicView.viewport.containerSprite.sortMode = ViewportLayerSortMode.INDEX_SORT;
daeLayer.layerIndex = 1;
daeLayer.addDisplayObject3D(yourDAE);
Best Answer
You can transform the frame into time.