Changes

Jump to: navigation, search

XB PointStream/custom parsers

460 bytes added, 14:40, 16 February 2011
Parser Skeleton
==Parser Skeleton==
The following bit of code is a skeleton which you can use as an aid to help you write your own parserfor XB PointStream.
<pre>
var Your_Parser_Name = (function() {
/** XBPS will create an instance of your parser and pass in an object with three named properties:
start - must occur exactly once. Has one argumentWhen you call this function, the pass in a reference to your parser itself end - must occur exactly once. Has When you call this function, pass in a reference to your parser parse - may occur one or many times. When you call this function, pass in a reference to your parser as the first argument, and an object as the parser itselfsecond argument.
Everytime your parser calls the parse function, it This second object must send in an object withhave variables referencing typed single-dimensional arrays which contain named arraysthe parsed values. In the following For example, vertexArray is a if vertsArray and colsArray were Float32Array which containarrays, you would call the vertices which have already been read and parsed.parse function like this:
var attributes = {};
attributes["ps_Vertex"] = vertexArrayvertsArray; attributes["ps_Color"] = colorsArraycolsArray; parse(thisParser, attributes);  PointStream will create buffers using these values and start rendering them using the built-in shaders. Notice the variable names have been qualified with "ps_". If you are using the XB PointStream built-in shaders, you will need to use these exact variable names.
parse These are the only two variables the built- may occur one or many timesin shaders read. Has two argumentsIf your parser reads in vertex normal data, the parser itself and a Your parser is responsible for calling these functions at the appropriate timesyou will need to write your own shaders to handle lighting.
*/
function Your_Parser_Name(config) {
/*Returns the version of this parser.*/
this.__defineGetter__("version", function(){ return /*!!*/; });
/*Get the number of parsed points so far.*/
this.__defineGetter__("numParsedPoints", function(){ return /*!!*/; });
/*Get the total number of points in the point cloud.*/
this.__defineGetter__("numTotalPoints", function(){ return /*!!*/; });
/*Returns the progress of downloading the point cloud between zero and one.*/
this.__defineGetter__("progress", function(){ return /*!!*/; });
/*Returns the file size of the resource in bytes.*/
this.__defineGetter__("fileSize", function(){ return /*!!*/; });
/** @param Path = path Path to the resource */ this.load = function(path){ /*!!*/ };
}
return Your_Parser_Name;
1
edit

Navigation menu