Skip to content
Browse files

colored models can also be highlighted now.

  • Loading branch information...
1 parent 5a2d438 commit b603b2a397882b9d5eb63aa7e91d8346da280121 Benjamin Loesch committed May 21, 2012
View
7 source/core/earthpolyline.js
@@ -62,6 +62,10 @@ function EarthPolyline(engine,options)
this.options = options;
+ /** @type {vec4} */
+ this.highlightcolor = new vec4();
+ this.highlightcolor.Set(1, 1, 1, 1);
+
}
@@ -211,7 +215,8 @@ EarthPolyline.prototype.Draw = function()
this.gl.enableVertexAttribArray(1);
this.gl.vertexAttribPointer(0, 3, this.gl.FLOAT, false, 7*4, 0*4); // position
this.gl.vertexAttribPointer(1, 4, this.gl.FLOAT, false, 7*4, 3*4); // color
- this.engine.shadermanager.UseShader_PC(this.engine.matModelViewProjection);
+
+ this.engine.shadermanager.UseShader_PC(this.engine.matModelViewProjection,this.highlightcolor);
this.gl.lineWidth(this.options["linewidth"]);
View
6 source/core/shaders.js
@@ -160,13 +160,15 @@ ShaderManager.prototype.UseShader_PNT = function(normalmatrix, modelview, projec
/**
*
* @param {mat4} modelviewprojection
+ * @param {vec4} color
*/
-ShaderManager.prototype.UseShader_PC = function(modelviewprojection)
+ShaderManager.prototype.UseShader_PC = function(modelviewprojection, color)
{
if (this.program_pc)
{
this.gl.useProgram(this.program_pc);
this.gl.uniformMatrix4fv(this.gl.getUniformLocation(this.program_pc, "matMVP"), false, modelviewprojection.ToFloat32Array());
+ this.gl.uniform4fv(this.gl.getUniformLocation(this.program_pc, "uColor"), color.ToFloat32Array());
}
}
//------------------------------------------------------------------------------
@@ -339,7 +341,7 @@ ShaderManager.prototype.InitShader_PNT = function()
ShaderManager.prototype.InitShader_PC = function()
{
var src_vertexshader_PC= "uniform mat4 matMVP;\nattribute vec3 aPosition;\nattribute vec4 aColor;\nvarying vec4 vColor;\n\nvoid main()\n{\n gl_Position = matMVP * vec4(aPosition, 1.0);\n vColor = aColor;\n gl_PointSize = 1.0;}\n";
- var src_fragmentshader_PC= "#ifdef GL_ES\nprecision highp float;\n#endif\n\nvarying vec4 vColor;\n\nvoid main()\n{\n gl_FragColor = vColor;\n}\n\n";
+ var src_fragmentshader_PC= "#ifdef GL_ES\nprecision highp float;\n#endif\n\nvarying vec4 vColor;\n\nuniform vec4 uColor;\nvoid main()\n{\n gl_FragColor = vColor * uColor;\n}\n\n";
this.vs_pc = this._createShader(this.gl.VERTEX_SHADER, src_vertexshader_PC);
this.fs_pc = this._createShader(this.gl.FRAGMENT_SHADER, src_fragmentshader_PC);
View
2 source/core/surface.js
@@ -462,7 +462,7 @@ Surface.prototype.Draw = function (opt_ranged, opt_count, opt_offset, opt_fontco
this.gl.enableVertexAttribArray(1);
this.gl.vertexAttribPointer(0, 3, this.gl.FLOAT, false, 7 * 4, 0 * 4); // position
this.gl.vertexAttribPointer(1, 4, this.gl.FLOAT, false, 7 * 4, 3 * 4); // color
- this.engine.shadermanager.UseShader_PC(this.engine.matModelViewProjection);
+ this.engine.shadermanager.UseShader_PC(this.engine.matModelViewProjection,this.highlightcolor);
break;
case "pt":
View
8 source/tutorials/06_3D-Geometry/3DGeometry_Highlight.html
@@ -29,10 +29,10 @@
<!DOCTYPE html>
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<script type="text/javascript" src="../../../compiled/owg-optimized.js"></script>
-<!--<script type="text/javascript" src="../../../external/closure-library/closure/goog/base.js"></script>
+<!--<script type="text/javascript" src="../../../compiled/owg-optimized.js"></script>-->
+<script type="text/javascript" src="../../../external/closure-library/closure/goog/base.js"></script>
<script type="text/javascript" src="../../../compiled/deps.js"></script>
-<script type="text/javascript">goog.require('owg.OpenWebGlobe');</script>-->
+<script type="text/javascript">goog.require('owg.OpenWebGlobe');</script>
<script type="text/javascript">
var geometry = null;
@@ -138,7 +138,7 @@
// A geometry is a container for meshes
// a mesh is a container of surfaces. every surface needs a json file.
- geometry = ogLoadGeometryAsync(geometrylayer,"torus.json");
+ geometry = ogLoadGeometryAsync(geometrylayer,"cubepc.json");
var scene = ogGetScene(ctx);
ogFlyToLookAtPosition(scene,7.438637,46.951081,3400,1000);
View
2 source/tutorials/06_3D-Geometry/cubepc.json
@@ -3,7 +3,7 @@
[
{
"id" : "1",
- "Center" : [7.66, 46.13, 8000],
+ "Center" : [7.438637,46.951081,3400],
"VertexSemantic" : "pc",
"Vertices" : [-100,-100,-100,1.0,1.0,1.0,0.0,
-100,-100, 100,1.0,0.0,0.0,0.2,

0 comments on commit b603b2a

Please sign in to comment.
Something went wrong with that request. Please try again.