WEB开发网      婵犻潧鍊婚弲顐︽偟椤栨稓闄勯柦妯侯槸閻庤霉濠婂骸浜剧紒杈ㄥ笚閹峰懘鎮╅崹顐ゆ殸婵炴垶鎸撮崑鎾趁归悩鐑橆棄闁搞劌瀛╃粋宥夘敃閿濆柊锕傛煙鐎涙ê鐏f繝濠冨灴閹啴宕熼鍡╀紘婵炲濮惧Λ鍕叏閳哄懎绀夋繛鎴濈-楠炪垽鎮归崶褍妲婚柛銊ュ缁傚秹鏁撻敓锟� ---闂佹寧娲╅幏锟�
开发学院图形图像Flash Papervision3D: understanding Plane object – p... 阅读

Papervision3D: understanding Plane object – part 3

 2009-10-21 00:00:00 来源:WEB开发网 闂侀潧妫撮幏锟�闂佸憡鍨电换鎰版儍椤掑倵鍋撳☉娆嶄沪缂傚稄鎷�婵犫拃鍛粶闁靛洤娲ㄩ埀顒佺⊕閵囩偟绱為敓锟�闂侀潧妫撮幏锟�  闂佺ǹ绻楀▍鏇㈠极閻愬搫绾ч柕濠忕細閼割亜顪冪€n剙浠ф繛鍫熷灥椤曘儵顢欓悡搴ば�
核心提示:In this 3rd part we’ll discover two interesting features:1) How to add a bitmap texture to a plane2) How to set the camera to make Papervision3D units mat

In this 3rd part we’ll discover two interesting features:

1) How to add a bitmap texture to a plane

2) How to set the camera to make Papervision3D units match pixels

Let’s start… the “units Vs pixels” issue can be a problem when we want a plane (or whatever) to have a precise size in pixels.

Settings the camera properly can solve the problem… this is the same script used in Papervision3D: understanding Plane object – part 2 with a couple of modifications:

package {
 import flash.display.Sprite;
 import flash.events.Event;
 import org.papervision3d.cameras.Camera3D;
 import org.papervision3d.render.BasicRenderEngine;
 import org.papervision3d.scenes.Scene3D;
 import org.papervision3d.view.Viewport3D;
 import org.papervision3d.objects.primitives.Plane;
 import org.papervision3d.materials.ColorMaterial;
 import org.papervision3d.materials.BitmapFileMaterial;
 public class papervision extends Sprite {
  public var viewport:Viewport3D = new Viewport3D();
  public var scene:Scene3D = new Scene3D();
  public var camera:Camera3D = new Camera3D();
  public var renderer:BasicRenderEngine = new BasicRenderEngine();
  public var bitmap_material:BitmapFileMaterial = new BitmapFileMaterial("http://www.google.com/intl/en_ALL/images/logo.gif");
  public var red_material:ColorMaterial=new ColorMaterial(0xff0000);
  public var frontplane:Plane=new Plane(red_material,200,300,4,5);
  public var backplane:Plane=new Plane(bitmap_material,200,300,4,5);
  public function papervision() {
   addChild(viewport);
   camera.focus=100;
   camera.zoom=10;
   backplane.rotationY=180;
   scene.addChild(frontplane);
   scene.addChild(backplane);
   addEventListener(Event.ENTER_FRAME, render);
  }
  public function render(e:Event) {
   frontplane.yaw(1);
   backplane.yaw(1);
   renderer.renderScene(scene, camera, viewport);
  }
 }
}

At lines 22-23 I am setting the camera in a way the 200 and 300 “units” defining the plane size at lines 18-19 are equivalent to pixels.

Our planes now are 200×300 pixels sized.

Then I introduced a new material, the BitmapFileMaterial one… imported at line 10, declared at line 16 (look how do I import the image… passing the URL) at assigned at line 19

And that’s all… look at the double sided plane with the Google logo on its back…

Next time, we’ll add some interaction.

Tags:PapervisionD understanding Plane

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接