Archive for the ‘Papervision’ Category

This is a LIVE completed DEMO (of the test video), for what could be achieved with PV3D and Flash AS3 –

click this link to try it out

File  is about 1.3MB so would take about 10sec to load, i havent put in a pre-loader, so just give it a few seconds (click on the screen) and you will soon see the obect and be able to play around with it!
>most tutorials needed to accomplish this can be found on this blog, from the ground up – if you need any help with anything just leave me a comment!

importing dae Tutorial
Mouse and Keyboard interaction Tutorial

When creating models/importing models into flash, and testing code in run time etc, sometimes it is very usefull to have Statistics displayed on the runtime page, to see how well your program is running, any memory leaks etc..

This however is very easy to set up in Papervision3D.
First you need to import StatView:
import org.papervision3d.view.stats.StatsView;

If you have employed BasicView for your scene setup, add

private var view:StatsView;

in your class, and then call it using:

addChild(new StatsView(renderer));

Thats it! very simple, you should end up with something looking like this in your window

  • Try and keep your models as simple as possible without loosing much on detail (obviously some sacrifices have to be made).
  • When exporting to a DAE file, try and use a model that is newly made, rather than editing one that is already textured and in a scene with other objects.
  • DO NOT, texture your objects, until you are ready to add your UVW map, this will avoid confusion in the DAE, where max has exported the files, with paths to textures that you no longer use, this will throw errors when testing movie in Actionscript.
  • Having a clean model, with few gemoetries and one UVW map will help reduce complications and errors in the long run – trust me, im speaking from experiance! :)
  • .DAE files, can be opened in Notepad, and edited – do not edit if you are unsure of what to do, you may end up corrupting your file, and having to re-export.
  • Notepad2, is a lot better than Notepad – with syntax highliting and numbered lines, get it here, its free!

If you have any tips you would like to add, please feel free to leave them in the comments! :)

This tutorial is an expansion on Loading 3D objects created in Max (using COLLADA)…

There are 3 main methods that can be use in Flash Actionscript to import bitmaps (i.e. textures)
BitmapAssetMaterial
BitmapFileMaterial
BitmapMaterial
BitmapAssetMaterial doesn’t work because the function expects a linkage id, linkage ids were in as2, not as3. so this will never work (I think).
BitmapFileMaterial Just links to a url file and therfore doesn’t need anything in the library.
BitmapMaterial is the one to use when you have a bitmap in the library. it expects a Bitmapdata object.
so, to get it to work with a material called examplematerial in the library with the class name examplematerial use:
BitmapMaterial(new examplematerial(width, height));
changing the width and height to the dimentions of the examplematerial image.
Also, this is assuming your examplematerial parent class is bitmapData (the default for an image so it should be).
So if you find that for some reason BitmapFileMaterial is not being loaded from your .DAE file, then simply change it and use BitmapMaterial.
To do this firstly in your .FLA file in the toolbar:
File > Import >  Import to Library
select your texture file and choose ok (I would use a .PNG file type, as they keep file sizes small, allow for transparency, and retain original quality)
once your texture is imported into the library make sure you right click it and select Linkage…
this will pop up with a window, make sure you have the relevant boxes ticked and have filled in the Class section with the name of your texture, in this case “examplematerial”
once this is done, go back into you .as file and add the following lines of code:
var myobjMaterials:MaterialsList = new MaterialsList();myobjMaterials.addMaterial(new BitmapMaterial(new sacktexture(1024, 1024)));

and thats all there is to it!

This tutorial will show you how to basically import a 3D object into Flash, using Papervision.
IF you are completely new to this (i.e. need to know how to set up flash and PV3D, then please follow this tutorial steps 1-4 and read the beginners guide to creating your first 3D shapes here – if you want to know how to export 3D files into the COLLADA .DAE format that papervision read steps 2 -3 here.

This tutorial, assumes that you have read the other tutorials linked above, that provide full explanations for beginners!
In order to import a 3D object, you need to convert(export from 3Ds Max – COLLADA max extension can be downloaded here) it into a .DAE (COLLADA) file that papervision can use,  we will then use AS3 to read this file, and import the model.
package{ 
import org.papervision3d.view.BasicView; 
//For importing objects  
import org.papervision3d.objects.parsers.Collada; 
import org.papervision3d.objects.parsers.DAE; 
import org.papervision3d.objects.DisplayObject3D;

 [SWF(width="640", height="320", backgroundColor="#000000", frameRate="60")]

 public class import3D extends BasicView 
{  
public function import3D()  
{   
var myFirstObject= new Collada("myfirstobject.dae");   
//Set different scales, if your models is too small or too big   
myFirstObject.scaleX = 8;   
myFirstObject.scaleY = 8;   
myFirstObject.scaleZ = 8;   
//rotate object if you want it at a different angle   
myFirstObject.rotationX+=30;   
myFirstObject.rotationY+=30;   
scene.addChild(myFirstObject);

   startRendering();  
} 
}
}

And thats all there is to it! – very simple once you know how – keep an eye out for the next tutorial – TEXTURING! :)

subscribe to my RSS feeds, to get the latest updated tutorials!
Subscribe
Follow me on Twitter
free counters
PayPal Donation
If you like this blog and the help it has given you, why not donate for this good cause? Click on the button below to pay Safely and Securely through PayPal.
Thanks.