Exporting textured objects from 3d MAX to PV3D 2.0 tutorial

f

[SEE WHAT YOU ARE GOING TO LEARN]

This tutorial explains how to make a 3d object with 3d Studio MAX , unwrap the uvw, export it to actionscript 3, import to your papervision 3d project , texture it and deploy as a flash movie :)

What you need to use this:

1. Papervision3d (latest classes included) - http://blog.papervision3d.org
2. Flash CS3 - http://www.adobe.com/flash
3. 3D Studio MAX (I’ve used the latest 2009 ver. Should work with previous ones too) - http://www.autodesk.com
4. AS3GeomClassExporter for 3DStudio MAX (included) by http://dreammania.net - extended by mr.doob.
5. Some basic modelling and texturing skills to make something. Some Max interface knowledge proofs useful here too.

You could use different software for this (Maya and so on..) but I didn’t test it so I’ll focus on MAX right now.

I’m not a real tutorial writer so I’ll make this as short as possible - explaining with screenshots where possible :)

Let’s get on with this:

Part I - MAX

1. You need to open max and install the script (AS3GeomClassExporter) - this screenshots shows where and how to do this:

2. Run the script like here (it executes and shows the panel when you select the script from the combobox):

3. Configure the script for PV3d 2.0 like I did it here:

4. Model anything you want. I’ve made a simple chamfer box here:

At this point you should remember a few important things:

- use as little polygons you can handle to improve the speed (low-poly is your friend here:)),
- you can connect (boolean, modify mesh, combine with loft or lathes and so on) everything you want. But you must keep the object as ONE mesh - closed one. If you want to combine many objects you have to do this in papervision - not in max - the exporter allows to export 1 object.

Here is a sample Boolean (with union) of the chamfer box and a loft made of text and a line (for loft depth):

AS you can see in properties this is a single object with a simple structure (low amount of faces and vertices).
5. Now a very important part! You need to place the PIVOT for the object correctly. The pivot is the point which papervision would read as 0,0,0 coordinates. So it is crucial for rotating/positioning and moving the object later. This is how you do this

6. Now it is time to prepare the UVW texture coordinates and map for the object. We’ll do this in parts:
a) You need to unwrap the Mesh using UVW Unwrap. Select the object and do EDIT/select modifier Unwrap UVW from the combo:

b) Now you need to select Face from the Unwrap modifier and select all the faces (CTRL+A) of the object - then press “EDIT..”

c) A new window will open up - the selected faces (red) will overlap each other - this is time to unwrap the mesh so select MAPPING from the main menu –> normal mapping. You can modify some parameters in the window that appears - but for this object it is just fine to CLICK OK:

d) Hurray! it is done. The mesh will unwrap like in the screen below. Of course you can modify the unwrap - play with the unwrap tool a little yourself ;). In this case the automated unwrap worked rather fine (the mesh was simple) and I don’t need to correct anything here. I have one overlap which I should correct but it’s not important for this tutorial.

e) Now it is time to render the map (you need something to paint on and texture in pv3d :)). I would suggest rendering two maps in the same resolution (don’t select them too big - a 1500×1500 map is just fine and fast for a complicated object in pv3d if you don’t use too many objects). One with the edges visible (this can be helpful when drawing in photoshop - you can  apply the edges on a different layer and use as a helper :). The second one shaded - to use as a canvas for painting.
The renders aren’t to pretty but they should do:

You are done with Unwrapping at this point :) Congratulations. Lets proceed to the next section.

7. Now the fun part. As you have the object created (it is a single closed mesh with uvw coordinates applied and ready to go!) you can now EXPORT THE AS3 CLASS with this object :) Select the object with the select tool and press EXPORT CLASS in the scripts panel/as3geomexporter. Like that:

Thanks for your attention. When you finish this tutorial you should have:

- an AS3 class with the object you’ve created (it contains the mesh definition + the UVW map definition),
- a texture which you can paint on and use with the object,
- a max file which you can use again if you don’t like the results,

Part II - AS3 in FLASH

What you need next (I’m not going to explain it in details here because the code is well commented):

- the source code - you can see it working here. You can download it here.

So you are ready to go - now you can import your object and use it in papervision WITH MAPPING! :)

I hope this tutorial helps.
Feel free to comment! You are welcome as usual! :)

Have fun,

FLAIM

Real 3d in Html - updates

updates to html3d

Hello,

The update includes:

- z-sorting for html objects (see this page),

- simple mouse interactivity,

- optimized z-scaling of fonts,

- optimized speed (redesigned communication with js).

 

The complete updated source is here.

Known issues:

- Antivirus software (checked with KAV) causes major slowdown when checking Javascript (only Internet Explorer browsers) …use Mozilla if you have Kaspersky turned on - fixed that

- slow…as hell ;) - it’s better now :)

have fun,

FLAIM

***** RECENT UPDATE ******

I’ve optimized the code and changed the files in this post (both the sources and example link) - everything is 500-800% faster than in the previous post. Thanks to the optimization the issue with Kaspersky disappeared also :)

… have fun :)

Real 3d in html / javascript / pv3d

Hello everyone,

In the previous post I’ve mentioned that it could be possible to use papervision 3d and ExternalInterface to create 3d in HTML :)

..well that wasn’t too hard to imagine when I’ve found out that it is possible to get coordinates of any vertex of a pv3d object you want - using : “..geometry.vertices[index].vertex3DInstance.attribute “..so I did it..

It’s a bit “proof of concept” idea - it of course ‘doable’ rather than ‘usable’ (too slow) but that didn’t put me off ;)

You can see the test movies right here (or by clicking the large image above). Click the embed button first and then wait for the flash to load. I did it on purpose - because it is processor heavy.

You can download the complete source! here.

So how does it work?

It’s described in the sources but shortly:

- creates a whole pv3d environment with a simple cube, a camera and so on…

- dynamically creates html content then used to animate (simple divs with text),

- creates communication (see the html source) between js and as3,

- uses Tweener for animation :) yep - that’s a cool part:),

- the pv3d cube is a fake all the time - it exists but it’s not really visible - the coordinates are passed to html objects using the method described in the beginning of this post,

What could be done with it? 

- a lot! You could do a whole menu/website with it - as long as you don’t use too many items on the stage. It’s very easy to add full mouse interaction to it using the same methods I used in the demo. It’s also very easy to modify the 3d environment and steer the camera from js :) Use your imagination!

I hope you like the little demo - comments are welcome!

FLAIM

*** UPDATE

Please use the code from my newer post about the 3dHTML - it’s optimized and works significantly faster.