dae

MorphController – Mighty Morphing Papervision3D

Friday, July 3rd, 2009 | examples | Comments

I’ll do an in-depth tutorial on the MorphController later. I just wanted to get this up before I go to sleep.


source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package {
	import flash.events.Event;
 
	import gs.TweenMax;
	import gs.easing.Elastic;
 
	import org.papervision3d.core.controller.MorphController;
	import org.papervision3d.core.geom.TriangleMesh3D;
	import org.papervision3d.events.FileLoadEvent;
	import org.papervision3d.lights.PointLight3D;
	import org.papervision3d.materials.shadematerials.EnvMapMaterial;
	import org.papervision3d.objects.parsers.DAE;
	import org.papervision3d.view.BasicView;
 
	[SWF(width="900", height="480", backgroundColor="#000000", frameRate="31")]
	public class MightyMorphingPapervision3D extends BasicView
	{
		[Embed(source="assets/cached.dae", mimeType="application/octet-stream")]
		private var cachedAsset:Class; 
 
		[Embed(source="assets/twisty.dae", mimeType="application/octet-stream")]
		private var twistyAsset:Class; 
 
		[Embed(source="assets/235.jpg")]
		private var textureAsset:Class; 
 
 
		private var cached:DAE = new DAE(); 
		private var twisty:DAE = new DAE(); 
 
		private var dummyMorph:TriangleMesh3D;
		private var cachedChild:TriangleMesh3D;
		private var twistyChild:TriangleMesh3D;
 
		private var morphController:MorphController;
 
		private var light:PointLight3D;
		private var tweenDummy:Object;
 
		public function MightyMorphingPapervision3D()
		{
			super(900, 480);
 
			cached.addEventListener(FileLoadEvent.LOAD_COMPLETE, cached_loadCompleteHandler);
			cached.load(new cachedAsset());
		}
 
		protected function cached_loadCompleteHandler(event:Event):void
		{
			twisty.addEventListener(FileLoadEvent.LOAD_COMPLETE, twisty_loadCompleteHandler);
			twisty.load(new twistyAsset());
		} 
 
		protected function twisty_loadCompleteHandler(event:Event):void
		{
			cached.scale = 50;
			twisty.scale = 50;
 
			cachedChild = cached.getChildByName("pSphere1", true) as TriangleMesh3D;
			twistyChild = twisty.getChildByName("pSphere1", true) as TriangleMesh3D;
 
			dummyMorph = cachedChild.clone() as TriangleMesh3D;
			dummyMorph.scale = 50;
 
			light = new PointLight3D();
			light.x = -1000;
			light.y = 1000;
			var material:EnvMapMaterial = new EnvMapMaterial(light, new textureAsset().bitmapData);
 
			cachedChild.material = material;
			twistyChild.material = material;
			dummyMorph.material = material;
 
			morphController = new MorphController(dummyMorph);
			morphController.addMorphTarget(cachedChild, 0);
			morphController.addMorphTarget(twistyChild, 1);
 
			scene.addChild(dummyMorph);
 
			startRendering();	
 
			tweenDummy = {};
			tweenDummy.dummyProp = 0;
			TweenMax.to(tweenDummy, 1, {dummyProp:1, ease:Elastic.easeInOut, loop:true, yoyo:true});
		}
 
		override protected function onRenderTick(event:Event=null):void
		{
			dummyMorph.rotationX += 1;
			dummyMorph.rotationY += .5;
 
			morphController.weights[0] = 1- tweenDummy.dummyProp;
			morphController.weights[1] = tweenDummy.dummyProp;
 
			morphController.update();
 
			light.x = Math.cos(dummyMorph.rotationY / 10) * 1000;
 
			super.onRenderTick(event);
		}
	}
}

Tags: , ,

How to click on stuff in Papervision3D – Viewport, ViewportLayers, InteractiveScene3DEvent, Mouse3D, and MovieMaterial Buttons

Saturday, June 13th, 2009 | tutorials, videos | Comments

I’ve been super busy the past couple months and tomorrow I’m heading to Alaska to take a week-long vacation. I thought to myself, “this isn’t fair to my readers, I haven’t provided any quality original content on pv3d.org in a long time.” So, I took a couple hours tonight to answer pretty much every question on interacting with stuff in Papervision3D in the following five videos. That’s right, five videos explaining the ins and outs of working with interactivity events in Papervision3D. Just don’t say I never did anything nice for you :)

Click to view the video in a pop-up. Right-click and “save as” to download the video to your hard drive.

Watch Part 1 on the Viewport

Download part 1 source

Watch Part 2 on ViewportLayers

Download part 2 source

Watch Part 3 on InteractiveScene3DEvent

Download part 3 source

Watch Part 4 on Mouse3D

Download part 4 source

Watch Part 5 on Buttons on MovieMaterials

Download part 5 source

Tags: , , , , ,

Animating a Collada File from 3ds max

Sunday, December 7th, 2008 | requests, tutorials | Comments

Pablo made another great video tutorial about using a custom class he made to control frame animations of a collada file. He asked me to host it since his free screencast account couldn’t handle all the traffic he was getting :) It’s likely that we’ll take these concepts into the actual Papervision3D library, but if you need this *right now*, you’ll need his class.

Watch tutorial

Thanks, Pablo.

Tags: ,

Collada with CellShader and PointLight3D

Sunday, December 7th, 2008 | examples, requests | Comments

Pretty much the same as the last example, but this one has a Cell Shader overlaying the BitmapMaterial. Also, the light follows the camera as the camera orbits the collada model.

Drag mouse to orbit. Scroll wheel to zoom.

source

package
{
	import flash.display.Bitmap;
	import flash.events.MouseEvent;
	import flash.utils.ByteArray;
 
	import org.papervision3d.lights.PointLight3D;
	import org.papervision3d.materials.BitmapMaterial;
	import org.papervision3d.materials.shaders.CellShader;
	import org.papervision3d.materials.shaders.ShadedMaterial;
	import org.papervision3d.objects.parsers.DAE;
	import org.papervision3d.view.BasicView;
 
	[SWF(width="640", height="480", backgroundColor="#000000", frameRate="60")]
	public class CellShadedCollada extends BasicView
	{
		[Embed(source="assets/c.DAE", mimeType = "application/octet-stream")]
		private var daeAsset:Class;
 
		[Embed(source="assets/materials/c.png")]
		private var materialAsset:Class;
 
		private var cameraPitch:Number = 90;
		private var cameraYaw:Number = 270;
		private var isOrbiting:Boolean = false;
		private var previousMouseX:Number;
		private var previousMouseY:Number;
		private var light:PointLight3D;
 
		public function CellShadedCollada()
		{
			var byteArray:ByteArray = new daeAsset() as ByteArray;
			var dae:DAE = new DAE();
			dae.load(byteArray);
 
			var bitmap:Bitmap = new materialAsset() as Bitmap;
			var bitmapMaterial:BitmapMaterial = new BitmapMaterial(bitmap.bitmapData, true);
 
			light = new PointLight3D();
 
			var cellShader:CellShader = new CellShader(light, 0xffffff, 0x000000, 10);
			var shadedMaterial:ShadedMaterial = new ShadedMaterial(bitmapMaterial, cellShader);
 
			dae.materials.addMaterial(shadedMaterial, "cMaterial");
 
			scene.addChild(dae);
 
			startRendering();
 
			stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
			stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
			stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
			stage.addEventListener(MouseEvent.MOUSE_WHEEL, mouseWheelHandler);
		}
 
		private function mouseWheelHandler(event:MouseEvent):void
		{
			camera.moveForward(10 * event.delta);
		}
 
		private function onMouseDown(event:MouseEvent):void
		{
			isOrbiting = true;
			previousMouseX = event.stageX;
			previousMouseY = event.stageY;
		}
 
		private function onMouseUp(event:MouseEvent):void
		{
			isOrbiting = false;
		}
 
		private function onMouseMove(event:MouseEvent):void
		{
			var differenceX:Number = event.stageX - previousMouseX;
			var differenceY:Number = event.stageY - previousMouseY;
 
			if(isOrbiting)
			{
				cameraPitch += differenceY;
				cameraYaw += differenceX;
 
				cameraPitch %= 360;
				cameraYaw %= 360;
 
				cameraPitch = cameraPitch > 0 ? cameraPitch : 0.0001;
				cameraPitch = cameraPitch < 90 ? cameraPitch : 89.9999;
 
				previousMouseX = event.stageX;
				previousMouseY = event.stageY;
 
				camera.orbit(cameraPitch, cameraYaw);
				light.position = camera.position;
			}
		}
 
	}
}

Tags: , ,

Search

Recommended Books

Speaking at FITC Toronto

 

February 2012
M T W T F S S
« May    
 12345
6789101112
13141516171819
20212223242526
272829  

Preferred Video Tutorial Resolution

  • 1024x768 (53%, 85 Votes)
  • 1280x1024 (15%, 24 Votes)
  • 1920x1080 (15%, 24 Votes)
  • 800x600 (13%, 20 Votes)
  • 480x320 (4%, 6 Votes)
  • 640x480 (0%, 2 Votes)

Total Voters: 160

Loading ... Loading ...