FLARToolKit demo Rasengan from NARUTO

Rasengan.as

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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package org.tarotaro.flash.pv3d 
{
    import org.papervision3d.core.material.TriangleMaterial;
    import org.papervision3d.lights.PointLight3D;
    import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
    import org.papervision3d.materials.special.CompositeMaterial;
    import org.papervision3d.materials.WireframeMaterial;
    import org.papervision3d.objects.DisplayObject3D;
    import soulwire.papervision3d.Ribbon3D;
 
    /**
     * 
     * @author
     */
    public class Rasengan extends DisplayObject3D
    {
        private var _ribbons:Vector.<Ribbon3D>;
        private var _rasengan:DisplayObject3D;
        private var _theta:Number;
        private var _speed:Number;
        private var _rotateSpeed:Number;
        private var _sizeMin:uint;
        private var _sizeDelta:uint;
 
        public function Rasengan(ribbonCount:Number,
                                 speed:Number = 2,
                                 rotateSpeed:Number = 3,
                                 sizeMin:uint = 50,
                                 sizeDelta:uint = 3,
                                 thickness:uint = 2,
                                 light:PointLight3D = null,
                                 lightColorMin:uint = 0,
                                 lightColorMax:uint = 0xFFFFFF,
                                 ambientColorMin:uint = 0,
                                 ambientColorMax:uint = 0xFFFFFF) 
        {
            this._theta = 0;
            this._speed = speed;
            this._rotateSpeed = rotateSpeed;
            this._sizeMin = sizeMin;
            this._sizeDelta = sizeDelta;
 
            this._ribbons = new Vector.<Ribbon3D>();
 
            if (light == null) {
                light = new PointLight3D();
            }
 
            var mat:TriangleMaterial;
            var lightColor:uint;
            var ambientColor:uint;
            var r:Ribbon3D;
 
            for (var i:int = 0; i < ribbonCount; i++) {
                lightColor = Math.random() * (lightColorMax - lightColorMin) + lightColorMin;
                ambientColor = Math.random() * (ambientColorMax - ambientColorMin) + ambientColorMin;
                mat = new FlatShadeMaterial(light, lightColor, ambientColor, 10);
                mat.doubleSided = true;
                r = new Ribbon3D(mat, thickness, Math.random() * 100+50);
                r.rotationX = Math.random() * ribbonCount * (90 * i);
                r.rotationY = Math.random() * ribbonCount * (90 * i);
                r.rotationZ = Math.random() * ribbonCount * (90 * i);
 
                this._ribbons.push(r);
                this.addChild(r);
            }
        }
 
        public function draw():void 
        {
            this._theta += this._speed;
            this.rotationX += this._rotateSpeed;
            this.rotationY += this._rotateSpeed;
            this.rotationZ += this._rotateSpeed;
 
            var tp:Number = (this._theta * Math.PI / 180);
 
            var size:Number = this._sizeMin;
 
            var xBase:Number = Math.cos((this._theta * Math.PI / 180)) * Math.cos((this._theta * Math.PI / 180) * 12);
            var yBase:Number = Math.cos((this._theta * Math.PI / 180)) * Math.sin((this._theta * Math.PI / 180) * 12);
            var zBase:Number = Math.sin((this._theta * Math.PI / 180));
            for each(var r:Ribbon3D in this._ribbons) {
                r.x = size * xBase;
                r.y = size * yBase;
                r.z = size * zBase;
                r.draw();
                size += this._sizeDelta;
            }
 
            this._theta %= 360;
        }
 
        private function get numRibbons():int
        {
            return this._ribbons.length;
        }
 
        public function get sizeMin():uint { return _sizeMin; }
 
        public function set sizeMin(value:uint):void 
        {
            _sizeMin = value;
        }
 
        public function get sizeDelta():uint { return _sizeDelta; }
 
        public function set sizeDelta(value:uint):void 
        {
            _sizeDelta = value;
        }
 
    }
 
}
Ads

Ad

Ad

Share

  • Add this article to hatena bookmark
  • 0

Follow

Ads

Ad

Comments

  1. i watch Naruto series after going to school. i love the action and powers of naruto.”;`

Leave a Comment

Your email address will not be published. Required fields are marked *