home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
404 Jogos
/
CLJG.iso
/
Esportes
/
CrossingCup.swf
/
scripts
/
__Packages
/
sandy
/
primitive
/
Box.as
next >
Wrap
Text File
|
2007-12-11
|
5KB
|
89 lines
class sandy.primitive.Box extends sandy.core.Object3D implements sandy.primitive.Primitive3D
{
function Box(rad, h, lg, mode, quality)
{
super();
this._h = h !== undefined ? h : 6;
this._lg = lg !== undefined ? lg : 6;
this._radius = rad !== undefined ? rad : 100;
this._q = !(undefined == quality || quality <= 0 || quality > 10) ? int(quality) : 1;
this._mode = !(undefined == mode || mode != "tri" && mode != "quad") ? mode : "tri";
this.generate();
}
function generate(Void)
{
this.aPoints = [];
this.aNormals = [];
this._aFaces = [];
var _loc2_ = (- this._h) / 2;
var _loc4_ = this._radius / 2;
var _loc3_ = this._lg / 2;
var _loc16_ = new sandy.core.data.Vertex(- _loc4_,- _loc2_,_loc3_);
this.aPoints.push(_loc16_);
var _loc15_ = new sandy.core.data.Vertex(_loc4_,- _loc2_,_loc3_);
this.aPoints.push(_loc15_);
var _loc14_ = new sandy.core.data.Vertex(_loc4_,_loc2_,_loc3_);
this.aPoints.push(_loc14_);
var _loc13_ = new sandy.core.data.Vertex(- _loc4_,_loc2_,_loc3_);
this.aPoints.push(_loc13_);
var _loc12_ = new sandy.core.data.Vertex(- _loc4_,- _loc2_,- _loc3_);
this.aPoints.push(_loc12_);
var _loc11_ = new sandy.core.data.Vertex(_loc4_,- _loc2_,- _loc3_);
this.aPoints.push(_loc11_);
var _loc10_ = new sandy.core.data.Vertex(_loc4_,_loc2_,- _loc3_);
this.aPoints.push(_loc10_);
var _loc9_ = new sandy.core.data.Vertex(- _loc4_,_loc2_,- _loc3_);
this.aPoints.push(_loc9_);
var _loc8_ = this.addUVCoordinate(0,0);
var _loc7_ = this.addUVCoordinate(1,0);
var _loc6_ = this.addUVCoordinate(0,1);
var _loc5_ = this.addUVCoordinate(1,1);
this.__tesselate(_loc16_,_loc15_,_loc14_,_loc13_,_loc8_,_loc7_,_loc5_,_loc6_,this._q - 1);
this.__tesselate(_loc12_,_loc9_,_loc10_,_loc11_,_loc7_,_loc5_,_loc6_,_loc8_,this._q - 1);
this.__tesselate(_loc14_,_loc10_,_loc9_,_loc13_,_loc7_,_loc5_,_loc6_,_loc8_,this._q - 1);
this.__tesselate(_loc16_,_loc12_,_loc11_,_loc15_,_loc6_,_loc5_,_loc7_,_loc8_,this._q - 1);
this.__tesselate(_loc16_,_loc13_,_loc9_,_loc12_,_loc7_,_loc5_,_loc6_,_loc8_,this._q - 1);
this.__tesselate(_loc15_,_loc11_,_loc10_,_loc14_,_loc8_,_loc7_,_loc5_,_loc6_,this._q - 1);
}
function __tesselate(p0, p1, p2, p3, uv0, uv1, uv2, uv3, level)
{
var _loc8_ = undefined;
if(level == 0)
{
if(this._mode == "tri")
{
_loc8_ = new sandy.core.face.TriFace3D(this,p0,p1,p3);
_loc8_.setUVCoordinates(uv0,uv1,uv3);
this.addFace(_loc8_);
_loc8_ = new sandy.core.face.TriFace3D(this,p2,p3,p1);
_loc8_.setUVCoordinates(uv2,uv3,uv1);
this.addFace(_loc8_);
}
else if(this._mode == "quad")
{
_loc8_ = new sandy.core.face.QuadFace3D(this,p0,p1,p2,p3);
_loc8_.setUVCoordinates(uv0,uv1,uv2,uv3);
this.addFace(_loc8_);
}
}
else
{
var _loc17_ = new sandy.core.data.Vertex((p0.x + p1.x) / 2,(p0.y + p1.y) / 2,(p0.z + p1.z) / 2);
var _loc15_ = new sandy.core.data.Vertex((p1.x + p2.x) / 2,(p1.y + p2.y) / 2,(p1.z + p2.z) / 2);
var _loc14_ = new sandy.core.data.Vertex((p2.x + p3.x) / 2,(p2.y + p3.y) / 2,(p2.z + p3.z) / 2);
var _loc16_ = new sandy.core.data.Vertex((p3.x + p0.x) / 2,(p3.y + p0.y) / 2,(p3.z + p0.z) / 2);
var _loc11_ = new sandy.core.data.Vertex((p0.x + p1.x + p2.x + p3.x) / 4,(p0.y + p1.y + p2.y + p3.y) / 4,(p0.z + p1.z + p2.z + p3.z) / 4);
this.aPoints.push(_loc17_,_loc15_,_loc14_,_loc16_,_loc11_);
var _loc21_ = this.addUVCoordinate((uv0.u + uv1.u) / 2,(uv0.v + uv1.v) / 2);
var _loc19_ = this.addUVCoordinate((uv1.u + uv2.u) / 2,(uv1.v + uv2.v) / 2);
var _loc18_ = this.addUVCoordinate((uv2.u + uv3.u) / 2,(uv2.v + uv3.v) / 2);
var _loc20_ = this.addUVCoordinate((uv3.u + uv0.u) / 2,(uv3.v + uv0.v) / 2);
var _loc12_ = this.addUVCoordinate((uv0.u + uv1.u + uv2.u + uv3.u) / 4,(uv0.v + uv1.v + uv2.v + uv3.v) / 4);
this.__tesselate(_loc11_,_loc16_,p0,_loc17_,_loc12_,_loc20_,uv0,_loc21_,level - 1);
this.__tesselate(_loc11_,_loc17_,p1,_loc15_,_loc12_,_loc21_,uv1,_loc19_,level - 1);
this.__tesselate(_loc11_,_loc15_,p2,_loc14_,_loc12_,_loc19_,uv2,_loc18_,level - 1);
this.__tesselate(_loc11_,_loc14_,p3,_loc16_,_loc12_,_loc18_,uv3,_loc20_,level - 1);
}
}
}