WEB开发网      濠电娀娼ч崐濠氬疾椤愶附鍋熸い鏍ㄧ〒闂勫嫰鏌﹀Ο渚Ц闁诲氦顕ч湁婵犲﹤楠告禍鍓х磼鏉堛劌绗氶柟宄版嚇閹晠宕归銈嗘濠电偞鍨堕幐鎾磻閹捐秮褰掓偐閻戞﹩妫勯梺鎼炲妼鐎涒晝绮嬪澶樻晝闁挎繂鏌婇敃鍌涚厵閻庢稒锚閻忥絾绻濇繝鍐ㄧ伌闁诡垰鍟村畷鐔碱敂閸♀晙绱樺┑鐐差嚟婵儳螞閸曨剚鍙忛柍鍝勬噹缁€澶嬬箾閹存繄锛嶆鐐灲閹綊宕惰濡插鏌涢妸銉ヮ劉缂佸倸绉归弫鎾绘晸閿燂拷 ---闂備焦瀵уú鈺呭箯閿燂拷
开发学院图形图像Flash Papervision3D: understanding Plane object – p... 阅读

Papervision3D: understanding Plane object – part 3

 2009-10-21 00:00:00 来源:WEB开发网 闂備線娼уΛ鎾箯閿燂拷闂備礁鎲¢崹鐢垫崲閹扮増鍎嶆い鎺戝€甸崑鎾斥槈濞嗗秳娌紓鍌氱▌閹凤拷濠电姭鎷冮崨顓濈捕闂侀潧娲ゅú銊╁焵椤掍胶鈯曢柕鍥╁仧缁辩偤鏁撻敓锟�闂備線娼уΛ鎾箯閿燂拷  闂備胶枪缁绘鈻嶉弴銏犳瀬闁绘劕鎼痪褔鏌曟繝蹇曠窗闁煎壊浜滈—鍐偓锝庡墮娴犙勭箾閸喎鐏ユい鏇樺劦椤㈡瑩鎮℃惔銇帮拷
核心提示: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

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