Changeset 63
- Timestamp:
- 05/13/08 23:18:03 (5 months ago)
- Files:
-
- trunk/bin/yage3d.exe (modified) (previous)
- trunk/proj/buildme.d (modified) (1 diff)
- trunk/src/demo1/gameobj.d (modified) (3 diffs)
- trunk/src/demo1/main.d (modified) (1 diff)
- trunk/src/demo1/ship.d (modified) (3 diffs)
- trunk/src/demo2/gameobj.d (modified) (3 diffs)
- trunk/src/demo2/main.d (modified) (1 diff)
- trunk/src/demo2/ship.d (modified) (1 diff)
- trunk/src/yage/node/camera.d (modified) (2 diffs)
- trunk/src/yage/node/graph.d (modified) (2 diffs)
- trunk/src/yage/node/model.d (modified) (2 diffs)
- trunk/src/yage/node/node.d (modified) (5 diffs)
- trunk/src/yage/node/sprite.d (modified) (1 diff)
- trunk/src/yage/node/terrain.d (modified) (2 diffs)
- trunk/src/yage/system/render.d (modified) (4 diffs)
- trunk/src/yage/util/misc.d (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/proj/buildme.d
r62 r63 36 36 // Paths are relative to the build script. 37 37 char[] mod_path = "../src"; // The root folder of all modules 38 char[][] src_path = ["../src/yage", "../src/demo 2"];// Array of folders to look for source files38 char[][] src_path = ["../src/yage", "../src/demo1"];// Array of folders to look for source files 39 39 char[][] imp_path = ["../src/derelict"]; // Array of folders to look for imports 40 40 char[][] lib_path = ["../lib"]; // Array of folders to scan for libraries trunk/src/demo1/gameobj.d
r53 r63 13 13 import yage.core.timer; 14 14 import yage.core.types; 15 import yage.core.vector; 15 16 import yage.resource.resource; 16 17 import yage.resource.model; … … 44 45 void setMass(float mass) 45 46 { this.mass = mass; 46 children[0].s etScale(pow(mass, .33333)/2);47 children[0].scale = Vec3f(pow(mass, .33333)/2); 47 48 radius = pow(mass, .3333)*.75*4; 48 49 } … … 60 61 SpriteNode flare = new SpriteNode(this); 61 62 flare.setMaterial("fx/flare1.xml"); 62 flare.s etScale(2);63 flare.scale = Vec3f(2); 63 64 64 65 if (timer is null) trunk/src/demo1/main.d
r62 r63 107 107 SpriteNode star = new SpriteNode(l1); 108 108 star.setMaterial("space/star.xml"); 109 star.s etScale(2500);109 star.scale = Vec3f(2500); 110 110 111 111 // Planet 112 112 auto planet = new ModelNode(scene); 113 113 planet.setModel("space/planet.ms3d"); 114 planet.s etScale(60);114 planet.scale = Vec3f(60); 115 115 planet.setAngularVelocity(0, -0.01, 0); 116 116 trunk/src/demo1/ship.d
r62 r63 35 35 ship = new ModelNode(pitch); 36 36 ship.setModel("scifi/fighter.ms3d"); 37 ship.s etScale(.25);37 ship.scale = Vec3f(.25); 38 38 39 39 spring = new Spring(ship); … … 78 78 puff.setMaterial(Resource.material("fx/smoke.xml")); 79 79 puff.setLifetime(1); 80 puff.s etScale(.4);80 puff.scale = Vec3f(.4); 81 81 //puff.setVelocity(vel); 82 82 puff.setPosition(ship.getAbsolutePosition()+Vec3f(.8, 0, 2.5).rotate(ship.getAbsoluteTransform())); … … 104 104 mouseDelta.x = mouseDelta.y = 0; 105 105 } 106 107 writefln(getRotation());108 106 109 107 // Bank on turn trunk/src/demo2/gameobj.d
r54 r63 13 13 import yage.core.timer; 14 14 import yage.core.types; 15 import yage.core.vector; 15 16 import yage.resource.resource; 16 17 import yage.resource.model; … … 44 45 void setMass(float mass) 45 46 { this.mass = mass; 46 children[0].s etScale(pow(mass, .33333)/2);47 children[0].scale = Vec3f(pow(mass, .33333)/2); 47 48 radius = pow(mass, .3333)*.75*4; 48 49 } … … 60 61 SpriteNode flare = new SpriteNode(this); 61 62 flare.setMaterial("fx/flare1.xml"); 62 flare.s etScale(2);63 flare.scale = Vec3f(2); 63 64 64 65 if (timer is null) trunk/src/demo2/main.d
r58 r63 202 202 SpriteNode star = new SpriteNode(l1); 203 203 star.setMaterial("space/star.xml"); 204 star.s etScale(2500);204 star.scale = Vec3f(2500); 205 205 206 206 // Planet 207 207 auto planet = new ModelNode(scene); 208 208 planet.setModel("space/planet.ms3d"); 209 planet.s etScale(600);209 planet.scale = Vec3f(600); 210 210 planet.setAngularVelocity(0, -0.01, 0); 211 211 trunk/src/demo2/ship.d
r57 r63 34 34 ship = new ModelNode(pitch); 35 35 ship.setModel("obj/tie2.obj"); 36 ship.s etScale(.25);36 ship.scale = Vec3f(.25); 37 37 38 38 spring = new Spring(ship); trunk/src/yage/node/camera.d
r59 r63 61 61 capture = new GPUTexture(); 62 62 setResolution(xres, yres); 63 setVisible(false);63 visible = false; 64 64 } 65 65 … … 295 295 protected void addNodesToRender(Node node) 296 296 { 297 if (node. getVisible())297 if (node.visible) 298 298 { node.setOnscreen(true); 299 299 trunk/src/yage/node/graph.d
r31 r63 45 45 this(BaseNode parent) 46 46 { super(parent); 47 setVisible(true);47 visible = true; 48 48 setWindow(-1, 1, -1, 1); 49 49 … … 99 99 } 100 100 101 101 102 /// Overridden to cache the radius if changed by the scale. 102 void s etScale(float x, float y, float z)103 { super.setScale(x, y, z);103 void scale(Vec3f scale) 104 { this.scale = scale; 104 105 radius = model.getDimensions().scale(scale).length(); 105 106 } 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; 115 110 } 116 111 trunk/src/yage/node/model.d
r28 r63 26 26 this(BaseNode parent) 27 27 { super(parent); 28 setVisible(true);28 visible = true; 29 29 } 30 30 … … 60 60 61 61 /// Overridden to cache the radius if changed by the scale. 62 void s etScale(float x, float y, float z)63 { super.s etScale(x, y,z);62 void scale(Vec3f s) 63 { super.scale = Vec3f(s.x, s.y, s.z); 64 64 if (model) 65 65 radius = model.getDimensions().scale(scale).max(); 66 66 } 67 68 /// ditto 69 void setScale(Vec3f scale) 70 { setScale(scale.x, scale.y, scale.z); 67 68 Vec3f scale() 69 { return super.scale; 71 70 } 72 71 73 /// ditto74 void setScale(float scale)75 { setScale(scale, scale, scale);76 }77 72 78 73 /** trunk/src/yage/node/node.d
r54 r63 60 60 { 61 61 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 65 64 protected float lifetime = float.infinity; // in seconds 66 65 67 66 protected LightNode[] lights; // Lights that affect this Node 68 67 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; 69 80 70 81 /// Construct this Node as a child of parent. … … 118 129 } 119 130 120 /// Get the color of the Node.121 Color getColor()122 { return color;123 }124 125 131 /// Get the time before the Node will be removed. 126 132 float getLifetime() … … 145 151 } // This is the radius of a 1x1x1 cube 146 152 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 158 154 159 155 /// Remove this Node. This function should be used instead of delete. … … 170 166 foreach(Node c; children) 171 167 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 have177 * 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 /// Ditto183 void setColor(Color color)184 { this.color = color;185 168 } 186 169 … … 216 199 } 217 200 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 244 202 /* 245 203 * Update the position and rotation of this node based on its velocity and angular velocity. trunk/src/yage/node/sprite.d
r28 r63 23 23 this(BaseNode parent) 24 24 { super(parent); 25 setVisible(true);25 visible = true; 26 26 } 27 27 trunk/src/yage/node/terrain.d
r32 r63 49 49 model = new Model(); 50 50 model.setMeshes([new Mesh()]); 51 setVisible(true);51 visible = true; 52 52 } 53 53 … … 148 148 } 149 149 150 151 // Overridden to cache the radius if changed by the scale.152 void s etScale(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; 154 154 if (width != 0) // if heightmap loaded 155 155 radius = model.getDimensions().scale(scale).length(); 156 156 } 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 167 163 168 164 /* trunk/src/yage/system/render.d
r59 r63 83 83 glPushMatrix(); 84 84 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); 86 86 n.enableLights(); 87 87 … … 120 120 foreach (AlphaTriangle at; alpha) 121 121 { foreach (layer; at.matl.getLayers()) 122 { layer.bind(at.node.getLights(), at.node. getColor());122 { layer.bind(at.node.getLights(), at.node.color); 123 123 glBegin(GL_TRIANGLES); 124 124 … … 201 201 // If not translucent 202 202 if (!sort) 203 { l.bind(node.getLights(), node. getColor(), model);203 { l.bind(node.getLights(), node.color, model); 204 204 draw(); 205 205 l.unbind(); … … 211 211 { AlphaTriangle at; 212 212 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); 214 214 at.texcoords[i] = &t[tri.v[i]]; 215 215 at.normals[i] = &n[tri.v[i]]; trunk/src/yage/util/misc.d
r57 r63 54 54 55 55 a.setModel(Resource.model("space/asteroid1.ms3d")); 56 a.s etScale(value5*value5*value5*value5*value5*value5*value5*1.1 + .2);56 a.scale = Vec3f(value5*value5*value5*value5*value5*value5*value5*1.1 + .2); 57 57 a.rotate(Vec3f(value4*12, value2*12, value3*12)); 58 58 a.setAngularVelocity(random(-.2, .2), random(-.2, .2), random(-.2, .2)); … … 73 73 74 74 a.setModel(Resource.model("../media/planet/phobos.ms3d")); 75 a.s etScale(value5*value5*.4 + .2);75 a.scale = Vec3f(value5*value5*.4 + .2); 76 76 a.rotate(Vec3f(value4*12, value2*7, value3*11)); 77 77 } … … 90 90 91 91 a.setModel(Resource.model("../media/planet/phobos.ms3d")); 92 a.s etScale(value5*value5*.4 + .2);92 a.scale = Vec3f(value5*value5*.4 + .2); 93 93 a.rotate(Vec3f(value4*12, value2*7, value*11)); 94 94 }
