Skip to content

Commit

Permalink
surfaces built
Browse files Browse the repository at this point in the history
  • Loading branch information
obviousjim committed Jun 26, 2012
1 parent 9bc81b8 commit b285e49
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 16 deletions.
Expand Up @@ -44,7 +44,6 @@
E788F1B515960FEB0089EBC2 /* Wrappers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E788F09B15960FE90089EBC2 /* Wrappers.cpp */; };
E788F1B615960FEB0089EBC2 /* readme.md in Resources */ = {isa = PBXBuildFile; fileRef = E788F09C15960FE90089EBC2 /* readme.md */; };
E788F1B715960FEB0089EBC2 /* update-projects.py in Resources */ = {isa = PBXBuildFile; fileRef = E788F09F15960FE90089EBC2 /* update-projects.py */; };
E788F1F8159610140089EBC2 /* install.xml in Resources */ = {isa = PBXBuildFile; fileRef = E788F1EF159610140089EBC2 /* install.xml */; };
E788F1F9159610140089EBC2 /* tinyxml.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E788F1F1159610140089EBC2 /* tinyxml.cpp */; };
E788F1FA159610140089EBC2 /* tinyxmlerror.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E788F1F3159610140089EBC2 /* tinyxmlerror.cpp */; };
E788F1FB159610140089EBC2 /* tinyxmlparser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E788F1F4159610140089EBC2 /* tinyxmlparser.cpp */; };
Expand All @@ -57,7 +56,6 @@
E788F28D1596130C0089EBC2 /* ofxRGBDPlayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E788F2521596130C0089EBC2 /* ofxRGBDPlayer.cpp */; };
E788F28F1596130C0089EBC2 /* ofxRGBDScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E788F2561596130C0089EBC2 /* ofxRGBDScene.cpp */; };
E788F2901596130C0089EBC2 /* ofxRGBDVideoDepthSequence.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E788F2581596130C0089EBC2 /* ofxRGBDVideoDepthSequence.cpp */; };
E788F307159614710089EBC2 /* opencv.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E788F2F9159614710089EBC2 /* opencv.a */; };
E788F308159614710089EBC2 /* opencv_calib3d.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E788F2FA159614710089EBC2 /* opencv_calib3d.a */; };
E788F309159614710089EBC2 /* opencv_contrib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E788F2FB159614710089EBC2 /* opencv_contrib.a */; };
E788F30A159614710089EBC2 /* opencv_core.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E788F2FC159614710089EBC2 /* opencv_core.a */; };
Expand Down Expand Up @@ -167,7 +165,6 @@
E788F09C15960FE90089EBC2 /* readme.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = readme.md; sourceTree = "<group>"; };
E788F09E15960FE90089EBC2 /* ofxCv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxCv.h; sourceTree = "<group>"; };
E788F09F15960FE90089EBC2 /* update-projects.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = "update-projects.py"; sourceTree = "<group>"; };
E788F1EF159610140089EBC2 /* install.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = install.xml; sourceTree = "<group>"; };
E788F1F1159610140089EBC2 /* tinyxml.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tinyxml.cpp; sourceTree = "<group>"; };
E788F1F2159610140089EBC2 /* tinyxml.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tinyxml.h; sourceTree = "<group>"; };
E788F1F3159610140089EBC2 /* tinyxmlerror.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tinyxmlerror.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -269,7 +266,6 @@
E788F2F4159614710089EBC2 /* background_segm.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = background_segm.hpp; sourceTree = "<group>"; };
E788F2F5159614710089EBC2 /* tracking.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = tracking.hpp; sourceTree = "<group>"; };
E788F2F6159614710089EBC2 /* video.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = video.hpp; sourceTree = "<group>"; };
E788F2F9159614710089EBC2 /* opencv.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = opencv.a; sourceTree = "<group>"; };
E788F2FA159614710089EBC2 /* opencv_calib3d.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = opencv_calib3d.a; sourceTree = "<group>"; };
E788F2FB159614710089EBC2 /* opencv_contrib.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = opencv_contrib.a; sourceTree = "<group>"; };
E788F2FC159614710089EBC2 /* opencv_core.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = opencv_core.a; sourceTree = "<group>"; };
Expand Down Expand Up @@ -309,7 +305,6 @@
E4C2424810CC5A17004149E2 /* Cocoa.framework in Frameworks */,
E4C2424910CC5A17004149E2 /* IOKit.framework in Frameworks */,
E7121EE11549997400BA5A72 /* libz.dylib in Frameworks */,
E788F307159614710089EBC2 /* opencv.a in Frameworks */,
E788F308159614710089EBC2 /* opencv_calib3d.a in Frameworks */,
E788F309159614710089EBC2 /* opencv_contrib.a in Frameworks */,
E788F30A159614710089EBC2 /* opencv_core.a in Frameworks */,
Expand Down Expand Up @@ -568,7 +563,6 @@
E788F1EE159610140089EBC2 /* ofxXmlSettings */ = {
isa = PBXGroup;
children = (
E788F1EF159610140089EBC2 /* install.xml */,
E788F1F0159610140089EBC2 /* libs */,
E788F1F5159610140089EBC2 /* src */,
);
Expand Down Expand Up @@ -847,7 +841,6 @@
E788F2F8159614710089EBC2 /* osx */ = {
isa = PBXGroup;
children = (
E788F2F9159614710089EBC2 /* opencv.a */,
E788F2FA159614710089EBC2 /* opencv_calib3d.a */,
E788F2FB159614710089EBC2 /* opencv_contrib.a */,
E788F2FC159614710089EBC2 /* opencv_core.a */,
Expand Down Expand Up @@ -977,7 +970,6 @@
E788F1AC15960FEB0089EBC2 /* .gitignore in Resources */,
E788F1B615960FEB0089EBC2 /* readme.md in Resources */,
E788F1B715960FEB0089EBC2 /* update-projects.py in Resources */,
E788F1F8159610140089EBC2 /* install.xml in Resources */,
E788F2841596130C0089EBC2 /* README in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
101 changes: 95 additions & 6 deletions DelaunyTriangulator/src/testApp.cpp
Expand Up @@ -140,7 +140,6 @@ void testApp::update(){
player.getVideoPlayer().setFrame( player.getVideoPlayer().getCurrentFrame() + 1);
player.update();
createTriangulation();

}
}

Expand Down Expand Up @@ -186,20 +185,30 @@ void testApp::draw(){
glEnable(GL_DEPTH_TEST);
player.getVideoPlayer().getTextureReference().bind();
ofEnableAlphaBlending();
/*
ofSetColor(255, 255, 255, 255);
glShadeModel(GL_FLAT);
ofEnableLighting();
ofLight l;
l.setPosition(lightX,lightY,lightZ);
l.setAttenuation(0,.01,0);
l.enable();
triangulatedMesh.draw();
ofDisableLighting();
*/

// triangulatedMesh.draw();
// triangulatedMesh.drawWireframe();
// ofDisableLighting();

ofSetLineWidth(4);
ofBlendMode(OF_BLENDMODE_ADD);
ofSetLineWidth(1);
//s ofBlendMode(OF_BLENDMODE_ADD);
// triangulatedMesh.drawWireframe();
player.getVideoPlayer().getTextureReference().unbind();

latticeMesh.drawWireframe();
// glBegin(GL_POINTS);
// glColor3f(1.0,0,0);
// for(int i = 0; i < innerPoints.size(); i++) glVertex3f(innerPoints[i].x, innerPoints[i].y, innerPoints[i].z);
// glEnd();

// //draw face normals
// ofSetLineWidth(1);
Expand Down Expand Up @@ -341,9 +350,89 @@ void testApp::createTriangulation(){
}

//Create a lattice structure
latticeMesh.clear();

//copy the main vertices into the lattice mesh
for(int i = 0; i < triangulatedMesh.getNumVertices(); i++){
latticeMesh.addVertex(triangulatedMesh.getVertex(i));
latticeMesh.addNormal(triangulatedMesh.getNormal(i));
}

innerPoints.clear();
backInnerPoints.clear();
backPoints.clear();




//for each triangle, find the centroid and create 3 new vertices that move a fixed distane towards the center
//then
//then stitch them

for(int i = 0 ; i < triangulatedMesh.getNumIndices(); i+=3){

ofIndexType o1 = triangulatedMesh.getIndex(i);
ofIndexType o2 = triangulatedMesh.getIndex(i+1);
ofIndexType o3 = triangulatedMesh.getIndex(i+2);

ofVec3f& va = triangulatedMesh.getVertices()[o1];
ofVec3f& vb = triangulatedMesh.getVertices()[o2];
ofVec3f& vc = triangulatedMesh.getVertices()[o3];

ofVec3f& center = faceCenters[i/3];
ofVec3f& normal = faceNormals[i/3];

ofVec3f innerA = va + (center - va).normalized() * 2;
ofVec3f innerB = vb + (center - vb).normalized() * 2;
ofVec3f innerC = vc + (center - vc).normalized() * 2;

innerPoints.push_back(innerA);
innerPoints.push_back(innerB);
innerPoints.push_back(innerC);


backPoints.push_back(va - triangulatedMesh.getNormal(o1) * 2);
backPoints.push_back(vb - triangulatedMesh.getNormal(o2) * 2);
backPoints.push_back(vc - triangulatedMesh.getNormal(o3) * 2);

backInnerPoints.push_back(innerA - normal*2);
backInnerPoints.push_back(innerB - normal*2);
backInnerPoints.push_back(innerC - normal*2);

//get the indices of the inner points
ofIndexType i1 = latticeMesh.getNumVertices();
ofIndexType i2 = i1+1;
ofIndexType i3 = i1+2;

//add the inner points to the mesh
latticeMesh.addVertex(innerA);
latticeMesh.addVertex(innerB);
latticeMesh.addVertex(innerC);

latticeMesh.addNormal(normal);
latticeMesh.addNormal(normal);
latticeMesh.addNormal(normal);

//stitch the 3 quads around the inner mesh
latticeMesh.addIndex(o1);latticeMesh.addIndex(o2);latticeMesh.addIndex(i2);
latticeMesh.addIndex(i2);latticeMesh.addIndex(i1);latticeMesh.addIndex(o1);

latticeMesh.addIndex(o2);latticeMesh.addIndex(o3);latticeMesh.addIndex(i3);
latticeMesh.addIndex(i3);latticeMesh.addIndex(i2);latticeMesh.addIndex(o2);

latticeMesh.addIndex(o3);latticeMesh.addIndex(o1);latticeMesh.addIndex(i1);
latticeMesh.addIndex(i1);latticeMesh.addIndex(i3);latticeMesh.addIndex(o3);

//add back vertices
ofIndexType bo1 = latticeMesh.getNumVertices();
ofIndexType bo2 = bo1+1;
ofIndexType bo3 = bo1+2;

latticeMesh.addVertex(innerA);
latticeMesh.addVertex(innerB);
latticeMesh.addVertex(innerC);

}



}
Expand Down
9 changes: 7 additions & 2 deletions DelaunyTriangulator/src/testApp.h
Expand Up @@ -62,11 +62,16 @@ class testApp : public ofBaseApp{
ofFbo previewFBO;

ofMesh triangulatedMesh;

ofMesh latticeMesh;

vector<cv::Point2f> featurePoints;
vector<ofVec3f> faceNormals;
vector<ofVec3f> faceCenters;

vector<ofVec3f> innerPoints;
vector<ofVec3f> backPoints;
vector<ofVec3f> backInnerPoints;


ofxButton loadNew;
ofxDelaunay triangulate;

Expand Down

0 comments on commit b285e49

Please sign in to comment.