Skip to content

Instantly share code, notes, and snippets.

@roxlu
Created July 15, 2011 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roxlu/1084689 to your computer and use it in GitHub Desktop.
Save roxlu/1084689 to your computer and use it in GitHub Desktop.
ofxGeometry - PRE BETA - testing ofxGeometry with isosurfaces
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
ofSetFrameRate(60);
ofSetVerticalSync(true);
ofBackground(33);
ax.setup(15);
float s = 0.01;
iso = gts.createIsoSurface(100,100);
float* data = new float[(iso->getWidth() * iso->getHeight())];
for(int k = 0; k < 100; ++k) {
for(int j = 0; j < iso->getHeight() ; ++j) {
for(int i = 0; i < iso->getWidth(); ++i) {
data[(j*iso->getWidth())+i] = ofNoise(i*s, j*s, k*s);
}
}
iso->addLayer(data);
}
iso->createIsoSurface(0.4);
iso->fillVertexData(vd);
vbo.setVertexData(vd);
delete[] data;
cout<< parts.size() << endl;
}
//--------------------------------------------------------------
void testApp::update(){
}
//--------------------------------------------------------------
void testApp::draw(){
cam.place();
ax.draw();
glScalef(0.3,.3,.3);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
vbo.drawArrays(GL_TRIANGLES, 0, vd.getNumVertices() * 3);
}
//--------------------------------------------------------------
void testApp::keyPressed(int key){
}
//--------------------------------------------------------------
void testApp::keyReleased(int key){
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){
}
// =======================
#pragma once
#include "ofMain.h"
#include "ofxGts.h"
#include "ofxOpenGL.h"
class Particle {
public:
Particle() {
alive = (int)ofRandom(0,5);
}
bool operator()(const Particle& p) {
return p.alive;
}
int alive;
};
class testApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void keyPressed (int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
ofxGtsIsoSurface* iso;
ofxGtsSurface* surf;
ofxGts gts;
EasyCam cam;
Axis ax;
VertexData vd;
VBO vbo;
vector<Particle> parts;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment