/* <copyright>
This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
</copyright> */
var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils;
var CanvasController = require("js/controllers/elements/canvas-controller").CanvasController;
var GeomObj = require("js/lib/geom/geom-obj").GeomObj;
var AnchorPoint = require("js/lib/geom/anchor-point").AnchorPoint;
var MaterialsModel = require("js/models/materials-model").MaterialsModel;
// TODO Those function do not seems to be used. We should remove them
/*
function SubpathOffsetPoint(pos, mapPos) {
this.Pos = [pos[0],pos[1],pos[2]];
this.CurveMapPos = [mapPos[0], mapPos[1], mapPos[2]];
}
function SubpathOffsetTriangle(v0, v1, v2) {
this.v0 = v0;
this.v1 = v1;
this.v2 = v2;
this.n = [0,0,1]; //replace with the actual cross product later
}
function sortNumberAscending(a,b){
return a-b;
}
function sortNumberDescending(a,b){
return b-a;
}
function SegmentIntersections(){
this.paramArray = [];
}
*/
///////////////////////////////////////////////////////////////////////
// Class GLSubpath
// representation a sequence of cubic bezier curves.
// Derived from class GeomObj
///////////////////////////////////////////////////////////////////////
var GLSubpath = function GLSubpath() {
///////////////////////////////////////////////////
// Instance variables
///////////////////////////////////////////////////
this._Anchors = [];
this._BBoxMin = [0, 0, 0];
this._BBoxMax = [0, 0, 0];
this._isClosed = false;
this._samples = []; //polyline representation of this curve in stage world space
this._sampleParam = []; //parametric distance of samples, within [0, N], where N is # of Bezier curves (=# of anchor points if closed, =#anchor pts -1 if open)
this._anchorSampleIndex = []; //index within _samples corresponding to anchor points
this._LocalPoints = []; //polyline representation of this curve in canvas space
this._LocalBBoxMin = [0,0,0]; //bbox min point of _LocalPoints
this._LocalBBoxMax = [0,0,0]; //bbox max point of _LocalPoints
this._UnprojectedAnchors = [];
//initially set the _dirty bit so we will construct samples
this._dirty = true;
//initially set the local dirty bit so we will construct local coordinates
this._isLocalDirty = true;
//whether or not to use the canvas drawing to stroke/fill
this._useCanvasDrawing = true;
//the canvas that will draw this subpath
this._canvas = null;
//the top left location of this subpath's canvas in screen space
this._canvasLeft = 0;
this._canvasTop = 0;
//stroke information
this._strokeWidth = 1.0;
this._strokeColor = [0.4, 0.4, 0.4, 1.0];
this._strokeMaterial = null
this._strokeStyle = "Solid";
this._materialAmbient = [0.2, 0.2, 0.2, 1.0];
this._materialDiffuse = [0.4, 0.4, 0.4, 1.0];
this._materialSpecular = [0.4, 0.4, 0.4, 1.0];
this._fillColor = [1.0, 1.0, 1.0, 0.0];
this._fillMaterial = null;
this._DISPLAY_ANCHOR_RADIUS = 5;
//drawing context
this._world = null;
//tool that owns this subpath
this._drawingTool = null;
this._planeMat = null;
this._planeMatInv = null;
this._planeCenter = null;
//used to query what the user selected, OR-able for future extensions
this.SEL_NONE = 0; //nothing was selected
this.SEL_ANCHOR = 1; //anchor point was selected
this.SEL_PREV = 2; //previous handle of anchor point was selected
this.SEL_NEXT = 4; //next handle of anchor point was selected
this.SEL_PATH = 8; //the path itself was selected
this._selectMode = this.SEL_NONE;
this._selectedAnchorIndex = -1;
this._SAMPLING_EPSILON = 0.5; //epsilon used for sampling the curve
this._DEFAULT_STROKE_WIDTH = 20; //use only if stroke width not specified
this._MAX_OFFSET_ANGLE = 10; //max angle (in degrees) between consecutive vectors from curve to offset path
// (current GeomObj complains if buildBuffers/render is added to GLSubpath prototype)
//buildBuffers
// Build the stroke vertices, normals, textures and colors
// Add that array data to the GPU using OpenGL data binding
this.buildBuffers = function () {
// return; //no need to do anything for now
};
this._offsetLocalCoord = function(deltaW, deltaH){
var numPoints = this._LocalPoints.length;
for (var i=0;i<numPoints;i++) {
this._LocalPoints[i][0]+= deltaW;
this._LocalPoints[i][1]+= deltaH;
}
};
|