Skip to content

Commit

Permalink
everything omg!!
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt committed Jul 28, 2010
1 parent e1e29b7 commit fb9298d
Show file tree
Hide file tree
Showing 84 changed files with 3,723 additions and 548 deletions.
20 changes: 9 additions & 11 deletions c3dl-dev/demos/rts/source/main.js
Expand Up @@ -51,24 +51,22 @@ function loadLevel(board) {
switch (board[z][x]) {
case 0:
{
var earth = new c3dl.Collada();
earth.init(PLANE_PATH);
// move down y to prevent z-fighting with planes
// under models
earth.scale([3,1,3]);
earth.translate([z*30,-0.5,x*30]);
//set the id for later use during picking
earth.id = i;
scn.addObjectToScene(earth);
var earth = new c3dl.Collada();
earth.init(PLANE_PATH);
// move down y to prevent z-fighting with planes
// under models
earth.scale([3,1,3]);
earth.translate([z*30,-0.5,x*30]);
//set the id for later use during picking
scn.addObjectToScene(earth);
}break;
case 1:
{
var townHall = new c3dl.Collada();
townHall.init(BARRACKS_PATH);
townHall.translate([z*10,0,x*10]);
scn.addObjectToScene(townHall);

var earth = new c3dl.Collada();
var earth = new c3dl.Collada();
earth.init(PLANE_PATH);
// move down y to prevent z-fighting with planes
// under models
Expand Down
197 changes: 0 additions & 197 deletions c3dl-dev/tests/frustum culling/box.dae

This file was deleted.

96 changes: 84 additions & 12 deletions c3dl-dev/tests/frustum culling/fc.js
@@ -1,7 +1,28 @@
c3dl.addMainCallBack(canvasMain, "test");
c3dl.addModel("box.dae");
c3dl.addModel("obj.dae");
var timesincelastchange=0;
var box;
var obj;
var cam = [];
cam[0] = new c3dl.FreeCamera();
cam[1] = new c3dl.FreeCamera();
cam[2] = new c3dl.FreeCamera();
cam[3] = new c3dl.FreeCamera();
cam[4] = new c3dl.FreeCamera();
cam[5] = new c3dl.FreeCamera();
cam[0].setPosition([0, 0, 50]);
cam[0].setLookAtPoint([0.0, 0.0, 0.0]);
cam[1].setPosition([0, 0, -50]);
cam[1].setLookAtPoint([0.0, 0.0, 0.0]);
cam[2].setPosition([0, 50, 0]);
cam[2].setLookAtPoint([0.01, 0.0, 0.0]);
cam[3].setPosition([0, -50, 0]);
cam[3].setLookAtPoint([0.01, 0.0, 0.0]);
cam[4].setPosition([50, 0, 0]);
cam[4].setLookAtPoint([0.0, 0.0, 0.0]);
cam[5].setPosition([-50, 0, 0]);
cam[5].setLookAtPoint([0.0, 0.0, 0.0]);
var start = +new Date();
var currentCam = 0;
function canvasMain(canvasName){
scn = new c3dl.Scene();
scn.setCanvasTag(canvasName);
Expand All @@ -11,21 +32,72 @@ function canvasMain(canvasName){
scn.init(canvasName);
if(renderer.isReady() )
{
var now = new Date();
box = new c3dl.Collada();
box.init("box.dae");
box.setPosition(new Array(0.0, 0.0, 0));
box.setLinearVel(new Array(0.001, 0.0, 0.0));
scn.addObjectToScene(box);
var cam = new c3dl.FreeCamera();
cam.setPosition(new Array(10, 20, 30.0));
cam.setLookAtPoint(new Array(0.0, 0.0, 0.0));
scn.setCamera(cam);

obj = new c3dl.Collada();
obj.init("obj.dae");
obj.setPosition(new Array(0.0, 0.0, 0));
obj.scale([0.5,0.5,0.5]);
scn.addObjectToScene(obj);
scn.setCamera(cam[0]);
scn.setUpdateCallback(test);
scn.startScene();
}
}
function test(){
scn.setCamera(cam[currentCam]);
document.getElementById('fps').value = scn.getFPS();
var checker;
var camera = scn.getCamera();
camera.applyToWorld(scn.getCanvas().width / scn.getCanvas().height);
var projMatrix = camera.getProjectionMatrix();
var viewMatrix = camera.getViewMatrix();
var frustumMatrix = c3dl.multiplyMatrixByMatrix(projMatrix,viewMatrix);
var frustumCulling = new Frustum(frustumMatrix);
//Culling using spheres
var boundingSpheres = obj.getBoundingSpheres();
for (var j = 0; j < boundingSpheres.length; j++) {
checker = frustumCulling.sphereInFrustum(boundingSpheres[j]);
if (checker === "INSIDE") {
break;
}
}
document.getElementById('InOut').value = checker;

}

function nextCam() {
(currentCam === 5) ? currentCam = 0 : currentCam++;
}
function prevCam() {
(currentCam === 0) ? currentCam = 5 : currentCam--;
}

function blastOff() {
var velocity = [0,0,0];
if (document.getElementById('X').checked) {
if (document.getElementById('Xlist').value === "Xpos") {
velocity = [0.01, velocity[1],velocity[2]];
}
else {
velocity = [-0.01, velocity[1],velocity[2]];
}
}
if (document.getElementById('Y').checked) {
if (document.getElementById('Ylist').value === "Ypos") {
velocity = [velocity[0], 0.01,velocity[2]];
}
else {
velocity = [velocity[0], -0.01,velocity[2]];
}
}
if (document.getElementById('Z').checked) {
if (document.getElementById('Zlist').value === "Zpos") {
velocity = [velocity[0], velocity[1],0.01];
}
else {
velocity = [velocity[0], velocity[1],-1];
}
}
obj.setPosition(new Array(0.0, 0.0, 0));
obj.setLinearVel(velocity);
}
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.
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.
40 changes: 37 additions & 3 deletions c3dl-dev/tests/frustum culling/index.html
Expand Up @@ -5,8 +5,42 @@
<script type="application/javascript" src="fc.js"></script>
</head>
<body>

<canvas id="test" style="border: 2px solid blue" width="500" height="500"></canvas>
<input type="label" id="fps" value="">
<table>
<tr>
<td><canvas id="test" style="border: 2px solid blue" width="500" height="500"></canvas><td/>
<td>
<input type="button" id="NCam" value="Next Cam" onclick="nextCam();">
<input type="button" id="PCam" value="Previous Cam" onclick="prevCam();">
<br/>
Select Axis:
<br/>
<input type="checkbox" id="X" value=""> X
<SELECT id="Xlist">
<OPTION VALUE="Xpos"> Positive
<OPTION VALUE="Xneg"> Negative
</SELECT>
<br/>
<input type="checkbox" id="Y" value=""> Y
<SELECT id="Ylist">
<OPTION VALUE="Ypos"> Positive
<OPTION VALUE="Yneg"> Negative
</SELECT>
<br/>
<input type="checkbox" id="Z" value=""> Z
<SELECT id="Zlist">
<OPTION VALUE="Zpos"> Positive
<OPTION VALUE="Zneg"> Negative
</SELECT>
<br/>
<input type="button" id="fire" value="Fire!" onclick="blastOff();"/>
<br/>
Object:<input type="text" id="InOut" value="">
</td>
</tr>
<tr>
<td> FPS:<input type="text" id="fps" value=""><td/>
<td></td>
</tr>
<table>
</body>
</html>

0 comments on commit fb9298d

Please sign in to comment.