diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..ab665f9 Binary files /dev/null and b/.DS_Store differ diff --git a/INSTRUCTION.md b/INSTRUCTION.md new file mode 100644 index 0000000..c1cda32 --- /dev/null +++ b/INSTRUCTION.md @@ -0,0 +1,130 @@ +# Homework 4: L-systems + +For this assignment, you will design a set of formal grammar rules to create +a plant life using an L-system program. Once again, you will work from a +TypeScript / WebGL 2.0 base code like the one you used in homework 0. You will +implement your own set of classes to handle the L-system grammar expansion and +drawing. You will rasterize your L-system using faceted geometry. Feel free +to use ray marching to generate an interesting background, but trying to +raymarch an entire L-system will take too long to render! + +## Base Code +The provided code is very similar to that of homework 1, with the same camera and GUI layout. Additionally, we have provided you with a `Mesh` class that, given a filepath, will construct VBOs describing the vertex positions, normals, colors, uvs, and indices for any `.obj` file. The provided code also uses instanced rendering to draw a single square 10,000 times at different locations and with different colors; refer to the Assignment Requirements section for more details on instanced rendering. Farther down this README, we have also provided some example code snippets for setting up hash map structures in TypeScript. + +## Assignment Requirements +- __(15 points)__ Create a collection of classes to represent an L-system. You should have at least the following components to make your L-system functional: + - A `Turtle` class to represent the current drawing state of your L-System. It should at least keep track of its current position, current orientation, and recursion depth (how many `[` characters have been found while drawing before `]`s) + - A stack of `Turtle`s to represent your `Turtle` history. Push a copy of your current `Turtle` onto this when you reach a `[` while drawing, and pop the top `Turtle` from the stack and make it your current `Turtle` when you encounter a `]`. Note that in TypeScript, `push()` and `pop()` operations can be done on regular arrays. + - An expandable string of characters to represent your grammar as you iterate on it. + - An `ExpansionRule` class to represent the result of mapping a particular character to a new set of characters during the grammar expansion phase of the L-System. By making a class to represent the expansion, you can have a single character expand to multiple possible strings depending on some probability by querying a `Map`. + - A `DrawingRule` class to represent the result of mapping a character to an L-System drawing operation (possibly with multiple outcomes depending on a probability). + +- __(10 points)__ Set up the code in `main.ts` and `ShaderProgram.ts` to pass a collection of transformation data to the GPU to draw your L-System geometric components using __instanced rendering__. We will be using instanced rendering to draw our L-Systems because it is much more efficient to pass a single transformation for each object to be drawn rather than an entire collection of vertices. The provided base code has examples of passing a set of `vec3`s to offset the position of each instanced object, and a set of `vec4`s to change the color of each object. You should at least alter the following via instanced rendering (note that these can be accomplished with a single `mat4`): + - Position + - Orientation + - Scaling + +- __(55 points)__ Your L-System scene must have the following attributes: + - Your plant must grow in 3D (branches must not just exist in one plane) + - Your plant must have flowers, leaves, or some other branch decoration in addition to basic branch geometry + - Organic variation (i.e. noise or randomness in grammar expansion and/or drawing operations) + - The background should be a colorful backdrop to complement your plant, incorporating some procedural elements. + - A flavorful twist. Don't just make a basic variation of the example F[+FX]-FX from the slides! Create a plant that is unique to you. Make an alien tentacle monster plant if you want to! Play around with drawing operations; don't feel compelled to always make your branches straight lines. Curved forms can look quite visually appealing too. + +- __(10 points)__ Using dat.GUI, make at least three aspects of your L-System interactive, such as: + - The probability thresholds in your grammar expansions + - The angle of rotation in various drawing aspects + - The size or color or material of the plant components + - Anything else in your L-System expansion or drawing you'd like to make modifiable; it doesn't have to be these particular elements + +- __(10 points)__ Following the specifications listed +[here](https://github.com/pjcozzi/Articles/blob/master/CIS565/GitHubRepo/README.md), +create your own README.md, renaming the file you are presently reading to +INSTRUCTIONS.md. Don't worry about discussing runtime optimization for this +project. Make sure your README contains the following information: + - Your name and PennKey + - Citation of any external resources you found helpful when implementing this + assignment. + - A link to your live github.io demo (refer to the pinned Piazza post on + how to make a live demo through github.io) + - An explanation of the techniques you used to generate your L-System features. + Please be as detailed as you can; not only will this help you explain your work + to recruiters, but it helps us understand your project when we grade it! + +## Writing classes and functions in TypeScript +Example of a basic Turtle class in TypeScript (Turtle.ts) +``` +import {vec3} from 'gl-matrix'; + +export default class Turtle { + constructor(pos: vec3, orient: vec3) { + this.position = pos; + this.orientation = orient; + } + + moveForward() { + add(this.position, this.position, this.orientation * 10.0); + } +} +``` +Example of a hash map in TypeScript: +``` +let expansionRules : Map = new Map(); +expansionRules.set('A', 'AB'); +expansionRules.set('B', 'A'); + +console.log(expansionRules.get('A')); // Will print out 'AB' +console.log(expansionRules.get('C')); // Will print out 'undefined' +``` +Using functions as map values in TypeScript: +``` +function moveForward() {...} +function rotateLeft() {...} +let drawRules : Map = new Map(); +drawRules.set('F', moveForward); +drawRules.set('+', rotateLeft); + +let func = drawRules.get('F'); +if(func) { // Check that the map contains a value for this key + func(); +} +``` +Note that in the above case, the code assumes that all functions stored in the `drawRules` map take in no arguments. If you want to store a class's functions as values in a map, you'll have to refer to a specific instance of a class, e.g. +``` +let myTurtle: Turtle = new Turtle(); +let drawRules: Map = new Map(); +drawRules.set('F', myTurtle.moveForward.bind(myTurtle)); +let func = drawRules.get('F'); +if(func) { // Check that the map contains a value for this key + func(); +} +``` +TypeScript's `bind` operation sets the `this` variable inside the bound function to refer to the object inside `bind`. This ensures that the `Turtle` in question is the one on which `moveForward` is invoked when `func()` is called with no object. + +## Examples from previous years (Click to go to live demo) + +Andrea Lin: + +[![](andreaLin.png)](http://andrea-lin.com/Project3-LSystems/) + +Ishan Ranade: + +[![](ishanRanade.png)](https://ishanranade.github.io/homework-4-l-systems-IshanRanade/) + +Joe Klinger: + +[![](joeKlinger.png)](https://klingerj.github.io/Project3-LSystems/) + +Linshen Xiao: + +[![](linshenXiao.png)](https://githublsx.github.io/homework-4-l-systems-githublsx/) + +## Useful Resources +- [The Algorithmic Beauty of Plants](http://algorithmicbotany.org/papers/abop/abop-ch1.pdf) +- [OpenGL Instanced Rendering (Learn OpenGL)](https://learnopengl.com/Advanced-OpenGL/Instancing) +- [OpenGL Instanced Rendering (OpenGL-Tutorial)](http://www.opengl-tutorial.org/intermediate-tutorials/billboards-particles/particles-instancing/) + +## Extra Credit (Up to 20 points) +- For bonus points, add functionality to your L-system drawing that ensures geometry will never overlap. In other words, make your plant behave like a real-life plant so that its branches and other components don't compete for the same space. The more complex you make your L-system self-interaction, the more +points you'll earn. +- Any additional visual polish you add to your L-System will count towards extra credit, at your grader's discretion. For example, you could add animation of the leaves or branches in your vertex shader, or add falling leaves or flower petals. diff --git a/README.md b/README.md index c1cda32..611df2f 100644 --- a/README.md +++ b/README.md @@ -1,130 +1,45 @@ -# Homework 4: L-systems - -For this assignment, you will design a set of formal grammar rules to create -a plant life using an L-system program. Once again, you will work from a -TypeScript / WebGL 2.0 base code like the one you used in homework 0. You will -implement your own set of classes to handle the L-system grammar expansion and -drawing. You will rasterize your L-system using faceted geometry. Feel free -to use ray marching to generate an interesting background, but trying to -raymarch an entire L-system will take too long to render! - -## Base Code -The provided code is very similar to that of homework 1, with the same camera and GUI layout. Additionally, we have provided you with a `Mesh` class that, given a filepath, will construct VBOs describing the vertex positions, normals, colors, uvs, and indices for any `.obj` file. The provided code also uses instanced rendering to draw a single square 10,000 times at different locations and with different colors; refer to the Assignment Requirements section for more details on instanced rendering. Farther down this README, we have also provided some example code snippets for setting up hash map structures in TypeScript. - -## Assignment Requirements -- __(15 points)__ Create a collection of classes to represent an L-system. You should have at least the following components to make your L-system functional: - - A `Turtle` class to represent the current drawing state of your L-System. It should at least keep track of its current position, current orientation, and recursion depth (how many `[` characters have been found while drawing before `]`s) - - A stack of `Turtle`s to represent your `Turtle` history. Push a copy of your current `Turtle` onto this when you reach a `[` while drawing, and pop the top `Turtle` from the stack and make it your current `Turtle` when you encounter a `]`. Note that in TypeScript, `push()` and `pop()` operations can be done on regular arrays. - - An expandable string of characters to represent your grammar as you iterate on it. - - An `ExpansionRule` class to represent the result of mapping a particular character to a new set of characters during the grammar expansion phase of the L-System. By making a class to represent the expansion, you can have a single character expand to multiple possible strings depending on some probability by querying a `Map`. - - A `DrawingRule` class to represent the result of mapping a character to an L-System drawing operation (possibly with multiple outcomes depending on a probability). - -- __(10 points)__ Set up the code in `main.ts` and `ShaderProgram.ts` to pass a collection of transformation data to the GPU to draw your L-System geometric components using __instanced rendering__. We will be using instanced rendering to draw our L-Systems because it is much more efficient to pass a single transformation for each object to be drawn rather than an entire collection of vertices. The provided base code has examples of passing a set of `vec3`s to offset the position of each instanced object, and a set of `vec4`s to change the color of each object. You should at least alter the following via instanced rendering (note that these can be accomplished with a single `mat4`): - - Position - - Orientation - - Scaling - -- __(55 points)__ Your L-System scene must have the following attributes: - - Your plant must grow in 3D (branches must not just exist in one plane) - - Your plant must have flowers, leaves, or some other branch decoration in addition to basic branch geometry - - Organic variation (i.e. noise or randomness in grammar expansion and/or drawing operations) - - The background should be a colorful backdrop to complement your plant, incorporating some procedural elements. - - A flavorful twist. Don't just make a basic variation of the example F[+FX]-FX from the slides! Create a plant that is unique to you. Make an alien tentacle monster plant if you want to! Play around with drawing operations; don't feel compelled to always make your branches straight lines. Curved forms can look quite visually appealing too. - -- __(10 points)__ Using dat.GUI, make at least three aspects of your L-System interactive, such as: - - The probability thresholds in your grammar expansions - - The angle of rotation in various drawing aspects - - The size or color or material of the plant components - - Anything else in your L-System expansion or drawing you'd like to make modifiable; it doesn't have to be these particular elements - -- __(10 points)__ Following the specifications listed -[here](https://github.com/pjcozzi/Articles/blob/master/CIS565/GitHubRepo/README.md), -create your own README.md, renaming the file you are presently reading to -INSTRUCTIONS.md. Don't worry about discussing runtime optimization for this -project. Make sure your README contains the following information: - - Your name and PennKey - - Citation of any external resources you found helpful when implementing this - assignment. - - A link to your live github.io demo (refer to the pinned Piazza post on - how to make a live demo through github.io) - - An explanation of the techniques you used to generate your L-System features. - Please be as detailed as you can; not only will this help you explain your work - to recruiters, but it helps us understand your project when we grade it! - -## Writing classes and functions in TypeScript -Example of a basic Turtle class in TypeScript (Turtle.ts) -``` -import {vec3} from 'gl-matrix'; - -export default class Turtle { - constructor(pos: vec3, orient: vec3) { - this.position = pos; - this.orientation = orient; - } - - moveForward() { - add(this.position, this.position, this.orientation * 10.0); - } -} -``` -Example of a hash map in TypeScript: -``` -let expansionRules : Map = new Map(); -expansionRules.set('A', 'AB'); -expansionRules.set('B', 'A'); - -console.log(expansionRules.get('A')); // Will print out 'AB' -console.log(expansionRules.get('C')); // Will print out 'undefined' -``` -Using functions as map values in TypeScript: -``` -function moveForward() {...} -function rotateLeft() {...} -let drawRules : Map = new Map(); -drawRules.set('F', moveForward); -drawRules.set('+', rotateLeft); - -let func = drawRules.get('F'); -if(func) { // Check that the map contains a value for this key - func(); -} -``` -Note that in the above case, the code assumes that all functions stored in the `drawRules` map take in no arguments. If you want to store a class's functions as values in a map, you'll have to refer to a specific instance of a class, e.g. -``` -let myTurtle: Turtle = new Turtle(); -let drawRules: Map = new Map(); -drawRules.set('F', myTurtle.moveForward.bind(myTurtle)); -let func = drawRules.get('F'); -if(func) { // Check that the map contains a value for this key - func(); -} -``` -TypeScript's `bind` operation sets the `this` variable inside the bound function to refer to the object inside `bind`. This ensures that the `Turtle` in question is the one on which `moveForward` is invoked when `func()` is called with no object. - -## Examples from previous years (Click to go to live demo) - -Andrea Lin: - -[![](andreaLin.png)](http://andrea-lin.com/Project3-LSystems/) - -Ishan Ranade: - -[![](ishanRanade.png)](https://ishanranade.github.io/homework-4-l-systems-IshanRanade/) - -Joe Klinger: - -[![](joeKlinger.png)](https://klingerj.github.io/Project3-LSystems/) - -Linshen Xiao: - -[![](linshenXiao.png)](https://githublsx.github.io/homework-4-l-systems-githublsx/) - -## Useful Resources -- [The Algorithmic Beauty of Plants](http://algorithmicbotany.org/papers/abop/abop-ch1.pdf) -- [OpenGL Instanced Rendering (Learn OpenGL)](https://learnopengl.com/Advanced-OpenGL/Instancing) -- [OpenGL Instanced Rendering (OpenGL-Tutorial)](http://www.opengl-tutorial.org/intermediate-tutorials/billboards-particles/particles-instancing/) - -## Extra Credit (Up to 20 points) -- For bonus points, add functionality to your L-system drawing that ensures geometry will never overlap. In other words, make your plant behave like a real-life plant so that its branches and other components don't compete for the same space. The more complex you make your L-system self-interaction, the more -points you'll earn. -- Any additional visual polish you add to your L-System will count towards extra credit, at your grader's discretion. For example, you could add animation of the leaves or branches in your vertex shader, or add falling leaves or flower petals. +# CIS 566 Homework 4: L-systems + +## Objective + +- Design a set of formal grammar rules to create a plant life using an L-system program +- Implement your own set of classes to handle the L-system grammar expansion and drawing +- Rasterized L-system using faceted geometry + +## Techniques + +![](fin1.png) ![](fin0.png) + +Tree "explodes" when angle > 35 ![](fin2.png) + +Collection of classes to represent an L-system + +- created `Turtle, ExpansionRule, DrawingRule`, and `LSystem` class inside the lsystem folder + +Instanced rendering + +- Set up the code in `main.ts` and `ShaderProgram.ts` to pass a collection of transformation data to the GPU to draw L-System geometric components +- Created `setInstanceVBOTransform` function inside mesh class to pass transform data for instance rendering + +Lsystem scene progress: + +lsystem experimentation with turtle renderer: ![](lsystem.png) + +- using https://kevs3d.co.uk/dev/lsystems/ to experiment with the lsystem grammar + +houdini tree: ![](htree1.jpg) ![](htree2.jpg) + +- experimenting with houdini + +## General Information + +Name: Amelia Peng + +PennKey: pqy + +Live Demo: https://ameliapqy.github.io/hw04-l-systems/ + +Resources: + +- https://kevs3d.co.uk/dev/lsystems/ +- https://www.sidefx.com/docs/houdini/nodes/sop/lsystem.html diff --git a/fin0.png b/fin0.png new file mode 100644 index 0000000..289ccfa Binary files /dev/null and b/fin0.png differ diff --git a/fin1.png b/fin1.png new file mode 100644 index 0000000..e7ee166 Binary files /dev/null and b/fin1.png differ diff --git a/fin2.png b/fin2.png new file mode 100644 index 0000000..09f7c00 Binary files /dev/null and b/fin2.png differ diff --git a/htree1.jpg b/htree1.jpg new file mode 100644 index 0000000..74511a3 Binary files /dev/null and b/htree1.jpg differ diff --git a/htree2.jpg b/htree2.jpg new file mode 100644 index 0000000..731a829 Binary files /dev/null and b/htree2.jpg differ diff --git a/lsystem.png b/lsystem.png new file mode 100644 index 0000000..697e0d9 Binary files /dev/null and b/lsystem.png differ diff --git a/package-lock.json b/package-lock.json index 095aa6c..f370cda 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1743,7 +1743,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -1764,12 +1765,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -1784,17 +1787,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -1911,7 +1917,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -1923,6 +1930,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -1937,6 +1945,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -1944,12 +1953,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -1968,6 +1979,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2048,7 +2060,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -2060,6 +2073,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -2145,7 +2159,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -2181,6 +2196,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2200,6 +2216,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2243,12 +2260,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, diff --git a/progress1.png b/progress1.png new file mode 100644 index 0000000..6858199 Binary files /dev/null and b/progress1.png differ diff --git a/progress2.png b/progress2.png new file mode 100644 index 0000000..ef7ce85 Binary files /dev/null and b/progress2.png differ diff --git a/src/Camera.ts b/src/Camera.ts index 777e9d9..7f39647 100644 --- a/src/Camera.ts +++ b/src/Camera.ts @@ -1,5 +1,5 @@ var CameraControls = require('3d-view-controls'); -import {vec3, mat4} from 'gl-matrix'; +import { vec3, mat4 } from 'gl-matrix'; class Camera { controls: any; @@ -8,7 +8,7 @@ class Camera { fovy: number = 45; aspectRatio: number = 1; near: number = 0.1; - far: number = 1000; + far: number = 2000; position: vec3 = vec3.create(); direction: vec3 = vec3.create(); target: vec3 = vec3.create(); @@ -17,10 +17,10 @@ class Camera { forward: vec3 = vec3.create(); constructor(position: vec3, target: vec3) { - const canvas = document.getElementById('canvas'); + const canvas = document.getElementById('canvas'); this.controls = CameraControls(canvas, { - position: position, + eye: position, center: target, }); @@ -61,6 +61,6 @@ class Camera { vec3.cross(this.up, this.right, this.forward); vec3.normalize(this.up, this.up); } -}; +} export default Camera; diff --git a/src/geometry/Cube.ts b/src/geometry/Cube.ts new file mode 100644 index 0000000..74095b8 --- /dev/null +++ b/src/geometry/Cube.ts @@ -0,0 +1,68 @@ +import { vec3, vec4 } from 'gl-matrix'; +import Drawable from '../rendering/gl/Drawable'; +import { gl } from '../globals'; + +class Cube extends Drawable { + indices: Uint32Array; + positions: Float32Array; + normals: Float32Array; + center: vec4; + + constructor(center: vec3) { + super(); // Call the constructor of the super class. This is required. + this.center = vec4.fromValues(center[0], center[1], center[2], 1); + } + + create() { + this.indices = new Uint32Array([ + 0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23, + ]); + + this.normals = new Float32Array([ + 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, + //top + 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, + //back + 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, + + //right + 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, + //bottom + 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, + //left + 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, + ]); + + this.positions = new Float32Array([ + -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, + //top + -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, + //back + -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, + //right + 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, + //bottom + 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, + //left + -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, + ]); + + this.generateIdx(); + this.generatePos(); + this.generateNor(); + + this.count = this.indices.length; + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.bufIdx); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.bufNor); + gl.bufferData(gl.ARRAY_BUFFER, this.normals, gl.STATIC_DRAW); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.bufPos); + gl.bufferData(gl.ARRAY_BUFFER, this.positions, gl.STATIC_DRAW); + + console.log(`Created cube`); + } +} + +export default Cube; diff --git a/src/geometry/Mesh.ts b/src/geometry/Mesh.ts index c5591ce..ddd1f8a 100644 --- a/src/geometry/Mesh.ts +++ b/src/geometry/Mesh.ts @@ -1,6 +1,6 @@ -import {vec3, vec4} from 'gl-matrix'; +import { vec3, vec4 } from 'gl-matrix'; import Drawable from '../rendering/gl/Drawable'; -import {gl} from '../globals'; +import { gl } from '../globals'; import * as Loader from 'webgl-obj-loader'; class Mesh extends Drawable { @@ -11,6 +11,11 @@ class Mesh extends Drawable { uvs: Float32Array; center: vec4; + col1: Float32Array; + col2: Float32Array; + col3: Float32Array; + col4: Float32Array; + objString: string; constructor(objString: string, center: vec3) { @@ -20,7 +25,8 @@ class Mesh extends Drawable { this.objString = objString; } - create() { + create() { + this.numInstances = 1; let posTemp: Array = []; let norTemp: Array = []; let uvsTemp: Array = []; @@ -44,7 +50,7 @@ class Mesh extends Drawable { // white vert color for now this.colors = new Float32Array(posTemp.length); - for (var i = 0; i < posTemp.length; ++i){ + for (var i = 0; i < posTemp.length; ++i) { this.colors[i] = 1.0; } @@ -59,6 +65,11 @@ class Mesh extends Drawable { this.generateUV(); this.generateCol(); + this.generateCol1(); + this.generateCol2(); + this.generateCol3(); + this.generateCol4(); + this.count = this.indices.length; gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.bufIdx); gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW); @@ -76,8 +87,27 @@ class Mesh extends Drawable { gl.bufferData(gl.ARRAY_BUFFER, this.uvs, gl.STATIC_DRAW); console.log(`Created Mesh from OBJ`); - this.objString = ""; // hacky clear + this.objString = ''; // hacky clear + } + + setInstanceVBOsTransform(colors: Float32Array, col1: Float32Array, col2: Float32Array, col3: Float32Array, col4: Float32Array) { + this.col1 = col1; + this.col2 = col2; + this.col3 = col3; + this.col4 = col4; + this.colors = colors; + gl.bindBuffer(gl.ARRAY_BUFFER, this.bufCol1); + gl.bufferData(gl.ARRAY_BUFFER, this.col1, gl.STATIC_DRAW); + gl.bindBuffer(gl.ARRAY_BUFFER, this.bufCol2); + gl.bufferData(gl.ARRAY_BUFFER, this.col2, gl.STATIC_DRAW); + gl.bindBuffer(gl.ARRAY_BUFFER, this.bufCol3); + gl.bufferData(gl.ARRAY_BUFFER, this.col3, gl.STATIC_DRAW); + gl.bindBuffer(gl.ARRAY_BUFFER, this.bufCol4); + gl.bufferData(gl.ARRAY_BUFFER, this.col4, gl.STATIC_DRAW); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.bufCol); + gl.bufferData(gl.ARRAY_BUFFER, this.colors, gl.STATIC_DRAW); } -}; +} export default Mesh; diff --git a/src/geometry/Square.ts b/src/geometry/Square.ts index 5fdb8ba..d34a742 100644 --- a/src/geometry/Square.ts +++ b/src/geometry/Square.ts @@ -1,6 +1,6 @@ -import {vec3, vec4} from 'gl-matrix'; +import { vec3, vec4 } from 'gl-matrix'; import Drawable from '../rendering/gl/Drawable'; -import {gl} from '../globals'; +import { gl } from '../globals'; class Square extends Drawable { indices: Uint32Array; @@ -8,19 +8,13 @@ class Square extends Drawable { colors: Float32Array; offsets: Float32Array; // Data for bufTranslate - constructor() { super(); // Call the constructor of the super class. This is required. } create() { - - this.indices = new Uint32Array([0, 1, 2, - 0, 2, 3]); - this.positions = new Float32Array([-0.5, -0.5, 0, 1, - 0.5, -0.5, 0, 1, - 0.5, 0.5, 0, 1, - -0.5, 0.5, 0, 1]); + this.indices = new Uint32Array([0, 1, 2, 0, 2, 3]); + this.positions = new Float32Array([-0.5, -0.5, 0, 1, 0.5, -0.5, 0, 1, 0.5, 0.5, 0, 1, -0.5, 0.5, 0, 1]); this.generateIdx(); this.generatePos(); @@ -46,6 +40,6 @@ class Square extends Drawable { gl.bindBuffer(gl.ARRAY_BUFFER, this.bufTranslate); gl.bufferData(gl.ARRAY_BUFFER, this.offsets, gl.STATIC_DRAW); } -}; +} export default Square; diff --git a/src/globals.ts b/src/globals.ts index cac5bf2..88e2566 100644 --- a/src/globals.ts +++ b/src/globals.ts @@ -1,5 +1,24 @@ - export var gl: WebGL2RenderingContext; export function setGL(_gl: WebGL2RenderingContext) { gl = _gl; } + +export function readTextFile(file: string): string { + var text = ''; + var rawFile = new XMLHttpRequest(); + rawFile.open('GET', file, false); + rawFile.onreadystatechange = function () { + if (rawFile.readyState === 4) { + if (rawFile.status === 200 || rawFile.status == 0) { + var allText = rawFile.responseText; + text = allText; + } + } + }; + rawFile.send(null); + return text; +} + +export function toRadian(angle: number) { + return (angle * Math.PI) / 180.0; +} diff --git a/src/lsystem/DrawingRule.ts b/src/lsystem/DrawingRule.ts new file mode 100644 index 0000000..ec581ed --- /dev/null +++ b/src/lsystem/DrawingRule.ts @@ -0,0 +1,99 @@ +import { defaultCipherList } from 'constants'; +import { vec3, vec4, mat4, quat } from 'gl-matrix'; +import Drawable from '../rendering/gl/Drawable'; +import Turtle from './Turtle'; + +// Represent the result of mapping a character to an L-System drawing operation +// (possibly with multiple outcomes depending on a probability). +class DrawingRule { + rules: Map = new Map(); + turtle: Turtle; + turtleStack: Turtle[] = []; + controls: any; + + constructor(controls: any) { + this.turtle = new Turtle( + vec3.fromValues(0, -25, 0), //pos + vec3.fromValues(0, 1, 0), //up + vec3.fromValues(1, 0, 0), //right + vec3.fromValues(0, 2.5, 0), //forward + vec3.fromValues(1, 1, 1), //scale + quat.fromValues(0, 0, 0, 1), //quat + 3, //recursion depth + controls //control + ); + this.turtleStack.push(this.turtle); + //set up drawing rules + this.rules.set('[', this.presave.bind(this)); + this.rules.set(']', this.save.bind(this)); + + this.rules.set('F', this.turtle.moveForward.bind(this.turtle)); + this.rules.set('X', this.turtle.moveForward.bind(this.turtle)); + this.rules.set('U', this.turtle.moveForwardU.bind(this.turtle)); + this.rules.set('T', this.turtle.moveForward.bind(this.turtle)); + this.rules.set('B', this.turtle.addFlower.bind(this.turtle)); + this.rules.set('A', this.turtle.moveBackward.bind(this.turtle)); + + this.rules.set('+', this.turtle.rotatePos.bind(this.turtle)); + this.rules.set('/', this.turtle.rotateF.bind(this.turtle)); + this.rules.set('-', this.turtle.rotateNeg.bind(this.turtle)); + this.rules.set('1', this.turtle.scaleUp.bind(this.turtle)); + this.rules.set('0', this.turtle.scaleDown.bind(this.turtle)); + } + + //[ + presave() { + let oldt = this.turtle.copy(); + this.turtleStack.push(oldt); + let amt = 0.995; + let amt2 = 0.99; + this.turtle.scale[0] *= amt; + this.turtle.scale[2] *= amt; + this.turtle.scale[0] = Math.max(this.turtle.scale[0], 0.25); + this.turtle.scale[2] = Math.max(this.turtle.scale[2], 0.25); + } + + //] + save() { + let t: Turtle = this.turtleStack.pop(); + if (t) { + this.turtle.setTurtle(t); + } + } + + toRadian(angle: number) { + return (angle * Math.PI) / 180.0; + } + + draw(str: string) { + // console.log('string in draw:' + str); + //dummy string for testing + // str = 'FFB/B/B/B/B'; + let allData: any = []; + allData.transforms = []; + var i: number = 0; + for (let char of str) { + let currdata: any = {}; + currdata.transform = mat4.create(); + let func: any = this.rules.get(char); + if (func) { + let transformMat: any = func(); + if (transformMat) { + let newMat: mat4 = mat4.create(); + mat4.copy(newMat, transformMat); + currdata.transform = newMat; + currdata.char = char; + allData.push(currdata); + } + } + if (char == '[') { + this.presave(); + } + if (char == ']') { + this.save(); + } + } + return allData; + } +} +export default DrawingRule; diff --git a/src/lsystem/ExpansionRule.ts b/src/lsystem/ExpansionRule.ts new file mode 100644 index 0000000..a1e98ad --- /dev/null +++ b/src/lsystem/ExpansionRule.ts @@ -0,0 +1,61 @@ +// Represent the result of mapping a particular character to a new set of characters +// during the grammar expansion phase of the L-System + +//maintain a quaternion/ forward right +class ExpansionRule { + grammar: Map; // // + string: string; + axiom: any; + controls: any; + + constructor(controls: any) { + this.axiom = 'TAAAX5'; + this.grammar = new Map(); + this.grammar.set('F', this.expandF()); + this.grammar.set('X', this.expandX()); + this.grammar.set('U', this.expandU()); + this.grammar.set('T', this.expandT()); + } + + expandT() { + return '11T0T0'; + } + + //F = FF + expandF() { + return 'F'; + } + + //X = +F+F-[[X]+X]+F[+FX]-X + //'FF+[[FXU]+XU]+FF[+FXU]-XUU'; + expandX() { + return 'FFF-[[FXU]+XU]+FF[+FXU]-XUU'; + } + + expandU() { + let rand = Math.random(); + if (rand < 0.9) return 'B/B//B/B/B'; + else if (rand < 0.8) return 'B///B//B'; + else return '/U'; + } + expandAxiom(iter: number) { + let result: string = this.axiom; + + for (let i = 0; i < iter; i++) { + let curr: string = ''; + for (let old_sym of result) { + let func = this.grammar.get(old_sym); + if (func) { + curr += func; + } else { + curr += old_sym; + } + } + result = curr; + } + console.log('expandedStr' + result); + return result; + } +} + +export default ExpansionRule; diff --git a/src/lsystem/LSystem.ts b/src/lsystem/LSystem.ts new file mode 100644 index 0000000..b0ac3bd --- /dev/null +++ b/src/lsystem/LSystem.ts @@ -0,0 +1,105 @@ +import { vec3, vec4, mat4, quat } from 'gl-matrix'; +import Turtle from './Turtle'; +import ExpansionRule from './ExpansionRule'; +import DrawingRule from './DrawingRule'; +import ShaderProgram from '../rendering/gl/ShaderProgram'; +import Mesh from '../geometry/Mesh'; +import { readTextFile, toRadian } from '../globals'; +// import { random } from 'gl-matrix/src/gl-matrix/vec2'; + +class LSystem { + expansionRule: ExpansionRule; + drawingRule: DrawingRule; + recursionDepth: number; + controls: any; + + constructor(controls: any) { + this.expansionRule = new ExpansionRule(controls); + this.drawingRule = new DrawingRule(controls); + this.controls = controls; + this.recursionDepth = controls.iterations; + } + + //return VBO data to main + draw() { + let expandedStr = this.expansionRule.expandAxiom(this.recursionDepth); + // console.log('expandedStr: ' + expandedStr); + // let expandedStr = this.expansionRule.string; + let transforms: any[] = this.drawingRule.draw(expandedStr); + + //init data + let data: any = {}; + data.trunks = {}; + data.trunks.color = []; + data.trunks.col1 = []; + data.trunks.col2 = []; + data.trunks.col3 = []; + data.trunks.col4 = []; + + data.flowers = {}; + data.flowers.color = []; + data.flowers.col1 = []; + data.flowers.col2 = []; + data.flowers.col3 = []; + data.flowers.col4 = []; + let flower_color = vec4.fromValues( + this.controls.flower_color[0] / 255.0, + this.controls.flower_color[1] / 255.0, + this.controls.flower_color[2] / 255.0, + 1 + ); + + let type: string = ''; + let fcol1 = vec4.fromValues(0.9, 0.1, 0.6, 1.0); + + for (let currData of transforms) { + if (currData.char.toUpperCase() == currData.char.toLowerCase()) { + continue; + } + let transformation: mat4 = currData.transform; + if (currData.char == 'U' || currData.char == 'B') { + type = 'flowers'; + //add variation to color + let rand: number = Math.random(); + let tempCol0: number = flower_color[0] + rand * flower_color[0] * 0.5; + let tempCol1: number = flower_color[1] - rand * flower_color[1] * 0.1; + let tempCol2: number = flower_color[2] + (rand - 0.3) * flower_color[2] * 0.2; + data[type].color.push(tempCol0); + data[type].color.push(tempCol1); + data[type].color.push(tempCol2); + data[type].color.push(1); + } else { + type = 'trunks'; + data[type].color.push(0.06); + data[type].color.push(0.05); + data[type].color.push(0.05); + // data[type].color.push(flower_color[0]); + // data[type].color.push(flower_color[1]); + // data[type].color.push(flower_color[2]); + data[type].color.push(1); + } + data[type].col1.push(transformation[0]); + data[type].col1.push(transformation[1]); + data[type].col1.push(transformation[2]); + data[type].col1.push(transformation[3]); + + data[type].col2.push(transformation[4]); + data[type].col2.push(transformation[5]); + data[type].col2.push(transformation[6]); + data[type].col2.push(transformation[7]); + + data[type].col3.push(transformation[8]); + data[type].col3.push(transformation[9]); + data[type].col3.push(transformation[10]); + data[type].col3.push(transformation[11]); + + data[type].col4.push(transformation[12]); + data[type].col4.push(transformation[13]); + data[type].col4.push(transformation[14]); + data[type].col4.push(transformation[15]); + } + return data; + } +} + +export default LSystem; diff --git a/src/lsystem/Turtle.ts b/src/lsystem/Turtle.ts new file mode 100644 index 0000000..a1071f9 --- /dev/null +++ b/src/lsystem/Turtle.ts @@ -0,0 +1,222 @@ +import { vec3, vec4, mat4, quat } from 'gl-matrix'; +import { toRadian } from '../globals'; +// import { fromValues } from 'gl-matrix/src/gl-matrix/vec2'; + +class Turtle { + pos: vec3 = vec3.create(); + up: vec3 = vec3.create(); + right: vec3 = vec3.create(); + forward: vec3 = vec3.create(); + quaternion: quat = quat.create(); + scale: vec3 = vec3.create(); + tempScale: vec3 = vec3.create(); + depth: number = 0; + stepSize: vec3 = vec3.create(); + controls: any; + deg: number = toRadian(25.0); + transform: mat4 = mat4.create(); + + constructor(pos: vec3, up: vec3, right: vec3, forward: vec3, scale: vec3, q: quat, depth: number, controls: any) { + this.pos = pos; + this.up = up; + this.right = right; + this.forward = forward; + this.quaternion = q; + this.depth = depth; + this.controls = controls; + this.scale = scale; + this.stepSize = vec3.fromValues(1, 1, 1); + this.tempScale = vec3.fromValues(5.0, 5.0, 5.0); + } + + updateTransform() { + mat4.fromRotationTranslationScale(this.transform, this.quaternion, this.pos, this.scale); + } + + updateTransformU() { + let fs1 = this.controls.flower_scale; + + if (this.controls.angle < 35 && this.controls.angle >= 15) { + fs1 += fs1 * Math.random(); + } else { + fs1 = Math.max(fs1, 2 * Math.random()); + } + + let s: vec3 = vec3.fromValues(fs1, fs1, fs1); + + mat4.fromRotationTranslationScale(this.transform, this.quaternion, this.pos, s); + } + + updateTransformUR() { + let fs1 = 100; + fs1 += fs1 * Math.random(); + let s: vec3 = vec3.fromValues(fs1, fs1, fs1); + + mat4.fromRotationTranslationScale(this.transform, this.quaternion, s, s); + } + + copy() { + let newPos: vec3 = vec3.create(); + vec3.copy(newPos, this.pos); + + let newUp: vec3 = vec3.create(); + vec3.copy(newUp, this.up); + + let newRight: vec3 = vec3.create(); + vec3.copy(newRight, this.right); + + let newForward: vec3 = vec3.create(); + vec3.copy(newForward, this.forward); + + let newScale: vec3 = vec3.create(); + vec3.copy(newScale, this.scale); + + let newQuat: quat = quat.create(); + quat.copy(newQuat, this.quaternion); + + let newt = new Turtle(newPos, newUp, newRight, newForward, newScale, newQuat, this.depth, this.controls); + this.depth++; + return newt; + } + + scaleDown() { + let amt = 1.05; + let amt2 = 0.8; + this.scale[0] /= amt; + this.scale[1] /= amt2; + this.scale[2] /= amt; + this.stepSize[0] /= amt; + this.stepSize[1] /= amt2; + this.stepSize[2] /= amt; + } + + scaleUp() { + let amt = 1.05; + let amt2 = 0.8; + this.scale[0] *= amt; + this.scale[1] *= amt2; + this.scale[2] *= amt; + this.stepSize[0] *= amt; + this.stepSize[1] *= amt2; + this.stepSize[2] *= amt; + } + + moveForward() { + let n = vec3.create(); + vec3.multiply(n, this.forward, this.stepSize); + vec3.add(this.pos, this.pos, n); + this.updateTransform(); + if (this.controls.angle < 35 && this.controls.angle >= 15) { + return this.transform; + } + } + addFlower() { + this.updateTransformU(); + return this.transform; + } + + moveForwardU() { + let half = vec3.create(); + vec3.normalize(half, this.forward); + let fs1 = this.controls.flower_scale; + let s: vec3 = vec3.fromValues(fs1, fs1, fs1); + vec3.multiply(half, half, s); + vec3.max(half, this.stepSize, half); + vec3.add(this.pos, this.pos, half); + this.updateTransformU(); + return this.transform; + } + + moveRight(neg: boolean = false, axis: vec3) { + let n = vec3.create(); + let temp = vec3.create(); + let amt = 0.8; + if (neg) { + amt = -0.8; + } + vec3.multiply(temp, this.stepSize, vec3.fromValues(amt, amt, amt)); + vec3.multiply(n, this.right, temp); + vec3.add(this.pos, this.pos, n); + this.updateTransform(); + // return this.transform; + } + + moveBackward() { + vec3.subtract(this.pos, this.pos, this.forward); + this.updateTransform(); + // return this.transform; + } + + moveForwardH() { + let half = vec3.create(); + vec3.divide(half, this.forward, vec3.fromValues(2, 2, 2)); + vec3.add(this.pos, this.pos, half); + this.updateTransform(); + return this.transform; + } + + //left and right + rotatePos() { + this.rotate(0, 1, 1); + } + + rotateF() { + let rand = Math.random(); + this.rotate(1.0 * rand, 1 * rand, 1 * rand, false, true); + } + + //along y axis + rotatePosY() { + this.rotate(0, 1, 0); + } + + //rotate for flower + rotateFR() { + let rand = Math.random(); + this.rotate(1.0 * rand, 1 * rand, 1 * rand, false, true); + return this.transform; + } + + rotateNeg() { + this.rotate(0, 0, 1, true); + } + + //pass in the axis + rotate(x: number, y: number, z: number, neg: boolean = false, flower: boolean = false, deg: number = this.controls.angle) { + if (neg) { + deg = -deg; + } + if (flower) { + deg *= 1 + 5.0 * Math.random(); + } + let axis = vec3.fromValues(x, y, z); + + let q: quat = quat.create(); + quat.setAxisAngle(q, axis, toRadian(deg)); + + let tempForward: vec4 = vec4.fromValues(this.forward[0], this.forward[1], this.forward[2], 0); + vec4.transformQuat(tempForward, tempForward, q); + this.forward = vec3.fromValues(tempForward[0], tempForward[1], tempForward[2]); + + let tempRight: vec4 = vec4.fromValues(this.right[0], this.right[1], this.right[2], 1.0); + vec4.transformQuat(tempRight, tempRight, q); + this.right = vec3.fromValues(tempRight[0], tempRight[1], tempRight[2]); + + // update quat + quat.multiply(this.quaternion, q, this.quaternion); + quat.normalize(this.quaternion, this.quaternion); + // this.moveRight(neg, axis); + } + + setTurtle(turtle: Turtle) { + vec3.copy(this.pos, turtle.pos); + vec3.copy(this.forward, turtle.forward); + vec3.copy(this.up, turtle.up); + vec3.copy(this.right, turtle.right); + quat.copy(this.quaternion, turtle.quaternion); + this.depth = turtle.depth - 1; + this.controls = turtle.controls; + } +} + +export default Turtle; diff --git a/src/main.ts b/src/main.ts index 932c78f..6e32782 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,21 +1,85 @@ -import {vec3} from 'gl-matrix'; +import { vec3, vec4 } from 'gl-matrix'; import * as Stats from 'stats-js'; import * as DAT from 'dat-gui'; import Square from './geometry/Square'; import ScreenQuad from './geometry/ScreenQuad'; import OpenGLRenderer from './rendering/gl/OpenGLRenderer'; import Camera from './Camera'; -import {setGL} from './globals'; -import ShaderProgram, {Shader} from './rendering/gl/ShaderProgram'; +import { setGL } from './globals'; +import ShaderProgram, { Shader } from './rendering/gl/ShaderProgram'; + +import Turtle from './lsystem/Turtle'; +import LSystem from './lsystem/LSystem'; +import ExpansionRule from './lsystem/ExpansionRule'; +import { readTextFile, toRadian } from './globals'; +import Mesh from './geometry/Mesh'; // Define an object with application parameters and button callbacks // This will be referred to by dat.GUI's functions that add GUI elements. const controls = { + iterations: 5, + angle: 25, + flower_color: [255, 170, 170], + flower_scale: 4, + speed: 1, + time: 0, }; let square: Square; let screenQuad: ScreenQuad; +let cylinder: Mesh; +let flower: Mesh; +let base: Mesh; + let time: number = 0.0; +let changed: boolean = true; + +function backgroundSetup() { + let colorsArray = [0.5, 0.55, 0.6, 1.0]; + + let col1sArray = [50, 0, 0, 0]; + let col2sArray = [0, 10, 0, 0]; + let col3sArray = [0, 0, 50, 0]; + let col4sArray = [0, -35, 0, 1]; + + let colors: Float32Array = new Float32Array(colorsArray); + let col1s: Float32Array = new Float32Array(col1sArray); + let col2s: Float32Array = new Float32Array(col2sArray); + let col3s: Float32Array = new Float32Array(col3sArray); + let col4s: Float32Array = new Float32Array(col4sArray); + + base.setInstanceVBOsTransform(colors, col1s, col2s, col3s, col4s); + base.setNumInstances(1); +} + +function lsystermSetup() { + if (changed) { + changed = false; + } else { + return; + } + // Init LSystem + let lsystem: LSystem = new LSystem(controls); //new ExpansionRule(controls)); + let data = lsystem.draw(); + console.log(data); + let colors: Float32Array = new Float32Array(data['trunks'].color); + let col1s: Float32Array = new Float32Array(data['trunks'].col1); + let col2s: Float32Array = new Float32Array(data['trunks'].col2); + let col3s: Float32Array = new Float32Array(data['trunks'].col3); + let col4s: Float32Array = new Float32Array(data['trunks'].col4); + + cylinder.setInstanceVBOsTransform(colors, col1s, col2s, col3s, col4s); + cylinder.setNumInstances(data['trunks'].color.length / 4); + + flower.setInstanceVBOsTransform( + new Float32Array(data['flowers'].color), + new Float32Array(data['flowers'].col1), + new Float32Array(data['flowers'].col2), + new Float32Array(data['flowers'].col3), + new Float32Array(data['flowers'].col4) + ); + flower.setNumInstances(data['flowers'].color.length / 4); +} function loadScene() { square = new Square(); @@ -23,30 +87,23 @@ function loadScene() { screenQuad = new ScreenQuad(); screenQuad.create(); - // Set up instanced rendering data arrays here. - // This example creates a set of positional - // offsets and gradiated colors for a 100x100 grid - // of squares, even though the VBO data for just - // one square is actually passed to the GPU - let offsetsArray = []; - let colorsArray = []; - let n: number = 100.0; - for(let i = 0; i < n; i++) { - for(let j = 0; j < n; j++) { - offsetsArray.push(i); - offsetsArray.push(j); - offsetsArray.push(0); - - colorsArray.push(i / n); - colorsArray.push(j / n); - colorsArray.push(1.0); - colorsArray.push(1.0); // Alpha channel - } - } - let offsets: Float32Array = new Float32Array(offsetsArray); - let colors: Float32Array = new Float32Array(colorsArray); - square.setInstanceVBOs(offsets, colors); - square.setNumInstances(n * n); // grid of "particles" + //load from obj + let cylinderObj: string = readTextFile('https://raw.githubusercontent.com/ameliapqy/hw04-l-systems/master/src/obj/cylinder.obj'); + cylinder = new Mesh(cylinderObj, vec3.fromValues(0, 0, 0)); + cylinder.create(); + + let baseObj: string = readTextFile('https://raw.githubusercontent.com/ameliapqy/hw04-l-systems/master/src/obj/base.obj'); + base = new Mesh(baseObj, vec3.fromValues(0, 0, 0)); + base.create(); + + let flowerObj: string = readTextFile('https://raw.githubusercontent.com/ameliapqy/hw04-l-systems/master/src/obj/flower.obj'); + flower = new Mesh(flowerObj, vec3.fromValues(0, 0, 0)); + flower.create(); + + backgroundSetup(); + + //lsystem + lsystermSetup(); } function main() { @@ -60,10 +117,55 @@ function main() { // Add controls to the gui const gui = new DAT.GUI(); + gui + .add(controls, 'iterations', 1, 6) + .step(1) + .onChange( + function () { + changed = true; + }.bind(this) + ); + gui + .add(controls, 'angle', 15, 100) + .step(1) + .onChange( + function () { + changed = true; + }.bind(this) + ); + gui.addColor(controls, 'flower_color').onChange( + function () { + changed = true; + }.bind(this) + ); + gui + .add(controls, 'flower_scale', 1, 10) + .step(0.5) + .onChange( + function () { + changed = true; + }.bind(this) + ); + // gui + // .add(controls, 'speed', 0, 10) + // .step(1) + // .onChange( + // function () { + // changed = true; + // }.bind(this) + // ); + // gui + // .add(controls, 'time', 0, 10) + // .step(1) + // .onChange( + // function () { + // changed = true; + // }.bind(this) + // ); // get canvas and webgl context - const canvas = document.getElementById('canvas'); - const gl = canvas.getContext('webgl2'); + const canvas = document.getElementById('canvas'); + const gl = canvas.getContext('webgl2'); if (!gl) { alert('WebGL 2 not supported!'); } @@ -74,12 +176,13 @@ function main() { // Initial call to load scene loadScene(); - const camera = new Camera(vec3.fromValues(50, 50, 10), vec3.fromValues(50, 50, 0)); + const camera = new Camera(vec3.fromValues(100, 10, 50), vec3.fromValues(0, 10, 0)); const renderer = new OpenGLRenderer(canvas); renderer.setClearColor(0.2, 0.2, 0.2, 1); - gl.enable(gl.BLEND); - gl.blendFunc(gl.ONE, gl.ONE); // Additive blending + // gl.enable(gl.BLEND); + // gl.blendFunc(gl.ONE, gl.ONE); // Additive blending + gl.enable(gl.DEPTH_TEST); const instancedShader = new ShaderProgram([ new Shader(gl.VERTEX_SHADER, require('./shaders/instanced-vert.glsl')), @@ -94,34 +197,39 @@ function main() { // This function will be called every frame function tick() { camera.update(); + // console.log(camera.position); stats.begin(); instancedShader.setTime(time); flat.setTime(time++); + controls.time = time; gl.viewport(0, 0, window.innerWidth, window.innerHeight); renderer.clear(); + //set LSystem Up + lsystermSetup(); renderer.render(camera, flat, [screenQuad]); - renderer.render(camera, instancedShader, [ - square, - ]); + renderer.render(camera, instancedShader, [cylinder, flower, base]); stats.end(); - // Tell the browser to call `tick` again whenever it renders a new frame requestAnimationFrame(tick); } - window.addEventListener('resize', function() { - renderer.setSize(window.innerWidth, window.innerHeight); - camera.setAspectRatio(window.innerWidth / window.innerHeight); - camera.updateProjectionMatrix(); - flat.setDimensions(window.innerWidth, window.innerHeight); - }, false); + window.addEventListener( + 'resize', + function () { + renderer.setSize(window.innerWidth, window.innerHeight); + camera.setAspectRatio(window.innerWidth / window.innerHeight); + camera.updateProjectionMatrix(); + flat.setDimensions(window.innerWidth, window.innerHeight); + }, + false + ); renderer.setSize(window.innerWidth, window.innerHeight); camera.setAspectRatio(window.innerWidth / window.innerHeight); camera.updateProjectionMatrix(); flat.setDimensions(window.innerWidth, window.innerHeight); - // Start the render loop + // flowert the render loop tick(); } diff --git a/src/obj/base.obj b/src/obj/base.obj new file mode 100644 index 0000000..a18c56b --- /dev/null +++ b/src/obj/base.obj @@ -0,0 +1,861 @@ +# This file uses centimeters as units for non-parametric coordinates. + +mtllib base.mtl +g default +v 2.042002 0.000000 -0.663487 +v 1.737031 0.000000 -1.262027 +v 1.262027 0.000000 -1.737031 +v 0.663487 0.000000 -2.042002 +v 0.000000 0.000000 -2.147088 +v -0.663487 0.000000 -2.042002 +v -1.262026 0.000000 -1.737030 +v -1.737030 0.000000 -1.262026 +v -2.042001 0.000000 -0.663486 +v -2.147087 0.000000 0.000000 +v -2.042001 0.000000 0.663486 +v -1.737030 0.000000 1.262026 +v -1.262026 0.000000 1.737030 +v -0.663486 0.000000 2.042001 +v -0.000000 0.000000 2.147087 +v 0.663486 0.000000 2.042001 +v 1.262026 0.000000 1.737030 +v 1.737030 0.000000 1.262026 +v 2.042001 0.000000 0.663486 +v 2.147087 0.000000 0.000000 +v 2.016862 0.156434 -0.655318 +v 1.715645 0.156434 -1.246489 +v 1.246489 0.156434 -1.715645 +v 0.655318 0.156434 -2.016861 +v 0.000000 0.156434 -2.120654 +v -0.655318 0.156434 -2.016861 +v -1.246489 0.156434 -1.715645 +v -1.715644 0.156434 -1.246489 +v -2.016861 0.156434 -0.655318 +v -2.120653 0.156434 0.000000 +v -2.016861 0.156434 0.655318 +v -1.715644 0.156434 1.246489 +v -1.246489 0.156434 1.715644 +v -0.655318 0.156434 2.016861 +v -0.000000 0.156434 2.120653 +v 0.655318 0.156434 2.016861 +v 1.246488 0.156434 1.715644 +v 1.715644 0.156434 1.246488 +v 2.016861 0.156434 0.655318 +v 2.120653 0.156434 0.000000 +v 1.942060 0.309017 -0.631013 +v 1.652015 0.309017 -1.200259 +v 1.200259 0.309017 -1.652014 +v 0.631013 0.309017 -1.942059 +v 0.000000 0.309017 -2.042002 +v -0.631013 0.309017 -1.942059 +v -1.200259 0.309017 -1.652014 +v -1.652014 0.309017 -1.200258 +v -1.942059 0.309017 -0.631013 +v -2.042001 0.309017 0.000000 +v -1.942059 0.309017 0.631013 +v -1.652014 0.309017 1.200258 +v -1.200258 0.309017 1.652014 +v -0.631013 0.309017 1.942059 +v -0.000000 0.309017 2.042001 +v 0.631013 0.309017 1.942058 +v 1.200258 0.309017 1.652014 +v 1.652013 0.309017 1.200258 +v 1.942058 0.309017 0.631013 +v 2.042001 0.309017 0.000000 +v 1.819437 0.453991 -0.591171 +v 1.547706 0.453991 -1.124474 +v 1.124474 0.453991 -1.547706 +v 0.591171 0.453991 -1.819437 +v 0.000000 0.453991 -1.913069 +v -0.591171 0.453991 -1.819437 +v -1.124474 0.453991 -1.547705 +v -1.547705 0.453991 -1.124474 +v -1.819437 0.453991 -0.591171 +v -1.913069 0.453991 0.000000 +v -1.819437 0.453991 0.591171 +v -1.547705 0.453991 1.124474 +v -1.124474 0.453991 1.547705 +v -0.591171 0.453991 1.819436 +v -0.000000 0.453991 1.913069 +v 0.591171 0.453991 1.819436 +v 1.124473 0.453991 1.547705 +v 1.547705 0.453991 1.124473 +v 1.819436 0.453991 0.591171 +v 1.913068 0.453991 0.000000 +v 1.652015 0.587785 -0.536772 +v 1.405287 0.587785 -1.021001 +v 1.021001 0.587785 -1.405287 +v 0.536772 0.587785 -1.652014 +v 0.000000 0.587785 -1.737030 +v -0.536772 0.587785 -1.652014 +v -1.021001 0.587785 -1.405287 +v -1.405287 0.587785 -1.021001 +v -1.652014 0.587785 -0.536772 +v -1.737030 0.587785 0.000000 +v -1.652014 0.587785 0.536772 +v -1.405287 0.587785 1.021001 +v -1.021001 0.587785 1.405287 +v -0.536772 0.587785 1.652014 +v -0.000000 0.587785 1.737030 +v 0.536772 0.587785 1.652014 +v 1.021000 0.587785 1.405287 +v 1.405287 0.587785 1.021001 +v 1.652013 0.587785 0.536772 +v 1.737030 0.587785 0.000000 +v 1.443914 0.707107 -0.469156 +v 1.228266 0.707107 -0.892388 +v 0.892388 0.707107 -1.228266 +v 0.469156 0.707107 -1.443913 +v 0.000000 0.707107 -1.518220 +v -0.469156 0.707107 -1.443913 +v -0.892387 0.707107 -1.228266 +v -1.228266 0.707107 -0.892387 +v -1.443913 0.707107 -0.469156 +v -1.518220 0.707107 0.000000 +v -1.443913 0.707107 0.469156 +v -1.228266 0.707107 0.892387 +v -0.892387 0.707107 1.228266 +v -0.469156 0.707107 1.443913 +v -0.000000 0.707107 1.518220 +v 0.469156 0.707107 1.443913 +v 0.892387 0.707107 1.228266 +v 1.228266 0.707107 0.892387 +v 1.443913 0.707107 0.469156 +v 1.518220 0.707107 0.000000 +v 1.200259 0.809017 -0.389988 +v 1.021001 0.809017 -0.741801 +v 0.741801 0.809017 -1.021001 +v 0.389988 0.809017 -1.200259 +v 0.000000 0.809017 -1.262027 +v -0.389988 0.809017 -1.200259 +v -0.741801 0.809017 -1.021001 +v -1.021001 0.809017 -0.741800 +v -1.200258 0.809017 -0.389988 +v -1.262026 0.809017 0.000000 +v -1.200258 0.809017 0.389988 +v -1.021001 0.809017 0.741800 +v -0.741800 0.809017 1.021001 +v -0.389988 0.809017 1.200258 +v -0.000000 0.809017 1.262026 +v 0.389987 0.809017 1.200258 +v 0.741800 0.809017 1.021001 +v 1.021000 0.809017 0.741800 +v 1.200258 0.809017 0.389987 +v 1.262026 0.809017 0.000000 +v 0.927050 0.891007 -0.301217 +v 0.788596 0.891007 -0.572948 +v 0.572948 0.891007 -0.788595 +v 0.301217 0.891007 -0.927050 +v 0.000000 0.891007 -0.974757 +v -0.301217 0.891007 -0.927049 +v -0.572948 0.891007 -0.788595 +v -0.788595 0.891007 -0.572948 +v -0.927049 0.891007 -0.301217 +v -0.974757 0.891007 0.000000 +v -0.927049 0.891007 0.301217 +v -0.788595 0.891007 0.572948 +v -0.572948 0.891007 0.788595 +v -0.301217 0.891007 0.927049 +v -0.000000 0.891007 0.974757 +v 0.301216 0.891007 0.927049 +v 0.572948 0.891007 0.788595 +v 0.788595 0.891007 0.572948 +v 0.927049 0.891007 0.301217 +v 0.974757 0.891007 0.000000 +v 0.631013 0.951057 -0.205029 +v 0.536772 0.951057 -0.389988 +v 0.389988 0.951057 -0.536772 +v 0.205029 0.951057 -0.631013 +v 0.000000 0.951057 -0.663487 +v -0.205029 0.951057 -0.631013 +v -0.389988 0.951057 -0.536772 +v -0.536772 0.951057 -0.389988 +v -0.631013 0.951057 -0.205029 +v -0.663486 0.951057 0.000000 +v -0.631013 0.951057 0.205029 +v -0.536772 0.951057 0.389988 +v -0.389988 0.951057 0.536772 +v -0.205029 0.951057 0.631013 +v -0.000000 0.951057 0.663486 +v 0.205029 0.951057 0.631013 +v 0.389987 0.951057 0.536772 +v 0.536772 0.951057 0.389987 +v 0.631013 0.951057 0.205029 +v 0.663486 0.951057 0.000000 +v 0.319440 0.987688 -0.103792 +v 0.271731 0.987688 -0.197424 +v 0.197424 0.987688 -0.271731 +v 0.103792 0.987688 -0.319440 +v 0.000000 0.987688 -0.335879 +v -0.103792 0.987688 -0.319439 +v -0.197424 0.987688 -0.271731 +v -0.271731 0.987688 -0.197424 +v -0.319439 0.987688 -0.103792 +v -0.335878 0.987688 0.000000 +v -0.319439 0.987688 0.103792 +v -0.271731 0.987688 0.197424 +v -0.197424 0.987688 0.271731 +v -0.103792 0.987688 0.319439 +v -0.000000 0.987688 0.335878 +v 0.103792 0.987688 0.319439 +v 0.197424 0.987688 0.271731 +v 0.271731 0.987688 0.197424 +v 0.319439 0.987688 0.103792 +v 0.335878 0.987688 0.000000 +v 0.000000 1.000000 0.000000 +vt 0.000000 0.500000 +vt 0.050000 0.500000 +vt 0.100000 0.500000 +vt 0.150000 0.500000 +vt 0.200000 0.500000 +vt 0.250000 0.500000 +vt 0.300000 0.500000 +vt 0.350000 0.500000 +vt 0.400000 0.500000 +vt 0.450000 0.500000 +vt 0.500000 0.500000 +vt 0.550000 0.500000 +vt 0.600000 0.500000 +vt 0.650000 0.500000 +vt 0.700000 0.500000 +vt 0.750000 0.500000 +vt 0.800000 0.500000 +vt 0.850000 0.500000 +vt 0.900000 0.500000 +vt 0.950000 0.500000 +vt 1.000000 0.500000 +vt 0.000000 0.550000 +vt 0.050000 0.550000 +vt 0.100000 0.550000 +vt 0.150000 0.550000 +vt 0.200000 0.550000 +vt 0.250000 0.550000 +vt 0.300000 0.550000 +vt 0.350000 0.550000 +vt 0.400000 0.550000 +vt 0.450000 0.550000 +vt 0.500000 0.550000 +vt 0.550000 0.550000 +vt 0.600000 0.550000 +vt 0.650000 0.550000 +vt 0.700000 0.550000 +vt 0.750000 0.550000 +vt 0.800000 0.550000 +vt 0.850000 0.550000 +vt 0.900000 0.550000 +vt 0.950000 0.550000 +vt 1.000000 0.550000 +vt 0.000000 0.600000 +vt 0.050000 0.600000 +vt 0.100000 0.600000 +vt 0.150000 0.600000 +vt 0.200000 0.600000 +vt 0.250000 0.600000 +vt 0.300000 0.600000 +vt 0.350000 0.600000 +vt 0.400000 0.600000 +vt 0.450000 0.600000 +vt 0.500000 0.600000 +vt 0.550000 0.600000 +vt 0.600000 0.600000 +vt 0.650000 0.600000 +vt 0.700000 0.600000 +vt 0.750000 0.600000 +vt 0.800000 0.600000 +vt 0.850000 0.600000 +vt 0.900000 0.600000 +vt 0.950000 0.600000 +vt 1.000000 0.600000 +vt 0.000000 0.650000 +vt 0.050000 0.650000 +vt 0.100000 0.650000 +vt 0.150000 0.650000 +vt 0.200000 0.650000 +vt 0.250000 0.650000 +vt 0.300000 0.650000 +vt 0.350000 0.650000 +vt 0.400000 0.650000 +vt 0.450000 0.650000 +vt 0.500000 0.650000 +vt 0.550000 0.650000 +vt 0.600000 0.650000 +vt 0.650000 0.650000 +vt 0.700000 0.650000 +vt 0.750000 0.650000 +vt 0.800000 0.650000 +vt 0.850000 0.650000 +vt 0.900000 0.650000 +vt 0.950000 0.650000 +vt 1.000000 0.650000 +vt 0.000000 0.700000 +vt 0.050000 0.700000 +vt 0.100000 0.700000 +vt 0.150000 0.700000 +vt 0.200000 0.700000 +vt 0.250000 0.700000 +vt 0.300000 0.700000 +vt 0.350000 0.700000 +vt 0.400000 0.700000 +vt 0.450000 0.700000 +vt 0.500000 0.700000 +vt 0.550000 0.700000 +vt 0.600000 0.700000 +vt 0.650000 0.700000 +vt 0.700000 0.700000 +vt 0.750000 0.700000 +vt 0.800000 0.700000 +vt 0.850000 0.700000 +vt 0.900000 0.700000 +vt 0.950000 0.700000 +vt 1.000000 0.700000 +vt 0.000000 0.750000 +vt 0.050000 0.750000 +vt 0.100000 0.750000 +vt 0.150000 0.750000 +vt 0.200000 0.750000 +vt 0.250000 0.750000 +vt 0.300000 0.750000 +vt 0.350000 0.750000 +vt 0.400000 0.750000 +vt 0.450000 0.750000 +vt 0.500000 0.750000 +vt 0.550000 0.750000 +vt 0.600000 0.750000 +vt 0.650000 0.750000 +vt 0.700000 0.750000 +vt 0.750000 0.750000 +vt 0.800000 0.750000 +vt 0.850000 0.750000 +vt 0.900000 0.750000 +vt 0.950000 0.750000 +vt 1.000000 0.750000 +vt 0.000000 0.800000 +vt 0.050000 0.800000 +vt 0.100000 0.800000 +vt 0.150000 0.800000 +vt 0.200000 0.800000 +vt 0.250000 0.800000 +vt 0.300000 0.800000 +vt 0.350000 0.800000 +vt 0.400000 0.800000 +vt 0.450000 0.800000 +vt 0.500000 0.800000 +vt 0.550000 0.800000 +vt 0.600000 0.800000 +vt 0.650000 0.800000 +vt 0.700000 0.800000 +vt 0.750000 0.800000 +vt 0.800000 0.800000 +vt 0.850000 0.800000 +vt 0.900000 0.800000 +vt 0.950000 0.800000 +vt 1.000000 0.800000 +vt 0.000000 0.850000 +vt 0.050000 0.850000 +vt 0.100000 0.850000 +vt 0.150000 0.850000 +vt 0.200000 0.850000 +vt 0.250000 0.850000 +vt 0.300000 0.850000 +vt 0.350000 0.850000 +vt 0.400000 0.850000 +vt 0.450000 0.850000 +vt 0.500000 0.850000 +vt 0.550000 0.850000 +vt 0.600000 0.850000 +vt 0.650000 0.850000 +vt 0.700000 0.850000 +vt 0.750000 0.850000 +vt 0.800000 0.850000 +vt 0.850000 0.850000 +vt 0.900000 0.850000 +vt 0.950000 0.850000 +vt 1.000000 0.850000 +vt 0.000000 0.900000 +vt 0.050000 0.900000 +vt 0.100000 0.900000 +vt 0.150000 0.900000 +vt 0.200000 0.900000 +vt 0.250000 0.900000 +vt 0.300000 0.900000 +vt 0.350000 0.900000 +vt 0.400000 0.900000 +vt 0.450000 0.900000 +vt 0.500000 0.900000 +vt 0.550000 0.900000 +vt 0.600000 0.900000 +vt 0.650000 0.900000 +vt 0.700000 0.900000 +vt 0.750000 0.900000 +vt 0.800000 0.900000 +vt 0.850000 0.900000 +vt 0.900000 0.900000 +vt 0.950000 0.900000 +vt 1.000000 0.900000 +vt 0.000000 0.950000 +vt 0.050000 0.950000 +vt 0.100000 0.950000 +vt 0.150000 0.950000 +vt 0.200000 0.950000 +vt 0.250000 0.950000 +vt 0.300000 0.950000 +vt 0.350000 0.950000 +vt 0.400000 0.950000 +vt 0.450000 0.950000 +vt 0.500000 0.950000 +vt 0.550000 0.950000 +vt 0.600000 0.950000 +vt 0.650000 0.950000 +vt 0.700000 0.950000 +vt 0.750000 0.950000 +vt 0.800000 0.950000 +vt 0.850000 0.950000 +vt 0.900000 0.950000 +vt 0.950000 0.950000 +vt 1.000000 0.950000 +vt 0.025000 1.000000 +vt 0.075000 1.000000 +vt 0.125000 1.000000 +vt 0.175000 1.000000 +vt 0.225000 1.000000 +vt 0.275000 1.000000 +vt 0.325000 1.000000 +vt 0.375000 1.000000 +vt 0.425000 1.000000 +vt 0.475000 1.000000 +vt 0.525000 1.000000 +vt 0.575000 1.000000 +vt 0.625000 1.000000 +vt 0.675000 1.000000 +vt 0.725000 1.000000 +vt 0.775000 1.000000 +vt 0.825000 1.000000 +vt 0.875000 1.000000 +vt 0.925000 1.000000 +vt 0.975000 1.000000 +vn 0.937763 0.166618 -0.304697 +vn 0.797708 0.166617 -0.579569 +vn 0.767071 0.317817 -0.557310 +vn 0.901746 0.317818 -0.292994 +vn 0.579569 0.166618 -0.797708 +vn 0.557310 0.317818 -0.767071 +vn 0.304697 0.166618 -0.937762 +vn 0.292995 0.317818 -0.901746 +vn 0.000000 0.166617 -0.986022 +vn 0.000000 0.317818 -0.948152 +vn -0.304698 0.166618 -0.937762 +vn -0.292995 0.317818 -0.901746 +vn -0.579569 0.166617 -0.797708 +vn -0.557310 0.317817 -0.767071 +vn -0.797708 0.166617 -0.579569 +vn -0.767071 0.317817 -0.557310 +vn -0.937762 0.166617 -0.304697 +vn -0.901746 0.317817 -0.292995 +vn -0.986022 0.166616 0.000000 +vn -0.948152 0.317817 0.000000 +vn -0.937762 0.166616 0.304698 +vn -0.901746 0.317817 0.292995 +vn -0.797708 0.166617 0.579569 +vn -0.767071 0.317817 0.557310 +vn -0.579569 0.166618 0.797708 +vn -0.557310 0.317817 0.767071 +vn -0.304697 0.166617 0.937762 +vn -0.292995 0.317818 0.901746 +vn 0.000000 0.166617 0.986022 +vn 0.000000 0.317818 0.948152 +vn 0.304697 0.166617 0.937762 +vn 0.292995 0.317818 0.901746 +vn 0.579569 0.166617 0.797708 +vn 0.557310 0.317817 0.767071 +vn 0.797708 0.166617 0.579569 +vn 0.767071 0.317817 0.557310 +vn 0.937762 0.166617 0.304697 +vn 0.901746 0.317817 0.292995 +vn 0.986021 0.166618 0.000001 +vn 0.948152 0.317818 0.000001 +vn 0.666788 0.566305 -0.484450 +vn 0.783857 0.566305 -0.254690 +vn 0.484450 0.566305 -0.666789 +vn 0.254690 0.566305 -0.783857 +vn -0.000000 0.566305 -0.824196 +vn -0.254691 0.566305 -0.783857 +vn -0.484450 0.566305 -0.666788 +vn -0.666789 0.566305 -0.484450 +vn -0.783857 0.566305 -0.254690 +vn -0.824196 0.566305 -0.000000 +vn -0.783857 0.566305 0.254691 +vn -0.666789 0.566305 0.484450 +vn -0.484450 0.566305 0.666789 +vn -0.254690 0.566305 0.783857 +vn 0.000000 0.566305 0.824196 +vn 0.254691 0.566305 0.783857 +vn 0.484450 0.566305 0.666788 +vn 0.666788 0.566305 0.484450 +vn 0.783857 0.566305 0.254691 +vn 0.824196 0.566305 0.000001 +vn 0.550781 0.732466 -0.400166 +vn 0.647483 0.732466 -0.210379 +vn 0.400166 0.732466 -0.550781 +vn 0.210380 0.732467 -0.647482 +vn -0.000000 0.732467 -0.680803 +vn -0.210380 0.732467 -0.647482 +vn -0.400166 0.732466 -0.550781 +vn -0.550781 0.732466 -0.400166 +vn -0.647482 0.732466 -0.210380 +vn -0.680803 0.732466 -0.000000 +vn -0.647482 0.732466 0.210380 +vn -0.550781 0.732466 0.400166 +vn -0.400166 0.732466 0.550781 +vn -0.210380 0.732466 0.647482 +vn 0.000000 0.732466 0.680803 +vn 0.210380 0.732466 0.647482 +vn 0.400166 0.732466 0.550781 +vn 0.550781 0.732466 0.400166 +vn 0.647482 0.732466 0.210380 +vn 0.680803 0.732466 0.000001 +vn 0.442554 0.837115 -0.321534 +vn 0.520254 0.837115 -0.169040 +vn 0.321534 0.837115 -0.442554 +vn 0.169040 0.837115 -0.520253 +vn -0.000000 0.837115 -0.547027 +vn -0.169041 0.837115 -0.520253 +vn -0.321534 0.837115 -0.442554 +vn -0.442554 0.837115 -0.321534 +vn -0.520253 0.837115 -0.169041 +vn -0.547027 0.837115 -0.000000 +vn -0.520253 0.837115 0.169041 +vn -0.442554 0.837115 0.321534 +vn -0.321534 0.837115 0.442554 +vn -0.169041 0.837115 0.520254 +vn 0.000000 0.837115 0.547027 +vn 0.169041 0.837115 0.520253 +vn 0.321534 0.837115 0.442554 +vn 0.442554 0.837115 0.321534 +vn 0.520254 0.837115 0.169041 +vn 0.547027 0.837115 0.000001 +vn 0.348169 0.902657 -0.252960 +vn 0.409298 0.902657 -0.132988 +vn 0.252960 0.902657 -0.348169 +vn 0.132989 0.902657 -0.409298 +vn -0.000000 0.902657 -0.430361 +vn -0.132989 0.902657 -0.409298 +vn -0.252960 0.902657 -0.348169 +vn -0.348169 0.902657 -0.252960 +vn -0.409297 0.902657 -0.132989 +vn -0.430361 0.902657 0.000000 +vn -0.409298 0.902657 0.132989 +vn -0.348169 0.902657 0.252960 +vn -0.252960 0.902657 0.348169 +vn -0.132989 0.902657 0.409298 +vn -0.000000 0.902657 0.430361 +vn 0.132989 0.902657 0.409298 +vn 0.252960 0.902657 0.348169 +vn 0.348169 0.902657 0.252960 +vn 0.409298 0.902657 0.132989 +vn 0.430361 0.902657 0.000000 +vn 0.266582 0.944151 -0.193683 +vn 0.313386 0.944151 -0.101825 +vn 0.193683 0.944151 -0.266582 +vn 0.101825 0.944151 -0.313386 +vn -0.000000 0.944151 -0.329513 +vn -0.101825 0.944151 -0.313386 +vn -0.193683 0.944151 -0.266582 +vn -0.266582 0.944151 -0.193683 +vn -0.313386 0.944151 -0.101825 +vn -0.329513 0.944151 0.000000 +vn -0.313386 0.944151 0.101825 +vn -0.266582 0.944151 0.193683 +vn -0.193683 0.944151 0.266582 +vn -0.101825 0.944151 0.313386 +vn 0.000000 0.944151 0.329513 +vn 0.101825 0.944151 0.313386 +vn 0.193683 0.944151 0.266582 +vn 0.266582 0.944151 0.193683 +vn 0.313386 0.944151 0.101825 +vn 0.329513 0.944151 0.000000 +vn 0.195114 0.970482 -0.141759 +vn 0.229370 0.970482 -0.074527 +vn 0.141758 0.970482 -0.195114 +vn 0.074527 0.970482 -0.229370 +vn -0.000000 0.970482 -0.241174 +vn -0.074527 0.970482 -0.229370 +vn -0.141759 0.970482 -0.195114 +vn -0.195114 0.970482 -0.141758 +vn -0.229370 0.970482 -0.074527 +vn -0.241174 0.970482 0.000000 +vn -0.229370 0.970482 0.074527 +vn -0.195114 0.970482 0.141759 +vn -0.141758 0.970482 0.195114 +vn -0.074527 0.970482 0.229370 +vn 0.000000 0.970482 0.241174 +vn 0.074527 0.970482 0.229370 +vn 0.141759 0.970482 0.195114 +vn 0.195114 0.970482 0.141759 +vn 0.229370 0.970482 0.074527 +vn 0.241174 0.970482 0.000000 +vn 0.131554 0.986691 -0.095579 +vn 0.154651 0.986691 -0.050249 +vn 0.095579 0.986691 -0.131554 +vn 0.050249 0.986691 -0.154650 +vn -0.000000 0.986691 -0.162609 +vn -0.050249 0.986691 -0.154650 +vn -0.095579 0.986691 -0.131554 +vn -0.131554 0.986691 -0.095579 +vn -0.154651 0.986691 -0.050249 +vn -0.162609 0.986691 0.000000 +vn -0.154651 0.986691 0.050249 +vn -0.131554 0.986691 0.095579 +vn -0.095579 0.986691 0.131554 +vn -0.050249 0.986691 0.154651 +vn 0.000000 0.986691 0.162609 +vn 0.050249 0.986691 0.154651 +vn 0.095579 0.986691 0.131554 +vn 0.131554 0.986691 0.095579 +vn 0.154651 0.986691 0.050249 +vn 0.162609 0.986691 0.000000 +vn 0.076711 0.995494 -0.055734 +vn 0.090179 0.995494 -0.029301 +vn 0.055734 0.995494 -0.076711 +vn 0.029301 0.995494 -0.090179 +vn -0.000000 0.995494 -0.094820 +vn -0.029301 0.995494 -0.090179 +vn -0.055734 0.995494 -0.076711 +vn -0.076711 0.995494 -0.055734 +vn -0.090179 0.995494 -0.029301 +vn -0.094820 0.995494 0.000000 +vn -0.090179 0.995494 0.029301 +vn -0.076711 0.995494 0.055734 +vn -0.055734 0.995494 0.076711 +vn -0.029301 0.995494 0.090179 +vn 0.000000 0.995494 0.094820 +vn 0.029301 0.995494 0.090179 +vn 0.055734 0.995494 0.076711 +vn 0.076711 0.995494 0.055734 +vn 0.090179 0.995494 0.029301 +vn 0.094820 0.995494 0.000000 +vn -0.000000 1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +s 1 +g pSphere1 +usemtl initialShadingGroup +f 1/1/1 2/2/2 22/23/3 21/22/4 +f 2/2/2 3/3/5 23/24/6 22/23/3 +f 3/3/5 4/4/7 24/25/8 23/24/6 +f 4/4/7 5/5/9 25/26/10 24/25/8 +f 5/5/9 6/6/11 26/27/12 25/26/10 +f 6/6/11 7/7/13 27/28/14 26/27/12 +f 7/7/13 8/8/15 28/29/16 27/28/14 +f 8/8/15 9/9/17 29/30/18 28/29/16 +f 9/9/17 10/10/19 30/31/20 29/30/18 +f 10/10/19 11/11/21 31/32/22 30/31/20 +f 11/11/21 12/12/23 32/33/24 31/32/22 +f 12/12/23 13/13/25 33/34/26 32/33/24 +f 13/13/25 14/14/27 34/35/28 33/34/26 +f 14/14/27 15/15/29 35/36/30 34/35/28 +f 15/15/29 16/16/31 36/37/32 35/36/30 +f 16/16/31 17/17/33 37/38/34 36/37/32 +f 17/17/33 18/18/35 38/39/36 37/38/34 +f 18/18/35 19/19/37 39/40/38 38/39/36 +f 19/19/37 20/20/39 40/41/40 39/40/38 +f 20/20/39 1/21/1 21/42/4 40/41/40 +f 21/22/4 22/23/3 42/44/41 41/43/42 +f 22/23/3 23/24/6 43/45/43 42/44/41 +f 23/24/6 24/25/8 44/46/44 43/45/43 +f 24/25/8 25/26/10 45/47/45 44/46/44 +f 25/26/10 26/27/12 46/48/46 45/47/45 +f 26/27/12 27/28/14 47/49/47 46/48/46 +f 27/28/14 28/29/16 48/50/48 47/49/47 +f 28/29/16 29/30/18 49/51/49 48/50/48 +f 29/30/18 30/31/20 50/52/50 49/51/49 +f 30/31/20 31/32/22 51/53/51 50/52/50 +f 31/32/22 32/33/24 52/54/52 51/53/51 +f 32/33/24 33/34/26 53/55/53 52/54/52 +f 33/34/26 34/35/28 54/56/54 53/55/53 +f 34/35/28 35/36/30 55/57/55 54/56/54 +f 35/36/30 36/37/32 56/58/56 55/57/55 +f 36/37/32 37/38/34 57/59/57 56/58/56 +f 37/38/34 38/39/36 58/60/58 57/59/57 +f 38/39/36 39/40/38 59/61/59 58/60/58 +f 39/40/38 40/41/40 60/62/60 59/61/59 +f 40/41/40 21/42/4 41/63/42 60/62/60 +f 41/43/42 42/44/41 62/65/61 61/64/62 +f 42/44/41 43/45/43 63/66/63 62/65/61 +f 43/45/43 44/46/44 64/67/64 63/66/63 +f 44/46/44 45/47/45 65/68/65 64/67/64 +f 45/47/45 46/48/46 66/69/66 65/68/65 +f 46/48/46 47/49/47 67/70/67 66/69/66 +f 47/49/47 48/50/48 68/71/68 67/70/67 +f 48/50/48 49/51/49 69/72/69 68/71/68 +f 49/51/49 50/52/50 70/73/70 69/72/69 +f 50/52/50 51/53/51 71/74/71 70/73/70 +f 51/53/51 52/54/52 72/75/72 71/74/71 +f 52/54/52 53/55/53 73/76/73 72/75/72 +f 53/55/53 54/56/54 74/77/74 73/76/73 +f 54/56/54 55/57/55 75/78/75 74/77/74 +f 55/57/55 56/58/56 76/79/76 75/78/75 +f 56/58/56 57/59/57 77/80/77 76/79/76 +f 57/59/57 58/60/58 78/81/78 77/80/77 +f 58/60/58 59/61/59 79/82/79 78/81/78 +f 59/61/59 60/62/60 80/83/80 79/82/79 +f 60/62/60 41/63/42 61/84/62 80/83/80 +f 61/64/62 62/65/61 82/86/81 81/85/82 +f 62/65/61 63/66/63 83/87/83 82/86/81 +f 63/66/63 64/67/64 84/88/84 83/87/83 +f 64/67/64 65/68/65 85/89/85 84/88/84 +f 65/68/65 66/69/66 86/90/86 85/89/85 +f 66/69/66 67/70/67 87/91/87 86/90/86 +f 67/70/67 68/71/68 88/92/88 87/91/87 +f 68/71/68 69/72/69 89/93/89 88/92/88 +f 69/72/69 70/73/70 90/94/90 89/93/89 +f 70/73/70 71/74/71 91/95/91 90/94/90 +f 71/74/71 72/75/72 92/96/92 91/95/91 +f 72/75/72 73/76/73 93/97/93 92/96/92 +f 73/76/73 74/77/74 94/98/94 93/97/93 +f 74/77/74 75/78/75 95/99/95 94/98/94 +f 75/78/75 76/79/76 96/100/96 95/99/95 +f 76/79/76 77/80/77 97/101/97 96/100/96 +f 77/80/77 78/81/78 98/102/98 97/101/97 +f 78/81/78 79/82/79 99/103/99 98/102/98 +f 79/82/79 80/83/80 100/104/100 99/103/99 +f 80/83/80 61/84/62 81/105/82 100/104/100 +f 81/85/82 82/86/81 102/107/101 101/106/102 +f 82/86/81 83/87/83 103/108/103 102/107/101 +f 83/87/83 84/88/84 104/109/104 103/108/103 +f 84/88/84 85/89/85 105/110/105 104/109/104 +f 85/89/85 86/90/86 106/111/106 105/110/105 +f 86/90/86 87/91/87 107/112/107 106/111/106 +f 87/91/87 88/92/88 108/113/108 107/112/107 +f 88/92/88 89/93/89 109/114/109 108/113/108 +f 89/93/89 90/94/90 110/115/110 109/114/109 +f 90/94/90 91/95/91 111/116/111 110/115/110 +f 91/95/91 92/96/92 112/117/112 111/116/111 +f 92/96/92 93/97/93 113/118/113 112/117/112 +f 93/97/93 94/98/94 114/119/114 113/118/113 +f 94/98/94 95/99/95 115/120/115 114/119/114 +f 95/99/95 96/100/96 116/121/116 115/120/115 +f 96/100/96 97/101/97 117/122/117 116/121/116 +f 97/101/97 98/102/98 118/123/118 117/122/117 +f 98/102/98 99/103/99 119/124/119 118/123/118 +f 99/103/99 100/104/100 120/125/120 119/124/119 +f 100/104/100 81/105/82 101/126/102 120/125/120 +f 101/106/102 102/107/101 122/128/121 121/127/122 +f 102/107/101 103/108/103 123/129/123 122/128/121 +f 103/108/103 104/109/104 124/130/124 123/129/123 +f 104/109/104 105/110/105 125/131/125 124/130/124 +f 105/110/105 106/111/106 126/132/126 125/131/125 +f 106/111/106 107/112/107 127/133/127 126/132/126 +f 107/112/107 108/113/108 128/134/128 127/133/127 +f 108/113/108 109/114/109 129/135/129 128/134/128 +f 109/114/109 110/115/110 130/136/130 129/135/129 +f 110/115/110 111/116/111 131/137/131 130/136/130 +f 111/116/111 112/117/112 132/138/132 131/137/131 +f 112/117/112 113/118/113 133/139/133 132/138/132 +f 113/118/113 114/119/114 134/140/134 133/139/133 +f 114/119/114 115/120/115 135/141/135 134/140/134 +f 115/120/115 116/121/116 136/142/136 135/141/135 +f 116/121/116 117/122/117 137/143/137 136/142/136 +f 117/122/117 118/123/118 138/144/138 137/143/137 +f 118/123/118 119/124/119 139/145/139 138/144/138 +f 119/124/119 120/125/120 140/146/140 139/145/139 +f 120/125/120 101/126/102 121/147/122 140/146/140 +f 121/127/122 122/128/121 142/149/141 141/148/142 +f 122/128/121 123/129/123 143/150/143 142/149/141 +f 123/129/123 124/130/124 144/151/144 143/150/143 +f 124/130/124 125/131/125 145/152/145 144/151/144 +f 125/131/125 126/132/126 146/153/146 145/152/145 +f 126/132/126 127/133/127 147/154/147 146/153/146 +f 127/133/127 128/134/128 148/155/148 147/154/147 +f 128/134/128 129/135/129 149/156/149 148/155/148 +f 129/135/129 130/136/130 150/157/150 149/156/149 +f 130/136/130 131/137/131 151/158/151 150/157/150 +f 131/137/131 132/138/132 152/159/152 151/158/151 +f 132/138/132 133/139/133 153/160/153 152/159/152 +f 133/139/133 134/140/134 154/161/154 153/160/153 +f 134/140/134 135/141/135 155/162/155 154/161/154 +f 135/141/135 136/142/136 156/163/156 155/162/155 +f 136/142/136 137/143/137 157/164/157 156/163/156 +f 137/143/137 138/144/138 158/165/158 157/164/157 +f 138/144/138 139/145/139 159/166/159 158/165/158 +f 139/145/139 140/146/140 160/167/160 159/166/159 +f 140/146/140 121/147/122 141/168/142 160/167/160 +f 141/148/142 142/149/141 162/170/161 161/169/162 +f 142/149/141 143/150/143 163/171/163 162/170/161 +f 143/150/143 144/151/144 164/172/164 163/171/163 +f 144/151/144 145/152/145 165/173/165 164/172/164 +f 145/152/145 146/153/146 166/174/166 165/173/165 +f 146/153/146 147/154/147 167/175/167 166/174/166 +f 147/154/147 148/155/148 168/176/168 167/175/167 +f 148/155/148 149/156/149 169/177/169 168/176/168 +f 149/156/149 150/157/150 170/178/170 169/177/169 +f 150/157/150 151/158/151 171/179/171 170/178/170 +f 151/158/151 152/159/152 172/180/172 171/179/171 +f 152/159/152 153/160/153 173/181/173 172/180/172 +f 153/160/153 154/161/154 174/182/174 173/181/173 +f 154/161/154 155/162/155 175/183/175 174/182/174 +f 155/162/155 156/163/156 176/184/176 175/183/175 +f 156/163/156 157/164/157 177/185/177 176/184/176 +f 157/164/157 158/165/158 178/186/178 177/185/177 +f 158/165/158 159/166/159 179/187/179 178/186/178 +f 159/166/159 160/167/160 180/188/180 179/187/179 +f 160/167/160 141/168/142 161/189/162 180/188/180 +f 161/169/162 162/170/161 182/191/181 181/190/182 +f 162/170/161 163/171/163 183/192/183 182/191/181 +f 163/171/163 164/172/164 184/193/184 183/192/183 +f 164/172/164 165/173/165 185/194/185 184/193/184 +f 165/173/165 166/174/166 186/195/186 185/194/185 +f 166/174/166 167/175/167 187/196/187 186/195/186 +f 167/175/167 168/176/168 188/197/188 187/196/187 +f 168/176/168 169/177/169 189/198/189 188/197/188 +f 169/177/169 170/178/170 190/199/190 189/198/189 +f 170/178/170 171/179/171 191/200/191 190/199/190 +f 171/179/171 172/180/172 192/201/192 191/200/191 +f 172/180/172 173/181/173 193/202/193 192/201/192 +f 173/181/173 174/182/174 194/203/194 193/202/193 +f 174/182/174 175/183/175 195/204/195 194/203/194 +f 175/183/175 176/184/176 196/205/196 195/204/195 +f 176/184/176 177/185/177 197/206/197 196/205/196 +f 177/185/177 178/186/178 198/207/198 197/206/197 +f 178/186/178 179/187/179 199/208/199 198/207/198 +f 179/187/179 180/188/180 200/209/200 199/208/199 +f 180/188/180 161/189/162 181/210/182 200/209/200 +f 181/190/182 182/191/181 201/211/201 +f 182/191/181 183/192/183 201/212/201 +f 183/192/183 184/193/184 201/213/201 +f 184/193/184 185/194/185 201/214/201 +f 185/194/185 186/195/186 201/215/201 +f 186/195/186 187/196/187 201/216/201 +f 187/196/187 188/197/188 201/217/201 +f 188/197/188 189/198/189 201/218/201 +f 189/198/189 190/199/190 201/219/201 +f 190/199/190 191/200/191 201/220/201 +f 191/200/191 192/201/192 201/221/201 +f 192/201/192 193/202/193 201/222/201 +f 193/202/193 194/203/194 201/223/201 +f 194/203/194 195/204/195 201/224/201 +f 195/204/195 196/205/196 201/225/201 +f 196/205/196 197/206/197 201/226/201 +f 197/206/197 198/207/198 201/227/201 +f 198/207/198 199/208/199 201/228/201 +f 199/208/199 200/209/200 201/229/201 +f 200/209/200 181/210/182 201/230/201 +s off +f 2/2/202 1/21/203 20/20/204 19/19/205 18/18/206 17/17/207 16/16/208 15/15/209 14/14/210 13/13/211 12/12/212 11/11/213 10/10/214 9/9/215 8/8/216 7/7/217 6/6/218 5/5/219 4/4/220 3/3/221 diff --git a/src/obj/cylinder.obj b/src/obj/cylinder.obj new file mode 100644 index 0000000..7bd9265 --- /dev/null +++ b/src/obj/cylinder.obj @@ -0,0 +1,212 @@ +# This file uses centimeters as units for non-parametric coordinates. + +mtllib cylinder.mtl +g default +v 0.913545 -3.000000 -0.406736 +v 0.669131 -3.000000 -0.743145 +v 0.309017 -3.000000 -0.951056 +v -0.104528 -3.000000 -0.994522 +v -0.500000 -3.000000 -0.866025 +v -0.809017 -3.000000 -0.587785 +v -0.978147 -3.000000 -0.207912 +v -0.978148 -3.000000 0.207912 +v -0.809017 -3.000000 0.587785 +v -0.500000 -3.000000 0.866025 +v -0.104529 -3.000000 0.994522 +v 0.309017 -3.000000 0.951056 +v 0.669131 -3.000000 0.743145 +v 0.913545 -3.000000 0.406737 +v 1.000000 -3.000000 0.000000 +v 0.913545 3.000000 -0.406736 +v 0.669131 3.000000 -0.743145 +v 0.309017 3.000000 -0.951056 +v -0.104528 3.000000 -0.994522 +v -0.500000 3.000000 -0.866025 +v -0.809017 3.000000 -0.587785 +v -0.978147 3.000000 -0.207912 +v -0.978148 3.000000 0.207912 +v -0.809017 3.000000 0.587785 +v -0.500000 3.000000 0.866025 +v -0.104529 3.000000 0.994522 +v 0.309017 3.000000 0.951056 +v 0.669131 3.000000 0.743145 +v 0.913545 3.000000 0.406737 +v 1.000000 3.000000 0.000000 +v 0.000000 -3.000000 0.000000 +v 0.000000 3.000000 0.000000 +vt 0.642741 0.092697 +vt 0.604552 0.040134 +vt 0.548284 0.007647 +vt 0.483667 0.000856 +vt 0.421875 0.020934 +vt 0.373591 0.064409 +vt 0.347164 0.123764 +vt 0.347164 0.188736 +vt 0.373591 0.248091 +vt 0.421875 0.291566 +vt 0.483667 0.311644 +vt 0.548284 0.304853 +vt 0.604552 0.272366 +vt 0.642741 0.219803 +vt 0.656250 0.156250 +vt 0.375000 0.312500 +vt 0.391667 0.312500 +vt 0.408333 0.312500 +vt 0.425000 0.312500 +vt 0.441667 0.312500 +vt 0.458333 0.312500 +vt 0.475000 0.312500 +vt 0.491667 0.312500 +vt 0.508333 0.312500 +vt 0.525000 0.312500 +vt 0.541667 0.312500 +vt 0.558333 0.312500 +vt 0.575000 0.312500 +vt 0.591667 0.312500 +vt 0.608333 0.312500 +vt 0.625000 0.312500 +vt 0.375000 0.688440 +vt 0.391667 0.688440 +vt 0.408333 0.688440 +vt 0.425000 0.688440 +vt 0.441667 0.688440 +vt 0.458333 0.688440 +vt 0.475000 0.688440 +vt 0.491667 0.688440 +vt 0.508333 0.688440 +vt 0.525000 0.688440 +vt 0.541667 0.688440 +vt 0.558333 0.688440 +vt 0.575000 0.688440 +vt 0.591667 0.688440 +vt 0.608333 0.688440 +vt 0.625000 0.688440 +vt 0.642741 0.780197 +vt 0.604552 0.727634 +vt 0.548284 0.695147 +vt 0.483667 0.688356 +vt 0.421875 0.708434 +vt 0.373591 0.751909 +vt 0.347164 0.811264 +vt 0.347164 0.876236 +vt 0.373591 0.935591 +vt 0.421875 0.979066 +vt 0.483667 0.999144 +vt 0.548284 0.992353 +vt 0.604552 0.959866 +vt 0.642741 0.907303 +vt 0.656250 0.843750 +vt 0.500000 0.150000 +vt 0.500000 0.837500 +vn 0.913545 0.000000 -0.406737 +vn 0.669131 0.000000 -0.743145 +vn 0.669131 0.000000 -0.743145 +vn 0.913545 0.000000 -0.406737 +vn 0.309017 0.000000 -0.951056 +vn 0.309017 0.000000 -0.951056 +vn -0.104528 0.000000 -0.994522 +vn -0.104528 0.000000 -0.994522 +vn -0.500000 0.000000 -0.866026 +vn -0.500000 0.000000 -0.866026 +vn -0.809017 0.000000 -0.587785 +vn -0.809017 0.000000 -0.587785 +vn -0.978148 0.000000 -0.207912 +vn -0.978148 0.000000 -0.207912 +vn -0.978148 0.000000 0.207912 +vn -0.978148 0.000000 0.207912 +vn -0.809017 0.000000 0.587785 +vn -0.809017 0.000000 0.587785 +vn -0.500000 0.000000 0.866025 +vn -0.500000 0.000000 0.866025 +vn -0.104529 0.000000 0.994522 +vn -0.104529 0.000000 0.994522 +vn 0.309017 0.000000 0.951057 +vn 0.309017 0.000000 0.951057 +vn 0.669131 0.000000 0.743145 +vn 0.669131 0.000000 0.743145 +vn 0.913545 0.000000 0.406737 +vn 0.913545 0.000000 0.406737 +vn 1.000000 0.000000 -0.000000 +vn 1.000000 0.000000 -0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +s 1 +g pCylinder1 +usemtl initialShadingGroup +f 1/16/1 2/17/2 17/33/3 16/32/4 +f 2/17/2 3/18/5 18/34/6 17/33/3 +f 3/18/5 4/19/7 19/35/8 18/34/6 +f 4/19/7 5/20/9 20/36/10 19/35/8 +f 5/20/9 6/21/11 21/37/12 20/36/10 +f 6/21/11 7/22/13 22/38/14 21/37/12 +f 7/22/13 8/23/15 23/39/16 22/38/14 +f 8/23/15 9/24/17 24/40/18 23/39/16 +f 9/24/17 10/25/19 25/41/20 24/40/18 +f 10/25/19 11/26/21 26/42/22 25/41/20 +f 11/26/21 12/27/23 27/43/24 26/42/22 +f 12/27/23 13/28/25 28/44/26 27/43/24 +f 13/28/25 14/29/27 29/45/28 28/44/26 +f 14/29/27 15/30/29 30/46/30 29/45/28 +f 15/30/29 1/31/1 16/47/4 30/46/30 +s 2 +f 2/2/31 1/1/32 31/63/33 +f 3/3/34 2/2/31 31/63/33 +f 4/4/35 3/3/34 31/63/33 +f 5/5/36 4/4/35 31/63/33 +f 6/6/37 5/5/36 31/63/33 +f 7/7/38 6/6/37 31/63/33 +f 8/8/39 7/7/38 31/63/33 +f 9/9/40 8/8/39 31/63/33 +f 10/10/41 9/9/40 31/63/33 +f 11/11/42 10/10/41 31/63/33 +f 12/12/43 11/11/42 31/63/33 +f 13/13/44 12/12/43 31/63/33 +f 14/14/45 13/13/44 31/63/33 +f 15/15/46 14/14/45 31/63/33 +f 1/1/32 15/15/46 31/63/33 +s 3 +f 16/61/47 17/60/48 32/64/49 +f 17/60/48 18/59/50 32/64/49 +f 18/59/50 19/58/51 32/64/49 +f 19/58/51 20/57/52 32/64/49 +f 20/57/52 21/56/53 32/64/49 +f 21/56/53 22/55/54 32/64/49 +f 22/55/54 23/54/55 32/64/49 +f 23/54/55 24/53/56 32/64/49 +f 24/53/56 25/52/57 32/64/49 +f 25/52/57 26/51/58 32/64/49 +f 26/51/58 27/50/59 32/64/49 +f 27/50/59 28/49/60 32/64/49 +f 28/49/60 29/48/61 32/64/49 +f 29/48/61 30/62/62 32/64/49 +f 30/62/62 16/61/47 32/64/49 diff --git a/src/obj/flower.obj b/src/obj/flower.obj new file mode 100644 index 0000000..ce02fd9 --- /dev/null +++ b/src/obj/flower.obj @@ -0,0 +1,1065 @@ +# This file uses centimeters as units for non-parametric coordinates. + +mtllib flower.mtl +g default +v 0.927766 0.027819 -0.072526 +v 1.070136 -0.396469 0.152248 +v 1.364120 -0.097838 0.090874 +v 0.889233 -0.229350 0.121032 +v 1.353313 -0.408708 0.143660 +v 1.187676 0.073809 0.058727 +v 1.126887 -0.192285 -0.076299 +v 1.045803 0.098335 -0.054345 +v 0.841141 -0.109561 -0.011619 +v 0.985510 -0.222099 -0.006719 +v 1.162752 -0.042056 -0.043721 +v 1.027209 -0.083091 -0.079114 +v 0.946488 -0.327706 0.141227 +v 1.248742 -0.417382 0.045205 +v 1.226918 -0.296005 -0.041179 +v 1.091622 -0.322694 0.012096 +v 1.373370 -0.290785 0.019187 +v 1.308219 0.003735 0.070168 +v 1.268865 -0.142651 -0.024906 +v 0.961694 0.093447 -0.080669 +v 0.526228 -0.063055 0.110877 +v 0.853356 -0.331903 0.119918 +v 0.680420 0.128468 0.076632 +v 0.538534 -0.345263 0.135788 +v 1.012508 -0.144457 0.085810 +v 0.760895 -0.125126 -0.084632 +v 1.038939 -0.014457 -0.040350 +v 0.811204 0.172705 -0.046644 +v 0.711210 0.019625 -0.036713 +v 0.908434 -0.142463 -0.031262 +v 0.861013 -0.016333 -0.087397 +v 0.585388 0.064626 0.092545 +v 0.533413 -0.253716 0.024897 +v 0.662257 -0.230118 -0.049354 +v 0.618164 -0.092909 -0.016416 +v 0.672091 -0.367688 0.028729 +v 0.951743 -0.269147 0.104028 +v 0.815388 -0.254996 -0.010966 +v 0.979588 0.054033 -0.075779 +v 0.633396 0.391676 0.054452 +v 0.528859 -0.017888 0.080954 +v 0.874643 0.333213 0.051227 +v 0.382004 0.260613 0.060609 +v 0.768521 -0.082563 0.078130 +v 0.698577 0.140049 -0.117536 +v 0.910692 -0.059149 -0.034804 +v 0.983466 0.225976 -0.053254 +v 0.802415 0.250566 -0.065369 +v 0.739390 0.003641 -0.049391 +v 0.839049 0.096746 -0.101429 +v 0.775282 0.392262 0.051891 +v 0.474550 0.296892 -0.043425 +v 0.558520 0.185955 -0.100982 +v 0.659611 0.287131 -0.063573 +v 0.430234 0.123267 -0.032190 +v 0.628659 -0.080422 0.080610 +v 0.596586 0.040206 -0.047595 +v 0.986378 0.067517 -0.049622 +v 1.221334 0.502892 0.028205 +v 0.798549 0.508823 0.003892 +v 1.218630 0.258468 0.071549 +v 1.037539 0.702039 -0.025787 +v 0.789433 0.264490 0.046866 +v 1.012161 0.348008 -0.143266 +v 0.856759 0.113565 -0.031897 +v 1.151087 0.109435 -0.014971 +v 1.136134 0.285503 -0.063009 +v 0.881238 0.289079 -0.077667 +v 0.999531 0.206829 -0.101125 +v 1.253676 0.367431 0.055463 +v 1.105698 0.613001 -0.107071 +v 1.023609 0.495541 -0.153283 +v 1.139644 0.430637 -0.088640 +v 0.926468 0.615516 -0.117378 +v 0.760189 0.398663 0.020142 +v 0.884748 0.434213 -0.103299 +v 0.998877 0.027817 -0.072526 +v 1.466170 0.105613 0.089948 +v 1.221666 0.444993 0.023518 +v 1.266036 -0.041068 0.097669 +v 1.529278 0.378554 0.045974 +v 1.017824 0.303458 0.030232 +v 1.249817 0.178357 -0.122289 +v 0.954060 0.158633 -0.061827 +v 1.124275 -0.077631 -0.015581 +v 1.261252 0.041531 -0.039431 +v 1.113842 0.246142 -0.079482 +v 1.124593 0.102336 -0.102122 +v 1.374970 -0.002561 0.100882 +v 1.506543 0.265038 -0.039472 +v 1.373675 0.259021 -0.110048 +v 1.381211 0.127116 -0.043718 +v 1.402891 0.408910 -0.067634 +v 1.109782 0.408387 0.019957 +v 1.233801 0.331727 -0.083768 +v 1.159282 -0.044578 -0.034688 +v 1.183239 0.069994 0.066783 +v 1.044317 0.097169 -0.045162 +v 1.027874 -0.082020 -0.069194 +v 0.929157 0.028480 -0.062645 +v 0.843938 -0.106381 -0.003148 +v 0.894218 -0.223574 0.127412 +v 0.989565 -0.217021 0.000882 +v 1.126966 -0.190441 -0.066471 +v 0.951299 -0.320826 0.146454 +v 1.094685 -0.316205 0.019062 +v 1.073992 -0.388561 0.157002 +v 1.249511 -0.410748 0.051640 +v 1.350357 -0.403951 0.151897 +v 1.224938 -0.292050 -0.032210 +v 1.368123 -0.290052 0.026725 +v 1.263880 -0.144123 -0.016363 +v 1.357219 -0.100528 0.097593 +v 1.302514 0.000071 0.077340 +v 0.904545 -0.138261 -0.023064 +v 1.007381 -0.139534 0.092782 +v 1.036536 -0.012070 -0.031607 +v 0.860910 -0.015776 -0.077413 +v 0.961249 0.093242 -0.070681 +v 0.813540 0.171195 -0.037591 +v 0.685760 0.124810 0.084183 +v 0.715633 0.016956 -0.028151 +v 0.761520 -0.123925 -0.074724 +v 0.591949 0.061117 0.099061 +v 0.623979 -0.094531 -0.008444 +v 0.533784 -0.065574 0.116924 +v 0.539247 -0.253115 0.032081 +v 0.541984 -0.340957 0.144081 +v 0.664904 -0.226773 -0.040310 +v 0.671457 -0.361583 0.035600 +v 0.812473 -0.249250 -0.003319 +v 0.849303 -0.324584 0.125394 +v 0.946769 -0.263053 0.109989 +v 0.740610 0.009529 -0.041402 +v 0.770004 -0.075335 0.084816 +v 0.910847 -0.055342 -0.026238 +v 0.838393 0.097784 -0.091504 +v 0.978102 0.055049 -0.065942 +v 0.982085 0.223862 -0.044126 +v 0.872768 0.327364 0.059050 +v 0.800929 0.246040 -0.056577 +v 0.698816 0.140704 -0.107560 +v 0.774171 0.385307 0.058835 +v 0.659720 0.281764 -0.055136 +v 0.633649 0.384221 0.061112 +v 0.476755 0.292411 -0.035610 +v 0.386410 0.259953 0.069518 +v 0.561638 0.185655 -0.091485 +v 0.434690 0.126955 -0.025019 +v 0.599668 0.045847 -0.039935 +v 0.533117 -0.010698 0.086446 +v 0.631372 -0.072899 0.086394 +v 0.886282 0.290832 -0.069212 +v 0.795983 0.266071 0.054197 +v 0.859484 0.115939 -0.023247 +v 0.999237 0.209564 -0.091511 +v 0.985889 0.071021 -0.040269 +v 1.147674 0.111952 -0.006503 +v 1.211643 0.260312 0.078382 +v 1.130401 0.287477 -0.055056 +v 1.011690 0.349809 -0.133441 +v 1.245890 0.368116 0.061523 +v 1.133506 0.430807 -0.080748 +v 1.213399 0.502104 0.034240 +v 1.101014 0.611237 -0.099299 +v 1.036857 0.699260 -0.016234 +v 1.022915 0.494227 -0.143394 +v 0.930136 0.613460 -0.109208 +v 0.889992 0.434058 -0.094785 +v 0.805817 0.507528 0.010638 +v 0.767403 0.398975 0.026871 +v 1.116755 0.243162 -0.070392 +v 1.021702 0.299183 0.038344 +v 0.956035 0.157870 -0.052694 +v 1.124872 0.104184 -0.092298 +v 0.999685 0.030289 -0.062870 +v 1.122715 -0.073433 -0.007236 +v 1.262094 -0.034434 0.103943 +v 1.257967 0.047243 -0.031909 +v 1.249222 0.179777 -0.112408 +v 1.369779 0.004007 0.106148 +v 1.376290 0.132074 -0.036562 +v 1.459744 0.111404 0.094964 +v 1.500993 0.267735 -0.032548 +v 1.525090 0.377428 0.054941 +v 1.370539 0.258762 -0.100556 +v 1.402122 0.404688 -0.059481 +v 1.235351 0.327426 -0.074874 +v 1.223830 0.438402 0.030721 +v 1.113171 0.402816 0.027366 +vt 0.066987 0.250000 +vt 0.933013 0.250000 +vt 0.500000 1.000000 +vt 0.500000 0.000000 +vt 0.933013 0.750000 +vt 0.066987 0.750000 +vt 0.500000 0.500000 +vt 0.000000 0.500000 +vt 0.250000 0.066987 +vt 0.500000 0.250000 +vt 0.283494 0.625000 +vt 0.283494 0.375000 +vt 0.750000 0.066987 +vt 1.000000 0.500000 +vt 0.716506 0.625000 +vt 0.716506 0.375000 +vt 0.750000 0.933013 +vt 0.250000 0.933013 +vt 0.500000 0.750000 +vt 0.283494 0.625000 +vt 0.066987 0.750000 +vt 0.000000 0.500000 +vt 0.283494 0.375000 +vt 0.066987 0.250000 +vt 0.250000 0.066987 +vt 0.500000 0.000000 +vt 0.500000 0.250000 +vt 0.500000 0.500000 +vt 0.750000 0.066987 +vt 0.716506 0.375000 +vt 0.933013 0.250000 +vt 1.000000 0.500000 +vt 0.933013 0.750000 +vt 0.716506 0.625000 +vt 0.750000 0.933013 +vt 0.500000 0.750000 +vt 0.500000 1.000000 +vt 0.250000 0.933013 +vt 0.283494 0.625000 +vt 0.066987 0.750000 +vt 0.000000 0.500000 +vt 0.283494 0.375000 +vt 0.066987 0.250000 +vt 0.250000 0.066987 +vt 0.500000 0.000000 +vt 0.500000 0.250000 +vt 0.500000 0.500000 +vt 0.750000 0.066987 +vt 0.716506 0.375000 +vt 0.933013 0.250000 +vt 1.000000 0.500000 +vt 0.933013 0.750000 +vt 0.716506 0.625000 +vt 0.750000 0.933013 +vt 0.500000 0.750000 +vt 0.500000 1.000000 +vt 0.250000 0.933013 +vt 0.283494 0.625000 +vt 0.066987 0.750000 +vt 0.000000 0.500000 +vt 0.283494 0.375000 +vt 0.066987 0.250000 +vt 0.250000 0.066987 +vt 0.500000 0.000000 +vt 0.500000 0.250000 +vt 0.500000 0.500000 +vt 0.750000 0.066987 +vt 0.716506 0.375000 +vt 0.933013 0.250000 +vt 1.000000 0.500000 +vt 0.933013 0.750000 +vt 0.716506 0.625000 +vt 0.750000 0.933013 +vt 0.500000 0.750000 +vt 0.500000 1.000000 +vt 0.250000 0.933013 +vt 0.283494 0.625000 +vt 0.066987 0.750000 +vt 0.000000 0.500000 +vt 0.283494 0.375000 +vt 0.066987 0.250000 +vt 0.250000 0.066987 +vt 0.500000 0.000000 +vt 0.500000 0.250000 +vt 0.500000 0.500000 +vt 0.750000 0.066987 +vt 0.716506 0.375000 +vt 0.933013 0.250000 +vt 1.000000 0.500000 +vt 0.933013 0.750000 +vt 0.716506 0.625000 +vt 0.750000 0.933013 +vt 0.500000 0.750000 +vt 0.500000 1.000000 +vt 0.250000 0.933013 +vt 0.283494 0.625000 +vt 0.066987 0.750000 +vt 0.000000 0.500000 +vt 0.283494 0.375000 +vt 0.066987 0.250000 +vt 0.250000 0.066987 +vt 0.500000 0.000000 +vt 0.500000 0.250000 +vt 0.500000 0.500000 +vt 0.750000 0.066987 +vt 0.716506 0.375000 +vt 0.933013 0.250000 +vt 1.000000 0.500000 +vt 0.933013 0.750000 +vt 0.716506 0.625000 +vt 0.750000 0.933013 +vt 0.500000 0.750000 +vt 0.500000 1.000000 +vt 0.250000 0.933013 +vt 0.283494 0.625000 +vt 0.066987 0.750000 +vt 0.000000 0.500000 +vt 0.283494 0.375000 +vt 0.066987 0.250000 +vt 0.250000 0.066987 +vt 0.500000 0.000000 +vt 0.500000 0.250000 +vt 0.500000 0.500000 +vt 0.750000 0.066987 +vt 0.716506 0.375000 +vt 0.933013 0.250000 +vt 1.000000 0.500000 +vt 0.933013 0.750000 +vt 0.716506 0.625000 +vt 0.750000 0.933013 +vt 0.500000 0.750000 +vt 0.500000 1.000000 +vt 0.250000 0.933013 +vt 0.283494 0.625000 +vt 0.066987 0.750000 +vt 0.000000 0.500000 +vt 0.283494 0.375000 +vt 0.066987 0.250000 +vt 0.250000 0.066987 +vt 0.500000 0.000000 +vt 0.500000 0.250000 +vt 0.500000 0.500000 +vt 0.750000 0.066987 +vt 0.716506 0.375000 +vt 0.933013 0.250000 +vt 1.000000 0.500000 +vt 0.933013 0.750000 +vt 0.716506 0.625000 +vt 0.750000 0.933013 +vt 0.500000 0.750000 +vt 0.500000 1.000000 +vt 0.250000 0.933013 +vt 0.283494 0.625000 +vt 0.066987 0.750000 +vt 0.000000 0.500000 +vt 0.283494 0.375000 +vt 0.066987 0.250000 +vt 0.250000 0.066987 +vt 0.500000 0.000000 +vt 0.500000 0.250000 +vt 0.500000 0.500000 +vt 0.750000 0.066987 +vt 0.716506 0.375000 +vt 0.933013 0.250000 +vt 1.000000 0.500000 +vt 0.933013 0.750000 +vt 0.716506 0.625000 +vt 0.750000 0.933013 +vt 0.500000 0.750000 +vt 0.500000 1.000000 +vt 0.250000 0.933013 +vt 0.283494 0.625000 +vt 0.066987 0.750000 +vt 0.000000 0.500000 +vt 0.283494 0.375000 +vt 0.066987 0.250000 +vt 0.250000 0.066987 +vt 0.500000 0.000000 +vt 0.500000 0.250000 +vt 0.500000 0.500000 +vt 0.750000 0.066987 +vt 0.716506 0.375000 +vt 0.933013 0.250000 +vt 1.000000 0.500000 +vt 0.933013 0.750000 +vt 0.716506 0.625000 +vt 0.750000 0.933013 +vt 0.500000 0.750000 +vt 0.500000 1.000000 +vt 0.250000 0.933013 +vt 0.066987 0.750000 +vt 0.000000 0.500000 +vt 0.066987 0.250000 +vt 0.250000 0.066987 +vt 0.500000 0.000000 +vt 0.750000 0.066987 +vt 0.933013 0.250000 +vt 1.000000 0.500000 +vt 0.933013 0.750000 +vt 0.750000 0.933013 +vt 0.500000 1.000000 +vt 0.250000 0.933013 +vt 0.066987 0.750000 +vt 0.000000 0.500000 +vt 0.066987 0.250000 +vt 0.250000 0.066987 +vt 0.500000 0.000000 +vt 0.750000 0.066987 +vt 0.933013 0.250000 +vt 1.000000 0.500000 +vt 0.933013 0.750000 +vt 0.750000 0.933013 +vt 0.500000 1.000000 +vt 0.250000 0.933013 +vt 0.066987 0.750000 +vt 0.000000 0.500000 +vt 0.066987 0.250000 +vt 0.250000 0.066987 +vt 0.500000 0.000000 +vt 0.750000 0.066987 +vt 0.933013 0.250000 +vt 1.000000 0.500000 +vt 0.933013 0.750000 +vt 0.750000 0.933013 +vt 0.500000 1.000000 +vt 0.250000 0.933013 +vt 0.066987 0.750000 +vt 0.000000 0.500000 +vt 0.066987 0.250000 +vt 0.250000 0.066987 +vt 0.500000 0.000000 +vt 0.750000 0.066987 +vt 0.933013 0.250000 +vt 1.000000 0.500000 +vt 0.933013 0.750000 +vt 0.750000 0.933013 +vt 0.500000 1.000000 +vt 0.250000 0.933013 +vt 0.066987 0.750000 +vt 0.000000 0.500000 +vt 0.066987 0.250000 +vt 0.250000 0.066987 +vt 0.500000 0.000000 +vt 0.750000 0.066987 +vt 0.933013 0.250000 +vt 1.000000 0.500000 +vt 0.933013 0.750000 +vt 0.750000 0.933013 +vt 0.500000 1.000000 +vt 0.250000 0.933013 +vn -0.365217 -0.269745 0.890985 +vn -0.450299 -0.390132 0.803136 +vn -0.255010 -0.181410 0.949769 +vn 0.064809 0.118869 0.990793 +vn 0.139775 0.066324 0.987960 +vn 0.351817 0.445105 0.823473 +vn 0.504424 0.584428 0.635611 +vn 0.415569 0.522526 0.744492 +vn 0.004924 0.185340 0.982662 +vn 0.512344 0.668862 0.538636 +vn 0.328746 0.662761 0.672811 +vn 0.388798 0.790614 0.473038 +vn -0.033869 0.658874 0.751491 +vn -0.308930 0.465144 0.829580 +vn -0.205101 0.391963 0.896827 +vn -0.468894 0.257169 0.844986 +vn -0.505717 -0.152921 0.849038 +vn -0.690400 -0.273008 0.669937 +vn -0.545697 -0.399299 0.736733 +vn -0.406244 0.435100 0.803526 +vn -0.521545 0.497792 0.692960 +vn -0.317005 0.341210 0.884920 +vn 0.001319 0.058451 0.998289 +vn -0.044118 -0.021073 0.998804 +vn 0.368174 -0.212715 0.905097 +vn 0.541608 -0.371277 0.754198 +vn 0.459696 -0.277159 0.843720 +vn 0.063117 0.123174 0.990376 +vn 0.637667 -0.381845 0.669011 +vn 0.600024 -0.185809 0.778104 +vn 0.755942 -0.255276 0.602815 +vn 0.556616 0.181267 0.810754 +vn 0.332744 0.443386 0.832280 +vn 0.260679 0.341184 0.903128 +vn 0.111971 0.583272 0.804523 +vn -0.297146 0.580613 0.758019 +vn -0.409166 0.731609 0.545281 +vn -0.530331 0.583813 0.614745 +vn 0.129939 0.609773 0.781852 +vn 0.149927 0.732720 0.663809 +vn 0.074132 0.494748 0.865869 +vn -0.058280 0.094461 0.993821 +vn -0.149065 0.101053 0.983650 +vn -0.136700 -0.359047 0.923254 +vn -0.189163 -0.594085 0.781844 +vn -0.149126 -0.473493 0.868081 +vn 0.026934 0.066246 0.997440 +vn -0.148558 -0.691049 0.707377 +vn -0.000332 -0.564920 0.825146 +vn 0.022655 -0.747487 0.663890 +vn 0.307818 -0.365208 0.878562 +vn 0.446537 -0.049257 0.893409 +vn 0.316251 -0.023537 0.948384 +vn 0.482129 0.207696 0.851125 +vn 0.312004 0.571221 0.759184 +vn 0.424199 0.722105 0.546460 +vn 0.232308 0.772216 0.591367 +vn 0.528363 0.169602 0.831906 +vn 0.665541 0.158035 0.729438 +vn 0.394864 0.210798 0.894230 +vn -0.036906 0.264525 0.963672 +vn -0.049484 0.350663 0.935194 +vn -0.485166 0.216813 0.847116 +vn -0.707930 0.183702 0.681974 +vn -0.592314 0.190771 0.782797 +vn -0.045731 0.177292 0.983095 +vn -0.784168 0.107798 0.611114 +vn -0.642768 0.018574 0.765835 +vn -0.795819 -0.076919 0.600629 +vn -0.385397 -0.222291 0.895576 +vn -0.054085 -0.278689 0.958857 +vn -0.063162 -0.132466 0.989173 +vn 0.207006 -0.255976 0.944259 +vn 0.534212 -0.017907 0.845161 +vn 0.729808 -0.127598 0.671639 +vn 0.730491 0.075562 0.678729 +vn 0.303602 -0.320486 0.897282 +vn 0.394707 -0.435914 0.808818 +vn 0.244876 -0.189755 0.950804 +vn 0.015920 0.185353 0.982543 +vn 0.080650 0.247854 0.965435 +vn -0.269618 0.512799 0.815072 +vn -0.400111 0.670333 0.624951 +vn -0.342938 0.582341 0.737070 +vn -0.060939 0.139210 0.988386 +vn -0.492742 0.685004 0.536633 +vn -0.504402 0.518100 0.690761 +vn -0.642214 0.581916 0.498934 +vn -0.557944 0.171492 0.811966 +vn -0.410245 -0.127127 0.903071 +vn -0.311585 -0.033550 0.949626 +vn -0.235019 -0.322533 0.916918 +vn 0.158675 -0.438725 0.884502 +vn 0.220079 -0.660336 0.717998 +vn 0.378023 -0.537385 0.753867 +vn 0.361471 0.266932 -0.893357 +vn -0.067880 -0.116041 -0.990922 +vn 0.252485 0.183873 -0.949970 +vn 0.446205 0.390017 -0.805474 +vn -0.353379 -0.441651 -0.824662 +vn -0.139152 -0.066077 -0.988064 +vn -0.413509 -0.519068 -0.748050 +vn -0.505140 -0.581120 -0.638070 +vn -0.004255 -0.185592 -0.982618 +vn -0.323985 -0.661463 -0.676388 +vn -0.509802 -0.669870 -0.539793 +vn 0.032237 -0.661241 -0.749481 +vn -0.385632 -0.790764 -0.475374 +vn 0.205002 -0.391226 -0.897171 +vn 0.310057 -0.464863 -0.829317 +vn 0.504374 0.147917 -0.850721 +vn 0.473335 -0.253199 -0.843709 +vn 0.546653 0.396084 -0.737759 +vn 0.690108 0.268959 -0.671872 +vn 0.403445 -0.431932 -0.806639 +vn 0.001241 -0.055156 -0.998477 +vn 0.319257 -0.338498 -0.885152 +vn 0.521381 -0.494016 -0.695780 +vn -0.364742 0.214459 -0.906074 +vn 0.044426 0.020469 -0.998803 +vn -0.455669 0.275055 -0.846588 +vn -0.538094 0.372029 -0.756339 +vn -0.063316 -0.123856 -0.990278 +vn -0.597909 0.180824 -0.780902 +vn -0.638313 0.379104 -0.669953 +vn -0.559337 -0.179657 -0.809237 +vn -0.755542 0.251868 -0.604747 +vn -0.259916 -0.341054 -0.903397 +vn -0.332406 -0.444444 -0.831851 +vn 0.292293 -0.579957 -0.760404 +vn -0.107835 -0.587137 -0.802273 +vn 0.527356 -0.585183 -0.616000 +vn 0.405376 -0.731928 -0.547678 +vn -0.127926 -0.606109 -0.785026 +vn 0.062346 -0.095355 -0.993489 +vn -0.070715 -0.495620 -0.865656 +vn -0.146286 -0.731142 -0.666357 +vn 0.139829 0.356643 -0.923717 +vn 0.148653 -0.101591 -0.983657 +vn 0.149257 0.468762 -0.870623 +vn 0.191563 0.591098 -0.783522 +vn -0.027643 -0.066354 -0.997413 +vn -0.002945 0.560670 -0.828034 +vn 0.145925 0.690380 -0.708577 +vn -0.307690 0.368458 -0.877249 +vn -0.025336 0.745521 -0.666001 +vn -0.315781 0.022889 -0.948556 +vn -0.447392 0.048526 -0.893020 +vn -0.313198 -0.566741 -0.762044 +vn -0.484109 -0.212924 -0.848706 +vn -0.234658 -0.770221 -0.593040 +vn -0.425821 -0.719003 -0.549282 +vn -0.524001 -0.171221 -0.834330 +vn 0.036904 -0.268551 -0.962558 +vn -0.394976 -0.214222 -0.893366 +vn -0.662907 -0.161590 -0.731057 +vn 0.483587 -0.220458 -0.847078 +vn 0.048873 -0.350400 -0.935324 +vn 0.588058 -0.192496 -0.785578 +vn 0.705766 -0.187009 -0.683317 +vn 0.045473 -0.176606 -0.983231 +vn 0.638280 -0.016951 -0.769618 +vn 0.783055 -0.105601 -0.612922 +vn 0.388461 0.223282 -0.894004 +vn 0.793499 0.078749 -0.603455 +vn 0.062620 0.131798 -0.989297 +vn 0.053075 0.279370 -0.958715 +vn -0.529841 0.019622 -0.847870 +vn -0.212866 0.257099 -0.942649 +vn -0.728860 -0.073095 -0.680749 +vn -0.726768 0.129484 -0.674569 +vn -0.301837 0.316043 -0.899450 +vn -0.019261 -0.187805 -0.982018 +vn -0.247769 0.187757 -0.950451 +vn -0.395633 0.431665 -0.810642 +vn 0.265818 -0.513762 -0.815714 +vn -0.080789 -0.247208 -0.965589 +vn 0.339514 -0.580006 -0.740489 +vn 0.396456 -0.670626 -0.626963 +vn 0.061313 -0.138602 -0.988448 +vn 0.503582 -0.513557 -0.694740 +vn 0.494055 -0.682838 -0.538184 +vn 0.560195 -0.173348 -0.810020 +vn 0.642662 -0.579089 -0.501639 +vn 0.310806 0.033564 -0.949881 +vn 0.410211 0.128308 -0.902920 +vn -0.154246 0.436263 -0.886500 +vn 0.232120 0.327773 -0.915798 +vn -0.374835 0.537583 -0.755316 +vn -0.216418 0.659063 -0.720277 +vn -0.035823 0.963299 0.266031 +vn -0.035822 0.963299 0.266031 +vn -0.035823 0.963299 0.266031 +vn -0.035822 0.963299 0.266031 +vn -0.514728 0.857117 0.020156 +vn -0.710612 0.701699 0.051464 +vn -0.704728 0.707681 0.050459 +vn -0.514728 0.857117 0.020156 +vn -0.828509 0.555210 0.072905 +vn -0.828509 0.555210 0.072905 +vn -0.903500 0.090293 0.418968 +vn -0.903500 0.090293 0.418968 +vn -0.903500 0.090293 0.418968 +vn -0.903500 0.090293 0.418968 +vn -0.620944 -0.211550 0.754769 +vn -0.443332 -0.330687 0.833129 +vn -0.457436 -0.322357 0.828757 +vn -0.620944 -0.211550 0.754769 +vn -0.300613 -0.406173 0.862934 +vn -0.300613 -0.406173 0.862934 +vn 0.336894 -0.639139 0.691378 +vn 0.336894 -0.639139 0.691378 +vn 0.336894 -0.639139 0.691378 +vn 0.336894 -0.639139 0.691378 +vn -0.437434 -0.740734 0.509867 +vn -0.437434 -0.740734 0.509867 +vn -0.437434 -0.740734 0.509867 +vn -0.437434 -0.740734 0.509867 +vn 0.891117 0.257201 0.373844 +vn 0.891117 0.257201 0.373844 +vn 0.891117 0.257201 0.373844 +vn 0.891117 0.257201 0.373844 +vn 0.759887 -0.191490 0.621212 +vn 0.759887 -0.191490 0.621212 +vn 0.759887 -0.191490 0.621212 +vn 0.759887 -0.191490 0.621212 +vn 0.552388 0.445009 0.704866 +vn 0.460585 0.596793 0.657039 +vn 0.455530 0.603933 0.654032 +vn 0.552388 0.445009 0.704865 +vn 0.363987 0.716942 0.594566 +vn 0.363987 0.716942 0.594566 +vn 0.917107 0.158115 0.365943 +vn 0.917107 0.158115 0.365943 +vn 0.917107 0.158115 0.365943 +vn 0.917107 0.158115 0.365943 +vn 0.802765 0.593953 0.052811 +vn 0.629058 0.776211 0.042222 +vn 0.635582 0.770856 0.042623 +vn 0.802765 0.593953 0.052811 +vn 0.471824 0.881094 0.032475 +vn 0.471824 0.881094 0.032475 +vn -0.036638 0.949248 0.312387 +vn -0.036638 0.949248 0.312387 +vn -0.036638 0.949248 0.312387 +vn -0.036638 0.949248 0.312387 +vn -0.353064 0.678350 0.644350 +vn -0.465860 0.499996 0.730054 +vn -0.458249 0.514256 0.724947 +vn -0.353064 0.678350 0.644350 +vn -0.532406 0.354912 0.768493 +vn -0.532406 0.354912 0.768493 +vn -0.689173 -0.317283 0.651438 +vn -0.689173 -0.317283 0.651438 +vn -0.689173 -0.317283 0.651438 +vn -0.689173 -0.317283 0.651438 +vn -0.831249 0.418384 0.366033 +vn -0.831249 0.418384 0.366033 +vn -0.831249 0.418384 0.366033 +vn -0.831249 0.418384 0.366033 +vn 0.282012 -0.814595 0.506857 +vn 0.282012 -0.814595 0.506857 +vn 0.282012 -0.814595 0.506857 +vn 0.282012 -0.814596 0.506857 +vn -0.202949 -0.700342 0.684348 +vn -0.202949 -0.700342 0.684348 +vn -0.202949 -0.700342 0.684348 +vn -0.202949 -0.700342 0.684348 +vn 0.399182 -0.424393 0.812739 +vn 0.547596 -0.324328 0.771330 +vn 0.554607 -0.318979 0.768546 +vn 0.399182 -0.424393 0.812739 +vn 0.666122 -0.224214 0.711344 +vn 0.666122 -0.224214 0.711344 +vn 0.489009 -0.730793 0.476247 +vn 0.489009 -0.730793 0.476247 +vn 0.489009 -0.730793 0.476247 +vn 0.489009 -0.730793 0.476247 +vn 0.867606 -0.462014 0.183853 +vn 0.959287 -0.227901 0.166823 +vn 0.957183 -0.236053 0.167572 +vn 0.867606 -0.462014 0.183853 +vn 0.988246 -0.041928 0.147008 +vn 0.988246 -0.041928 0.147008 +vn 0.803391 0.464522 0.372534 +vn 0.803391 0.464522 0.372534 +vn 0.803391 0.464522 0.372534 +vn 0.803391 0.464522 0.372534 +vn 0.388956 0.655658 0.647167 +vn 0.171306 0.686204 0.706950 +vn 0.187920 0.685151 0.703744 +vn 0.388956 0.655658 0.647167 +vn 0.008403 0.686172 0.727391 +vn 0.008403 0.686172 0.727391 +vn -0.649354 0.528909 0.546438 +vn -0.649354 0.528909 0.546438 +vn -0.649354 0.528909 0.546438 +vn -0.649354 0.528909 0.546438 +vn -0.015916 0.953938 0.299583 +vn -0.015916 0.953938 0.299583 +vn -0.015916 0.953938 0.299583 +vn -0.015916 0.953938 0.299583 +vn -0.669999 -0.569319 0.476421 +vn -0.670000 -0.569319 0.476421 +vn -0.670000 -0.569319 0.476421 +vn -0.669999 -0.569319 0.476421 +vn -0.792032 -0.071341 0.606297 +vn -0.792032 -0.071341 0.606297 +vn -0.792032 -0.071341 0.606297 +vn -0.792032 -0.071341 0.606297 +vn -0.303666 -0.484773 0.820233 +vn -0.146320 -0.578008 0.802806 +vn -0.138233 -0.582204 0.801205 +vn -0.303666 -0.484773 0.820233 +vn 0.000514 -0.645652 0.763632 +vn 0.000514 -0.645652 0.763632 +vn -0.654340 -0.552343 0.516485 +vn -0.654340 -0.552343 0.516485 +vn -0.654340 -0.552343 0.516486 +vn -0.654340 -0.552343 0.516486 +vn -0.276168 -0.902997 0.329132 +vn -0.027194 -0.937145 0.347880 +vn -0.035642 -0.936963 0.347607 +vn -0.276168 -0.902997 0.329132 +vn 0.161580 -0.923671 0.347454 +vn 0.161580 -0.923671 0.347454 +vn 0.584694 -0.583441 0.563675 +vn 0.584694 -0.583441 0.563675 +vn 0.584694 -0.583441 0.563675 +vn 0.584694 -0.583441 0.563675 +vn 0.645892 -0.091277 0.757953 +vn 0.620236 0.134555 0.772789 +vn 0.623274 0.117878 0.773068 +vn 0.645892 -0.091277 0.757953 +vn 0.581691 0.293516 0.758607 +vn 0.581691 0.293516 0.758607 +vn 0.303583 0.848117 0.434206 +vn 0.303583 0.848117 0.434206 +vn 0.303583 0.848117 0.434206 +vn 0.303583 0.848117 0.434206 +vn 0.876336 0.324107 0.356355 +vn 0.876336 0.324107 0.356355 +vn 0.876336 0.324107 0.356355 +vn 0.876336 0.324107 0.356355 +vn -0.733088 0.614649 0.291187 +vn -0.475004 0.790427 0.386777 +vn -0.519011 0.768372 0.374476 +vn -0.733088 0.614649 0.291187 +vn -0.314217 0.850677 0.421445 +vn -0.314217 0.850677 0.421445 +vn -0.631963 0.326244 0.702985 +vn -0.685295 0.150690 0.712505 +vn -0.687377 0.141679 0.712348 +vn -0.631963 0.326244 0.702985 +vn -0.713658 -0.012769 0.700378 +vn -0.713658 -0.012769 0.700378 +vn -0.913988 0.181091 0.363088 +vn -0.913988 0.181091 0.363088 +vn -0.913988 0.181091 0.363088 +vn -0.913988 0.181091 0.363088 +vn -0.928471 -0.331421 0.167637 +vn -0.809206 -0.549937 0.206771 +vn -0.814078 -0.543120 0.205662 +vn -0.928471 -0.331421 0.167637 +vn -0.685467 -0.691612 0.227613 +vn -0.685467 -0.691612 0.227613 +vn -0.203946 -0.821727 0.532138 +vn -0.203946 -0.821727 0.532138 +vn -0.203946 -0.821727 0.532138 +vn -0.203946 -0.821727 0.532138 +vn 0.183206 -0.572040 0.799504 +vn 0.341639 -0.414435 0.843520 +vn 0.330387 -0.426986 0.841741 +vn 0.183206 -0.572040 0.799504 +vn 0.445190 -0.287112 0.848158 +vn 0.445190 -0.287112 0.848158 +vn 0.769195 0.271768 0.578344 +vn 0.769195 0.271768 0.578344 +vn 0.769195 0.271768 0.578344 +vn 0.769195 0.271768 0.578344 +vn 0.703561 -0.521565 0.482671 +vn 0.703561 -0.521565 0.482671 +vn 0.703561 -0.521565 0.482671 +vn 0.703561 -0.521565 0.482671 +vn -0.041344 0.957031 0.287024 +vn -0.041344 0.957031 0.287024 +vn -0.041345 0.957031 0.287024 +vn -0.041344 0.957031 0.287024 +vn 0.402065 0.765416 0.502475 +vn 0.402065 0.765416 0.502475 +vn 0.402065 0.765416 0.502476 +vn 0.402065 0.765416 0.502475 +vn -0.246902 0.696591 0.673647 +vn -0.417665 0.632146 0.652646 +vn -0.425924 0.628322 0.650999 +vn -0.246902 0.696591 0.673647 +vn -0.560229 0.555340 0.614606 +vn -0.560229 0.555340 0.614606 +s 1 +g pDisc6 +usemtl initialShadingGroup +f 96/11/1 97/191/2 98/192/3 99/12/4 +f 98/192/3 100/193/5 101/194/6 99/12/4 +f 101/194/6 102/195/7 103/10/8 99/12/4 +f 103/10/8 104/7/9 96/11/1 99/12/4 +f 103/10/8 102/195/7 105/196/10 106/16/11 +f 105/196/10 107/197/12 108/198/13 106/16/11 +f 108/198/13 109/199/14 110/15/15 106/16/11 +f 110/15/15 104/7/9 103/10/8 106/16/11 +f 110/15/15 109/199/14 111/200/16 112/19/17 +f 111/200/16 113/201/18 114/202/19 112/19/17 +f 114/202/19 97/191/2 96/11/1 112/19/17 +f 96/11/1 104/7/9 110/15/15 112/19/17 +s 2 +f 115/20/20 116/203/21 117/204/22 118/23/23 +f 117/204/22 119/205/24 120/206/25 118/23/23 +f 120/206/25 121/207/26 122/27/27 118/23/23 +f 122/27/27 123/28/28 115/20/20 118/23/23 +f 122/27/27 121/207/26 124/208/29 125/30/30 +f 124/208/29 126/209/31 127/210/32 125/30/30 +f 127/210/32 128/211/33 129/34/34 125/30/30 +f 129/34/34 123/28/28 122/27/27 125/30/30 +f 129/34/34 128/211/33 130/212/35 131/36/36 +f 130/212/35 132/213/37 133/214/38 131/36/36 +f 133/214/38 116/203/21 115/20/20 131/36/36 +f 115/20/20 123/28/28 129/34/34 131/36/36 +s 3 +f 134/39/39 135/215/40 136/216/41 137/42/42 +f 136/216/41 138/217/43 139/218/44 137/42/42 +f 139/218/44 140/219/45 141/46/46 137/42/42 +f 141/46/46 142/47/47 134/39/39 137/42/42 +f 141/46/46 140/219/45 143/220/48 144/49/49 +f 143/220/48 145/221/50 146/222/51 144/49/49 +f 146/222/51 147/223/52 148/53/53 144/49/49 +f 148/53/53 142/47/47 141/46/46 144/49/49 +f 148/53/53 147/223/52 149/224/54 150/55/55 +f 149/224/54 151/225/56 152/226/57 150/55/55 +f 152/226/57 135/215/40 134/39/39 150/55/55 +f 134/39/39 142/47/47 148/53/53 150/55/55 +s 4 +f 153/58/58 154/227/59 155/228/60 156/61/61 +f 155/228/60 157/229/62 158/230/63 156/61/61 +f 158/230/63 159/231/64 160/65/65 156/61/61 +f 160/65/65 161/66/66 153/58/58 156/61/61 +f 160/65/65 159/231/64 162/232/67 163/68/68 +f 162/232/67 164/233/69 165/234/70 163/68/68 +f 165/234/70 166/235/71 167/72/72 163/68/68 +f 167/72/72 161/66/66 160/65/65 163/68/68 +f 167/72/72 166/235/71 168/236/73 169/74/74 +f 168/236/73 170/237/75 171/238/76 169/74/74 +f 171/238/76 154/227/59 153/58/58 169/74/74 +f 153/58/58 161/66/66 167/72/72 169/74/74 +s 5 +f 172/77/77 173/239/78 174/240/79 175/80/80 +f 174/240/79 176/241/81 177/242/82 175/80/80 +f 177/242/82 178/243/83 179/84/84 175/80/80 +f 179/84/84 180/85/85 172/77/77 175/80/80 +f 179/84/84 178/243/83 181/244/86 182/87/87 +f 181/244/86 183/245/88 184/246/89 182/87/87 +f 184/246/89 185/247/90 186/91/91 182/87/87 +f 186/91/91 180/85/85 179/84/84 182/87/87 +f 186/91/91 185/247/90 187/248/92 188/93/93 +f 187/248/92 189/249/94 190/250/95 188/93/93 +f 190/250/95 173/239/78 172/77/77 188/93/93 +f 172/77/77 180/85/85 186/91/91 188/93/93 +s 6 +f 11/96/96 12/99/97 8/98/98 6/97/99 +f 8/98/98 12/99/97 9/101/100 1/100/101 +f 9/101/100 12/99/97 10/103/102 4/102/103 +f 10/103/102 12/99/97 11/96/96 7/104/104 +f 10/103/102 16/106/105 13/105/106 4/102/103 +f 13/105/106 16/106/105 14/108/107 2/107/108 +f 14/108/107 16/106/105 15/110/109 5/109/110 +f 15/110/109 16/106/105 10/103/102 7/104/104 +f 15/110/109 19/112/111 17/111/112 5/109/110 +f 17/111/112 19/112/111 18/114/113 3/113/114 +f 18/114/113 19/112/111 11/96/96 6/97/99 +f 11/96/96 19/112/111 15/110/109 7/104/104 +s 7 +f 30/115/115 31/118/116 27/117/117 25/116/118 +f 27/117/117 31/118/116 28/120/119 20/119/120 +f 28/120/119 31/118/116 29/122/121 23/121/122 +f 29/122/121 31/118/116 30/115/115 26/123/123 +f 29/122/121 35/125/124 32/124/125 23/121/122 +f 32/124/125 35/125/124 33/127/126 21/126/127 +f 33/127/126 35/125/124 34/129/128 24/128/129 +f 34/129/128 35/125/124 29/122/121 26/123/123 +f 34/129/128 38/131/130 36/130/131 24/128/129 +f 36/130/131 38/131/130 37/133/132 22/132/133 +f 37/133/132 38/131/130 30/115/115 25/116/118 +f 30/115/115 38/131/130 34/129/128 26/123/123 +s 8 +f 49/134/134 50/137/135 46/136/136 44/135/137 +f 46/136/136 50/137/135 47/139/138 39/138/139 +f 47/139/138 50/137/135 48/141/140 42/140/141 +f 48/141/140 50/137/135 49/134/134 45/142/142 +f 48/141/140 54/144/143 51/143/144 42/140/141 +f 51/143/144 54/144/143 52/146/145 40/145/146 +f 52/146/145 54/144/143 53/148/147 43/147/148 +f 53/148/147 54/144/143 48/141/140 45/142/142 +f 53/148/147 57/150/149 55/149/150 43/147/148 +f 55/149/150 57/150/149 56/152/151 41/151/152 +f 56/152/151 57/150/149 49/134/134 44/135/137 +f 49/134/134 57/150/149 53/148/147 45/142/142 +s 9 +f 68/153/153 69/156/154 65/155/155 63/154/156 +f 65/155/155 69/156/154 66/158/157 58/157/158 +f 66/158/157 69/156/154 67/160/159 61/159/160 +f 67/160/159 69/156/154 68/153/153 64/161/161 +f 67/160/159 73/163/162 70/162/163 61/159/160 +f 70/162/163 73/163/162 71/165/164 59/164/165 +f 71/165/164 73/163/162 72/167/166 62/166/167 +f 72/167/166 73/163/162 67/160/159 64/161/161 +f 72/167/166 76/169/168 74/168/169 62/166/167 +f 74/168/169 76/169/168 75/171/170 60/170/171 +f 75/171/170 76/169/168 68/153/153 63/154/156 +f 68/153/153 76/169/168 72/167/166 64/161/161 +s 10 +f 87/172/172 88/175/173 84/174/174 82/173/175 +f 84/174/174 88/175/173 85/177/176 77/176/177 +f 85/177/176 88/175/173 86/179/178 80/178/179 +f 86/179/178 88/175/173 87/172/172 83/180/180 +f 86/179/178 92/182/181 89/181/182 80/178/179 +f 89/181/182 92/182/181 90/184/183 78/183/184 +f 90/184/183 92/182/181 91/186/185 81/185/186 +f 91/186/185 92/182/181 86/179/178 83/180/180 +f 91/186/185 95/188/187 93/187/188 81/185/186 +f 93/187/188 95/188/187 94/190/189 79/189/190 +f 94/190/189 95/188/187 87/172/172 82/173/175 +f 87/172/172 95/188/187 91/186/185 83/180/180 +s off +f 6/6/191 8/8/192 98/192/193 97/191/194 +s 11 +f 8/8/195 1/1/196 100/193/197 98/192/198 +f 1/1/196 9/9/199 101/194/200 100/193/197 +s off +f 9/9/201 4/4/202 102/195/203 101/194/204 +s 12 +f 4/4/205 13/13/206 105/196/207 102/195/208 +f 13/13/206 2/2/209 107/197/210 105/196/207 +s off +f 2/2/211 14/14/212 108/198/213 107/197/214 +f 14/14/215 5/5/216 109/199/217 108/198/218 +f 5/5/219 17/17/220 111/200/221 109/199/222 +f 17/17/223 3/3/224 113/201/225 111/200/226 +s 13 +f 3/3/227 18/18/228 114/202/229 113/201/230 +f 18/18/228 6/6/231 97/191/232 114/202/229 +s off +f 25/21/233 27/22/234 117/204/235 116/203/236 +s 14 +f 27/22/237 20/24/238 119/205/239 117/204/240 +f 20/24/238 28/25/241 120/206/242 119/205/239 +s off +f 28/25/243 23/26/244 121/207/245 120/206/246 +s 15 +f 23/26/247 32/29/248 124/208/249 121/207/250 +f 32/29/248 21/31/251 126/209/252 124/208/249 +s off +f 21/31/253 33/32/254 127/210/255 126/209/256 +f 33/32/257 24/33/258 128/211/259 127/210/260 +f 24/33/261 36/35/262 130/212/263 128/211/264 +f 36/35/265 22/37/266 132/213/267 130/212/268 +s 16 +f 22/37/269 37/38/270 133/214/271 132/213/272 +f 37/38/270 25/21/273 116/203/274 133/214/271 +s off +f 44/40/275 46/41/276 136/216/277 135/215/278 +s 17 +f 46/41/279 39/43/280 138/217/281 136/216/282 +f 39/43/280 47/44/283 139/218/284 138/217/281 +s off +f 47/44/285 42/45/286 140/219/287 139/218/288 +s 18 +f 42/45/289 51/48/290 143/220/291 140/219/292 +f 51/48/290 40/50/293 145/221/294 143/220/291 +s off +f 40/50/295 52/51/296 146/222/297 145/221/298 +f 52/51/299 43/52/300 147/223/301 146/222/302 +f 43/52/303 55/54/304 149/224/305 147/223/306 +f 55/54/307 41/56/308 151/225/309 149/224/310 +s 19 +f 41/56/311 56/57/312 152/226/313 151/225/314 +f 56/57/312 44/40/315 135/215/316 152/226/313 +s off +f 63/59/317 65/60/318 155/228/319 154/227/320 +s 20 +f 65/60/321 58/62/322 157/229/323 155/228/324 +f 58/62/322 66/63/325 158/230/326 157/229/323 +s off +f 66/63/327 61/64/328 159/231/329 158/230/330 +s 21 +f 61/64/331 70/67/332 162/232/333 159/231/334 +f 70/67/332 59/69/335 164/233/336 162/232/333 +s off +f 59/69/337 71/70/338 165/234/339 164/233/340 +f 71/70/341 62/71/342 166/235/343 165/234/344 +s 22 +f 62/71/345 74/73/346 168/236/347 166/235/348 +f 74/73/346 60/75/349 170/237/350 168/236/347 +s 23 +f 60/75/351 75/76/352 171/238/353 170/237/354 +f 75/76/352 63/59/355 154/227/356 171/238/353 +s off +f 82/78/357 84/79/358 174/240/359 173/239/360 +s 24 +f 84/79/361 77/81/362 176/241/363 174/240/364 +f 77/81/362 85/82/365 177/242/366 176/241/363 +s off +f 85/82/367 80/83/368 178/243/369 177/242/370 +s 25 +f 80/83/371 89/86/372 181/244/373 178/243/374 +f 89/86/372 78/88/375 183/245/376 181/244/373 +s off +f 78/88/377 90/89/378 184/246/379 183/245/380 +f 90/89/381 81/90/382 185/247/383 184/246/384 +f 81/90/385 93/92/386 187/248/387 185/247/388 +f 93/92/389 79/94/390 189/249/391 187/248/392 +s 26 +f 79/94/393 94/95/394 190/250/395 189/249/396 +f 94/95/394 82/78/397 173/239/398 190/250/395 diff --git a/src/obj/petal.obj b/src/obj/petal.obj new file mode 100644 index 0000000..60f138d --- /dev/null +++ b/src/obj/petal.obj @@ -0,0 +1,76 @@ +# This file uses centimeters as units for non-parametric coordinates. + +mtllib petal.mtl +g default +v -0.997470 -0.030122 -0.002697 +v 0.458976 0.287947 0.692038 +v 0.380800 0.206094 -0.739936 +v -0.380207 0.252675 0.750794 +v 1.129635 0.106298 0.001516 +v -0.459569 0.169581 -0.702897 +v -0.000000 -0.051881 -0.000000 +v -0.891046 -0.000130 -0.449175 +v -0.836622 0.056853 0.547715 +v -0.225801 0.055498 0.445889 +v -0.272934 0.006150 -0.417443 +v -0.498735 -0.048262 -0.000915 +v 0.000895 0.277048 0.839289 +v 0.880405 0.119554 0.254256 +v 0.498735 -0.005629 0.000024 +v 0.272934 0.076815 0.417443 +v 0.847263 0.084854 -0.352796 +v -0.005267 0.181100 -0.839289 +v 0.225801 0.027466 -0.445889 +vt 0.066987 0.250000 +vt 0.933013 0.250000 +vt 0.500000 1.000000 +vt 0.500000 0.000000 +vt 0.933013 0.750000 +vt 0.066987 0.750000 +vt 0.500000 0.500000 +vt 0.000000 0.500000 +vt 0.250000 0.066987 +vt 0.500000 0.250000 +vt 0.283494 0.625000 +vt 0.283494 0.375000 +vt 0.750000 0.066987 +vt 1.000000 0.500000 +vt 0.716506 0.625000 +vt 0.716506 0.375000 +vt 0.750000 0.933013 +vt 0.250000 0.933013 +vt 0.500000 0.750000 +vn -0.007354 0.970011 0.242950 +vn 0.002666 0.939331 0.343001 +vn 0.001092 0.989018 0.147794 +vn -0.001943 0.998755 -0.049839 +vn 0.036495 0.997590 -0.059015 +vn -0.025531 0.965329 -0.259784 +vn -0.039024 0.908625 -0.415785 +vn -0.038245 0.941936 -0.333608 +vn -0.043688 0.997766 -0.050543 +vn -0.069195 0.865568 -0.495989 +vn -0.119158 0.914719 -0.386122 +vn -0.191662 0.836516 -0.513330 +vn -0.160960 0.939666 -0.301861 +vn -0.148082 0.988159 -0.040165 +vn -0.121263 0.991364 -0.049922 +vn -0.145433 0.974722 0.169605 +vn -0.089291 0.954972 0.282942 +vn -0.157905 0.878678 0.450546 +vn -0.023565 0.907141 0.420166 +s 1 +g pDisc1 +usemtl initialShadingGroup +f 11/11/1 6/6/2 8/8/3 12/12/4 +f 8/8/3 1/1/5 9/9/6 12/12/4 +f 9/9/6 4/4/7 10/10/8 12/12/4 +f 10/10/8 7/7/9 11/11/1 12/12/4 +f 10/10/8 4/4/7 13/13/10 16/16/11 +f 13/13/10 2/2/12 14/14/13 16/16/11 +f 14/14/13 5/5/14 15/15/15 16/16/11 +f 15/15/15 7/7/9 10/10/8 16/16/11 +f 15/15/15 5/5/14 17/17/16 19/19/17 +f 17/17/16 3/3/18 18/18/19 19/19/17 +f 18/18/19 6/6/2 11/11/1 19/19/17 +f 11/11/1 7/7/9 15/15/15 19/19/17 diff --git a/src/obj/star.obj b/src/obj/star.obj new file mode 100644 index 0000000..a7ae32e --- /dev/null +++ b/src/obj/star.obj @@ -0,0 +1,272 @@ +# This file uses centimeters as units for non-parametric coordinates. + +mtllib star.mtl +g default +v -0.207815 0.286030 -0.192095 +v -0.336250 0.109255 -0.192095 +v -0.336250 -0.109255 -0.192095 +v -0.207815 -0.286030 -0.192095 +v -0.000000 -0.353555 -0.192095 +v 0.207815 -0.286030 -0.192095 +v 0.336250 -0.109255 -0.192095 +v 0.336250 0.109255 -0.192095 +v 0.207815 0.286030 -0.192095 +v 0.000000 0.353555 -0.192095 +v -0.555930 0.807740 -0.000000 +v -0.475530 0.154510 -0.000000 +v -0.899510 -0.249700 -0.000000 +v -0.293895 -0.404510 -0.000000 +v -0.000000 -0.903235 0.000000 +v 0.293895 -0.404510 0.000000 +v 0.899510 -0.249700 0.000000 +v 0.475530 0.154510 0.000000 +v 0.555930 0.807740 0.000000 +v 0.000000 0.500000 0.000000 +v -0.207815 0.286030 0.192095 +v -0.336250 0.109255 0.192095 +v -0.336250 -0.109255 0.192095 +v -0.207815 -0.286030 0.192095 +v -0.000000 -0.353555 0.192095 +v 0.207815 -0.286030 0.192095 +v 0.336250 -0.109255 0.192095 +v 0.336250 0.109255 0.192095 +v 0.207815 0.286030 0.192095 +v 0.000000 0.353555 0.192095 +v 0.000000 0.000000 -0.337570 +v -0.000000 0.000000 0.337570 +vt 0.000000 0.250000 +vt 0.100000 0.250000 +vt 0.100000 0.500000 +vt 0.000000 0.500000 +vt 0.200000 0.250000 +vt 0.200000 0.500000 +vt 0.300000 0.250000 +vt 0.300000 0.500000 +vt 0.400000 0.250000 +vt 0.400000 0.500000 +vt 0.500000 0.250000 +vt 0.500000 0.500000 +vt 0.600000 0.250000 +vt 0.600000 0.500000 +vt 0.700000 0.250000 +vt 0.700000 0.500000 +vt 0.800000 0.250000 +vt 0.800000 0.500000 +vt 0.900000 0.250000 +vt 0.900000 0.500000 +vt 1.000000 0.250000 +vt 1.000000 0.500000 +vt 0.100000 0.750000 +vt 0.000000 0.750000 +vt 0.200000 0.750000 +vt 0.300000 0.750000 +vt 0.400000 0.750000 +vt 0.500000 0.750000 +vt 0.600000 0.750000 +vt 0.700000 0.750000 +vt 0.800000 0.750000 +vt 0.900000 0.750000 +vt 1.000000 0.750000 +vt 0.050000 0.000000 +vt 0.150000 0.000000 +vt 0.250000 0.000000 +vt 0.350000 0.000000 +vt 0.450000 0.000000 +vt 0.550000 0.000000 +vt 0.650000 0.000000 +vt 0.750000 0.000000 +vt 0.850000 0.000000 +vt 0.950000 0.000000 +vt 0.050000 1.000000 +vt 0.150000 1.000000 +vt 0.250000 1.000000 +vt 0.350000 1.000000 +vt 0.450000 1.000000 +vt 0.550000 1.000000 +vt 0.650000 1.000000 +vt 0.750000 1.000000 +vt 0.850000 1.000000 +vt 0.950000 1.000000 +vn -0.593728 0.034361 -0.803932 +vn -0.593728 0.034361 -0.803932 +vn -0.593728 0.034361 -0.803932 +vn -0.593728 0.034361 -0.803932 +vn -0.486851 0.331478 -0.808145 +vn -0.486851 0.331478 -0.808145 +vn -0.486851 0.331478 -0.808145 +vn -0.486851 0.331478 -0.808145 +vn -0.249792 -0.552980 -0.794869 +vn -0.249792 -0.552980 -0.794869 +vn -0.249792 -0.552980 -0.794869 +vn -0.249792 -0.552980 -0.794869 +vn -0.451747 -0.400257 -0.797320 +vn -0.451747 -0.400257 -0.797320 +vn -0.451747 -0.400257 -0.797320 +vn -0.451747 -0.400257 -0.797320 +vn 0.451747 -0.400257 -0.797320 +vn 0.451747 -0.400257 -0.797320 +vn 0.451747 -0.400257 -0.797320 +vn 0.451747 -0.400257 -0.797320 +vn 0.249792 -0.552980 -0.794869 +vn 0.249792 -0.552980 -0.794869 +vn 0.249792 -0.552980 -0.794869 +vn 0.249792 -0.552980 -0.794869 +vn 0.486851 0.331478 -0.808145 +vn 0.486851 0.331478 -0.808145 +vn 0.486851 0.331478 -0.808145 +vn 0.486851 0.331478 -0.808145 +vn 0.593728 0.034361 -0.803932 +vn 0.593728 0.034361 -0.803932 +vn 0.593728 0.034361 -0.803932 +vn 0.593728 0.034361 -0.803932 +vn -0.175458 0.557844 -0.811187 +vn -0.175458 0.557844 -0.811187 +vn -0.175458 0.557844 -0.811187 +vn -0.175458 0.557844 -0.811187 +vn 0.175458 0.557845 -0.811187 +vn 0.175458 0.557845 -0.811187 +vn 0.175458 0.557845 -0.811187 +vn 0.175458 0.557845 -0.811187 +vn -0.593728 0.034361 0.803932 +vn -0.593728 0.034361 0.803932 +vn -0.593728 0.034361 0.803932 +vn -0.593728 0.034361 0.803932 +vn -0.486851 0.331478 0.808145 +vn -0.486851 0.331478 0.808145 +vn -0.486851 0.331478 0.808145 +vn -0.486851 0.331478 0.808145 +vn -0.249792 -0.552980 0.794869 +vn -0.249792 -0.552980 0.794869 +vn -0.249792 -0.552980 0.794869 +vn -0.249792 -0.552980 0.794869 +vn -0.451747 -0.400257 0.797320 +vn -0.451747 -0.400257 0.797320 +vn -0.451747 -0.400257 0.797320 +vn -0.451747 -0.400257 0.797320 +vn 0.451747 -0.400257 0.797320 +vn 0.451747 -0.400257 0.797320 +vn 0.451747 -0.400257 0.797320 +vn 0.451747 -0.400257 0.797320 +vn 0.249792 -0.552980 0.794869 +vn 0.249792 -0.552980 0.794869 +vn 0.249792 -0.552980 0.794869 +vn 0.249792 -0.552980 0.794869 +vn 0.486851 0.331478 0.808145 +vn 0.486851 0.331478 0.808145 +vn 0.486851 0.331478 0.808145 +vn 0.486851 0.331478 0.808145 +vn 0.593728 0.034361 0.803932 +vn 0.593728 0.034361 0.803932 +vn 0.593728 0.034361 0.803932 +vn 0.593728 0.034361 0.803932 +vn -0.175458 0.557844 0.811187 +vn -0.175458 0.557844 0.811187 +vn -0.175458 0.557844 0.811187 +vn -0.175458 0.557844 0.811187 +vn 0.175458 0.557845 0.811187 +vn 0.175458 0.557844 0.811187 +vn 0.175458 0.557845 0.811187 +vn 0.175458 0.557845 0.811187 +vn -0.321238 0.233393 -0.917787 +vn -0.321238 0.233393 -0.917787 +vn -0.321238 0.233393 -0.917787 +vn -0.397073 0.000000 -0.917787 +vn -0.397073 0.000000 -0.917787 +vn -0.397073 0.000000 -0.917787 +vn -0.321238 -0.233393 -0.917787 +vn -0.321238 -0.233393 -0.917787 +vn -0.321238 -0.233393 -0.917787 +vn -0.122702 -0.377638 -0.917787 +vn -0.122702 -0.377639 -0.917787 +vn -0.122702 -0.377639 -0.917787 +vn 0.122702 -0.377639 -0.917787 +vn 0.122702 -0.377639 -0.917787 +vn 0.122702 -0.377639 -0.917787 +vn 0.321239 -0.233393 -0.917787 +vn 0.321239 -0.233393 -0.917787 +vn 0.321239 -0.233393 -0.917787 +vn 0.397073 -0.000000 -0.917787 +vn 0.397073 -0.000000 -0.917787 +vn 0.397073 -0.000000 -0.917787 +vn 0.321239 0.233394 -0.917787 +vn 0.321239 0.233393 -0.917787 +vn 0.321239 0.233393 -0.917787 +vn 0.122702 0.377639 -0.917787 +vn 0.122702 0.377639 -0.917787 +vn 0.122702 0.377639 -0.917787 +vn -0.122702 0.377639 -0.917787 +vn -0.122702 0.377639 -0.917787 +vn -0.122702 0.377639 -0.917787 +vn -0.321238 0.233393 0.917787 +vn -0.321238 0.233393 0.917787 +vn -0.321238 0.233393 0.917787 +vn -0.397073 0.000000 0.917787 +vn -0.397073 0.000000 0.917787 +vn -0.397073 0.000000 0.917787 +vn -0.321238 -0.233393 0.917787 +vn -0.321238 -0.233393 0.917787 +vn -0.321238 -0.233393 0.917787 +vn -0.122702 -0.377639 0.917787 +vn -0.122702 -0.377639 0.917787 +vn -0.122702 -0.377639 0.917787 +vn 0.122702 -0.377639 0.917787 +vn 0.122702 -0.377639 0.917787 +vn 0.122702 -0.377639 0.917787 +vn 0.321238 -0.233393 0.917787 +vn 0.321238 -0.233393 0.917787 +vn 0.321238 -0.233393 0.917787 +vn 0.397073 -0.000000 0.917787 +vn 0.397073 -0.000000 0.917787 +vn 0.397073 -0.000000 0.917787 +vn 0.321239 0.233393 0.917787 +vn 0.321239 0.233394 0.917787 +vn 0.321239 0.233393 0.917787 +vn 0.122702 0.377639 0.917787 +vn 0.122702 0.377639 0.917787 +vn 0.122702 0.377639 0.917787 +vn -0.122702 0.377639 0.917787 +vn -0.122702 0.377639 0.917787 +vn -0.122702 0.377639 0.917787 +s off +g star:pSphere1 +usemtl initialShadingGroup +f 1/1/1 2/2/2 12/3/3 11/4/4 +f 2/2/5 3/5/6 13/6/7 12/3/8 +f 3/5/9 4/7/10 14/8/11 13/6/12 +f 4/7/13 5/9/14 15/10/15 14/8/16 +f 5/9/17 6/11/18 16/12/19 15/10/20 +f 6/11/21 7/13/22 17/14/23 16/12/24 +f 7/13/25 8/15/26 18/16/27 17/14/28 +f 8/15/29 9/17/30 19/18/31 18/16/32 +f 9/17/33 10/19/34 20/20/35 19/18/36 +f 10/19/37 1/21/38 11/22/39 20/20/40 +f 11/4/41 12/3/42 22/23/43 21/24/44 +f 12/3/45 13/6/46 23/25/47 22/23/48 +f 13/6/49 14/8/50 24/26/51 23/25/52 +f 14/8/53 15/10/54 25/27/55 24/26/56 +f 15/10/57 16/12/58 26/28/59 25/27/60 +f 16/12/61 17/14/62 27/29/63 26/28/64 +f 17/14/65 18/16/66 28/30/67 27/29/68 +f 18/16/69 19/18/70 29/31/71 28/30/72 +f 19/18/73 20/20/74 30/32/75 29/31/76 +f 20/20/77 11/22/78 21/33/79 30/32/80 +f 2/2/81 1/1/82 31/34/83 +f 3/5/84 2/2/85 31/35/86 +f 4/7/87 3/5/88 31/36/89 +f 5/9/90 4/7/91 31/37/92 +f 6/11/93 5/9/94 31/38/95 +f 7/13/96 6/11/97 31/39/98 +f 8/15/99 7/13/100 31/40/101 +f 9/17/102 8/15/103 31/41/104 +f 10/19/105 9/17/106 31/42/107 +f 1/21/108 10/19/109 31/43/110 +f 21/24/111 22/23/112 32/44/113 +f 22/23/114 23/25/115 32/45/116 +f 23/25/117 24/26/118 32/46/119 +f 24/26/120 25/27/121 32/47/122 +f 25/27/123 26/28/124 32/48/125 +f 26/28/126 27/29/127 32/49/128 +f 27/29/129 28/30/130 32/50/131 +f 28/30/132 29/31/133 32/51/134 +f 29/31/135 30/32/136 32/52/137 +f 30/32/138 21/33/139 32/53/140 diff --git a/src/rendering/gl/Drawable.ts b/src/rendering/gl/Drawable.ts index d5420f6..b6dfdf5 100644 --- a/src/rendering/gl/Drawable.ts +++ b/src/rendering/gl/Drawable.ts @@ -1,4 +1,4 @@ -import {gl} from '../../globals'; +import { gl } from '../../globals'; abstract class Drawable { count: number = 0; @@ -7,6 +7,10 @@ abstract class Drawable { bufPos: WebGLBuffer; bufNor: WebGLBuffer; bufTranslate: WebGLBuffer; + bufCol1: WebGLBuffer; + bufCol2: WebGLBuffer; + bufCol3: WebGLBuffer; + bufCol4: WebGLBuffer; bufCol: WebGLBuffer; bufUV: WebGLBuffer; @@ -15,11 +19,15 @@ abstract class Drawable { norGenerated: boolean = false; colGenerated: boolean = false; translateGenerated: boolean = false; + col1Generated: boolean = false; + col2Generated: boolean = false; + col3Generated: boolean = false; + col4Generated: boolean = false; uvGenerated: boolean = false; numInstances: number = 0; // How many instances of this Drawable the shader program should draw - abstract create() : void; + abstract create(): void; destory() { gl.deleteBuffer(this.bufIdx); @@ -27,6 +35,10 @@ abstract class Drawable { gl.deleteBuffer(this.bufNor); gl.deleteBuffer(this.bufCol); gl.deleteBuffer(this.bufTranslate); + gl.deleteBuffer(this.bufCol1); + gl.deleteBuffer(this.bufCol2); + gl.deleteBuffer(this.bufCol3); + gl.deleteBuffer(this.bufCol4); gl.deleteBuffer(this.bufUV); } @@ -55,6 +67,26 @@ abstract class Drawable { this.bufTranslate = gl.createBuffer(); } + generateCol1() { + this.col1Generated = true; + this.bufCol1 = gl.createBuffer(); + } + + generateCol2() { + this.col2Generated = true; + this.bufCol2 = gl.createBuffer(); + } + + generateCol3() { + this.col3Generated = true; + this.bufCol3 = gl.createBuffer(); + } + + generateCol4() { + this.col4Generated = true; + this.bufCol4 = gl.createBuffer(); + } + generateUV() { this.uvGenerated = true; this.bufUV = gl.createBuffer(); @@ -95,6 +127,34 @@ abstract class Drawable { return this.translateGenerated; } + bindCol1(): boolean { + if (this.col1Generated) { + gl.bindBuffer(gl.ARRAY_BUFFER, this.bufCol1); + } + return this.col1Generated; + } + + bindCol2(): boolean { + if (this.col2Generated) { + gl.bindBuffer(gl.ARRAY_BUFFER, this.bufCol2); + } + return this.col2Generated; + } + + bindCol3(): boolean { + if (this.col3Generated) { + gl.bindBuffer(gl.ARRAY_BUFFER, this.bufCol3); + } + return this.col3Generated; + } + + bindCol4(): boolean { + if (this.col4Generated) { + gl.bindBuffer(gl.ARRAY_BUFFER, this.bufCol4); + } + return this.col4Generated; + } + bindUV(): boolean { if (this.uvGenerated) { gl.bindBuffer(gl.ARRAY_BUFFER, this.bufUV); @@ -113,6 +173,6 @@ abstract class Drawable { setNumInstances(num: number) { this.numInstances = num; } -}; +} export default Drawable; diff --git a/src/rendering/gl/ShaderProgram.ts b/src/rendering/gl/ShaderProgram.ts index fa9f450..94ca6a9 100644 --- a/src/rendering/gl/ShaderProgram.ts +++ b/src/rendering/gl/ShaderProgram.ts @@ -1,6 +1,6 @@ -import {vec3, vec4, mat4, mat3} from 'gl-matrix'; +import { vec3, vec4, mat4, mat3 } from 'gl-matrix'; import Drawable from './Drawable'; -import {gl} from '../../globals'; +import { gl } from '../../globals'; var activeProgram: WebGLProgram = null; @@ -16,7 +16,7 @@ export class Shader { throw gl.getShaderInfoLog(this.shader); } } -}; +} class ShaderProgram { prog: WebGLProgram; @@ -25,6 +25,10 @@ class ShaderProgram { attrNor: number; attrCol: number; // This time, it's an instanced rendering attribute, so each particle can have a unique color. Not per-vertex, but per-instance. attrTranslate: number; // Used in the vertex shader during instanced rendering to offset the vertex positions to the particle's drawn position. + attrCol1: number; // Column1 of transformation + attrCol2: number; // Column2 of transformation + attrCol3: number; // Column3 of transformation + attrCol4: number; // Column4 of transformation attrUV: number; unifModel: WebGLUniformLocation; @@ -48,18 +52,23 @@ class ShaderProgram { throw gl.getProgramInfoLog(this.prog); } - this.attrPos = gl.getAttribLocation(this.prog, "vs_Pos"); - this.attrCol = gl.getAttribLocation(this.prog, "vs_Col"); - this.attrTranslate = gl.getAttribLocation(this.prog, "vs_Translate"); - this.attrUV = gl.getAttribLocation(this.prog, "vs_UV"); - this.unifModel = gl.getUniformLocation(this.prog, "u_Model"); - this.unifModelInvTr = gl.getUniformLocation(this.prog, "u_ModelInvTr"); - this.unifViewProj = gl.getUniformLocation(this.prog, "u_ViewProj"); - this.unifCameraAxes = gl.getUniformLocation(this.prog, "u_CameraAxes"); - this.unifTime = gl.getUniformLocation(this.prog, "u_Time"); - this.unifEye = gl.getUniformLocation(this.prog, "u_Eye"); - this.unifRef = gl.getUniformLocation(this.prog, "u_Ref"); - this.unifUp = gl.getUniformLocation(this.prog, "u_Up"); + this.attrPos = gl.getAttribLocation(this.prog, 'vs_Pos'); + this.attrNor = gl.getAttribLocation(this.prog, 'vs_Nor'); + this.attrCol = gl.getAttribLocation(this.prog, 'vs_Col'); + this.attrTranslate = gl.getAttribLocation(this.prog, 'vs_Translate'); + this.attrCol1 = gl.getAttribLocation(this.prog, 'vs_Transform1'); + this.attrCol2 = gl.getAttribLocation(this.prog, 'vs_Transform2'); + this.attrCol3 = gl.getAttribLocation(this.prog, 'vs_Transform3'); + this.attrCol4 = gl.getAttribLocation(this.prog, 'vs_Transform4'); + this.attrUV = gl.getAttribLocation(this.prog, 'vs_UV'); + this.unifModel = gl.getUniformLocation(this.prog, 'u_Model'); + this.unifModelInvTr = gl.getUniformLocation(this.prog, 'u_ModelInvTr'); + this.unifViewProj = gl.getUniformLocation(this.prog, 'u_ViewProj'); + this.unifCameraAxes = gl.getUniformLocation(this.prog, 'u_CameraAxes'); + this.unifTime = gl.getUniformLocation(this.prog, 'u_Time'); + this.unifEye = gl.getUniformLocation(this.prog, 'u_Eye'); + this.unifRef = gl.getUniformLocation(this.prog, 'u_Ref'); + this.unifUp = gl.getUniformLocation(this.prog, 'u_Up'); } use() { @@ -71,20 +80,20 @@ class ShaderProgram { setEyeRefUp(eye: vec3, ref: vec3, up: vec3) { this.use(); - if(this.unifEye !== -1) { + if (this.unifEye !== -1) { gl.uniform3f(this.unifEye, eye[0], eye[1], eye[2]); } - if(this.unifRef !== -1) { + if (this.unifRef !== -1) { gl.uniform3f(this.unifRef, ref[0], ref[1], ref[2]); } - if(this.unifUp !== -1) { + if (this.unifUp !== -1) { gl.uniform3f(this.unifUp, up[0], up[1], up[2]); } } setDimensions(width: number, height: number) { this.use(); - if(this.unifDimensions !== -1) { + if (this.unifDimensions !== -1) { gl.uniform2f(this.unifDimensions, width, height); } } @@ -151,6 +160,30 @@ class ShaderProgram { gl.vertexAttribDivisor(this.attrTranslate, 1); // Advance 1 index in translate VBO for each drawn instance } + if (this.attrCol1 != -1 && d.bindCol1()) { + gl.enableVertexAttribArray(this.attrCol1); + gl.vertexAttribPointer(this.attrCol1, 4, gl.FLOAT, false, 0, 0); + gl.vertexAttribDivisor(this.attrCol1, 1); // Advance 1 index in transformation VBO for each drawn instance + } + + if (this.attrCol2 != -1 && d.bindCol2()) { + gl.enableVertexAttribArray(this.attrCol2); + gl.vertexAttribPointer(this.attrCol2, 4, gl.FLOAT, false, 0, 0); + gl.vertexAttribDivisor(this.attrCol2, 1); // Advance 1 index in transformation VBO for each drawn instance + } + + if (this.attrCol3 != -1 && d.bindCol3()) { + gl.enableVertexAttribArray(this.attrCol3); + gl.vertexAttribPointer(this.attrCol3, 4, gl.FLOAT, false, 0, 0); + gl.vertexAttribDivisor(this.attrCol3, 1); // Advance 1 index in transformation VBO for each drawn instance + } + + if (this.attrCol4 != -1 && d.bindCol4()) { + gl.enableVertexAttribArray(this.attrCol4); + gl.vertexAttribPointer(this.attrCol4, 4, gl.FLOAT, false, 0, 0); + gl.vertexAttribDivisor(this.attrCol4, 1); // Advance 1 index in transformation VBO for each drawn instance + } + if (this.attrUV != -1 && d.bindUV()) { gl.enableVertexAttribArray(this.attrUV); gl.vertexAttribPointer(this.attrUV, 2, gl.FLOAT, false, 0, 0); @@ -177,8 +210,12 @@ class ShaderProgram { if (this.attrNor != -1) gl.disableVertexAttribArray(this.attrNor); if (this.attrCol != -1) gl.disableVertexAttribArray(this.attrCol); if (this.attrTranslate != -1) gl.disableVertexAttribArray(this.attrTranslate); + if (this.attrCol1 != -1) gl.disableVertexAttribArray(this.attrCol1); + if (this.attrCol2 != -1) gl.disableVertexAttribArray(this.attrCol2); + if (this.attrCol3 != -1) gl.disableVertexAttribArray(this.attrCol3); + if (this.attrCol4 != -1) gl.disableVertexAttribArray(this.attrCol4); if (this.attrUV != -1) gl.disableVertexAttribArray(this.attrUV); } -}; +} export default ShaderProgram; diff --git a/src/shaders/flat-frag.glsl b/src/shaders/flat-frag.glsl index 99362d2..21f1d62 100644 --- a/src/shaders/flat-frag.glsl +++ b/src/shaders/flat-frag.glsl @@ -8,6 +8,58 @@ uniform float u_Time; in vec2 fs_Pos; out vec4 out_Col; + +//toolbox functions +float mod289(float x){return x - floor(x * (1.0 / 289.0)) * 289.0;} +vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;} +vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);} + +float noise(vec3 p){ + vec3 a = floor(p); + vec3 d = p - a; + d = d * d * (3.0 - 2.0 * d); + + vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0); + vec4 k1 = perm(b.xyxy); + vec4 k2 = perm(k1.xyxy + b.zzww); + + vec4 c = k2 + a.zzzz; + vec4 k3 = perm(c); + vec4 k4 = perm(c + 1.0); + + vec4 o1 = fract(k3 * (1.0 / 41.0)); + vec4 o2 = fract(k4 * (1.0 / 41.0)); + + vec4 o3 = o2 * d.z + o1 * (1.0 - d.z); + vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x); + + return o4.y * d.y + o4.x * (1.0 - d.y); +} + +#define NUM_OCTAVES 5 + +float fbm(vec3 x) { + float v = 0.0; + float a = 0.9; //0.5 + int o = NUM_OCTAVES; + for (int i = 0; i < o; ++i) { + v += a * noise(x); + x = x * 2.25 + 2.0; //2.0 + a *= 0.55; //0.5 + } + return v; +} + void main() { - out_Col = vec4(0.5 * (fs_Pos + vec2(1.0)), 0.0, 1.0); + vec3 pos = vec3(fs_Pos,1.0); + float warp_noise = fbm(pos.xyz + fbm( pos.xyz + fbm( pos.xyz ))); + + out_Col = vec4(0.5 * (fs_Pos + vec2(1.0)), 0.0, 1.0) * warp_noise; + out_Col += vec4(0.2,-0.1,0.8,0.0); + //avg r,g,b + float avg = (out_Col.r+out_Col.g+out_Col.b)/10.0; + out_Col += vec4(avg,avg,avg,0.f); + out_Col = min(out_Col,vec4(1,0.98,1,1.f)); } + + diff --git a/src/shaders/instanced-frag.glsl b/src/shaders/instanced-frag.glsl index 72e7460..eb73c68 100644 --- a/src/shaders/instanced-frag.glsl +++ b/src/shaders/instanced-frag.glsl @@ -3,11 +3,28 @@ precision highp float; in vec4 fs_Col; in vec4 fs_Pos; +in vec4 fs_Nor; out vec4 out_Col; +in vec4 vs_Transform1; + void main() { - float dist = 1.0 - (length(fs_Pos.xyz) * 2.0); - out_Col = vec4(dist) * fs_Col; + // float dist = 1.0 - (length(fs_Pos.xyz) * 2.0); + // out_Col = vec4(dist) * fs_Col; + + //lambert + vec3 dir = vec3(10,100,10) - fs_Pos.xyz; + float diffuseTerm = dot(normalize(fs_Nor.xyz), normalize(dir)); + diffuseTerm = clamp(diffuseTerm, 0.0, 1.0); + float ambientTerm = 0.5; + + float lightIntensity = diffuseTerm + ambientTerm; + out_Col = clamp(vec4(fs_Col.rgb * lightIntensity, 1.0), 0.0, 1.0); + // out_Col = vs_Transform1; } + + + + diff --git a/src/shaders/instanced-vert.glsl b/src/shaders/instanced-vert.glsl index d8b8996..8870757 100644 --- a/src/shaders/instanced-vert.glsl +++ b/src/shaders/instanced-vert.glsl @@ -12,18 +12,27 @@ in vec4 vs_Col; // An instanced rendering attribute; each particle instance has in vec3 vs_Translate; // Another instance rendering attribute used to position each quad instance in the scene in vec2 vs_UV; // Non-instanced, and presently unused in main(). Feel free to use it for your meshes. +in vec4 vs_Transform1; // Another instance rendering attribute used to position each quad instance in the scene +in vec4 vs_Transform2; // Another instance rendering attribute used to position each quad instance in the scene +in vec4 vs_Transform3; // Another instance rendering attribute used to position each quad instance in the scene +in vec4 vs_Transform4; // Another instance rendering attribute used to position each quad instance in the scene + out vec4 fs_Col; out vec4 fs_Pos; +out vec4 fs_Nor; void main() { fs_Col = vs_Col; fs_Pos = vs_Pos; + fs_Nor = vs_Nor; - vec3 offset = vs_Translate; - offset.z = (sin((u_Time + offset.x) * 3.14159 * 0.1) + cos((u_Time + offset.y) * 3.14159 * 0.1)) * 1.5; - - vec3 billboardPos = offset + vs_Pos.x * u_CameraAxes[0] + vs_Pos.y * u_CameraAxes[1]; + // vec3 offset = vs_Translate; + // offset.z = (sin((u_Time + offset.x) * 3.14159 * 0.1) + cos((u_Time + offset.y) * 3.14159 * 0.1)) * 1.5; - gl_Position = u_ViewProj * vec4(billboardPos, 1.0); + // vec3 billboardPos = offset + vs_Pos.x * u_CameraAxes[0] + vs_Pos.y * u_CameraAxes[1]; + mat4 transformation = mat4(vs_Transform1, vs_Transform2, vs_Transform3, vs_Transform4); + vec4 instancedPos = transformation * vs_Pos; + gl_Position = u_ViewProj * vec4(instancedPos.xyz, 1.0); + // gl_Position = u_ViewProj * vs_Pos;//* vec4(billboardPos, 1.0); }