Skip to content

Instantly share code, notes, and snippets.

View cjcliffe's full-sized avatar

Charles J. Cliffe cjcliffe

  • Cubic Productions
  • Lansdowne, Ontario, Canada
  • X @ccliffe
View GitHub Profile
@cjcliffe
cjcliffe / scramble.c
Created September 23, 2012 22:35
Dreamcast ISO prepartion tool
#include <stdio.h>
#include <stdlib.h>
#define MAXCHUNK (2048*1024)
static unsigned int seed;
void my_srand(unsigned int n)
{
seed = n & 0xffff;
@cjcliffe
cjcliffe / cube_noscene_pointlight.html
Created May 18, 2012 23:51
Basic test with cube, light and no scene
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>
CubicVR.js: Basic Textured Cube
</title>
<script src="../../CubicVR.js" type="text/javascript">
</script>
<script type='text/javascript'>
@cjcliffe
cjcliffe / heightfield_test.html
Created March 10, 2012 22:44
Debugging ammo.js heightfield
<html>
<head>
<script src="ammo.js" type='text/javascript'></script>
<script type='text/javascript'>
var upIndex = 1;
var maxHeight = 100;
var flipQuadEdges=true;
var points = [0, 1, 2, 3,
@cjcliffe
cjcliffe / ml_manual.js
Created October 16, 2011 22:02
Manual mainloop setInterval with locked framerate step
var interval;
// finishes when time-stepped 30fps reaches a virtual 20 seconds (600/30 = 20)
var ml = new CubicVR.MainLoop(function(timer,gl) {
// ...
if (timer.getNumUpdates()===600) {
clearInterval(interval);
finished();
}
}, true, true); // true 3rd param prevents mainloop from starting..
@cjcliffe
cjcliffe / box_animated.js
Created October 11, 2011 23:30
Example of new animation constructor /w .get(xml/json) support
// SceneObject with motion constructor, xml/json/id/url compatible.
var boxObject = new CubicVR.SceneObject({
mesh:boxMesh,
motion: {
position: {
0.0: { x: 0, y: 1 },
1.0: { x: 1 },
2.0: { x: -1, y: 0 },
3.0: { x: -0.5 },
4.0: { x: 0, y: 1 },
@cjcliffe
cjcliffe / CustomShaderMinimal.vfs
Created September 23, 2011 20:46
Minimal Custom Shader with full pipeline rendering for CubicVR.js
<script id="vs" type="x-shader/x-vertex">
void main(void)
{
vertexTexCoordOut = cubicvr_texCoord();
gl_Position = matrixProjection * matrixModelView * cubicvr_transform();
vertexNormalOut = matrixNormal * cubicvr_normal();
cubicvr_lighting();
@cjcliffe
cjcliffe / multisplit.js
Created September 16, 2011 03:00
Split string into array by multiple characters, useful for script parsing.
function multiSplit(split_str, split_chars) {
var arr = split_str.split(split_chars[0]);
for (var i = 1, iMax = split_chars.length; i < iMax; i++) {
var sc = split_chars[i];
for (var j = 0, jMax = arr.length; j < jMax; j++) {
var arsplit = arr[j].split(sc);
if (arsplit.length > 1) {
for (var k = 0; k < arsplit.length; k++) {
if (arsplit[k].trim() !== "") {
@cjcliffe
cjcliffe / keyboard_code_enums.js
Created September 1, 2011 01:21
Javascript Keycode Enums
var enums = {};
enums.keyboard = {
BACKSPACE: 8,
TAB: 9,
ENTER: 13,
SHIFT: 16,
CTRL: 17,
ALT: 18,
PAUSE: 19,
CAPS_LOCK: 20,
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
void gluInvertMatrix(const double m[16], double invOut[16])
{
double inv[16], det;
int i;
@cjcliffe
cjcliffe / xml2json-badgerfish.js
Created March 27, 2011 19:44
XML Dom to Badgerfish JSON
function xml2badgerfish(xmlDoc) {
var jsonData = {};
var nodeStack = [];
var i, iMax, iMin;
var n = xmlDoc;
var j = jsonData;
var cn, tn;
var regEmpty = /^\s+|\s+$/g;