My favorites | Sign in
Logo
             
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package {
import alternativa.engine3d.core.Face;
import alternativa.engine3d.materials.TextureMaterial;
import alternativa.engine3d.primitives.Box;
import flash.geom.Point;

/**
* Sky box.
* @author makc
*/
public class SkyBox extends Box {

/**
* Constructor.
* @param rotateTop top image rotation angle in degrees (0, 90, 180 or 270).
* @param rotateBottom bottom image rotation angle in degrees (0, 90, 180 or 270).
*/
public function SkyBox (front:TextureMaterial, back:TextureMaterial, left:TextureMaterial, right:TextureMaterial, top:TextureMaterial, bottom:TextureMaterial,
rotateTop:Number = 0, rotateBottom:Number = 0) {

// large box with inward face normales
super (50000, 50000, 50000, 1, 1, 1, true);

// assign materials
setMaterialToSurface (front, "front"); front.repeat = false;
setMaterialToSurface (back, "back"); back.repeat = false;
setMaterialToSurface (left, "left"); left.repeat = false;
setMaterialToSurface (right, "right"); right.repeat = false;
setMaterialToSurface (top, "top"); top.repeat = false;
setMaterialToSurface (bottom, "bottom"); bottom.repeat = false;

var i:int, n:int, f:Face;

// rotate top
f = surfaces ["top"].faces.peek ();
n = Math.max (0, rotateTop / 90);
for (i = 0; i < n; i++) rotateFaceBy90 (f);

// rotate bottom
f = surfaces ["bottom"].faces.peek ();
n = Math.max (0, rotateBottom / 90);
for (i = 0; i < n; i++) rotateFaceBy90 (f);
}

private function rotateFaceBy90 (f:Face):void {
var aUV:Point, bUV:Point, cUV:Point;
aUV = f.aUV;
bUV = f.bUV;
cUV = f.cUV;
f.aUV = aUV.add (cUV).subtract (bUV);
f.bUV = aUV;
f.cUV = bUV;
}

}

}
Show details Hide details

Change log

r91 by makc.the.great on Aug 19, 2009   Diff
Sky box demo, Alternativa3D 5.5.0
Go to: 
Sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 1756 bytes, 57 lines
Hosted by Google Code