Skip to content

Instantly share code, notes, and snippets.

View davepape's full-sized avatar

Dave Pape davepape

View GitHub Profile
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class QuitButton : MonoBehaviour
{
void Start()
{
}
@davepape
davepape / globe.py
Last active June 24, 2022 09:33
Draws a sphere with a texture.
from pyglet.gl import *
from math import *
tex = pyglet.image.load('biosphere.png').get_texture()
step = 10
vlists = []
for lat in range(-90,90,step):
verts = []
@davepape
davepape / LeapPyglet-udp.py
Last active December 9, 2021 21:19
Pyglet program to receive hand & finger data from the hacked "LeapSample.py" program (via UDP) and render it in 2D
#
# Receive hand & finger data from "LeapSample.py" via UDP and render it in 2D
#
from pyglet.gl import *
# Create a UDP socket to receive the data
import socket
insock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Listen to port 5000
insock.bind(('',5000))
@davepape
davepape / Navigator.cs
Last active November 1, 2021 13:38
simple steamvr navigator
// Super-simple navigation for SteamVR. Attach this script to a Unity GameObject, and make the SteamVR CameraRig a child of that object.
// Travels in the direction that the left controller is pointing, speed scaled by how much the trigger is pulled.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Valve.VR;
public class Navigator : MonoBehaviour
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class QuitOnEsc : MonoBehaviour
{
void Start()
{
}
@davepape
davepape / texturedSquare_PIL.py
Last active June 17, 2021 13:57
Pyglet program to draw a single textured square - same as texturedSquare.py, except that it uses PIL (Python Image Library) to load the texture image, and then explicitly makes the OpenGL calls to create the texture (so that different tex parameters can be used).
import sys, time, math, os, random
import Image
from pyglet.gl import *
window = pyglet.window.Window()
keyboard = pyglet.window.key.KeyStateHandler()
window.push_handlers(keyboard)
def loadTexture(filename):
@davepape
davepape / texturedSquare.py
Last active May 1, 2020 21:40
pyglet program drawing a single textured square. The square can be moved, rotated, and scaled, to demonstrate how the image remains attached to the shape.
import sys, time, math, os, random
from pyglet.gl import *
window = pyglet.window.Window()
keyboard = pyglet.window.key.KeyStateHandler()
window.push_handlers(keyboard)
class TexturedSquare:
def __init__(self, width, height, xpos, ypos, texturefile):
@davepape
davepape / circle.py
Created September 19, 2013 12:44
draw a circle
# circle.py
# by Dave Pape, for DMS 423
#
# draws a circle, where the points for the vertex list are computed at run-time
from math import *
from pyglet.gl import *
window = pyglet.window.Window()
@davepape
davepape / 360VideoSphere.cs
Last active March 5, 2020 23:59
Create a sphere that a 360-video (or still image) texture can be applied to. This is the same as LatLonSphere.cs, except that the vertex order is tweaked so that the sphere will be visible from the inside, rather than outside.
/*
Create Unity mesh data for a sphere, which can be used with a video (or still) texture from a 360-camera.
The mesh is created so that it will be visible when the viewer is inside, rather than outside, of the sphere, with Unity's default backface-culling mode.
Texture coordinates are based on latitude & longitude (ie an equirectangular map projection) which matches the images from the 360-cameras that we use.
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LatLonSphere : MonoBehaviour
@davepape
davepape / gpw.cs
Last active November 19, 2019 18:46
Convert SEDAC global population data into a texture.
/*
Visualize data from SEDAC's Gridded Population of the World data set - https://sedac.ciesin.columbia.edu/data/set/gpw-v4-population-count-rev11
Parses the population counts and converts the data into a greyscale texture.
The data file must be in ASCII format, with its extension changed to ".txt" in order for Unity to recognize it as a TextAsset.
*/
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;