Skip to content

Commit

Permalink
Merge branches 'master' and 'bug19'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andor committed Jul 9, 2010
2 parents 10f49ea + e685a6f commit 0a91088
Show file tree
Hide file tree
Showing 22 changed files with 662 additions and 9 deletions.
54 changes: 51 additions & 3 deletions demos/acorn/acorn.html
@@ -1,13 +1,61 @@
<html>

<head>
<link rel="stylesheet" type="text/css" href="../style.css" />
<!-- jQuery stuff -->
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.2.custom.min.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="css/ui-lightness/jquery-ui-1.8.2.custom.css" />

<script src="../../pointstream.js"></script>
<script src="acorn.js"></script>
</head>

<body onLoad="start();">
<canvas id="canvas" width="500" height="500"></canvas>
<body onLoad="start();" bgcolor="#222" text="#FFF">
<script type="text/javascript">
$(function() {
$("#constant").slider({
value: 0.01,
min: 0,
max: 1,
step: 0.001,
slide: function(event, ui) {
$("#c").val(ui.value);
}});

$("#c").val($("#constant").slider("value"));
});

$(function() {
$("#linear").slider({
value: 0,
min: 0,
max: 1,
step: 0.001,
slide: function(event, ui) {
$("#l").val(ui.value);
}});

$("#l").val($("#linear").slider("value"));
});

$(function() {
$("#quadratic").slider({
value: 0.003,
min: 0,
max: 1,
step: 0.001,
slide: function(event, ui) {
$("#l").val(ui.value);
}});

$("#l").val($("#quadratic").slider("value"));
});
</script>

<canvas id="canvas" width="500" height="500"></canvas><br />
Constant: <span id="const"> </span><div id="constant"></div><br/>
Linear: <span id="lin"> </span><div id="linear"></div><br/>
Quadratic: <span id="quad"> </span><div id="quadratic"></div><br/>
</body>

</html>
12 changes: 11 additions & 1 deletion demos/acorn/acorn.js
@@ -1,7 +1,7 @@
var ps;

var buttonDown = false;
var zoomed = 0;
var zoomed = -50;

var rot =[0,0];
var curCoords = [0,0];
Expand Down Expand Up @@ -44,6 +44,14 @@ function render() {
ps.rotateY(rot[0]);
ps.rotateX(rot[1]);

ps.attenuation( $("#constant").slider("value"),
$("#linear").slider("value"),
$("#quadratic").slider("value"));

document.getElementById('const').innerHTML = $("#constant").slider("value");
document.getElementById('lin').innerHTML = $("#linear").slider("value");
document.getElementById('quad').innerHTML = $("#quadratic").slider("value");

// redraw
ps.clear();
ps.render();
Expand All @@ -53,7 +61,9 @@ function start(){
ps = new PointStream();

ps.setup(document.getElementById('canvas'), render);

ps.background([0,0,0,1]);
ps.pointSize(5);

ps.onMouseScroll = zoom;
ps.onMousePressed = mousePressed;
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
302 changes: 302 additions & 0 deletions demos/acorn/css/ui-lightness/jquery-ui-1.8.2.custom.css

Large diffs are not rendered by default.

154 changes: 154 additions & 0 deletions demos/acorn/js/jquery-1.4.2.min.js

Large diffs are not rendered by default.

96 changes: 96 additions & 0 deletions demos/acorn/js/jquery-ui-1.8.2.custom.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion demos/mickey/mickey.js
@@ -1,7 +1,7 @@
var ps;

var buttonDown = false;
var zoomed = 0;
var zoomed = -50;

var rot =[0,0];
var curCoords = [0,0];
Expand Down Expand Up @@ -57,6 +57,8 @@ function start(){
ps = new PointStream();

ps.setup(document.getElementById('canvas'), render);

ps.pointSize(8);
ps.background([0.3,0.5,0.7,0.2]);

ps.onMouseScroll = zoom;
Expand Down
49 changes: 45 additions & 4 deletions psapi.js
@@ -1,6 +1,12 @@
/*
Copyright (c) 2010 Seneca College
MIT LICENSE
TODO:
- add mouseScroll empty var?
- change verts, norms, cols to webglarrays?
- should mousewheel return single value or object?
- add external js loading so mjs isn't present in html file
*/

function PointStream(){
Expand All @@ -17,6 +23,9 @@ function PointStream(){
var bk = [1,1,1,1];
var VBOs;

// defaults
var attn = [0.01, 0.0, 0.003];

// browser detection to handle differences such as mouse scrolling
var browser = -1 ;
const MINEFIELD = 0;
Expand Down Expand Up @@ -59,7 +68,11 @@ function PointStream(){
"uniform vec3 mat_ambient;" +
"uniform vec3 mat_specular;" +
"uniform float shininess;" +


//
"uniform float pointSize;" +
"uniform vec3 attenuation;" +

"uniform mat4 model;" +
"uniform mat4 view;" +
"uniform mat4 projection;" +
Expand Down Expand Up @@ -119,9 +132,17 @@ function PointStream(){
" gl_FrontColor = vec4(finalDiffuse[0] * col[0], finalDiffuse[1] * col[1], finalDiffuse[2] * col[2], 1.0);" +
" }" +

" gl_PointSize = 3.0;" +
" float dist = length( view * model * vec4(aVertex, 1.0));" +
"float attn = attenuation[0] + (attenuation[1] * dist) + (attenuation[2] * dist * dist);" +

" gl_Position = projection * view * model * vec4( aVertex, 1.0 );" +
" if(attn > 0.0){" +
" gl_PointSize = pointSize * sqrt(1.0/attn);" +
" }" +
" else{" +
" gl_PointSize = 1.0;" +
" }"+

" gl_Position = projection * view * model * vec4(aVertex, 1.0);" +
"}";

var fragmentShaderSource =
Expand Down Expand Up @@ -442,17 +463,21 @@ function PointStream(){
}
}

uniformf(progObj, "pointSize", 1);
uniformf(progObj, "attenuation", [attn[0], attn[1], attn[2]]);

uniformMatrix(progObj, "view", false, M4x4.transpose(view));
uniformMatrix(progObj, "projection", false, M4x4.transpose(projection));
},

/**
*/
render: function(){

frames++;
xb.frameCount++;
var now = new Date();

if(ctx && VBOs){
vertexAttribPointer(progObj, "aVertex", 3, VBOs.posBuffer);

Expand Down Expand Up @@ -609,6 +634,22 @@ function PointStream(){
model = M4x4.rotate(radians,V3.$(0,1,0),model);
},

/**
constant
linear
quadratic
*/
attenuation: function(constant, linear, quadratic){
uniformf(progObj, "attenuation", [constant, linear, quadratic]);
},

/**
size - in pixels
*/
pointSize: function(size){
uniformf(progObj, "pointSize", size);
},

/**
radians
*/
Expand Down

0 comments on commit 0a91088

Please sign in to comment.