billboard 贴图
将Billboard贴图加入3D 识别系统中,可以增强很多简单的非3D模型就可以实现的应用技术。但是和3D模型拥有一样的
大小变化和坐标变化。基于一张图片,无法旋转。
这是 Bart Wttewaall-5 写的 billboard 因为 Pv3d不存在这样的 类
package org.papervision3d.objects.special {
/**
* @author Bart Wttewaall
* @website www.mediamonkey.nl
* @date 05-10-2008
* @version 1.0
*/
import org.papervision3d.core.proto.CameraObject3D;
import org.papervision3d.core.proto.MaterialObject3D;
import org.papervision3d.core.render.data.RenderSessionData;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.primitives.Plane;
/**
* To do:
* . override any rotation/pitch methods that can mess up the billboard?
* or add transform matrix to calculation
*/
public class Billboard extends DisplayObject3D {
public static const toDegrees :Number = 180/Math.PI;
public var plane
isplayObject3D;
protected var initialWidth :Number;
protected var initialHeight :Number;
protected var _width :Number;
protected var _height :Number;
protected var _segmentsW :uint;
protected var _segmentsH :uint;
// —- getters & setters —-
override public function get material():MaterialObject3D {
return super.material;
}
override public function set material(value:MaterialObject3D):void {
super.material = value;
if (plane.material != value) {
setChildMaterial(plane, material);
}
}
public function get width():Number {
return _width;
}
public function set width(value:Numb
er):void {
if (_width != value) {
// setting scale is faster then redrawing plane
plane.scaleX = value/initialWidth;
_width = value;
}
}
public function get height():Number {
return _height;
}
public function set height(value:Number):void {
if (_height != value) {
// setting scale is faster then redrawing plane
plane.scaleY = value/initialHeight;
plane.y = value/2;
_height = value;
}
}
public function get segmentsW():uint {
return _segmentsW;
}
public function set segmentsW(value:uint):void {
if (_segmentsW != value) {
_segmentsW = value;
redrawPlane();
}
}
public function get segmentsH():uint {
return _segmentsH;
}
public function set segmentsH(value:uint):void {
if (_segmentsH != value) {
_segmentsH = value;
redrawPlane();
}
}
// —- constructor —-
public function Billboard(material:MaterialObject3D, width:Number=100, height:Number=100, segmentsW:uint=0, segmentsH:uint=0) {
super();
initialWidth = _width = width;
initialHeight = _height = height;
redrawPlane();
// this will auto update the plane’s rotationY through calculateScreenCoords
autoCalcScreenCoords = true;
}
style=”font-family: courier new,monospace;”>
public function redrawPlane():void {
if (plane) removeChild(plane);
initialWidth = _width;
initialHeight = _height;
plane = new Plane(material, _width, _height, _segmentsW, _segmentsH);
plane.y = _height/2;
addChild(plane);
}
override public function calculateScreenCoords(camera:CameraObject3D):void {
super.calculateScreenCoords(camera);
faceCamera(camera);
}
/**
* This method isn’t foolproof: rotating this object will mess up the caculation
* todo: add transform matrix to calculation
*/
public function faceCamera(camera:CameraObject3D):void {
var dx:Number = camera.x – this.x;
var dz:Number = camera.z – this.z;
plane.rotationY = Math.atan2(dx, dz) * toDegrees + 180;
}
}
}






























Great , I love it.
AR billboard 做的很好 。但是图咋没有了呢?