This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import datetime | |
| import urllib2 | |
| # To read a locally saved file: | |
| # file = open('quakes.json') | |
| # Or, to read the latest data straight from the web: | |
| file = urllib2.urlopen('http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_day.geojson') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Demonstration of depth buffering | |
| # When depth buffering is active, the orbiting yellow planet | |
| # will be properly hidden by the blue and red planets as it | |
| # passes behind them. | |
| # Depth buffering is toggled on & off by pressing the space bar. | |
| import sys | |
| import time | |
| from pyglet.gl import * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Demonstration of perspective projection | |
| # | |
| import sys, time | |
| from pyglet.gl import * | |
| window = pyglet.window.Window() | |
| keys = pyglet.window.key.KeyStateHandler() | |
| window.push_handlers(keys) | |
| glLineWidth(5.0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma strict | |
| // Script to warp an existing mesh. | |
| // This can be attached to any GameObject that includes a Mesh Filter. | |
| // It will move the vertices up and down in Y, based on the sine of the X | |
| // value + the time. | |
| private var originalVerts : Vector3[]; | |
| function Start () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma strict | |
| // Script to create a mesh with 2 triangles. | |
| // This should be attached to an empty GameObject. | |
| // It assumes the existence of a custom shader to use the vertex colors | |
| // without texture or lighting. | |
| function Start () | |
| { | |
| gameObject.AddComponent.<MeshFilter>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma strict | |
| // Script to create a mesh with 2 triangles, getting colors from a text file. | |
| function Start () | |
| { | |
| gameObject.AddComponent.<MeshFilter>(); | |
| gameObject.AddComponent.<MeshRenderer>(); | |
| var mat = new Material(Shader.Find("Custom/Vertex Colored")); | |
| GetComponent.<Renderer>().material = mat; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // taken from http://answers.unity3d.com/questions/391561/create-a-mesh-and-color-cubes.html | |
| Shader "Custom/Vertex Colored" | |
| { | |
| Properties | |
| { | |
| } | |
| SubShader | |
| { | |
| Pass | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma strict | |
| // Script to create a mesh with 2 triangles with texture coordinates (UV). | |
| // This expects to be attached to a GameObject that already has a mesh | |
| // and material (such as a sphere), so that you can assign the texture | |
| // through the Unity editor, instead of here in the code | |
| // It uses the mesh's Clear() function to erase the old geometry before | |
| // creating the triangles. | |
| function Start () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma strict | |
| public var rows = 30; | |
| public var cols = 30; | |
| private var myVertices = Array(); | |
| private var myColors = Array(); | |
| private var myTriangles = Array(); | |
| function Start () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma strict | |
| public var rows = 30; | |
| public var cols = 30; | |
| private var myVertices = Array(); | |
| private var myColors = Array(); | |
| private var myTriangles = Array(); | |
| function Start () |