Skip to content

Instantly share code, notes, and snippets.

@onedayitwillmake
onedayitwillmake / cinderlightapp.cpp
Created February 22, 2011 22:35
Libcinder gl::light vs straight gl calls
#include "cinder/app/AppBasic.h"
#include "cinder/gl/gl.h"
#include "cinder/gl/Texture.h"
#include "cinder/gl/Light.h"
#include "cinder/gl/Material.h"
#include "cinder/MayaCamUI.h"
using namespace ci;
using namespace ci::app;
using namespace std;
@onedayitwillmake
onedayitwillmake / gist:905106
Created April 6, 2011 03:56
Cinder drawing a billboard plane
ci::Vec3f mRight, mUp;
_mayaCam.getCamera().getBillboardVectors(&mRight, &mUp);
ci::gl::drawBillboard( ci::Vec3f::zero(), ci::Vec2f(100.0f, 100.0f), 0.0f, mRight, mUp);
@onedayitwillmake
onedayitwillmake / gist:905108
Created April 6, 2011 03:57
A cinder app that draws 10,000 quad sprites into a Trimesh
/**
* EclipseLovesCinder example application
*
* * On first run, run Project -> Clean...
* * If you change your project name go into debug configurations (arrow next to bug icon), and modify where the debug application will run from
*
* This project is released under public domain, do whatever with it.
*
*
* Mario Gonzalez
@onedayitwillmake
onedayitwillmake / SphereUniform.cpp
Created April 6, 2011 04:30
Uniformly distributed points on a sphere
float theta = M_PI * (3.0 - sqrtf(5.0));
float o = 2.0f / count;
float radius = 1500;
for(int i = 0; i < count; ++i)
{
float y = i * o - 1 + (o / 2);
float r = sqrtf(1 - y*y);
float phi = i * theta;
ci::Vec3f pos = ci::Vec3f( cosf(phi)*r, y, sinf(phi)*r) * radius;
}
/**
* EclipseLovesCinder example application
*
* * On first run, run Project -> Clean...
* * If you change your project name go into debug configurations (arrow next to bug icon), and modify where the debug application will run from
*
* This project is released under public domain, do whatever with it.
*
*
* Mario Gonzalez
@onedayitwillmake
onedayitwillmake / PlaneGeometry
Created April 8, 2011 23:35
Generate geometry for a 3d plane and insert into ci::TriMesh
void QuadDistrustApp::createPlane()
{
_planeMesh = new ci::TriMesh();
_planeMesh->clear();
float segmentsW = 4;
float segmentsH = 4;
float width = 100;
float height = width;
@onedayitwillmake
onedayitwillmake / gist:937291
Created April 22, 2011 18:16
RealtimeMultiplayerGame stubb
/**
File:
AbstractServerGame.js
Created By:
Mario Gonzalez
Project:
RealtimeMultiplayerNodeJS
Abstract:
This class is the base Game controller in RealtimeMultiplayerGame on the server side.
It provides things such as dropping players, and contains a ServerNetChannel
@onedayitwillmake
onedayitwillmake / gist:943705
Created April 27, 2011 04:19
bison encoding
// BISON
entitiesࢮ|1,0,-1,197,188,0|2,0,-1,105,254,0|3,0,-1,383,38,0|4,0,-1,339,227,0|5,0,-1,373,235,0|6,0,-1,381,168,0|7,0,-1,447,327,0|8,0,-1,564,68,0|9,0,-1,17,166,0|10,0,-1,17,319,0|11,0,-1,17,29,0|12,0,-1,215,-30,0|13,0,-1,260,86,0|14,0,-1,273,235,0|15,0,-1,183,367,0|16,0,-1,621,199,0|17,0,-1,17,64,0|18,0,-1,207,72,0|19,0,-1,318,403,0|20,0,-1,250,-26,0|21,0,-1,170,237,0|22,0,-1,150,459,0|23,0,-1,260,172,0|24,0,-1,332,114,0|25,0,-1,636,168,0|26,0,-1,217,280,0|27,0,-1,423,214,0|28,0,-1,422,275,0|29,0,-1,107,339,0|30,0,-1,330,450,0|31,0,-1,230,154,0|32,0,-1,683,254,0|33,0,-1,285,467,0|34,0,-1,597,85,0|35,0,-1,341,78,0|36,0,-1,683,223,0|37,0,-1,274,54,0|38,0,-1,405,3,0|39,0,-1,217,335,0|40,0,-1,658,239,0|41,0,-1,25,229,0|42,0,-1,313,284,0|43,0,-1,367,204,0|44,0,-1,17,202,0|45,0,-1,300,434,0|46,0,-1,415,311,0|47,0,-1,61,212,0|48,0,-1,96,375,0|49,0,-1,683,188,0|50,0,-1,73,273,0|51,0,-1,195,37,0|52,0,-1,615,136,0|53,0,-1,271,295,0|54,0,-1,324,195,0|55,0,-1,302,310,0|56,0,-1,284,-5,0|57,0,-1,247,276,0|58,0,-1,2
@onedayitwillmake
onedayitwillmake / gist:957548
Created May 5, 2011 18:06
Globe camera rotation
function render() {
zoom(curZoomSpeed);
rotation.x += (target.x - rotation.x) * 0.1;
rotation.y += (target.y - rotation.y) * 0.1;
distance += (distanceTarget - distance) * 0.3;
camera.position.x = distance * Math.sin(rotation.x) * Math.cos(rotation.y);
camera.position.y = distance * Math.sin(rotation.y);
camera.position.z = distance * Math.cos(rotation.x) * Math.cos(rotation.y);
/**
File:
PerlinNoiseTrait.js
Created By:
Mario Gonzalez
Project :
RealtimeMultiplayerNodeJS
Abstract:
Applies perlin noise to an objects velocity
Basic Usage: