Archive for the ‘3D graphics’ Category

Viewing auto-stereo images on VR headset

Saturday, July 29th, 2017

Recently upgraded my google cardboard experience with a Utopia360 Virtual Reality 3D headset for $20 bucks from Microcenter.  Really impressed with WebVR, Android cardboard and daydream sdks.  While there is  lots of content in vextex rendering as well as 360 degree images, I am starting from the tradition auto-stereo images.  Thanks to professor Davidhazy from RIT for giving some that were originally photographed on sliver halide film.

In this exercise, I am loading two sets of images, Andy’s portrait and balloon explosion — highspeed.  The code is implemented in javascript, available on Github, StereoView project.  device orientation triggers next image set upload.  This code is tested on a Samsung Note II with Chrome browser.  Try it out here.


Sunday, May 26th, 2013

An exercise of the Tesseract.

My employer before Perceptive Software had a logo that ‘could have been’ a Tesseract.

Rotate the Tesseract by mouse-over anywhere other than center.

Source code available here on GitHub.

Screen Shot 2013-06-23 at 8.15.02 PM



Random Dot Stereogram

Sunday, January 6th, 2013

It has been a few years since I was fascinated over random dot sterograms; 3D without glasses or special technology, just have to cross your eyes.. and a headache afterward. :)

Thanks to GPU Gems-chapter 41, here is some javascript to produce the RDS pair of a box (source code on GitHub).

WPF STL decoder

Wednesday, September 26th, 2012

For my most recent enrichment, this is my first exercise using WPF.  I am implementing a STL binary decoder in C#.  The ASCII format decoder is ‘work-in-progress’.

Visual Studio 2008 DecoderExercise project on GitHub.


Might you advice on Rhino v4 ?

Tuesday, August 21st, 2012

Prerequisite to building a Rhino plugin, I need to validate my understanding of the sketchfab upload process. I begin with a python script from the API page, my new token and a sample lamp OBJ file.


type in ‘pythonw’ and a successful upload delivers a screen dump of the file transfer along with an id and validating success confirmation.

pythonUpload1My credential works and now I am ready to write my own uploader test in C#.  From the API and python script, I gather the four necessary steps; 1) load CAD file, 2) convert to base64, 3) build JSON, 4) upload/post JSON.

Rhino v4 supports plugin development with Visual Studio 2008, C#, VB and C++.  The simplest for me is a C# dialog application with default controls and OpenFileDialog module.

Using FileStream, CAD file is read in as a byte array.

Since some CAD files (STL, PLY) can be in binary or ASCII format, a base64 conversion is used.  Thanks to C#, the conversion is available in the System.Convert library.

Screen Shot 2012-08-21 at 7.38.57 AMFollowing Sketchfab API, I am creating a JSON string with  below function.  After conversion to a byte array, HttpWebRequest uploads my content to sketchfab server.

Screen Shot 2012-08-21 at 7.43.04 AMUpon a successful upload, I receive a confirmation id and ‘success : true’.


It is exciting working on my first Rhino plugin with C#, Visual Studio 2008.  The body of code samples is massive (over 150+).  From McNeel’s dialog example, I am able to incorporate the test code user interface.

plugin2The challenge is getting access to the mesh data.  It seems that each example requires user to select data and I am at a loss how.  Might you share some wisdom ?  Here is my source code for ExporterTest and RhinoExporter (experiment).


Happy to have found the most recent Rhino 5 API documentation online.

sketchfab – exporter test

Sunday, August 12th, 2012

Exciting opportunity to develop exporter(s) for sketchfab.  The offer is to implement exporter plugin(s) for popular CAD software in exchange for sketchfab account for a year.  There are already three such implementations: AutoDesk-3dMax, Blender and Google-SketchUp.  I am looking into Rhino and Meshlab.

Rhino v5 beta is available in Mac OSX and Windows.  Python scripting is a big feature I have been anticipating for sometime.  Sadly, I did not witness its functionality in OSX beta WIP.  Any suggestion(s) ?  Windows Rhino v5 is only available for licensed Rhino users.  So, I downloaded Rhino v4 evaluation which does not support python.  Pray to the Rhino deity that the documentation and SDK is excellent and writing a C# plugin will be a cinch !

Meshlab is an open source project with seemingly good documentation on wiki.  But apparently there is nothing under ‘plugin’ ?  I did find these plugin examples and this official documentation which includes instruction on C++ plugin development as well as the project location and compile.  Meshlab is compiled with QT.  Might QT Creator be the magical tool I seek ?

Before the actual implementation, I thought to make a prototype.  The API specification is available on sketchfab, token is provided upon sign up.  My prototype is in C#; got it working quickly (praise to a good language, tools and user community, thank you!)  So, here is the Visual Studio 2005 C# application for uploading your CAD file to sketchfab.  Feel free to use this GitHub source code for your next exporter implementation (if it is helpful).

Screen Shot 2012-08-12 at 4.56.25 PM

Loading local OBJ file, javascript

Friday, August 10th, 2012

Last year I implemented four decoders (wireframe-basic) for formats: STL, PLY, OFF and OBJ.  The decoders were based on Devon Govett’s bmp decoder.  The bmp decoder loaded binary data via AJAX and type cast as uint8Array.

Screen Shot 2012-08-22 at 8.09.29 AM

Unfortunately, IE9 and prior versions didn’t support uint8Array type (IE10 does, horay) !  So, for the ASCII only CAD formats (OBJ, OFF), I re-wrote their decoders to keep the returned data in ASCII.

Screen Shot 2012-08-22 at 8.12.29 AMI extracted the AJAX into its own common Loader class for re-usability across multiple decoders.  In addition, thanks to Eric Bidelman’s article on local file access, I am adding local file load capability to the Loader class in my OBJ decoder.

Screen Shot 2012-08-22 at 8.22.02 AM

A byproduct of handling ASCII data is the possibility of line parsing with Regular Expression as I have learned from Three.js’ very own Mr. Doob.  This is somewhat put into practice in my work-in-progress Three.js-OFF-decoder.

Source code is available on Github – OBJDecoder, Github – OFFDecoder.

Hello Three.js

Tuesday, April 24th, 2012

Thanks to Mr. Doob, I am learning Three.js and adding a Geomview Object File Format (OFF) decoder.  For this first go around, I am implementing flat shading.  Here is the source code.  Apology, it only works if you are on a Mac (does not work on windows’ browsers).

Screen Shot 2012-04-24 at 5.45.40 PM

3D-Javascript-Geomview Object File Format (OFF) Decoder

Saturday, March 17th, 2012

For personal enrichment in 3D file format, this is my exercise on Geomview Object File Format, OFF.  OFF can be encoded in binary or ascii but this decoder handles only ascii at this point.  Like the previous decoders, this OFF demo has been tested on Firefox, Safari, Chrome and **Internet Explorer 10 preview**.

Documentation, C++ source code and sample OFF files maybe found at Holmes3D.NET.

I have implemented the ascii format and will continue to work on the binary decoder.  Here is the demo and source code in GitHub.

Attending Minnebar conference, I learned that STL, OBJ decoders have already been implemented with Three.js by Thingiview.js.

Screen Shot 2012-03-17 at 11.04.45 PM

3D – Javascript – PLY Decoder

Tuesday, January 31st, 2012

For personal enrichment in 3D file format, this is my exercise on Stanford ploygon file format (PLY).  PLY is a popular format for 3D scanner with project like “The Digital Michelangelo, David”.

PLY file data can be stored in ascii, binary-big-endian or binary-little-endian.  Regardless of the data type, the file header is ascii.  For binary mode, data maybe stored in any type, char, short, int, float, etc.  In addition to the PLY wiki page, Stanford provides excellent documentation, sample code as well as a toolkit.

As in other 3D decoder exercises, I am using Devon Govett’s bmp.js as reference and tested on browsers: Chrome, Safari, Firefox and **Internet Explorer 10 preview**.

I have implemented the ascii format and will continue to work on the binary decoder.  Here is the demo and source code in GitHub.