Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

merged in changes from bug #126.

  • Loading branch information...
commit bb2500559a1684c37de148a1a2b11c9cf699dd5f 1 parent 17e352c
@Callaghan Callaghan authored
View
198 c3dl-dev/tests/backBearing/duck.dae
198 additions, 0 deletions not shown
View
BIN  c3dl-dev/tests/backBearing/duck.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
41 c3dl-dev/tests/backBearing/index.html
@@ -0,0 +1,41 @@
+<!--
+ Copyright (c) 2008 Seneca College
+ Licenced under the MIT License (http://www.c3dl.org/index.php/mit-license/)
+-->
+<html>
+ <head>
+ <title>C3DL Picking Back-Bearing test</title>
+ <script type="application/javascript" src="../../../c3dl/c3dapi.js" ></script>
+ <script type="application/javascript" src="test.js"></script>
+ <link rel="stylesheet" type="text/css" href="../style.css" />
+ <style>
+ canvas
+ {
+ width:500px;
+ height:500px;
+ border:1px solid #000;
+ }
+ span, div
+ {
+ font-size: 12px;
+ border:1px solid #000;
+ }
+ </style>
+ </head>
+ <body>
+ <h1><a href="http://www.c3dl.org">C3DL</a>Picking Back-Bearing Test</h1>
+
+ <p>
+ This pages tests to make sure that picking does not detect points behind the camera.<br />
+ An issue was identified where an object that extended behind the camera could have<br />
+ the portion behind the camera show up as picked. This occured because the ray used<br />
+ for picking did not determine the direction from the source to the object it hit.<br />
+ In short, a mirror image of the ray was being fired in the opposite direction and<br />
+ hitting things behind the camera. Clicking slightly above the end of the road<br />
+ that projects into the scene (and behind the camera) caused it to show up as picked<br />
+ (and start spinning). This should no longer happen.<br />
+ </p>
+ <!-- Add a canvas element to the page. It is scripted by using its id -->
+ <canvas id="tutorial" style="border: 2px solid blue" width="500" height="500"></canvas>
+ </body>
+</html>
View
114 c3dl-dev/tests/backBearing/road.dae
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="utf-8"?>
+<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
+ <asset>
+ <contributor>
+ <author>jhocking</author>
+ <authoring_tool>OpenCOLLADA for 3ds Max; Version: 1.2.5; Revision: 734:737M; Platform: Win32; Configuration: Release_Max2011_static</authoring_tool>
+ <source_data>file:///C:/xampplite/htdocs/c3d-panorama/road.max</source_data>
+ </contributor>
+ <created>2011-01-21T12:56:22</created>
+ <modified>2011-01-21T12:56:22</modified>
+ <unit name="inch" meter="0.0254"/>
+ <up_axis>Z_UP</up_axis>
+ </asset>
+ <library_effects>
+ <effect id="ColorEffectR143G224B87">
+ <profile_COMMON>
+ <technique sid="common">
+ <phong>
+ <ambient>
+ <color>0.5607843 0.8784314 0.3411765 1</color>
+ </ambient>
+ <diffuse>
+ <color>0.5607843 0.8784314 0.3411765 1</color>
+ </diffuse>
+ <specular>
+ <color>1 1 1 1</color>
+ </specular>
+ <shininess>
+ <float>10</float>
+ </shininess>
+ <reflective>
+ <color>0 0 0 1</color>
+ </reflective>
+ <transparent>
+ <color>1 1 1 1</color>
+ </transparent>
+ <transparency>
+ <float>1</float>
+ </transparency>
+ </phong>
+ </technique>
+ </profile_COMMON>
+ </effect>
+ </library_effects>
+ <library_materials>
+ <material id="ColorEffectR143G224B87-material" name="ColorEffectR143G224B87-material">
+ <instance_effect url="#ColorEffectR143G224B87"/>
+ </material>
+ </library_materials>
+ <library_geometries>
+ <geometry id="geom-Plane001" name="Plane001">
+ <mesh>
+ <source id="geom-Plane001-positions">
+ <float_array id="geom-Plane001-positions-array" count="510">-127.1318 -1007.266 28.33737 -63.56586 -1007.266 28.33737 -2.15971e-6 -1007.266 28.33737 63.56588 -1007.266 28.33736 127.1318 -1007.266 28.33736 -162.0191 -879.0221 -6.005867 -81.00956 -879.2859 -5.958204 -2.61214e-6 -879.286 -5.958206 81.00956 -879.286 -5.958206 162.0191 -879.0222 -6.005871 -200.0479 -750.9747 -19.97624 -100.0239 -751.0861 -19.9705 -3.82039e-7 -751.0861 -19.9705 100.0239 -751.0861 -19.9705 200.0479 -750.9747 -19.97624 -200 -625 -20 -100 -625 -20 0 -625 -20 100 -625 -20 200 -625 -20 -200 -500 -20 -100 -500 -20 0 -500 -20 100 -500 -20 200 -500 -20 -200 -375 -20 -100 -375 -20 0 -375 -20 100 -375 -20 200 -375 -20 -200 -250 -20 -100 -250 -20 0 -250 -20 100 -250 -20 200 -250 -20 -200 -125 -20 -100 -125 -20 0 -125 -20 100 -125 -20 200 -125 -20 -200 0 -20 -100 0 -20 0 0 -20 100 0 -20 200 0 -20 -200 125 -20 -100 125 -20 0 125 -20 100 125 -20 200 125 -20 -200 250 -20 -100 250 -20 0 250 -20 100 250 -20 200 250 -20 -200 375 -20 -100 375 -20 0 375 -20 100 375 -20 200 375 -20 -200 500 -20 -100 500 -20 0 500 -20 100 500 -20 200 500 -20 -200 625 -20 -100 625 -20 0 625 -20 100 625 -20 200 625 -20 -200.0479 751.0787 -19.97091 -100.0239 751.195 -19.96428 0 751.195 -19.96428 100.0239 751.195 -19.96428 200.0479 751.0787 -19.97091 -164.1685 877.9907 -4.728601 -82.08423 878.2873 -4.671347 1.20081e-6 878.2873 -4.671345 82.08423 878.2873 -4.671345 164.1685 877.9907 -4.7286 -122.2425 1003.284 30.7945 -61.12125 1003.284 30.7945 1.15382e-5 1003.284 30.7945 61.12125 1003.284 30.79452 122.2425 1003.284 30.79451 -127.1318 -1002.081 47.65345 -63.56586 -1002.081 47.65345 -1.40933e-6 -1002.081 47.65345 63.56588 -1002.081 47.65345 127.1318 -1002.081 47.65345 -162.0191 -875.598 13.69885 -81.00956 -875.598 13.69885 0 -875.5981 13.69884 81.00956 -875.5981 13.69884 162.0191 -875.5981 13.69884 -200.0479 -750.0002 -1.1555e-6 -100.0239 -750.0002 -1.1555e-6 0 -750.0002 -1.1555e-6 100.0239 -750.0002 -1.1555e-6 200.0479 -750.0002 -1.1555e-6 -200 -625 0 -100 -625 0 0 -625 0 100 -625 0 200 -625 0 -200 -500 0 -100 -500 0 0 -500 0 100 -500 0 200 -500 0 -200 -375 0 -100 -375 0 0 -375 0 100 -375 0 200 -375 0 -200 -250 0 -100 -250 0 0 -250 0 100 -250 0 200 -250 0 -200 -125 0 -100 -125 0 0 -125 0 100 -125 0 200 -125 0 -200 0 0 -100 0 0 0 0 0 100 0 0 200 0 0 -200 125 0 -100 125 0 0 125 0 100 125 0 200 125 0 -200 250 0 -100 250 0 0 250 0 100 250 0 200 250 0 -200 375 0 -100 375 0 0 375 0 100 375 0 200 375 0 -200 500 0 -100 500 0 0 500 0 100 500 0 200 500 0 -200 625 0 -100 625 0 0 625 0 100 625 0 200 625 0 -200.0479 750.0002 -4.9702e-6 -100.0239 750.0002 -4.9702e-6 0 750.0002 -4.9702e-6 100.0239 750.0002 -4.9702e-6 200.0479 750.0002 -4.9702e-6 -164.1685 874.3483 14.93692 -82.08423 874.3483 14.93692 2.38897e-11 874.3483 14.93692 82.08423 874.3483 14.93692 164.1685 874.3483 14.93692 -122.2425 997.8162 50.03241 -61.12125 997.8162 50.03241 3.07588e-6 997.8162 50.03241 61.12125 997.816 50.03243 122.2425 997.816 50.03242</float_array>
+ <technique_common>
+ <accessor source="#geom-Plane001-positions-array" count="170" stride="3">
+ <param name="X" type="float"/>
+ <param name="Y" type="float"/>
+ <param name="Z" type="float"/>
+ </accessor>
+ </technique_common>
+ </source>
+ <source id="geom-Plane001-normals">
+ <float_array id="geom-Plane001-normals-array" count="774">-8.88217e-5 -0.2588125 -0.9659275 -4.62161e-5 -0.1711047 -0.9852529 -1.92911e-6 -0.1843395 -0.9828625 -6.56097e-8 -0.2588425 -0.9659196 -1.18875e-7 -0.1842866 -0.9828726 -2.32239e-8 -0.2588426 -0.9659195 5.03934e-5 -0.1843423 -0.9828621 4.42796e-5 -0.2588002 -0.9659309 -5.57872e-5 -0.171034 -0.9852651 0 -0.2586807 -0.9659628 -1.06002e-5 -0.04893781 -0.9988018 2.4834e-5 -0.05450863 -0.9985133 -1.67289e-8 -0.05452403 -0.9985124 9.2999e-6 -0.05453933 -0.9985117 -5.03147e-5 -0.04896302 -0.9988006 0 -9.43003e-5 -1 6.10182e-6 -1.10478e-4 -1 0 -1.16972e-4 -1 0 -1.16972e-4 -1 -1.22091e-5 -1.07306e-4 -1 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 0 -1 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 0 -1 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 0 -1 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 0 -1 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 0 -1 1.40686e-5 1.30379e-4 -1 0 1.41508e-4 -1 0 1.41508e-4 -1 -7.0311e-6 1.34023e-4 -1 0 1.15389e-4 -1 5.81282e-5 0.05416933 -0.9985317 -1.05182e-5 0.05999972 -0.9981984 0 0.05998231 -0.9981995 -2.87712e-5 0.05996498 -0.9982006 1.22999e-5 0.05413947 -0.9985333 6.48571e-5 0.1819196 -0.9833134 -6.00296e-5 0.1968834 -0.980427 7.03959e-8 0.1968171 -0.9804403 4.6181e-6 0.1968796 -0.9804277 5.17455e-5 0.1820032 -0.9832979 0 0.2727674 -0.9620801 -5.11702e-5 0.2729116 -0.9620391 4.41698e-7 0.2729585 -0.9620258 2.61244e-7 0.2729588 -0.9620258 1.02214e-4 0.2729286 -0.9620343 1.33719e-7 0.1843929 0.9828526 0 0.1712029 0.9852358 0 0.2592722 0.9658043 8.11222e-8 0.2592723 0.9658043 1.30607e-7 0.1843929 0.9828526 3.75192e-8 0.2592725 0.9658042 7.80021e-9 0.1843929 0.9828526 6.28456e-8 0.2592724 0.9658043 0 0.1712029 0.9852358 0 0.2592724 0.9658042 0 0.05429316 0.9985251 0 0.04872768 0.9988121 1.91019e-8 0.0542931 0.998525 0 0.05429308 0.998525 0 0.04872762 0.9988121 0 -4.62201e-9 1 0 -4.62257e-9 0.9999999 0 -4.62201e-9 1 0 -4.62201e-9 1 0 -4.62257e-9 0.9999999 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 0 1 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 0 1 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 0 1 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 0 1 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 0 1 0 1.98808e-8 1 0 1.98832e-8 0.9999999 0 1.98808e-8 1 0 1.98808e-8 1 0 1.98832e-8 0.9999999 0 -0.05973897 0.9982139 0 -0.05392268 0.9985452 0 -0.05973897 0.9982139 0 -0.05973897 0.998214 0 -0.05392267 0.9985452 0 -0.1969503 0.9804135 0 -0.1821204 0.9832762 -6.00394e-8 -0.1969503 0.9804134 8.91533e-9 -0.1969505 0.9804134 0 -0.1821206 0.9832762 0 -0.2734168 0.9618956 0 -0.2734168 0.9618956 -4.23116e-7 -0.2734168 0.9618957 -2.49563e-7 -0.2734171 0.9618956 8.06761e-8 -0.2734172 0.9618956 -0.9626012 -0.2667307 0.04747276 -0.9671647 -0.2454599 0.06589397 -0.9670836 -0.2463027 0.06390837 -0.9625508 -0.2673692 0.04482884 0 -0.9658046 0.2592713 -7.54859e-10 -0.9658045 0.2592713 0 -0.9658046 0.2592713 0 -0.9658045 0.2592713 1.16695e-8 -0.9658046 0.2592713 1.24243e-8 -0.9658046 0.2592713 1.55593e-8 -0.9658045 0.2592713 1.55593e-8 -0.9658046 0.2592713 0.9663791 -0.2488741 0.0645984 0.9623626 -0.2680479 0.04481812 0.9623258 -0.2677055 0.04756757 0.9663002 -0.2486149 0.06674097 0 -0.9658046 0.2592713 0 -0.9658045 0.2592713 -0.9894392 -0.1446824 0.008790202 -0.9892684 -0.1459357 0.007120447 0.9897689 -0.1425097 0.006953359 0.9896303 -0.143377 0.008641046 -0.9999999 1.91306e-4 -9.35083e-7 -0.9999999 1.91467e-4 0 0.9999999 1.89974e-4 0 1 1.90134e-4 -9.35178e-7 -0.9999999 0 0 -0.9999999 0 0 0.9999999 0 0 0.9999999 0 0 -0.9999999 0 0 -0.9999999 0 0 0.9999999 0 0 0.9999999 0 0 -0.9999999 0 0 -0.9999999 0 0 0.9999999 0 0 0.9999999 0 0 -0.9999999 0 0 -0.9999999 0 0 0.9999999 0 0 0.9999999 0 0 -0.9999999 0 0 -0.9999999 0 0 0.9999999 0 0 0.9999999 0 0 -0.9999999 0 0 -0.9999999 0 0 0.9999999 0 0 0.9999999 0 0 -0.9999999 0 0 -0.9999999 0 0 0.9999999 0 0 0.9999999 0 0 -0.9999999 0 0 -0.9999999 0 0 0.9999999 0 0 0.9999999 0 0 -0.9999999 0 0 -0.9999999 0 0 0.9999999 0 0 0.9999999 0 0 -1 -1.89815e-4 0 -1 -1.89993e-4 -1.03402e-6 1 -1.91287e-4 -1.03392e-6 1 -1.91467e-4 0 -0.9907004 0.135863 0.007337688 -0.990568 0.1367237 0.009044639 0.9903835 0.1380424 0.009210845 0.9902169 0.1393334 0.007525029 -0.9566248 0.2867657 0.05132722 -0.9564078 0.286911 0.05446217 0.956782 0.2856861 0.05433076 0.9565324 0.2870409 0.05151051 -0.9506975 0.2990265 0.08220308 -0.9505774 0.2986567 0.08489233 0 0.9618958 0.2734162 0 0.9618958 0.2734162 0 0.9618958 0.2734162 0 0.9618958 0.2734162 9.13614e-7 0.9618958 0.2734162 9.14473e-7 0.9618958 0.2734162 9.34086e-7 0.9618958 0.2734163 9.34944e-7 0.9618958 0.2734162 3.41289e-8 0.9618958 0.2734162 3.41289e-8 0.9618958 0.2734162 0.9518886 0.2947672 0.08378675 0.9517654 0.2958591 0.08130311</float_array>
+ <technique_common>
+ <accessor source="#geom-Plane001-normals-array" count="258" stride="3">
+ <param name="X" type="float"/>
+ <param name="Y" type="float"/>
+ <param name="Z" type="float"/>
+ </accessor>
+ </technique_common>
+ </source>
+ <vertices id="geom-Plane001-vertices">
+ <input semantic="POSITION" source="#geom-Plane001-positions"/>
+ </vertices>
+ <triangles material="ColorMaterial" count="336">
+ <input semantic="VERTEX" source="#geom-Plane001-vertices" offset="0"/>
+ <input semantic="NORMAL" source="#geom-Plane001-normals" offset="1"/>
+ <p>0 0 5 1 6 2 6 2 1 3 0 0 1 3 6 2 7 4 7 4 2 5 1 3 2 5 7 4 8 6 8 6 3 7 2 5 3 7 8 6 9 8 9 8 4 9 3 7 5 1 10 10 11 11 11 11 6 2 5 1 6 2 11 11 12 12 12 12 7 4 6 2 7 4 12 12 13 13 13 13 8 6 7 4 8 6 13 13 14 14 14 14 9 8 8 6 10 10 15 15 16 16 16 16 11 11 10 10 11 11 16 16 17 17 17 17 12 12 11 11 12 12 17 17 18 18 18 18 13 13 12 12 13 13 18 18 19 19 19 19 14 14 13 13 15 15 20 20 21 21 21 21 16 16 15 15 16 16 21 21 22 22 22 22 17 17 16 16 17 17 22 22 23 23 23 23 18 18 17 17 18 18 23 23 24 24 24 24 19 19 18 18 20 20 25 25 26 26 26 26 21 21 20 20 21 21 26 26 27 27 27 27 22 22 21 21 22 22 27 27 28 28 28 28 23 23 22 22 23 23 28 28 29 29 29 29 24 24 23 23 25 25 30 30 31 31 31 31 26 26 25 25 26 26 31 31 32 32 32 32 27 27 26 26 27 27 32 32 33 33 33 33 28 28 27 27 28 28 33 33 34 34 34 34 29 29 28 28 30 30 35 35 36 36 36 36 31 31 30 30 31 31 36 36 37 37 37 37 32 32 31 31 32 32 37 37 38 38 38 38 33 33 32 32 33 33 38 38 39 39 39 39 34 34 33 33 35 35 40 40 41 41 41 41 36 36 35 35 36 36 41 41 42 42 42 42 37 37 36 36 37 37 42 42 43 43 43 43 38 38 37 37 38 38 43 43 44 44 44 44 39 39 38 38 40 40 45 45 46 46 46 46 41 41 40 40 41 41 46 46 47 47 47 47 42 42 41 41 42 42 47 47 48 48 48 48 43 43 42 42 43 43 48 48 49 49 49 49 44 44 43 43 45 45 50 50 51 51 51 51 46 46 45 45 46 46 51 51 52 52 52 52 47 47 46 46 47 47 52 52 53 53 53 53 48 48 47 47 48 48 53 53 54 54 54 54 49 49 48 48 50 50 55 55 56 56 56 56 51 51 50 50 51 51 56 56 57 57 57 57 52 52 51 51 52 52 57 57 58 58 58 58 53 53 52 52 53 53 58 58 59 59 59 59 54 54 53 53 55 55 60 60 61 61 61 61 56 56 55 55 56 56 61 61 62 62 62 62 57 57 56 56 57 57 62 62 63 63 63 63 58 58 57 57 58 58 63 63 64 64 64 64 59 59 58 58 60 60 65 65 66 66 66 66 61 61 60 60 61 61 66 66 67 67 67 67 62 62 61 61 62 62 67 67 68 68 68 68 63 63 62 62 63 63 68 68 69 69 69 69 64 64 63 63 65 65 70 70 71 71 71 71 66 66 65 65 66 66 71 71 72 72 72 72 67 67 66 66 67 67 72 72 73 73 73 73 68 68 67 67 68 68 73 73 74 74 74 74 69 69 68 68 70 70 75 75 76 76 76 76 71 71 70 70 71 71 76 76 77 77 77 77 72 72 71 71 72 72 77 77 78 78 78 78 73 73 72 72 73 73 78 78 79 79 79 79 74 74 73 73 75 75 80 80 81 81 81 81 76 76 75 75 76 76 81 81 82 82 82 82 77 77 76 76 77 77 82 82 83 83 83 83 78 78 77 77 78 78 83 83 84 84 84 84 79 79 78 78 91 85 90 86 85 87 85 87 86 88 91 85 92 89 91 85 86 88 86 88 87 90 92 89 93 91 92 89 87 90 87 90 88 92 93 91 94 93 93 91 88 92 88 92 89 94 94 93 96 95 95 96 90 86 90 86 91 85 96 95 97 97 96 95 91 85 91 85 92 89 97 97 98 98 97 97 92 89 92 89 93 91 98 98 99 99 98 98 93 91 93 91 94 93 99 99 101 100 100 101 95 96 95 96 96 95 101 100 102 102 101 100 96 95 96 95 97 97 102 102 103 103 102 102 97 97 97 97 98 98 103 103 104 104 103 103 98 98 98 98 99 99 104 104 106 105 105 106 100 101 100 101 101 100 106 105 107 107 106 105 101 100 101 100 102 102 107 107 108 108 107 107 102 102 102 102 103 103 108 108 109 109 108 108 103 103 103 103 104 104 109 109 111 110 110 111 105 106 105 106 106 105 111 110 112 112 111 110 106 105 106 105 107 107 112 112 113 113 112 112 107 107 107 107 108 108 113 113 114 114 113 113 108 108 108 108 109 109 114 114 116 115 115 116 110 111 110 111 111 110 116 115 117 117 116 115 111 110 111 110 112 112 117 117 118 118 117 117 112 112 112 112 113 113 118 118 119 119 118 118 113 113 113 113 114 114 119 119 121 120 120 121 115 116 115 116 116 115 121 120 122 122 121 120 116 115 116 115 117 117 122 122 123 123 122 122 117 117 117 117 118 118 123 123 124 124 123 123 118 118 118 118 119 119 124 124 126 125 125 126 120 121 120 121 121 120 126 125 127 127 126 125 121 120 121 120 122 122 127 127 128 128 127 127 122 122 122 122 123 123 128 128 129 129 128 128 123 123 123 123 124 124 129 129 131 130 130 131 125 126 125 126 126 125 131 130 132 132 131 130 126 125 126 125 127 127 132 132 133 133 132 132 127 127 127 127 128 128 133 133 134 134 133 133 128 128 128 128 129 129 134 134 136 135 135 136 130 131 130 131 131 130 136 135 137 137 136 135 131 130 131 130 132 132 137 137 138 138 137 137 132 132 132 132 133 133 138 138 139 139 138 138 133 133 133 133 134 134 139 139 141 140 140 141 135 136 135 136 136 135 141 140 142 142 141 140 136 135 136 135 137 137 142 142 143 143 142 142 137 137 137 137 138 138 143 143 144 144 143 143 138 138 138 138 139 139 144 144 146 145 145 146 140 141 140 141 141 140 146 145 147 147 146 145 141 140 141 140 142 142 147 147 148 148 147 147 142 142 142 142 143 143 148 148 149 149 148 148 143 143 143 143 144 144 149 149 151 150 150 151 145 146 145 146 146 145 151 150 152 152 151 150 146 145 146 145 147 147 152 152 153 153 152 152 147 147 147 147 148 148 153 153 154 154 153 153 148 148 148 148 149 149 154 154 156 155 155 156 150 151 150 151 151 150 156 155 157 157 156 155 151 150 151 150 152 152 157 157 158 158 157 157 152 152 152 152 153 153 158 158 159 159 158 158 153 153 153 153 154 154 159 159 161 160 160 161 155 156 155 156 156 155 161 160 162 162 161 160 156 155 156 155 157 157 162 162 163 163 162 162 157 157 157 157 158 158 163 163 164 164 163 163 158 158 158 158 159 159 164 164 166 165 165 166 160 161 160 161 161 160 166 165 167 167 166 165 161 160 161 160 162 162 167 167 168 168 167 167 162 162 162 162 163 163 168 168 169 169 168 168 163 163 163 163 164 164 169 169 5 170 0 171 85 172 85 172 90 173 5 170 0 174 1 175 86 176 86 176 85 177 0 174 1 175 2 178 87 179 87 179 86 176 1 175 2 178 3 180 88 181 88 181 87 179 2 178 4 182 9 183 94 184 94 184 89 185 4 182 3 180 4 186 89 187 89 187 88 181 3 180 10 188 5 170 90 173 90 173 95 189 10 188 9 183 14 190 99 191 99 191 94 184 9 183 15 192 10 188 95 189 95 189 100 193 15 192 14 190 19 194 104 195 104 195 99 191 14 190 20 196 15 192 100 193 100 193 105 197 20 196 19 194 24 198 109 199 109 199 104 195 19 194 25 200 20 196 105 197 105 197 110 201 25 200 24 198 29 202 114 203 114 203 109 199 24 198 30 204 25 200 110 201 110 201 115 205 30 204 29 202 34 206 119 207 119 207 114 203 29 202 35 208 30 204 115 205 115 205 120 209 35 208 34 206 39 210 124 211 124 211 119 207 34 206 40 212 35 208 120 209 120 209 125 213 40 212 39 210 44 214 129 215 129 215 124 211 39 210 45 216 40 212 125 213 125 213 130 217 45 216 44 214 49 218 134 219 134 219 129 215 44 214 50 220 45 216 130 217 130 217 135 221 50 220 49 218 54 222 139 223 139 223 134 219 49 218 55 224 50 220 135 221 135 221 140 225 55 224 54 222 59 226 144 227 144 227 139 223 54 222 60 228 55 224 140 225 140 225 145 229 60 228 59 226 64 230 149 231 149 231 144 227 59 226 65 232 60 228 145 229 145 229 150 233 65 232 64 230 69 234 154 235 154 235 149 231 64 230 70 236 65 232 150 233 150 233 155 237 70 236 69 234 74 238 159 239 159 239 154 235 69 234 75 240 70 236 155 237 155 237 160 241 75 240 74 238 79 242 164 243 164 243 159 239 74 238 80 244 75 240 160 241 160 241 165 245 80 244 81 246 80 247 165 248 165 248 166 249 81 246 82 250 81 246 166 249 166 249 167 251 82 250 83 252 82 250 167 251 167 251 168 253 83 252 84 254 83 252 168 253 168 253 169 255 84 254 79 242 84 256 169 257 169 257 164 243 79 242</p>
+ </triangles>
+ </mesh>
+ </geometry>
+ </library_geometries>
+ <library_lights>
+ <light id="EnvironmentAmbientLight" name="EnvironmentAmbientLight">
+ <technique_common>
+ <ambient>
+ <color>0 0 0</color>
+ </ambient>
+ </technique_common>
+ </light>
+ </library_lights>
+ <library_visual_scenes>
+ <visual_scene id="MaxScene">
+ <node name="EnvironmentAmbientLight">
+ <instance_light url="#EnvironmentAmbientLight"/>
+ </node>
+ <node id="node-Plane001" name="Plane001">
+ <translate>70 0 -45</translate>
+ <rotate>1 0 0 -2.499998</rotate>
+ <instance_geometry url="#geom-Plane001">
+ <bind_material>
+ <technique_common>
+ <instance_material symbol="ColorMaterial" target="#ColorEffectR143G224B87-material"/>
+ </technique_common>
+ </bind_material>
+ </instance_geometry>
+ </node>
+ </visual_scene>
+ </library_visual_scenes>
+ <scene>
+ <instance_visual_scene url="#MaxScene"/>
+ </scene>
+</COLLADA>
View
110 c3dl-dev/tests/backBearing/test.js
@@ -0,0 +1,110 @@
+// Tutorial 6: picking
+
+// The models used need to be parsed before the page
+// renders. This code will parse the model files
+// and when this is complete the parser will call the
+// main. The argument being passed - "tutorial" -
+// is the id of the canvas element on the html page.
+
+c3dl.addMainCallBack(canvasMain, "tutorial");
+c3dl.addModel("duck.dae");
+c3dl.addModel("road.dae");
+var drawPoint;
+
+// The program main
+function canvasMain(canvasName){
+
+ // Create new c3dl.Scene object
+ scn = new c3dl.Scene();
+ scn.setCanvasTag(canvasName);
+
+ // Create GL context
+ renderer = new c3dl.WebGL();
+ renderer.createRenderer(this);
+
+ // Attach renderer to the scene
+ scn.setRenderer(renderer);
+
+ var things = [];
+ if(scn.init(canvasName))
+ {
+ for(var i=0;i<4;i++)
+ {
+ things[i] = new c3dl.Collada();
+ things[i].init("duck.dae");
+ things[i].scale(new Array(0.05,0.05,0.05));
+
+ // set the position of the teapot
+ things[i].translate(new Array(-7 + i*9,1,-25));
+
+ // Add the object to the scene
+ scn.addObjectToScene(things[i]);
+ }
+
+ things[4] = new c3dl.Collada();
+ things[4].init("road.dae");
+ things[4].setPosition([0, 0, -15]);
+ scn.addObjectToScene(things[4]);
+
+ // Create a camera
+ var cam = new c3dl.FreeCamera();
+
+ // Place the camera at the origin.
+ // Canvas3d uses a right handed co-ordinate system.
+ cam.setPosition([0.0, 0.0, 200.0]);
+
+ // Point the camera.
+ // Here it is pointed directly along the z-axis
+ cam.setLookAtPoint([0.0, 0.0, -10.0]);
+
+ // Add the camera to the scene
+ scn.setCamera(cam);
+
+ // Start the scene
+ scn.startScene();
+
+ // tell the scene what function to use when
+ // a mouse event is detected
+ scn.setPickingCallback(handler);
+
+ }
+}
+
+// This function is the callback that is passed to the scene.
+// When a mouse down event is detected this function is called.
+// The handler is given an object that knows what button was
+// pressed and has a list of objects picked.
+function handler(result)
+{
+ var buttonUsed = result.getButtonUsed();
+ var objectsPicked = result.getObjects();
+ if(objectsPicked != undefined)
+ {
+ // a left mouse click will equal 1;
+ // at present that is the only mouse event implemented
+ if (buttonUsed == 1)
+ {
+ // loop through the objects
+ for(var i = 0 ; i < objectsPicked.length; i++)
+ {
+ // get the object that was picked
+ obj = objectsPicked[i];
+ //obj.setVisible(false);
+ // manipulate the object
+ if(obj.getAngularVel()[0] > 0)
+ {
+ obj.setAngularVel([0, 0, 0]);
+ }
+ else
+ {
+ obj.setAngularVel([0.0003,0.0008,0]);
+ }
+ if(i == 0) {
+ /*var cam = scn.getCamera();
+ cam.setPosition([0,10,0]);
+ cam.setLookAtPoint(drawPoint.getPosition());*/
+ }
+ }
+ }
+ }
+}
View
25 c3dl/interaction/picking.js
@@ -568,10 +568,27 @@ c3dl.rayIntersectsTriangle = function (orig, dir, vert0, vert1, vert2)
// should be near zero.
var diff = area - (area1 + area2 + area3);
- // delete edg1, edge2, edge3, area1, area2, area3, normDotDir, normDotRayorig, t, POI, area;
- // since we have done quite a few calculations on floats,
- // allow a small margin of error.
- return (Math.abs(diff) <= 0.0001);
+ if(Math.abs(diff) <= 0.0001) {
+ //get vector from ray origin to poi
+ var otherdir = c3dl.subtractVectors(POI,orig);
+ //get unit vector of that
+ var normOtherDir = c3dl.normalizeVector(otherdir);
+
+ //get unit vector of original dir (uvd)
+ var normDir = c3dl.normalizeVector(dir);
+ //find the angle between those two vectors
+ var angle = c3dl.getAngleBetweenVectors(normOtherDir,normDir);
+ //if it is less than 90, the object is probably visible
+ if(angle < 90) {
+ return true;
+ }
+ else {//if it is greater than 90, this is behind the point of origin somewhere
+ return false;
+ }
+ }
+ else {
+ return false;
+ }
}
c3dl.rayAABBIntersect = function (orig, dir, maxMins) {
Please sign in to comment.
Something went wrong with that request. Please try again.