Skip to content

Commit

Permalink
add Front page demo(J3DXPlorer) and asteroids game
Browse files Browse the repository at this point in the history
  • Loading branch information
cathyatseneca committed Feb 12, 2010
1 parent 96d1afb commit 5a8ffc1
Show file tree
Hide file tree
Showing 27 changed files with 2,539 additions and 0 deletions.
20 changes: 20 additions & 0 deletions canvas3dapi-dev/J3DXplorer/J3DXplorer.html
@@ -0,0 +1,20 @@
<html>
<head>
<title>Cavas3D test environment</title>
<!--Our directory structure is 2 above. If you download the entire repository as is, this will run-->
<script type="application/javascript">var SCRIPT_PATH = '../../canvas3dapi/'</script>
<script language="javascript" src="../../canvas3dapi/c3dapi.js"></script>
<script language="javascript" src="J3DXplorer.js"></script>

</head>

<body>
<canvas id="J3DXplorer" width="500" height="500">
<img src="frontpagess.png"></img>
</canvas>

<font face="verdana">
<span id="debug"> </span>
</font>
</body>
</html>
120 changes: 120 additions & 0 deletions canvas3dapi-dev/J3DXplorer/J3DXplorer.js
@@ -0,0 +1,120 @@
/*
Copyright (c) 2008 Seneca College
Licenced under the MIT License (http://www.c3dl.org/index.php/mit-license/)
*/

var cam = new c3dl.FreeCamera();
var scn;

var test = new Array();
const MAXOBJ = 20;
c3dl.debug.setVisible(false);
c3dl.addMainCallBack(J3DXplorer_main, 'J3DXplorer');
c3dl.addModel("J3DXplorer_window.dae");
c3dl.addModel("c3DL_logo.dae");
c3dl.addModel("SkySphere.dae");

var urls = ["http://www.google.com", "http://www.senecac.on.ca",
"http://www.twitter.com",
"http://www.c3dl.org","http://www.mozilla.com/en-US/firefox/personal.html"];
var imgs = ["windowTex_google.png",
"windowTex_seneca.png",
"windowTex_twitter.png",
"windowTex_c3dl.png",
"windowTex_firefox.png"];

function J3DXplorer_main(canvasName)
{
scn = new c3dl.Scene();
scn.setCanvasTag(canvasName);
var renderer = new c3dl.WebGL();
scn.setRenderer(renderer);
scn.init(canvasName);
if(!renderer.isReady()){
var canvas=document.getElementById(canvasName);
var ctx=canvas.getContext('2d');
var img=new Image();
img.src="frontpagess.png";
ctx.drawImage(img,0,0);
}
else{
var j=0;
// spinning 'windows'
for(var i = 0; i < MAXOBJ; i++){

var obj = new c3dl.Collada();
obj.init("J3DXplorer_window.dae");

var ranScale = 1 - ( Math.floor(Math.random()*11) / 20);
var ranScaleVector = new Array(ranScale,ranScale,ranScale);
var ranYaw = Math.floor(Math.random()*361) ;
var ranPitch = .5 - Math.floor(Math.random()*10) / 10 ;
var ranRoll = .5 - Math.floor(Math.random()*10) / 10 ; ;
var ranVel = 0.0001 + (Math.floor(Math.random()*11) * 0.00005);

obj.scale(ranScaleVector);
obj.yaw(ranYaw);
obj.pitch(ranPitch/1.5);
obj.roll(ranRoll/1.5);
obj.setAngularVel([0,ranVel,0]);

// generate a random number which will be used to index
// into a list of urls/images
// Math.random gives us a number from [0,1), so add a buffer
// to get the 1.
//var rand = Math.floor(((Math.random() + 0.2) * 4));

obj.url = urls[j];
obj.setTexture(imgs[j]);
j++;
if(j==5)
j=0;
scn.addObjectToScene(obj);
}

// c3dl logo
var logo = new c3dl.Collada();
logo.init("c3DL_logo.dae");
logo.scale([0.1,0.1,0.1]);
logo.setAngularVel([0,-0.001,0]);
logo.setPickable(false);
scn.addObjectToScene(logo);

// SkySphere
var skySphere = new c3dl.Collada();
skySphere.init("SkySphere.dae");
skySphere.translate([0,0,100]);
skySphere.setAngularVel(new Array(0,.00005,0));
skySphere.setPickable(false);
scn.addObjectToScene(skySphere);

//
scn.setBackgroundColor([0.15,0.15,0.15]);
scn.setAmbientLight([1,1,1]);
cam.setPosition([0,0,-30.0]);
cam.setLookAtPoint([0,0,0]);

scn.setCamera(cam);
scn.startScene();
scn.setPickingCallback(picking);
}
}

function picking(pickingObj)
{
var objectsHit = pickingObj.getObjects();

if( objectsHit.length > 0 )
{
var sepiaEffect = new c3dl.Effect();
sepiaEffect.init(c3dl.effects.SEPIA);
// document.addTab(objectsHit[0].url);
// window.open(objectsHit[0].url, objectsHit[0].url, "resizable=yes,scrollbars=yes,status=yes");
window.location=objectsHit[0].url;
objectsHit[0].setEffect(sepiaEffect);
for(var i = 0; i < MAXOBJ; i++){
if(objectsHit[0].url == scn.getObj(i).url)
scn.getObject(i).setEffect(sepiaEffect);
}
}
}
188 changes: 188 additions & 0 deletions canvas3dapi-dev/J3DXplorer/J3DXplorer_window.dae
@@ -0,0 +1,188 @@
<?xml version="1.0" encoding="utf-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
<asset>
<contributor>
<author>Administrator</author>
<authoring_tool>3dsMax 9 - Feeling ColladaMax v3.04C.</authoring_tool>
<comments>ColladaMax Export Options: ExportNormals=1;ExportEPolyAsTriangles=1;ExportXRefs=1;ExportSelected=0;ExportTangents=0;ExportAnimations=1;SampleAnim=0;ExportAnimClip=0;BakeMatrices=0;ExportRelativePaths=1;AnimStart=0;AnimEnd=16000;</comments>
<source_data>file:///C:/Documents%20and%20Settings/Administrator/Desktop/canvas%203d/plane02.max</source_data>
</contributor>
<created>2008-12-18T07:32:14Z</created>
<modified>2008-12-18T07:32:15Z</modified>
<unit meter="0.0254" name="inch"/>
<up_axis>Z_UP</up_axis>
</asset>
<library_images>
<image id="WindowTexture.jpg" name="WindowTexture_jpg">
<init_from>./WindowTexture.jpg</init_from>
</image>
</library_images>
<library_materials>
<material id="Material__4" name="Material__4">
<instance_effect url="#Material__4-fx"/>
</material>
</library_materials>
<library_effects>
<effect id="Material__4-fx" name="Material__4">
<profile_COMMON>
<newparam sid="WindowTexture_jpg-surface">
<surface type="2D">
<init_from>WindowTexture.jpg</init_from>
<format>A8R8G8B8</format>
</surface>
</newparam>
<newparam sid="WindowTexture_jpg-sampler">
<sampler2D>
<source>WindowTexture_jpg-surface</source>
<wrap_s>WRAP</wrap_s>
<wrap_t>WRAP</wrap_t>
<minfilter>NONE</minfilter>
<magfilter>NONE</magfilter>
<mipfilter>NONE</mipfilter>
</sampler2D>
</newparam>
<technique sid="common">
<blinn>
<ambient>
<color>0.588 0.588 0.588 1</color>
</ambient>
<diffuse>
<texture texture="WindowTexture_jpg-sampler" texcoord="CHANNEL1">
<extra>
<technique profile="MAYA">
<mirrorU>0</mirrorU>
<mirrorV>0</mirrorV>
<wrapU>1</wrapU>
<wrapV>1</wrapV>
<repeatU>1</repeatU>
<repeatV>1</repeatV>
<offsetU>0</offsetU>
<offsetV>0</offsetV>
</technique>
<technique profile="MAX3D">
<amount>1</amount>
</technique>
</extra>
</texture>
</diffuse>
<specular>
<color>0.9 0.9 0.9 1</color>
</specular>
<shininess>
<float>0.415939</float>
</shininess>
<reflective>
<color>0 0 0 1</color>
</reflective>
<reflectivity>
<float>1</float>
</reflectivity>
<transparent opaque="A_ONE">
<color>1 1 1 1</color>
</transparent>
<transparency>
<float>1</float>
</transparency>
<index_of_refraction>
<float>1</float>
</index_of_refraction>
</blinn>
<extra>
<technique profile="FCOLLADA">
<spec_level>
<float>0</float>
</spec_level>
<emission_level>
<float>0</float>
</emission_level>
</technique>
</extra>
</technique>
</profile_COMMON>
<extra>
<technique profile="MAX3D">
<faceted>0</faceted>
<double_sided>0</double_sided>
<wireframe>0</wireframe>
<face_map>0</face_map>
</technique>
</extra>
</effect>
</library_effects>
<library_geometries>
<geometry id="Box01-mesh" name="Box01">
<mesh>
<source id="Box01-mesh-positions">
<float_array id="Box01-mesh-positions-array" count="24">-4.37908 -2.48453 0 4.37908 -2.48453 0 -4.37908 2.48453 0 4.37908 2.48453 0 -4.37908 -2.48453 0.2 4.37908 -2.48453 0.2 -4.37908 2.48453 0.2 4.37908 2.48453 0.2</float_array>
<technique_common>
<accessor source="#Box01-mesh-positions-array" count="8" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="Box01-mesh-normals">
<float_array id="Box01-mesh-normals-array" count="72">0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 1 0 0 1 0 0 1 0 0 1 0 -1 0 0 -1 0 0 -1 0 0 -1 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 1 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0</float_array>
<technique_common>
<accessor source="#Box01-mesh-normals-array" count="24" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="Box01-mesh-map-channel1">
<float_array id="Box01-mesh-map-channel1-array" count="42">0.091845 0.913759 0.5 0.091805 0.497933 0.5 0.145345 0.032973 0.5 0.887265 0.032973 0.5 0.145345 0.433259 0.5 0.887265 0.433259 0.5 0.935204 0.497908 0.5 0.935242 0.913748 0.5 0.145336 0.969617 0.5 0.887258 0.969617 0.5 0.145327 0.497898 0.5 0.887255 0.497898 0.5 0.145327 0.913754 0.5 0.887255 0.913754 0.5</float_array>
<technique_common>
<accessor source="#Box01-mesh-map-channel1-array" count="14" stride="3">
<param name="S" type="float"/>
<param name="T" type="float"/>
<param name="P" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="Box01-mesh-vertices">
<input semantic="POSITION" source="#Box01-mesh-positions"/>
</vertices>
<triangles material="Material__4" count="12">
<input semantic="VERTEX" source="#Box01-mesh-vertices" offset="0"/>
<input semantic="NORMAL" source="#Box01-mesh-normals" offset="1"/>
<input semantic="TEXCOORD" source="#Box01-mesh-map-channel1" offset="2" set="1"/>
<p>0 0 2 2 1 4 3 2 5 3 2 5 1 3 3 0 0 2 4 4 10 5 5 11 7 6 13 7 6 13 6 7 12 4 4 10 0 8 4 1 9 5 5 10 11 5 10 11 4 11 10 0 8 4 1 12 6 3 13 7 7 14 13 7 14 13 5 15 11 1 12 6 3 16 9 2 17 8 6 18 12 6 18 12 7 19 13 3 16 9 2 20 1 0 21 0 4 22 12 4 22 12 6 23 10 2 20 1</p>
</triangles>
</mesh>
</geometry>
</library_geometries>
<library_visual_scenes>
<visual_scene id="plane02.max" name="plane02_max">
<node id="Box01-node" name="Box01" type="NODE">
<translate>0 0 10</translate>
<scale>0.295111 0.295111 1</scale>
<instance_geometry url="#Box01-mesh">
<bind_material>
<technique_common>
<instance_material symbol="Material__4" target="#Material__4">
<bind_vertex_input semantic="CHANNEL1" input_semantic="TEXCOORD" input_set="1"/>
</instance_material>
</technique_common>
</bind_material>
</instance_geometry>
</node>
<extra>
<technique profile="FCOLLADA">
<start_time>0</start_time>
<end_time>3.33333</end_time>
</technique>
</extra>
<extra>
<technique profile="MAX3D">
<frame_rate>30</frame_rate>
</technique>
</extra>
</visual_scene>
</library_visual_scenes>
<scene>
<instance_visual_scene url="#plane02.max"/>
</scene>
</COLLADA>

0 comments on commit 5a8ffc1

Please sign in to comment.