User Tools

Site Tools


obj_to_color_cloud_point

OBJ to Color Cloud Point

Summary

We can take the OBJ files with their accompanying JPG files to create a 3d cloud point with colors to be displayed with the HoloMonitor.

Further Information

I wrote a C++ program that takes the data produced by 123D catch and separates it into at least 3 files for easy importing into MATLAB. 1 file (.vert) that contains the vertices post decimation, 1 file (.tvert) that contains u v points on a 0 to 1 scale for texture points when mapping texture to faces, and n files (.f) that contain a link between vertices and texture vertices by using the index of the vertex in the .vert file, and the index of the texture vertex in the .tvert file, where n is the number of JPEG files created in 123D Catch. Because we know what the MTL files will contain, and that besides the JPG files referenced, this data is mostly pointless (possible application for shading, but again the shading properties are the same for all 123D Catch generated files).

This program is a command line pprogram and has the following syntax for execution:

decimateOBJv2.exe inputFileName outputBaseName decimationFactor

This will take the inputFile (ending in obj) and cut the number of vertices by 1/decimationFactor and then output collected data with the outputBaseName followed by .vert, .tvert, or .f.

From here I created a MATLAB function that will take in all of the .vert, .tvert and .f files and create an array 3xN in dimension representing a collection of 3d points with an accompanying 3xN array representing the color of these points. N is the number of points. The code simply takes all the colors from the tverts associated with a particular vert and averages them. The points with their respective colors are then plotted using scatter3 with a specific size.

This function can be run with the following syntax in MATLAB:

[points, colors] = plotHoloLines(directory, fileBaseName, textureBaseName, numHoloLines)

directory refers to the directory from MATLAB's working directory where the .vert, .tvert, .f, and .jpg files are located. The function assumes the same directory for all files. fileBaseName referes to the fileName of the .vert, .tvert, .f files without the extension and without the f files' numbering. The function assumes the same name for all these files. Similarly, the textureBaseName refers to the name of the texture files excluding the file extension and their numbering. numHoloLines refers to the number of holo lines to be used in the scaling. points is the vertices plotted in the scatterplot, and colors is the normalized RGB for each vertex.

These programs can be found in the groups folder under “Keith's files\objToHoloLines”.

Pictures:

Women's face/bust:

Original:

womanbustoriginal.jpg

MATLAB:

womanbustmorecorner.jpg

womanbustmorestraight.jpg

Cake:

Original:

cakeoriginal.jpg

MATLAB:

cakecorner.jpg

cakestraight.jpg

Zack Face:

Original:

zachfaceoriginal.jpg

MATLAB:

zachfacecorner.jpg

zachfacestraight.jpg

What's next

Next we'd like to create images for the Holodeck utilizing backface culling to remove parts that are behind front most pieces of the image.

obj_to_color_cloud_point.txt · Last modified: 2016/05/23 12:24 by kkh3049