Cliff Biffle avatar Cliff Biffle committed 9aeccac

Removed triangulated and mesh rendering, in the interest of merely being a Kinect *viewer* and not inferring data where there isn't any.

Comments (0)

Files changed (5)

English.lproj/MainMenu.xib

 									<reference key="NSOnImage" ref="35465992"/>
 									<reference key="NSMixedImage" ref="502551668"/>
 								</object>
-								<object class="NSMenuItem" id="264846174">
-									<reference key="NSMenu" ref="466310130"/>
-									<bool key="NSIsDisabled">YES</bool>
-									<bool key="NSIsSeparator">YES</bool>
-									<string key="NSTitle"/>
-									<string key="NSKeyEquiv"/>
-									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="35465992"/>
-									<reference key="NSMixedImage" ref="502551668"/>
-								</object>
-								<object class="NSMenuItem" id="719261243">
-									<reference key="NSMenu" ref="466310130"/>
-									<string key="NSTitle">Point Cloud</string>
-									<string key="NSKeyEquiv">1</string>
-									<int key="NSKeyEquivModMask">1048576</int>
-									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="35465992"/>
-									<reference key="NSMixedImage" ref="502551668"/>
-								</object>
-								<object class="NSMenuItem" id="477715379">
-									<reference key="NSMenu" ref="466310130"/>
-									<string key="NSTitle">Mesh</string>
-									<string key="NSKeyEquiv">2</string>
-									<int key="NSKeyEquivModMask">1048576</int>
-									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="35465992"/>
-									<reference key="NSMixedImage" ref="502551668"/>
-								</object>
-								<object class="NSMenuItem" id="578250298">
-									<reference key="NSMenu" ref="466310130"/>
-									<string key="NSTitle">Filled</string>
-									<string key="NSKeyEquiv">3</string>
-									<int key="NSKeyEquivModMask">1048576</int>
-									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="35465992"/>
-									<reference key="NSMixedImage" ref="502551668"/>
-								</object>
 							</object>
 						</object>
 					</object>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<string key="label">selectPointCloudRenderer:</string>
-						<reference key="source" ref="1014"/>
-						<reference key="destination" ref="719261243"/>
-					</object>
-					<int key="connectionID">543</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
 						<string key="label">toggleDepthFieldUpdates:</string>
 						<reference key="source" ref="1014"/>
 						<reference key="destination" ref="406940919"/>
 					</object>
 					<int key="connectionID">568</int>
 				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">selectMeshRenderer:</string>
-						<reference key="source" ref="1014"/>
-						<reference key="destination" ref="477715379"/>
-					</object>
-					<int key="connectionID">573</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">selectSolidRenderer:</string>
-						<reference key="source" ref="1014"/>
-						<reference key="destination" ref="578250298"/>
-					</object>
-					<int key="connectionID">574</int>
-				</object>
 			</object>
 			<object class="IBMutableOrderedSet" key="objectRecords">
 				<object class="NSArray" key="orderedObjects">
 							<bool key="EncodedWithXMLCoder">YES</bool>
 							<reference ref="102151532"/>
 							<reference ref="237841660"/>
-							<reference ref="719261243"/>
-							<reference ref="477715379"/>
-							<reference ref="578250298"/>
 							<reference ref="406940919"/>
 							<reference ref="26014547"/>
-							<reference ref="264846174"/>
 							<reference ref="1032511002"/>
 						</object>
 						<reference key="parent" ref="586577488"/>
 						<reference key="parent" ref="439893737"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">536</int>
-						<reference key="object" ref="719261243"/>
-						<reference key="parent" ref="466310130"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">539</int>
-						<reference key="object" ref="477715379"/>
-						<reference key="parent" ref="466310130"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">541</int>
-						<reference key="object" ref="578250298"/>
-						<reference key="parent" ref="466310130"/>
-					</object>
-					<object class="IBObjectRecord">
 						<int key="objectID">550</int>
 						<reference key="object" ref="406940919"/>
 						<reference key="parent" ref="466310130"/>
 						<reference key="parent" ref="466310130"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">562</int>
-						<reference key="object" ref="264846174"/>
-						<reference key="parent" ref="466310130"/>
-					</object>
-					<object class="IBObjectRecord">
 						<int key="objectID">567</int>
 						<reference key="object" ref="1032511002"/>
 						<reference key="parent" ref="466310130"/>
 					<string>5.ImportedFromIB2</string>
 					<string>533.CustomClassName</string>
 					<string>533.IBPluginDependency</string>
-					<string>536.IBPluginDependency</string>
-					<string>539.IBPluginDependency</string>
-					<string>541.IBPluginDependency</string>
 					<string>550.IBPluginDependency</string>
 					<string>556.IBPluginDependency</string>
 					<string>56.IBPluginDependency</string>
 					<string>56.ImportedFromIB2</string>
 					<string>560.IBPluginDependency</string>
-					<string>562.IBPluginDependency</string>
 					<string>567.IBPluginDependency</string>
 					<string>57.IBEditorWindowLastContentRect</string>
 					<string>57.IBPluginDependency</string>
 					<string>{74, 862}</string>
 					<string>{{6, 978}, {478, 20}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>{{547, 663}, {238, 173}}</string>
+					<string>{{547, 733}, {238, 103}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>{{475, 832}, {234, 43}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<integer value="1"/>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>{{392, 653}, {223, 183}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<integer value="1"/>
 						<bool key="EncodedWithXMLCoder">YES</bool>
 						<object class="NSArray" key="dict.sortedKeys">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>selectMeshRenderer:</string>
-							<string>selectPointCloudRenderer:</string>
-							<string>selectSolidRenderer:</string>
 							<string>toggleAnaglyph:</string>
 							<string>toggleDepthFieldUpdates:</string>
 							<string>toggleTextures:</string>
 							<string>id</string>
 							<string>id</string>
 							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
 						</object>
 					</object>
 					<object class="NSMutableDictionary" key="actionInfosByName">
 						<bool key="EncodedWithXMLCoder">YES</bool>
 						<object class="NSArray" key="dict.sortedKeys">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>selectMeshRenderer:</string>
-							<string>selectPointCloudRenderer:</string>
-							<string>selectSolidRenderer:</string>
 							<string>toggleAnaglyph:</string>
 							<string>toggleDepthFieldUpdates:</string>
 							<string>toggleTextures:</string>
 						<object class="NSMutableArray" key="dict.values">
 							<bool key="EncodedWithXMLCoder">YES</bool>
 							<object class="IBActionInfo">
-								<string key="name">selectMeshRenderer:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">selectPointCloudRenderer:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">selectSolidRenderer:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
 								<string key="name">toggleAnaglyph:</string>
 								<string key="candidateClassName">id</string>
 							</object>
 @property(assign, nonatomic) BOOL textured;
 @property(nonatomic) BOOL recording;
 @property(assign, nonatomic) projective_transform_t colorTransform;
-@property(assign, nonatomic) NSString *polygonMode;
 
 @property (assign) NSData *latestDepthSamples;
 @property (assign) NSData *latestColorSamples;
 
-- (IBAction) selectPointCloudRenderer: sender;
-- (IBAction) selectMeshRenderer: sender;
-- (IBAction) selectSolidRenderer: sender;
-
 - (IBAction) toggleDepthFieldUpdates: sender;
 - (IBAction) toggleAnaglyph: sender;
 - (IBAction) toggleTextures: sender;
 @synthesize frozen;
 @synthesize anaglyph;
 @synthesize recording;
-@synthesize polygonMode;
 
 #pragma mark --- Trivial NSView Overrides ---
 
   };
   
   self.renderer = [[[KVRenderer alloc] init] autorelease];
-  self.polygonMode = KVFilledPolygonMode;
 }
 
 #pragma mark --- GL Stuff ---
     
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   
-  NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
-                           self.polygonMode, KVPolygonMode, 
-                           nil];
-  
   if (self.anaglyph) {
     [self updateProjectionWithOffset: INTEROCULAR_DISTANCE / 2];
     [self updateModelViewWithOffset: INTEROCULAR_DISTANCE / 2];
   }
   
   // Draw right eye or center.
-  [renderer drawInCurrentOpenGLContextWithOptions: options];
+  [renderer drawInCurrentOpenGLContextWithOptions: nil];
   
   if (self.anaglyph) {
     // Draw left eye.
     [self updateProjectionWithOffset: -INTEROCULAR_DISTANCE / 2];
     [self updateModelViewWithOffset: -INTEROCULAR_DISTANCE / 2];
     glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE);
-    [renderer drawInCurrentOpenGLContextWithOptions: options];
+    [renderer drawInCurrentOpenGLContextWithOptions: nil];
     
     glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
   }
 
 #pragma mark --- Actions ---
 
-- (IBAction) selectPointCloudRenderer: sender {
-  self.polygonMode = KVDottedPolygonMode;
-  [self setNeedsDisplay: YES];
-}
-
-- (IBAction) selectMeshRenderer: sender {
-  self.polygonMode = KVWireframePolygonMode;
-  [self setNeedsDisplay: YES];
-}
-
-- (IBAction) selectSolidRenderer: sender {
-  self.polygonMode = KVFilledPolygonMode;
-  [self setNeedsDisplay: YES];
-}
-
 - (IBAction) toggleDepthFieldUpdates: sender {
   self.frozen = !self.frozen;
   [sender setState: self.frozen? NSOnState : NSOffState];
 
 - (void) drawInCurrentOpenGLContextWithOptions: (NSDictionary *) options;
 
-@end
-
-extern NSString * const KVPolygonMode;
-extern NSString * const KVFilledPolygonMode;
-extern NSString * const KVWireframePolygonMode;
-extern NSString * const KVDottedPolygonMode;
+@end
 #import "KVRenderer.h"
 #import "utility.h"
 
-NSString * const KVPolygonMode = @"KVPolygonMode";
-NSString * const KVFilledPolygonMode = @"KVFilledPolygonMode";
-NSString * const KVWireframePolygonMode = @"KVWireframePolygonMode";
-NSString * const KVDottedPolygonMode = @"KVDottedPolygonMode";
-
 @interface KVRenderer ()
 - (void) fillStaticComponents;
 
 @property GLuint depthTexture;
 
 - (void) renderAsPointsWithOptions: (NSDictionary *) options;
-- (void) renderAsMeshWithOptions: (NSDictionary *) options;
-- (void) renderAsSolidWithOptions: (NSDictionary *) options;
 @end
 
 @implementation KVRenderer
   glBindTexture(GL_TEXTURE_2D, depthTexture);
   glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE16, 640, 480, 0, GL_LUMINANCE, GL_UNSIGNED_SHORT, &depthImage);
   
-  id modeOption = [options valueForKey: KVPolygonMode];
-  if (modeOption == KVWireframePolygonMode) {
-    [self renderAsMeshWithOptions: options];
-  } else if (modeOption == KVDottedPolygonMode) {
-    [self renderAsPointsWithOptions: options];
-  } else {
-    [self renderAsSolidWithOptions: options];
-  }
+  [self renderAsPointsWithOptions: options];
   
   NSTimeInterval end = [NSDate timeIntervalSinceReferenceDate];
   vertexPlacementCount++;
   glDisableClientState(GL_VERTEX_ARRAY);
 }
 
-- (void) renderAsSolidWithOptions: (NSDictionary *) options {
-  int jump = 2;
-  
-  glColor3f(1, 1, 1);
-  glNormal3f(0, 0, 1);
-  
-  int vidx = 0;
-  
-  for (int y = 0; y < 480 - 1; y++) {
-    BOOL inStrip = NO;
-    int lastDepth = (int) rays[vidx].z;
-    for (int x = 0; x < 640; x++, vidx++) {
-      for (int step = 0; step < 640 * 2; step += 640) {
-        int z = (int) rays[vidx + step].z;
-        int delta = z - lastDepth;
-        lastDepth = z;
-        
-        if (delta < -jump || delta > jump || z == 0 || z == 2047) {
-          if (inStrip) {
-            glEnd();
-            inStrip = NO;
-          }
-        } else {
-          if (!inStrip) {
-            glBegin(GL_TRIANGLE_STRIP);
-            inStrip = YES;
-          }
-          glNormal3fv(&normals[vidx + step].x);
-          glVertex3fv(&rays[vidx + step].x);
-        }
-        
-        if (!inStrip) break;
-      }
-    }
-    if (inStrip) glEnd();
-  }
-}
-
-- (void) renderAsMeshWithOptions: (NSDictionary *) options {
-  float jump = 0.1f;
-  
-  glBegin(GL_LINES);
-  glColor3f(1, 1, 1);
-  int vidx = 0;
-  for (int y = 0; y < 480 - 1; y++) {
-    vidx = y * 640;
-    for (int x = 0; x < 640 - 1; x++, vidx++) {
-      float cornerZ = rays[vidx].z;
-      if (cornerZ == 0.f) continue;
-      
-      float delta;
-      
-      delta = cornerZ - rays[vidx + 640].z;
-      if (delta > -jump && delta < jump && delta != cornerZ) {
-        glVertex3fv(&rays[vidx].x);
-        glVertex3fv(&rays[vidx + 640].x);
-      } 
-      
-      delta = cornerZ - rays[vidx + 1].z;
-      if (delta > -jump && delta < jump && delta != cornerZ) {
-        glVertex3fv(&rays[vidx].x);
-        glVertex3fv(&rays[vidx + 1].x);
-      } 
-    }
-  }
-  glEnd();
-}
-
 // We pre-fill the X and Y components with distance from the center of
 // the image.  These values never make it to the rasterizer: they are
 // merely input to the vertex shader that performs perspective correction.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.