Mesh, Surface, SkyBox, and WireFrame
原文地址:http://wiki.alternativaplatform.com/Alternativa_8_for_Dummies_Part_III
1:Mesh
Mesh是所有多边形的集合,它也是Box, Decal, GeoSphere, Skin ,SkyBox的基类~只需记住在A3D中,几乎所有在三维空间中的多边形都是Mesh
2:Surface
面~~每个多边形都可以分割成N多个面,每个面都拥有自己的材质,一个面由一连串的三角形组成。
public function addSurface(material:Material, indexBegin:uint, numTriangles:uint):Surface
material:Material — surface material indexBegin:uint — Start index in IndexBuffer. numTriangles:uint — number of triangles
box = new Box(200, 200, 200); //create box
rootContainer.addChild(box);
for (var i:int = 0; i < 6; i++) { //box to add 6 surfaces
var texture:BitmapTextureResource = new BitmapTextureResource(new aLogo[i]().bitmapData);
box.addSurface(new TextureMaterial(texture), i*6, 2); //each impose its texture
}
3:SkyBox
天空盒。简单来说就是一个6面体,材质贴图都在内部,而摄像机处于天空盒当中,就能构建一般游戏中的最外层的背景图。当然,GeoSphere同样可以作为天空盒使用。
public function SkyBox(size:Number, left:Material = null,
right:Material = null,
back:Material = null,
front:Material = null,
bottom:Material = null,
top:Material = null,
uvPadding:Number = 0);

4:WireFrame
线框。可以将任意3D模型转化为三维线框。看图比较直接...
Mesh:

Wireframe:

源码:
var parser:ParserA3D = new ParserA3D();
parser.parse(new A3dModel());
car = parser.objects[1] as Mesh;
carWireFrame = WireFrame.createEdges(car, 0xFFFFFFFF, 1, 1); //transform the mesh into three-dimensional line.
rootContainer.addChild(carWireFrame);//add to a container
createEdges的四个参数分别为:Mesh, 颜色, 透明度, 线框粗细
我们也可以使用
createLinesList(points:Vector, color:uint = 0, alpha:Number = 1, thickness:Number = 1):WireFrame
方法来自己画一个线框:
var pointsVector:Vector.<Vector3D> = Vector.<Vector3D>([new Vector3D( 70, -70, 70), new Vector3D( 70, 70, 70),
new Vector3D( 70, 70, 70), new Vector3D( -70, 70, 70),
new Vector3D( -70, 70, 70), new Vector3D( -70, -70, 70),
new Vector3D( -70, -70, 70), new Vector3D( 70, -70, 70),
new Vector3D( 70, -70, -70), new Vector3D( 70, 70, -70),
new Vector3D( 70, 70, -70), new Vector3D( -70, 70, -70),
new Vector3D( -70, 70, -70), new Vector3D( -70, -70, -70),
new Vector3D( -70, -70, -70), new Vector3D( 70, -70, -70),
new Vector3D( 70, -70, 70), new Vector3D( 70, -70, -70),
new Vector3D( 70, 70, 70), new Vector3D( 70, 70, -70),
new Vector3D( -70, 70, 70), new Vector3D( -70, 70, -70),
new Vector3D( -70, -70, 70), new Vector3D( -70, -70, -70)]);
wireFrame = WireFrame.createLinesList(pointsVector, 0xFF00FF00, 1, 3); //pass the vector points, color, alpha and size of lines
rootContainer.addChild(wireFrame);
浙公网安备 33010602011771号