Archive for December 4th, 2008

Tweening vertices

Thursday, December 4th, 2008 | examples | Comments


source

package
{
	import gs.TweenMax;
	import gs.easing.Quad;
 
	import org.papervision3d.core.geom.renderables.Vertex3D;
	import org.papervision3d.lights.PointLight3D;
	import org.papervision3d.materials.shadematerials.PhongMaterial;
	import org.papervision3d.objects.primitives.Sphere;
	import org.papervision3d.view.BasicView;
 
	[SWF(width="640", height="480", backgroundColor="#000000", frameRate="60")]
	public class TweenVertices extends BasicView
	{
		private var sphere:Sphere;
 
		public function TweenVertices(viewportWidth:Number=640, viewportHeight:Number=480, scaleToStage:Boolean=true, interactive:Boolean=false, cameraType:String="Target")
		{
			var light:PointLight3D = new PointLight3D();
			light.x = -100;
			light.y = 100;
 
			var material:PhongMaterial = new PhongMaterial(light, 0x0000cc, 0x000000, 10);
			sphere = new Sphere(material, 500, 20, 20);
 
			for each(var vertex:Vertex3D in sphere.geometry.vertices)
			{
				var x:Number = vertex.x + Math.random() * 100 - 50;
				var y:Number = vertex.y + Math.random() * 100 - 50;
				var z:Number = vertex.z + Math.random() * 100 - 50;
				TweenMax.to(vertex, Math.random() * 2 + 2, {x:x, y:y, z:z, ease:Quad.easeOut, yoyo:true});
			}
 
			scene.addChild(sphere);
 
			startRendering();
		}
	}
}

Tags: ,

Neat camera and arrows thingy

Thursday, December 4th, 2008 | examples | Comments

I made this a while back for one of my classes. Not sure if it’s really helpful for anything, but I’m just going to file it under “camera” since it shows a technique to have the camera move around.

*note – this uses a custom Arrow.as class that’s included with the download.


source

package 
{
	import gs.TweenMax;
	import gs.easing.Cubic;
 
	import org.papervision3d.lights.PointLight3D;
	import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.objects.primitives.Sphere;
	import org.papervision3d.view.BasicView;
	import org.pv3d.objects.Arrow;		
 
	[SWF(width="640", height="480", backgroundColor="#000000", frameRate="60")]
	public class FollowCam extends BasicView 
	{
		private var dummyObject:DisplayObject3D;
		private var light:PointLight3D;
		private var origin:DisplayObject3D;
 
		public function FollowCam() 
		{
			origin = DisplayObject3D.ZERO;
			light = new PointLight3D();
			dummyObject = new DisplayObject3D();
 
			camera.fov = 120;
 
			for (var i:Number = 0;i < 50; i++) 
			{
				var arrow:Arrow = new Arrow(new FlatShadeMaterial(light, 0xcc0000, 0x000000));
				arrow.x = Math.cos(i) * 2000 - 1000;
				arrow.y = 4000 / 50 * i - 2000;
				arrow.z = Math.sin(i) * 2000 - 1000;
				arrow.lookAt(origin);
 
				scene.addChild(arrow);
			}
 
			var sphereMaterial:FlatShadeMaterial = new FlatShadeMaterial(light, 0x00cc00, 0x000000);
			sphereMaterial.doubleSided = true;
			var sphere:Sphere = new Sphere(sphereMaterial, 6100, 30, 30);
 
			scene.addChild(sphere);
 
			loopTweenMax();
		}
 
		private function loopTweenMax():void 
		{
			var bt:Array = [];
 
			for (var i:Number = 0;i < 3; i++) 
			{
				bt.push({
						x:Math.random() * 6000 - 3000, 
						y:Math.random() * 6000 - 3000, 
						z:Math.random() * 6000 - 3000
					});
			}
 
			TweenMax.to(dummyObject, 20, {
					x:Math.random() * 6000 - 3000, 
					y:Math.random() * 6000 - 3000, 
					z:Math.random() * 6000 - 3000, 
					bezierThrough:bt, 
					ease:Cubic.easeInOut, 
					onUpdate:onTweenUpdate, 
					onComplete:loopTweenMax
				});		
		}
 
		private function onTweenUpdate():void 
		{
			singleRender();
			camera.lookAt(dummyObject);
			camera.copyPosition(dummyObject);
			camera.moveBackward(500);
			light.copyTransform(camera);
			camera.lookAt(dummyObject);
		}
	}
}

Tags: ,

3ds max texture baking for Papervision3D

Thursday, December 4th, 2008 | tutorials | Comments

Pablo Bandin made an excellent video tutorial on baking textures with 3ds max for Papervision3D:

http://pablobandin.wordpress.com/2008/11/29/howto-3dmax-texture-baking-papervision/

Thanks Pablo.

Tags: ,

Updated Downloads

Thursday, December 4th, 2008 | announcements | Comments

I updated the .zip and .swc of Papervision3D to rev 815. You can grab them from here:

http://code.google.com/p/papervision3d/downloads/list

Tags:

Search

Recommended Books

Speaking at FITC Toronto

 

December 2008
M T W T F S S
« Nov   Jan »
1234567
891011121314
15161718192021
22232425262728
293031  

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 ...