020 7920 7120 | public@publicreative.com

January 23rd, 2009

3dsMax Texture Baking and Papervision

3d is really exciting us at the moment. Papervision is great but so far we’ve only used primitive shapes within Papervision to do all our work. Chris, our newest arrival in the Public development pit has been amazing us with his 3dsMax skills and of course prompted us to get up with the play and start exporting from Max into flash.

It’s also prompted me, having no 3dsMax experience but plenty of Papervision experience to start having a play. After many hours at work and home coming up to speed with the basics of modelling, lightning and materials and learning how to texture bake and deal with UV maps I think I’ve got a handle on what this is all about.

Here’s the first test. Nothing amazing but the speakers are fully UVW unwrapped in 3dsMax and the textures are baked on.

Next up will be testing animation exported from 3dsMax and some more detailed modeling.

Click image to open:

maxpreview.jpg


Here is the source:

package
{
	import com.publicreative.graphics.BackgroundGradient;
	import com.publicreative.pv.interaction.MouseGrab;
	import org.papervision3d.objects.parsers.DAE;
 
	import flash.events.Event;
	import flash.utils.ByteArray;
 
	import org.papervision3d.materials.BitmapFileMaterial;
	import org.papervision3d.materials.ColorMaterial;
	import org.papervision3d.materials.utils.MaterialsList;
	import org.papervision3d.objects.primitives.Cube;
	import org.papervision3d.view.BasicView;
 
	[SWF(width = "600", height = "450", backgroundColor = "#000000", frameRate = "60")]
 
	public class BakedStage extends BasicView
	{
		[Embed(source="speakers.DAE", mimeType = "application/octet-stream")]
		private var SpeakerDAE:Class; 
 
		private var _dae:DAE;
		private var _stage:Cube;
		private var _grab:MouseGrab;
 
		private const DISTANCE:int = 1200;
 
		public function BakedStage()
		{
			super(stage.stageWidth , stage.stageHeight);
			init();
		}
 
		private function init():void
		{
			addChildAt(new BackgroundGradient(),0);
 
			var byteArray:ByteArray = new SpeakerDAE() as ByteArray;
 
			 _dae = new DAE( false);
 
			var ml:MaterialsList = new MaterialsList();
			ml.addMaterial( new BitmapFileMaterial("SpeakerImageMap.png",true) , "SpeakerImageMap.png" );
 
			//Speakers are texture baked round dae file.
			_dae.load( byteArray , ml);
			_dae.scale = 3.5;
			_dae.useOwnContainer = true;
			_dae.rotationY = 180;
			scene.addChild( _dae ); 
 
			//Stage is done in traditional way using a skinned cube.
			var stageML:MaterialsList = new MaterialsList();
			stageML.addMaterial( new BitmapFileMaterial("floorFront.jpg") , "back");
			stageML.addMaterial( new BitmapFileMaterial("floorSide.jpg") , "left");
			stageML.addMaterial( new BitmapFileMaterial("floorSide.jpg") , "right");
			stageML.addMaterial( new BitmapFileMaterial("floorTop.jpg") , "top");
			stageML.addMaterial( new ColorMaterial(0x111111) , "bottom");
			stageML.addMaterial( new ColorMaterial(0x111111), "front");  
 
			stageML.getMaterialByName("top").smooth = true;
 
			_stage = new Cube( stageML , 484 , 484 , 16, 4 , 1 , 4);
			_stage.y = -8;
			scene.addChild( _stage );
 
			camera.zoom = 100;
			camera.z = -DISTANCE;
 
			_grab = new MouseGrab(  camera , stage );
			_grab.addSingleAxis( MouseGrab.VERTICAL , MouseGrab.Y , 1000 , 10 , 30 );
			_grab.addDoubleAxis( MouseGrab.HORIZONTAL , MouseGrab.XZ, DISTANCE, 1000, 10 );
 
			startRendering();
		}
 
		override protected function onRenderTick(event:Event=null):void
		{
			_grab.processFrame();
			super.onRenderTick(event);
		}
	}
}

Here is the MouseGrab class as a few people have requested. It’s far from my best work and pretty much untested so use at your own risk. MouseGrab. Things have been very busy here of late so sorry for the slow replies.

11 Responses to “3dsMax Texture Baking and Papervision”

  1. Gary says:

    Mark,

    When you import to Papervision from 3DSmax do all the textures that you have already applied come in or do you have to reapply in Papervision?

  2. Eric Eisaman says:

    This is very nice. Have you done any benchmarking against Away3D Lite?

  3. GeniusLabs says:

    Just a quick question about the MouseGrab class. It calls a MathUtils class that is not in the tutorials you posted. Is this correct? import com.publicreative.utils.MathUtils;
    Thus my question where can we find the defined class?

  4. isaac says:

    sorry, talking to myself… I suppose this demonstrates how to do DAE based animations
    http://techblog.floorplanner.com/2009/05/26/papervision3d-21-alpha/

  5. isaac says:

    Excellent… have you made any progress in using animated sequences from 3ds Max? The texture baking is great… I am trying to do an interactive page turning flash component which is true 3d… and was going to base it on this
    http://www.escalight.com/tutorials/3dsmax-tutorials/pageflip-animation-part-1.html... Maybe you’d be in to trying that kind of thing; but the exiting stuff you’ve done in this post is very helpful to that end.

  6. Fletcher says:

    Hello! I just came across the site. Love the works you guys are doing! I’m playing around with this whole idea at the moment. Lots to still figure out. I was wondering if you could post the MouseGrab class. I’d appreciate it. Thanks!

  7. Jerry says:

    it would be really helpful if you could post the MouseGrab class, thanks a lot.

  8. colouredFunk says:

    Hi,

    It would be great if you could post up the mouseGrab class! I dig it :)

    Cheers

  9. yonos says:

    hi – very nice demo! …can you post the MouseGrab class – I cant seem to get it working…I think thats what i am missing. Could you post it up? Cheers…

  10. Mark says:

    MouseGrab is a simple class I put together to interact with 3d scenes. By clicking and dragging along the x and y axis you can assign the scene to rotate or move along any axis. If you would like this class I could post it up.

  11. morphoz says:

    hi, really impressive, trying my own to do something like this for my personnal work…but only graphist not programmer ^^
    i’ve a question,
    when you call = ” import com.publicreative.pv.interaction.MouseGrab;” i suppose that it call a library… but not in pv3d !?
    have you try the 3ds parser?

Tell us what you think!