Chromium Code Reviews

Side by Side Diff: samples/o3djs/debug.js

Issue 155401: Shadow Map Sample (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « samples/MANIFEST ('k') | samples/shadow-map.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 245 matching lines...)
256 * 256 *
257 * @enum {number} 257 * @enum {number}
258 */ 258 */
259 o3djs.debug.VertexInfo.prototype.Offset = { 259 o3djs.debug.VertexInfo.prototype.Offset = {
260 X: 0, 260 X: 0,
261 Y: 1, 261 Y: 1,
262 Z: 2 262 Z: 2
263 }; 263 };
264 264
265 /** 265 /**
266 * Computes the number of vertices in this vertex info.
267 * @return {number} The number of vertices.
268 */
269 o3djs.debug.VertexInfo.prototype.numVertices = function() {
270 return this.vertices.length / 3;
271 };
272
273
274 /**
275 * Given the number of a vertex returns the index in the array where
276 * the coordinates of that vertex vertexIndex.
277 * @param {number} vertexNumber The vertex number.
278 * @return {number} The index where that vertex begins.
279 */
280 o3djs.debug.VertexInfo.prototype.vertexIndex = function(vertexNumber) {
281 return vertexNumber * 3;
282 }
283
284 /**
266 * Adds a vertex. 285 * Adds a vertex.
267 * @param {number} positionX The x position of the vertex. 286 * @param {number} positionX The x position of the vertex.
268 * @param {number} positionY The y position of the vertex. 287 * @param {number} positionY The y position of the vertex.
269 * @param {number} positionZ The z position of the vertex. 288 * @param {number} positionZ The z position of the vertex.
270 */ 289 */
271 o3djs.debug.VertexInfo.prototype.addVertex = function( 290 o3djs.debug.VertexInfo.prototype.addVertex = function(
272 positionX, positionY, positionZ) { 291 positionX, positionY, positionZ) {
273 this.vertices.push(positionX, positionY, positionZ); 292 this.vertices.push(positionX, positionY, positionZ);
274 }; 293 };
275 294
(...skipping 15 matching lines...)
291 */ 310 */
292 o3djs.debug.VertexInfo.prototype.createShape = function( 311 o3djs.debug.VertexInfo.prototype.createShape = function(
293 pack, 312 pack,
294 material) { 313 material) {
295 return o3djs.debug.createLineShape(pack, 314 return o3djs.debug.createLineShape(pack,
296 material, 315 material,
297 this.vertices, 316 this.vertices,
298 this.indices); 317 this.indices);
299 }; 318 };
300 319
320
301 /** 321 /**
302 * Reorients the vertex positions of this vertexInfo by the 322 * Reorients the vertex positions of this vertexInfo by the
303 * given matrix. In other words it multiplies each vertex by the 323 * given matrix. In other words it multiplies each vertex by the
304 * given matrix. 324 * given matrix.
305 * @param {!o3djs.math.Matrix4} matrix Matrix to multiply by. 325 * @param {!o3djs.math.Matrix4} matrix Matrix to multiply by.
306 */ 326 */
307 o3djs.debug.VertexInfo.prototype.reorient = function(matrix) { 327 o3djs.debug.VertexInfo.prototype.reorient = function(matrix) {
308 var math = o3djs.math; 328 var math = o3djs.math;
309 // Assume if it has a length it's not a Matrix4
310 if (matrix.length) {
311 matrix = math.matrix4.copy(matrix);
312 }
313 var numVerts = this.numVertices(); 329 var numVerts = this.numVertices();
314 for (var v = 0; v < numVerts; ++v) { 330 for (var v = 0; v < numVerts; ++v) {
315 var index = this.vertexIndex(v); 331 var index = this.vertexIndex(v);
316 var position = [this.vertices[index + this.Offset.X], 332 var position = [this.vertices[index + this.Offset.X],
317 this.vertices[index + this.Offset.Y], 333 this.vertices[index + this.Offset.Y],
318 this.vertices[index + this.Offset.Z], 334 this.vertices[index + this.Offset.Z],
319 1]; 335 1];
320 position = math.mulVectorMatrix(position, matrix); 336 position = math.mulVectorMatrix(position, matrix);
321 this.vertices[index + this.Offset.X] = position[0]; 337 this.vertices[index + this.Offset.X] = position[0];
322 this.vertices[index + this.Offset.Y] = position[1]; 338 this.vertices[index + this.Offset.Y] = position[1];
(...skipping 992 matching lines...)
1315 * @param {!o3d.Pack} pack Pack for DebugHelper to manage its resources 1331 * @param {!o3d.Pack} pack Pack for DebugHelper to manage its resources
1316 * with. 1332 * with.
1317 * @param {!o3djs.rendergraph.viewInfo} viewInfo ViewInfo for debug 1333 * @param {!o3djs.rendergraph.viewInfo} viewInfo ViewInfo for debug
1318 * visuals. 1334 * visuals.
1319 * @return {!o3djs.debug.DebugHelper} the DebugHelper object. 1335 * @return {!o3djs.debug.DebugHelper} the DebugHelper object.
1320 */ 1336 */
1321 o3djs.debug.createDebugHelper = function(pack, viewInfo) { 1337 o3djs.debug.createDebugHelper = function(pack, viewInfo) {
1322 return new o3djs.debug.DebugHelper(pack, viewInfo); 1338 return new o3djs.debug.DebugHelper(pack, viewInfo);
1323 }; 1339 };
1324 1340
OLDNEW
« no previous file with comments | « samples/MANIFEST ('k') | samples/shadow-map.html » ('j') | no next file with comments »

Powered by Google App Engine