Changeset 63

Show
Ignore:
Timestamp:
05/13/08 23:18:03 (5 months ago)
Author:
JoeCoder
Message:

Began the process of replacing lenghy getter/setter code with public properties that accomplish the same thing.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/proj/buildme.d

    r62 r63  
    3636// Paths are relative to the build script. 
    3737char[]   mod_path = "../src";                       // The root folder of all modules 
    38 char[][] src_path = ["../src/yage", "../src/demo2"];// Array of folders to look for source files 
     38char[][] src_path = ["../src/yage", "../src/demo1"];// Array of folders to look for source files 
    3939char[][] imp_path = ["../src/derelict"];            // Array of folders to look for imports 
    4040char[][] lib_path = ["../lib"];                     // Array of folders to scan for libraries 
  • trunk/src/demo1/gameobj.d

    r53 r63  
    1313import yage.core.timer; 
    1414import yage.core.types; 
     15import yage.core.vector; 
    1516import yage.resource.resource; 
    1617import yage.resource.model; 
     
    4445    void setMass(float mass) 
    4546    {   this.mass = mass; 
    46         children[0].setScale(pow(mass, .33333)/2); 
     47        children[0].scale = Vec3f(pow(mass, .33333)/2); 
    4748        radius = pow(mass, .3333)*.75*4; 
    4849    } 
     
    6061        SpriteNode flare = new SpriteNode(this); 
    6162        flare.setMaterial("fx/flare1.xml"); 
    62         flare.setScale(2); 
     63        flare.scale = Vec3f(2); 
    6364 
    6465        if (timer is null) 
  • trunk/src/demo1/main.d

    r62 r63  
    107107    SpriteNode star = new SpriteNode(l1); 
    108108    star.setMaterial("space/star.xml"); 
    109     star.setScale(2500); 
     109    star.scale = Vec3f(2500); 
    110110 
    111111    // Planet 
    112112    auto planet = new ModelNode(scene); 
    113113    planet.setModel("space/planet.ms3d"); 
    114     planet.setScale(60); 
     114    planet.scale = Vec3f(60); 
    115115    planet.setAngularVelocity(0, -0.01, 0); 
    116116     
  • trunk/src/demo1/ship.d

    r62 r63  
    3535        ship = new ModelNode(pitch); 
    3636        ship.setModel("scifi/fighter.ms3d"); 
    37         ship.setScale(.25); 
     37        ship.scale = Vec3f(.25); 
    3838 
    3939        spring = new Spring(ship); 
     
    7878            puff.setMaterial(Resource.material("fx/smoke.xml")); 
    7979            puff.setLifetime(1); 
    80             puff.setScale(.4); 
     80            puff.scale = Vec3f(.4); 
    8181            //puff.setVelocity(vel); 
    8282            puff.setPosition(ship.getAbsolutePosition()+Vec3f(.8, 0, 2.5).rotate(ship.getAbsoluteTransform())); 
     
    104104            mouseDelta.x = mouseDelta.y = 0; 
    105105        } 
    106          
    107         writefln(getRotation()); 
    108106 
    109107        // Bank on turn 
  • trunk/src/demo2/gameobj.d

    r54 r63  
    1313import yage.core.timer; 
    1414import yage.core.types; 
     15import yage.core.vector; 
    1516import yage.resource.resource; 
    1617import yage.resource.model; 
     
    4445    void setMass(float mass) 
    4546    {   this.mass = mass; 
    46         children[0].setScale(pow(mass, .33333)/2); 
     47        children[0].scale = Vec3f(pow(mass, .33333)/2); 
    4748        radius = pow(mass, .3333)*.75*4; 
    4849    } 
     
    6061        SpriteNode flare = new SpriteNode(this); 
    6162        flare.setMaterial("fx/flare1.xml"); 
    62         flare.setScale(2); 
     63        flare.scale = Vec3f(2); 
    6364 
    6465        if (timer is null) 
  • trunk/src/demo2/main.d

    r58 r63  
    202202    SpriteNode star = new SpriteNode(l1); 
    203203    star.setMaterial("space/star.xml"); 
    204     star.setScale(2500); 
     204    star.scale = Vec3f(2500); 
    205205 
    206206    // Planet 
    207207    auto planet = new ModelNode(scene); 
    208208    planet.setModel("space/planet.ms3d"); 
    209     planet.setScale(600); 
     209    planet.scale = Vec3f(600); 
    210210    planet.setAngularVelocity(0, -0.01, 0); 
    211211     
  • trunk/src/demo2/ship.d

    r57 r63  
    3434        ship = new ModelNode(pitch); 
    3535        ship.setModel("obj/tie2.obj"); 
    36         ship.setScale(.25); 
     36        ship.scale = Vec3f(.25); 
    3737 
    3838        spring = new Spring(ship); 
  • trunk/src/yage/node/camera.d

    r59 r63  
    6161        capture = new GPUTexture(); 
    6262        setResolution(xres, yres); 
    63         setVisible(false)
     63        visible = false
    6464    } 
    6565 
     
    295295    protected void addNodesToRender(Node node) 
    296296    { 
    297         if (node.getVisible()
     297        if (node.visible
    298298        {   node.setOnscreen(true); 
    299299 
  • trunk/src/yage/node/graph.d

    r31 r63  
    4545    this(BaseNode parent) 
    4646    {   super(parent); 
    47         setVisible(true)
     47        visible = true
    4848        setWindow(-1, 1, -1, 1); 
    4949 
     
    9999    } 
    100100 
     101 
    101102    /// Overridden to cache the radius if changed by the scale. 
    102     void setScale(float x, float y, float z
    103     {   super.setScale(x, y, z)
     103    void scale(Vec3f scale
     104    {   this.scale = scale
    104105        radius = model.getDimensions().scale(scale).length(); 
    105106    } 
    106  
    107     /// ditto 
    108     void setScale(Vec3f scale) 
    109     {   setScale(scale.x, scale.y, scale.z); 
    110     } 
    111  
    112     /// ditto 
    113     void setScale(float scale) 
    114     {   setScale(scale, scale, scale); 
     107     
     108    Vec3f scale() 
     109    {   return super.scale;      
    115110    } 
    116111 
  • trunk/src/yage/node/model.d

    r28 r63  
    2626    this(BaseNode parent) 
    2727    {   super(parent); 
    28         setVisible(true)
     28        visible = true
    2929    } 
    3030 
     
    6060 
    6161    /// Overridden to cache the radius if changed by the scale. 
    62     void setScale(float x, float y, float z
    63     {   super.setScale(x, y, z); 
     62    void scale(Vec3f s
     63    {   super.scale = Vec3f(s.x, s.y, s.z); 
    6464        if (model) 
    6565            radius = model.getDimensions().scale(scale).max(); 
    6666    } 
    67  
    68     /// ditto 
    69     void setScale(Vec3f scale) 
    70     {   setScale(scale.x, scale.y, scale.z); 
     67     
     68    Vec3f scale() 
     69    {   return super.scale;      
    7170    } 
    7271 
    73     /// ditto 
    74     void setScale(float scale) 
    75     {   setScale(scale, scale, scale); 
    76     } 
    7772 
    7873    /** 
  • trunk/src/yage/node/node.d

    r54 r63  
    6060{ 
    6161    protected bool  onscreen = true;    // used internally by cameras to mark if they can see this node. 
    62     protected bool  visible = true; 
    63     protected Vec3f scale; 
    64     protected Color color;              // RGBA, used for glColor4f() 
     62     
     63 
    6564    protected float lifetime = float.infinity;  // in seconds 
    6665 
    6766    protected LightNode[] lights;       // Lights that affect this Node 
    6867    protected float[]     intensities;  // stores the brightness of each light on this Node. 
     68     
     69    // Public properties 
     70    Vec3f scale;    /// The x,y,z scale of the Node. 
     71    bool visible = true; /// Set whether this Node is rendered. 
     72     
     73    /** 
     74     * The color and opacity of the Node, which is multiplied with any Materials that are 
     75     * rendered with the Node. 
     76     * This is equivalent to glColor4f(). If the materials of any meshes have 
     77     * blending enabled, their alpha value can be set via the fourth parameter. 
     78     * Default color is white (all 1's).*/ 
     79    Color color; 
    6980 
    7081    /// Construct this Node as a child of parent. 
     
    118129    } 
    119130 
    120     /// Get the color of the Node. 
    121     Color getColor() 
    122     {   return color; 
    123     } 
    124  
    125131    /// Get the time before the Node will be removed. 
    126132    float getLifetime() 
     
    145151    }                                   // This is the radius of a 1x1x1 cube 
    146152 
    147     /// Get the scale of the Node. 
    148     Vec3f getScale() 
    149     {   return scale; 
    150     } 
    151  
    152     /// Is rendering enabled for this node? 
    153     bool getVisible() 
    154     {   return visible; 
    155     } 
    156  
    157  
     153     
    158154 
    159155    /// Remove this Node.  This function should be used instead of delete. 
     
    170166        foreach(Node c; children) 
    171167            c.remove(); 
    172     } 
    173  
    174     /** 
    175      * Set the color of the Node, multiplied with the material properties. 
    176      * This is equivalent to glColor4f(). If the materials of any meshes have 
    177      * blending enabled, their alpha value can be set via the fourth parameter. 
    178      * Default color is white (all 1's).*/ 
    179     void setColor(float r, float g, float b, float a=1) 
    180     {   color = Color(r, g, b, a); 
    181     } 
    182     /// Ditto 
    183     void setColor(Color color) 
    184     {   this.color = color; 
    185168    } 
    186169 
     
    216199    } 
    217200 
    218     /** 
    219      * Set the scale of this Node in the x, y, and z directions. 
    220      * The default is (1, 1, 1).  Unlike position and rotation, scale is not inherited. */ 
    221     void setScale(float x, float y, float z) 
    222     {   scale.set(x, y, z); 
    223     } 
    224  
    225     /// ditto 
    226     void setScale(Vec3f scale) 
    227     {   setScale(scale.x, scale.y, scale.z); 
    228     } 
    229  
    230     /// ditto 
    231     void setScale(float scale) 
    232     {   setScale(scale, scale, scale); 
    233     } 
    234  
    235     /** Set whether this Node will be renered.  This has nothing to do with frustum culling. 
    236      *  Setting a Node as invisible will not make its children invisible also. */ 
    237     void setVisible(bool visible) 
    238     {   this.visible = visible; 
    239     } 
    240  
    241  
    242  
    243  
     201     
    244202    /* 
    245203     * Update the position and rotation of this node based on its velocity and angular velocity. 
  • trunk/src/yage/node/sprite.d

    r28 r63  
    2323    this(BaseNode parent) 
    2424    {   super(parent); 
    25         setVisible(true)
     25        visible = true
    2626    } 
    2727 
  • trunk/src/yage/node/terrain.d

    r32 r63  
    4949        model = new Model(); 
    5050        model.setMeshes([new Mesh()]); 
    51         setVisible(true)
     51        visible = true
    5252    } 
    5353 
     
    148148    } 
    149149 
    150  
    151     // Overridden to cache the radius if changed by the scale. 
    152     void setScale(float x, float y, float z
    153     {   super.setScale(x, y, z)
     150     
     151    /// Overridden to cache the radius if changed by the scale. 
     152    void scale(Vec3f scale
     153    {   this.scale = scale
    154154        if (width != 0) // if heightmap loaded 
    155155            radius = model.getDimensions().scale(scale).length(); 
    156156    } 
    157  
    158     // ditto 
    159     void setScale(Vec3f scale) 
    160     {   setScale(scale.x, scale.y, scale.z); 
    161     } 
    162  
    163     // ditto 
    164     void setScale(float scale) 
    165     {   setScale(scale, scale, scale); 
    166     } 
     157     
     158    Vec3f scale() 
     159    {   return super.scale;      
     160    } 
     161     
     162     
    167163 
    168164    /* 
  • trunk/src/yage/system/render.d

    r59 r63  
    8383            glPushMatrix(); 
    8484            glMultMatrixf(n.getAbsoluteTransform(true).v.ptr); 
    85             glScalef(n.getScale().x, n.getScale().y, n.getScale().z); 
     85            glScalef(n.scale.x, n.scale.y, n.scale.z); 
    8686            n.enableLights(); 
    8787 
     
    120120        foreach (AlphaTriangle at; alpha) 
    121121        {   foreach (layer; at.matl.getLayers()) 
    122             {   layer.bind(at.node.getLights(), at.node.getColor()); 
     122            {   layer.bind(at.node.getLights(), at.node.color); 
    123123                glBegin(GL_TRIANGLES); 
    124124                 
     
    201201                    // If not translucent 
    202202                    if (!sort) 
    203                     {   l.bind(node.getLights(), node.getColor(), model); 
     203                    {   l.bind(node.getLights(), node.color, model); 
    204204                        draw(); 
    205205                        l.unbind(); 
     
    211211                        {   AlphaTriangle at; 
    212212                            for (int i=0; i<3; i++) 
    213                             {   at.vertices[i] = abs_transform*v[tri.v[i]].scale(node.getScale()); 
     213                            {   at.vertices[i] = abs_transform*v[tri.v[i]].scale(node.scale); 
    214214                                at.texcoords[i] = &t[tri.v[i]]; 
    215215                                at.normals[i] = &n[tri.v[i]]; 
  • trunk/src/yage/util/misc.d

    r57 r63  
    5454         
    5555        a.setModel(Resource.model("space/asteroid1.ms3d")); 
    56         a.setScale(value5*value5*value5*value5*value5*value5*value5*1.1 + .2); 
     56        a.scale = Vec3f(value5*value5*value5*value5*value5*value5*value5*1.1 + .2); 
    5757        a.rotate(Vec3f(value4*12, value2*12, value3*12)); 
    5858        a.setAngularVelocity(random(-.2, .2), random(-.2, .2), random(-.2, .2)); 
     
    7373 
    7474        a.setModel(Resource.model("../media/planet/phobos.ms3d")); 
    75         a.setScale(value5*value5*.4 + .2); 
     75        a.scale = Vec3f(value5*value5*.4 + .2); 
    7676        a.rotate(Vec3f(value4*12, value2*7, value3*11)); 
    7777    } 
     
    9090 
    9191        a.setModel(Resource.model("../media/planet/phobos.ms3d")); 
    92         a.setScale(value5*value5*.4 + .2); 
     92        a.scale = Vec3f(value5*value5*.4 + .2); 
    9393        a.rotate(Vec3f(value4*12, value2*7, value*11)); 
    9494    }