Posts Tagged ‘collada’
This is to be the first of many tutorials on different shaders, and how they can be applied to dae files. Most tutorials you will find online explain how to add shaders to basic papervision objects, but not to DAE (COLLADA) files.
To begin with, we will start to learn about the simpler shaders, such as wireframe and solid colour shaders and work up to more complicated shaders such as envMapMaterial (environment material) shaders and Movie clip shaders.
All tutorials will be explained with the COMPLETE source code to allow you to get it going on your own machine!
Creating the initial project .Fla and .as Global files
These files will help link in all shader files so that you can learn how to add different shaders to more that one dae file, or different shaders to the same dae file.
first off, we will create an empty .FLA file (this will allow us to read the .as file we will make
and will help us run it!)
File > New (ctrl+N)
select Flash File (Actionscript3) and click ok.
Now save that under whatever name you like.Now we need to create an Actionscript file (.as)
File > new (Ctrl+N)
select Actionscript File and click ok.
Now save this using whatever name you like – I will call it MainShader.as
It is in this MainShader.as file where we will write our code. but first we need to link
it to the .FLA file we made earlier.
click on the tab to open your .FLA file and look near the bottom of your screen, in the
properties tab, for something called Document Class in the text box to the right of it, enter
your .as file name – in this case “Shader” (without the quotes) and click on the little pencil icon to scan for the file.
You will see a pop up message, just click OK to close it.
In this Tutorial, we now have yourfile.FLA and a MainShader.as file.
The MainShader.as file will be the Main file that will link all the other .as files
To find the Relevant Shader Tutorials, please use the drop down menu from the tabbed links at the top of this page, titled Papervision Tutorials.
This tutorial is an expansion on Loading 3D objects created in Max (using COLLADA)…
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.
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!
To Load .DAE files – simply use this code in Flash AS3:
import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.events.FileLoadEvent; private var modelDAE:DAE; private function load(){modelDAE = new DAE( );modelDAE.texturePath = “”; // assume that textures are in main DAE’s foldermodelDAE.load( “path/to/file.dae” ); modelDAE.addEventListener( FileLoadEvent.LOAD_COMPLETE , ldrComplete );} private function ldrComplete( e:Event ):void{try{model = DisplayObject3D( modelDAE ); } catch( e:TypeError ){loading = ERROR;return;}//And then you simply call the load function:load();
There are no error handlers in this code, only the basics of importing a model and loading it in flash. – more detailed tutorials will come soon with user interaction!
- Use an SVN client to download Papervision deposetries
- Install ColladaMax extension on 3Ds Max
- Convert models into .DAE files
- add PV3d (Papervision3D) component to Flash via the Extension Manager
- download and “install” it (once installed it will appear in the right click menu in windows – it does not technicaly appear in Programe folders)
- Create a new folder, and call it Papervision3d “or whatever you want to call it.
- right click the folder and chose SVN Checkout
- direct the folder to http://papervision3d.googlecode.com/svn/trunk
- Choose which directory you would like to install it in, and click ok – now the SVN should be doing all the work downloading the PV3D files into your specified directory.
- but for a direct download of the ColladaMax extension click here
- once this is downloaded and installed in 3ds Max, you can now start exporting models
3 – Exporting .DAE files
- As Papervision only reads .DAE files you need to export your models as .DAE this can be done by:
- Click File > Export , then select COLLADA (*.DAE)
- Make sure that, if you have more that one object in the scene that it is all connected as 1 object. and for Textures, use UVW mapping and apply it to the DIFFUSE channel in the material editor – otherwise texturing wont work.
- download the component here
- Open up Adobe Extension Manager, If you dont have it, you can get it from the Adobe site download it here
- once installed hold down Ctrl + O to add a new extension, browse to the component .MXP file that you just downloaded and click ok
- Open up Flash CS3, and now you should have PV3D in the Components window
- To gain access to the PV3D panel – in the toolbar click