Editing
Appendix/Ramblings/VirtualReality
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Cube Trio by a Blender Developer=== ====Implementing the Raw COLLADA Code==== We have found another relatively simple COLLADA-formatted 3D model file on a [https://developer.blender.org/F18376 web page titled, "cube.dae,"] that has been provided by [https://www.blender.org Blender] author, Martjn Berger. The interactive scene that is generated by this model file includes three separate — but identical — cubes; four of the cube faces are painted with one color (e.g., blue), another face is painted with a different color (e.g., green), and the sixth face is painted with yet a different color (e.g., red). The COLLADA-formatted (.dae) file presented immediately below as ''Example #4'' is modified slightly from this original [https://www.blender.org Blender] example; on my Mac, the filename is: '''/Dropbox/3Dviewers/Cube/FirstCube/colladaPlay06.dae''' <table border="0" align="center" width="80%" cellpadding="5"> <tr><th align="center" colspan="3">Example #4 — A [https://developer.blender.org/F18376 cube trio], slightly modified from a COLLADA file posted by [https://www.blender.org Blender]</th></tr> <tr><td align="left" colspan="2"> <div style="height: 400px; width: 700px; overflow: scroll;"> <pre> <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1"> <asset> <contributor> <authoring_tool>Google SketchUp 8.0.11752</authoring_tool> </contributor> <created>2012-04-27T21:07:03Z</created> <modified>2012-04-27T21:07:03Z</modified> <unit meter="0.0254" name="inch" /> <up_axis>Z_UP</up_axis> </asset> <library_visual_scenes> <visual_scene id="ID1"> <node name="SketchUp"> <node id="ID2" name="instance_0"> <matrix>1 0 0 0 0 1 0 25 0 0 1 0 0 0 0 1</matrix> <instance_node url="#ID3" /> </node> <node id="ID28" name="instance_1"> <matrix>1 0 0 15 0 1 0 120 0 0 1 0 0 0 0 1</matrix> <instance_node url="#ID3" /> </node> <node id="ID29" name="instance_2"> <matrix>1 0 0 120 0 1 0 0 0 0 1 0 0 0 0 1</matrix> <instance_node url="#ID3" /> </node> </node> </visual_scene> </library_visual_scenes> <library_nodes> <node id="ID3" name="cube_component"> <instance_geometry url="#ID4"> <bind_material> <technique_common> <instance_material symbol="Material2" target="#ID6"> <bind_vertex_input semantic="UVSET0" input_semantic="TEXCOORD" input_set="0" /> </instance_material> </technique_common> </bind_material> </instance_geometry> <instance_geometry url="#ID12"> <bind_material> <technique_common> <instance_material symbol="Material2" target="#ID13"> <bind_vertex_input semantic="UVSET0" input_semantic="TEXCOORD" input_set="0" /> </instance_material> </technique_common> </bind_material> </instance_geometry> <instance_geometry url="#ID20"> <bind_material> <technique_common> <instance_material symbol="Material2" target="#ID21"> <bind_vertex_input semantic="UVSET0" input_semantic="TEXCOORD" input_set="0" /> </instance_material> </technique_common> </bind_material> </instance_geometry> </node> </library_nodes> <library_geometries> <geometry id="ID4"> <mesh> <source id="ID7"> <float_array id="ID10" count="48">39.37007874015748 39.37007874015748 0 0 0 0 0 39.37007874015748 0 39.37007874015748 0 0 0 39.37007874015748 39.37007874015748 39.37007874015748 39.37007874015748 0 0 39.37007874015748 0 39.37007874015748 39.37007874015748 39.37007874015748 39.37007874015748 39.37007874015748 0 39.37007874015748 0 39.37007874015748 39.37007874015748 0 0 39.37007874015748 39.37007874015748 39.37007874015748 39.37007874015748 0 39.37007874015748 0 39.37007874015748 39.37007874015748 0 0 39.37007874015748 39.37007874015748 39.37007874015748 39.37007874015748</float_array> <technique_common> <accessor count="16" source="#ID10" stride="3"> <param name="X" type="float" /> <param name="Y" type="float" /> <param name="Z" type="float" /> </accessor> </technique_common> </source> <source id="ID8"> <float_array id="ID11" count="48">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 0 1 0 0 1 0 0 1 0 0 1</float_array> <technique_common> <accessor count="16" source="#ID11" stride="3"> <param name="X" type="float" /> <param name="Y" type="float" /> <param name="Z" type="float" /> </accessor> </technique_common> </source> <vertices id="ID9"> <input semantic="POSITION" source="#ID7" /> <input semantic="NORMAL" source="#ID8" /> </vertices> <triangles count="8" material="Material2"> <input offset="0" semantic="VERTEX" source="#ID9" /> <p>0 1 2 1 0 3 4 5 6 5 4 7 8 9 10 9 8 11 12 13 14 13 12 15</p> </triangles> </mesh> </geometry> <geometry id="ID12"> <mesh> <source id="ID15"> <float_array id="ID18" count="12">39.37007874015748 0 39.37007874015748 0 0 0 39.37007874015748 0 0 0 0 39.37007874015748</float_array> <technique_common> <accessor count="4" source="#ID18" stride="3"> <param name="X" type="float" /> <param name="Y" type="float" /> <param name="Z" type="float" /> </accessor> </technique_common> </source> <source id="ID16"> <float_array id="ID19" count="12">-0 -1 -0 -0 -1 -0 -0 -1 -0 -0 -1 -0</float_array> <technique_common> <accessor count="4" source="#ID19" stride="3"> <param name="X" type="float" /> <param name="Y" type="float" /> <param name="Z" type="float" /> </accessor> </technique_common> </source> <vertices id="ID17"> <input semantic="POSITION" source="#ID15" /> <input semantic="NORMAL" source="#ID16" /> </vertices> <triangles count="2" material="Material2"> <input offset="0" semantic="VERTEX" source="#ID17" /> <p>0 1 2 1 0 3</p> </triangles> </mesh> </geometry> <geometry id="ID20"> <mesh> <source id="ID23"> <float_array id="ID26" count="12">0 39.37007874015748 39.37007874015748 0 0 0 0 0 39.37007874015748 0 39.37007874015748 0</float_array> <technique_common> <accessor count="4" source="#ID26" stride="3"> <param name="X" type="float" /> <param name="Y" type="float" /> <param name="Z" type="float" /> </accessor> </technique_common> </source> <source id="ID24"> <float_array id="ID27" count="12">-1 0 0 -1 0 0 -1 0 0 -1 0 0</float_array> <technique_common> <accessor count="4" source="#ID27" stride="3"> <param name="X" type="float" /> <param name="Y" type="float" /> <param name="Z" type="float" /> </accessor> </technique_common> </source> <vertices id="ID25"> <input semantic="POSITION" source="#ID23" /> <input semantic="NORMAL" source="#ID24" /> </vertices> <triangles count="2" material="Material2"> <input offset="0" semantic="VERTEX" source="#ID25" /> <p>0 1 2 1 0 3</p> </triangles> </mesh> </geometry> </library_geometries> <library_materials> <material id="ID6" name="material"> <instance_effect url="#ID5" /> </material> <material id="ID13" name="Color_005_"> <instance_effect url="#ID14" /> </material> <material id="ID21" name="Color_A06_"> <instance_effect url="#ID22" /> </material> </library_materials> <library_effects> <effect id="ID5"> <profile_COMMON> <technique sid="COMMON"> <lambert> <diffuse> <color>0 0 1 1</color> </diffuse> </lambert> </technique> </profile_COMMON> </effect> <effect id="ID14"> <profile_COMMON> <technique sid="COMMON"> <lambert> <diffuse> <color>0 1 0 1</color> </diffuse> </lambert> </technique> </profile_COMMON> </effect> <effect id="ID22"> <profile_COMMON> <technique sid="COMMON"> <lambert> <diffuse> <color>0.8 0 0 1</color> </diffuse> </lambert> </technique> </profile_COMMON> </effect> </library_effects> <scene> <instance_visual_scene url="#ID1" /> </scene> </COLLADA> </pre> </div> </td> <td align="center" rowspan="1" bgcolor="lightgrey">[[File:ColladaPlay06_image.png|250px|ColladaPlay06_image]]</td> </tr> <tr> <td align="left" colspan="3"> <b>Principal responsibilities of various subsections from the above, <xml>-formatted code:</b> </td> </tr> <tr> <td align="center" width="50px" bgcolor="yellow">'''A.'''</td> <td align="left" colspan="2"> <pre> <library_visual_scenes> <visual_scene ID="ID1"> <node name="SketcUp"> </pre> <font color="darkblue">Generate 3 ''instances'' of </font><font color="green">#ID3</font><font color="darkblue">, placing them at 3 separate 16-argument "matrix" positions, as [[#Understanding_the_Positioning_Matrix|explained below]].</font> <pre> </node> </visual_scene> </library_visual_scenes> </pre> </td> </tr> <tr> <td align="center" width="50px" bgcolor="lightblue">'''B.'''</td> <td align="left" colspan="2"> <pre> <library_nodes> <node id="ID3"> </pre> <font color="darkblue">Define all components of a ''single node'' that describes a simple, 6-sided (8 vertices and 12 triangles) cube; this implementation builds the cube as being composed of ''three'' separate <instance_geometries>, as defined below:</font> <ul> <li><font color="#FF9999"><b>url = "</b></font><font color="darkgreen">#ID4</font><font color="#FF9999"><b>" should be colored/shaded as defined by material target = "</b></font><font color="darkgreen">#ID6</font><font color="#FF9999"><b>", which in turn points to library effect = "</b></font><font color="darkgreen">#ID5</font><font color="#FF9999"><b>".</b></font></li> <li><font color="#FF9999"><b>url = "</b></font><font color="darkgreen">#ID12</font><font color="#FF9999"><b>" should be colored/shaded as defined by material target = "</b></font><font color="darkgreen">#ID13</font><font color="#FF9999"><b>", which in turn points to library effect = "</b></font><font color="darkgreen">#ID14</font><font color="#FF9999"><b>".</b></font></li> <li><font color="#FF9999"><b>url = "</b></font><font color="darkgreen">#ID20</font><font color="#FF9999"><b>" should be colored/shaded as defined by material target = "</b></font><font color="darkgreen">#ID21</font><font color="#FF9999"><b>", which in turn points to library effect = "</b></font><font color="darkgreen">#ID22</font><font color="#FF9999"><b>".</b></font></li> </ul> <pre> </node> </library_nodes> </pre> </td> </tr> <tr> <td align="center" width="50px" bgcolor="yellow">'''C.'''</td> <td align="left" colspan="2"> <pre> <library_geometries> <geometry id="…"> </pre> <font color="darkblue">Two co-planar and adjacent triangles are prescribed such that, together, they define a square, which serves as ''one'' of the six sides of the cube; ''four'' unique vertices are required, referenced as … 0, 1, 2, 3.</font><br /> <mesh><br /> <vertices id="<font color="darkgreen">ID17</font>"> <ul> <li><font color="#FF9999"><b>(X, Y, Z) coordinate locations are pulled from</b></font> <source id="<font color="darkgreen">ID15</font>"> <font color="#FF9999"><b>, which contains a total of 4 × 3 = 12 floating-point numbers.</b></font></li> <li><font color="#FF9999"><b>The (X, Y, Z)-normals assigned to the four vertices are pulled from</b></font> <source id="<font color="darkgreen">ID16</font>"> <font color="#FF9999"><b>, which also contains a total of 4 × 3 = 12 floating-point numbers … the assigned values are usually 0 or ± 1.</b></font></li> </ul> </vertices><br /> <triangles source="<font color="darkgreen">#ID17</font>" count="2"><br /> <p>0 1 2 1 0 3</p> <ul> <li><font color="#FF9999"><b>This sequence of six integers means that the 1<sup>st</sup> (of count="2") triangular polygon is formed by connecting three vertices in the order … 0, 1, 2, then back to 0; and the 2<sup>nd</sup> (of count="2") triangular polygon is formed by connecting three vertices in the order … 1, 0, 3, then back to 1.</b></font></li> </ul> </triangles><br /> </mesh> <pre> </geometry> </library_geometries> </pre> </td> </tr> </table> ====Understanding the Positioning Matrix==== Evidently, the COLLADA language allows you to reposition an object — for example, one of the cubes in this trio — (a) by explicitly specifying the separate instructions to <translate>, <rotate>, and <scale>; or (b) by specifying, in the form of a 4×4 <matrix>, a single instruction that combines all of the others via matrix multiplication. For example, in COLLADA the instruction, '''<scale>S<sub>x</sub> S<sub>y</sub> S<sub>z</sub></scale>''', is equivalent to, <table border="0" align="center" cellpadding="8"> <tr> <td align="right" rowspan="1"><b>M</b><sub>scale</sub> = </td> <td align="left"> <table border="1" cellpadding="8"> <tr> <td align="center">S<sub>x</sub></td> <td align="center">0</td> <td align="center">0</td> </tr> <tr> <td align="center">0</td> <td align="center">S<sub>y</sub></td> <td align="center">0</td> </tr> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">S<sub>z</sub></td> </tr> </table> </td> </tr> </table> And, drawing from the [https://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations Wikipedia discussion of ''Basic Rotations''] in three dimensions, we recognize that rotations about the x, y, and z axes are quantitatively defined, respectively, by the following matrices: <table border="0" align="center" cellpadding="8"> <tr> <td align="right" rowspan="1"><b>R</b><sub>x</sub>(α) = </td> <td align="left"> <table border="1" cellpadding="8"> <tr> <td align="center">1</td> <td align="center">0</td> <td align="center">0</td> </tr> <tr> <td align="center">0</td> <td align="center">cos(α)</td> <td align="center">- sin(α)</td> </tr> <tr> <td align="center">0</td> <td align="center">sin(α)</td> <td align="center">cos(α)</td> </tr> </table> </td> <td align="center"> ; <b>R</b><sub>y</sub>(β) = </td> <td align="left"> <table border="1" cellpadding="8"> <tr> <td align="center">cos(β)</td> <td align="center">0</td> <td align="center">sin(β)</td> </tr> <tr> <td align="center">0</td> <td align="center">1</td> <td align="center">0</td> </tr> <tr> <td align="center">-sin(β)</td> <td align="center">0</td> <td align="center">cos(β)</td> </tr> </table> </td> <td align="center"> ; <b>R</b><sub>z</sub>(γ) = </td> <td align="left"> <table border="1" cellpadding="8"> <tr> <td align="center">cos(γ)</td> <td align="center">- sin(γ)</td> <td align="center">0</td> </tr> <tr> <td align="center">sin(γ)</td> <td align="center">cos(γ)</td> <td align="center">0</td> </tr> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">1</td> </tr> </table> </td> </tr> </table> The equivalent instructions in COLLADA are, respectively, <table border="0" align="center" cellpadding="8"> <tr> <td align="left"> '''<rotate> 1 0 0 α </rotate>''' ; </td> <td align="left"> '''<rotate> 0 1 0 β </rotate>''' ; </td> <td align="left"> '''<rotate> 0 0 1 γ </rotate>''' . </td> </tr> </table> Drawing furthermore from the [https://en.wikipedia.org/wiki/Rotation_matrix#General_rotations Wikipedia discussion of more ''General Rotations''], we recognize that other rotation matrices can be obtained from these three using matrix multiplications. For example, the product <div align="center"> <math>~R(\alpha,\beta,\gamma) = R_z(\alpha) \times R_y(\beta) \times R_x(\gamma) \, ,</math> </div> — a 3×3 matrix — represents a rotation whose ''yaw'', ''pitch'', and ''roll'' angles are α, β, and γ, respectively. Finally, including possible translations T<sub>x</sub>, T<sub>y</sub>, and T<sub>z</sub> in the x, y, and z directions, respectively, we can write <table border="0" align="center" cellpadding="8"> <tr> <td align="center"> <table border="1" align="center" cellpadding="8"> <tr> <td align="center">x'</td> </tr> <tr> <td align="center">y'</td> </tr> <tr> <td align="center">z'</td> </tr> </table> </td> <td align="right" rowspan="1"> = </td> <td align="center"> <table border="1" align="center" cellpadding="8"> <tr> <td align="center">T_x</td> </tr> <tr> <td align="center">T_y</td> </tr> <tr> <td align="center">T_z</td> </tr> </table> </td> <td align="right" rowspan="1"> + </td> <td align="left"> <table border="1" align="center" cellpadding="2"><tr><td align="left"> <table border="0" cellpadding="8"> <tr><td align="center"> </td></tr> <tr> <td align="center">R(α, β, γ) × M<sub>scale</sub><br />'''[3×3 matrix]'''</td> </tr> <tr><td align="center"> </td></tr> </table> </td></tr></table> </td> <td align="right" rowspan="1"> × </td> <td align="center"> <table border="1" align="center" cellpadding="8"> <tr> <td align="center">x</td> </tr> <tr> <td align="center">y</td> </tr> <tr> <td align="center">z</td> </tr> </table> </td> </tr> </table> or, equivalently (I ''think'' this is correct!), <table border="0" align="center" cellpadding="8"> <tr> <td align="center"> <table border="1" align="center" cellpadding="8"> <tr> <td align="center">x'</td> </tr> <tr> <td align="center">y'</td> </tr> <tr> <td align="center">z'</td> </tr> <tr> <td align="center">1</td> </tr> </table> </td> <td align="right" rowspan="1"> = </td> <td align="left"> <table border="1" cellpadding="8"> <tr> <td align="center" colspan="3" rowspan="3">R(α, β, γ) × M<sub>scale</sub></td> <td align="center">T<sub>x</sub></td> </tr> <tr> <td align="center">T<sub>y</sub></td> </tr> <tr> <td align="center">T<sub>z</sub></td> </tr> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">0</td> <td align="center">1</td> </tr> </table> </td> <td align="right" rowspan="1"> × </td> <td align="center"> <table border="1" align="center" cellpadding="8"> <tr> <td align="center">x</td> </tr> <tr> <td align="center">y</td> </tr> <tr> <td align="center">z</td> </tr> <tr> <td align="center">1</td> </tr> </table> </td> </tr> </table> ====Example Implementation==== =====Explicit Specification of Translate and Rotate Instructions===== Here we present a COLLADA-formatted (.dae) file that is similar — and in some respects, identical — to the file presented above as ''Example #4''. The new 3D model that is generated by this file consists of three identically colored cubes, as above, but here in ''Example #5'' … * The originating cube is centered on the origin (X,Y,Z) = (0,0,0) of the coordinate system; that is, in the subsection of the .dae file titled, '''<library_geometries>''', each cube edge extends from -20 to + 20 instead of (as in ''Example #4'') from 0 to + 40. * In the subsection of the .dae file titled, '''<library_vsual_scenes>''', the location and orientation of each of the three spawned cubes is determined by the explicit commands, '''<translate>''' and '''<rotate>''', instead of (as in ''Example #4'') by the consolidated '''<matrix>''' command. On my Mac, the filename of this ''Example #5'' COLLADA-formatted (.dae) file is: '''/Dropbox/3Dviewers/Cube/FirstCube/colladaOther20_HBook.dae''' <table border="0" align="center" width="80%" cellpadding="5"> <tr><th align="center" colspan="3">Example #5 — Another Cube Trio</th></tr> <tr><td align="left" colspan="2"> <div style="height: 400px; width: 700px; overflow: scroll;"> <pre> <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1"> <asset> <contributor> <authoring_tool>Google SketchUp 8.0.11752</authoring_tool> </contributor> <created>2012-04-27T21:07:03Z</created> <modified>2012-04-27T21:07:03Z</modified> <unit meter="0.0254" name="inch" /> <up_axis>Z_UP</up_axis> </asset> <library_visual_scenes> <visual_scene id="ID1"> <node name="SketchUp"> <node id="ID2" name="instance_0"> <translate>0.0 45.0 45.0</translate> <instance_node url="#ID3" /> </node> <node id="ID28" name="instance_1"> <translate>0.0 0.0 0.0</translate> <instance_node url="#ID3" /> </node> <node id="ID29" name="instance_2"> <translate>120.0 0.0 0.0</translate> <rotate> 0 0 1 -90</rotate> <rotate> 1 0 0 -90</rotate> <rotate> 0 1 0 -90</rotate> <!-- NOTE: Mac's Preview app excutes these rotations from the bottom (first) to the top (last). For example, this one does Y-rot, then X-rot, then Z-rot --> <instance_node url="#ID3" /> </node> </node> </visual_scene> </library_visual_scenes> <library_nodes> <node id="ID3" name="cube_component"> <instance_geometry url="#ID4"> <bind_material> <technique_common> <instance_material symbol="Material2" target="#ID6"> <bind_vertex_input semantic="UVSET0" input_semantic="TEXCOORD" input_set="0" /> </instance_material> </technique_common> </bind_material> </instance_geometry> <instance_geometry url="#ID12"> <bind_material> <technique_common> <instance_material symbol="Material2" target="#ID13"> <bind_vertex_input semantic="UVSET0" input_semantic="TEXCOORD" input_set="0" /> </instance_material> </technique_common> </bind_material> </instance_geometry> <instance_geometry url="#ID20"> <bind_material> <technique_common> <instance_material symbol="Material2" target="#ID21"> <bind_vertex_input semantic="UVSET0" input_semantic="TEXCOORD" input_set="0" /> </instance_material> </technique_common> </bind_material> </instance_geometry> </node> </library_nodes> <library_geometries> <geometry id="ID4"> <mesh> <source id="ID7"> <float_array id="ID10" count="48"> 20.0 20.0 -20.0 -20.0 -20.0 -20.0 -20.0 20.0 -20.0 20.0 -20.0 -20.0 -20.0 20.0 20.0 20.0 20.0 -20.0 -20.0 20.0 -20.0 20.0 20.0 20.0 20.0 20.0 -20.0 20.0 -20.0 20.0 20.0 -20.0 -20.0 20.0 20.0 20.0 20.0 -20.0 20.0 -20.0 20.0 20.0 -20.0 -20.0 20.0 20.0 20.0 20.0</float_array> <technique_common> <accessor count="16" source="#ID10" stride="3"> <param name="X" type="float" /> <param name="Y" type="float" /> <param name="Z" type="float" /> </accessor> </technique_common> </source> <source id="ID8"> <float_array id="ID11" count="48">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 0 1 0 0 1 0 0 1 0 0 1</float_array> <technique_common> <accessor count="16" source="#ID11" stride="3"> <param name="X" type="float" /> <param name="Y" type="float" /> <param name="Z" type="float" /> </accessor> </technique_common> </source> <vertices id="ID9"> <input semantic="POSITION" source="#ID7" /> <input semantic="NORMAL" source="#ID8" /> </vertices> <triangles count="8" material="Material2"> <input offset="0" semantic="VERTEX" source="#ID9" /> <p>0 1 2 1 0 3 4 5 6 5 4 7 8 9 10 9 8 11 12 13 14 13 12 15</p> </triangles> </mesh> </geometry> <geometry id="ID12"> <mesh> <source id="ID15"> <float_array id="ID18" count="12">20.0 -20.0 20.0 -20.0 -20.0 -20.0 20.0 -20.0 -20.0 -20.0 -20.0 20.0</float_array> <technique_common> <accessor count="4" source="#ID18" stride="3"> <param name="X" type="float" /> <param name="Y" type="float" /> <param name="Z" type="float" /> </accessor> </technique_common> </source> <source id="ID16"> <float_array id="ID19" count="12">-0 -1 -0 -0 -1 -0 -0 -1 -0 -0 -1 -0</float_array> <technique_common> <accessor count="4" source="#ID19" stride="3"> <param name="X" type="float" /> <param name="Y" type="float" /> <param name="Z" type="float" /> </accessor> </technique_common> </source> <vertices id="ID17"> <input semantic="POSITION" source="#ID15" /> <input semantic="NORMAL" source="#ID16" /> </vertices> <triangles count="2" material="Material2"> <input offset="0" semantic="VERTEX" source="#ID17" /> <p>0 1 2 1 0 3</p> </triangles> </mesh> </geometry> <geometry id="ID20"> <mesh> <source id="ID23"> <float_array id="ID26" count="12">-20.0 20.0 20.0 -20.0 -20.0 -20.0 -20.0 -20.0 20.0 -20.0 20.0 -20.0</float_array> <technique_common> <accessor count="4" source="#ID26" stride="3"> <param name="X" type="float" /> <param name="Y" type="float" /> <param name="Z" type="float" /> </accessor> </technique_common> </source> <source id="ID24"> <float_array id="ID27" count="12">-1 0 0 -1 0 0 -1 0 0 -1 0 0</float_array> <technique_common> <accessor count="4" source="#ID27" stride="3"> <param name="X" type="float" /> <param name="Y" type="float" /> <param name="Z" type="float" /> </accessor> </technique_common> </source> <vertices id="ID25"> <input semantic="POSITION" source="#ID23" /> <input semantic="NORMAL" source="#ID24" /> </vertices> <triangles count="2" material="Material2"> <input offset="0" semantic="VERTEX" source="#ID25" /> <p>0 1 2 1 0 3</p> </triangles> </mesh> </geometry> </library_geometries> <library_materials> <material id="ID6" name="material"> <instance_effect url="#ID5" /> </material> <material id="ID13" name="Color_005_"> <instance_effect url="#ID14" /> </material> <material id="ID21" name="Color_A06_"> <instance_effect url="#ID22" /> </material> </library_materials> <library_effects> <effect id="ID5"> <profile_COMMON> <technique sid="COMMON"> <lambert> <diffuse> <color>0 0 1 1</color> </diffuse> </lambert> </technique> </profile_COMMON> </effect> <effect id="ID14"> <profile_COMMON> <technique sid="COMMON"> <lambert> <diffuse> <color>0 1 0 1</color> </diffuse> </lambert> </technique> </profile_COMMON> </effect> <effect id="ID22"> <profile_COMMON> <technique sid="COMMON"> <lambert> <diffuse> <color>0.8 0 0 1</color> </diffuse> </lambert> </technique> </profile_COMMON> </effect> </library_effects> <scene> <instance_visual_scene url="#ID1" /> </scene> </COLLADA> </pre> </div> </td> <td align="center" rowspan="1" bgcolor="lightgrey">[[File:ColladaOther20_HBook.png|250px|ColladaOther20HBook]]</td> </tr> </table> The 2D, projected image that is shown here to the right of the ''Example #5'' COLLADA code presents the trio of cubes viewed from a particular camera distance and angle. Each of the three cubes is associated with a particular "node" and has been tagged with a unique ID number inside of the subsection of the code titled, '''<visual_scene>''': * '''ID28''' is the node/tag assigned to the cube that appears in the 2D projected image at the bottom-center of the trio; because '''<translate>''' X, Y, Z '''</translate>''' = '''<translate>''' 0.0 0.0 0.0 '''</translate>''', we appreciate that the center of this cube lies at the origin of the 3D coordinate system. * '''ID2''' is the node/tag assigned to the cube that appears in the upper-left position among the trio; according to the relevant '''<translate>''' instruction, the center of this cube has been shifted from the coordinate-system origin by 45.0 units in both the Y and Z directions. * '''ID29''' is the node/tag assigned to the cube that appears in the upper-right position among the trio; according to its '''<translate>''' instruction, the center of this cube has been shifted from the coordinate-system origin by 120.0 units in the X direction. From the text of the COLLADA-formatted code (displayed here in the scrolling window of ''Example #5''), we see that in addition to undergoing a translation, the cube tagged with '''ID29''' also has undergone three rotations. As seen in the projected 2D image, the result is that — relative to either one of the other two cubes, which have not undergone rotations — the ''green'' face of the cube has effectively swapped positions with a ''blue'' cube face. More specifically, here is what has happened to this cube in the 3D model. Reading the three '''<rotate>''' instructions from the bottom, up: * (First) the cube was rotated counter-clockwise by 90° about the Y-axis — the red face rolled under the cube and it was replaced with the blue face that was originally on the top of the cube. * (Second) the cube was rotated counter-clockwise by 90° about the X-axis — the green face rolled to the top of the cube and the (previously hidden) red face rolled from under the cube to the position previously occupied by the green face; and the location of the visible blue face remained unchanged. * (Third) the cube was rotated counter-clockwise by 90° about the Z-axis — the red face moved into the position previously occupied by the visible blue face while a separate (previously hidden) blue face rolled into the position previously held by the red face; and the location of the green face remained unchanged. <font color="red"><b>VERY IMPORTANT NOTE:</b></font> The ''ordering'' of the rotation instructions in three dimensions is critically important. For example, It is not possible to explain the final orientation of the cube tagged with '''ID29''' by reading and carrying out the three '''<rotate>''' commands from the top, down. =====Equivalent Matrix Instructions===== What is the overall '''<matrix>''' instruction associated with the position and orientation of each of these three cubes? <ul> <li>For '''ID28''': there are no associated rotation matrices; there is no associated translation; and, by default, the scaling is (S<sub>x</sub>,S<sub>y</sub>,S<sub>z</sub>) = (1, 1, 1). Hence, the relevant 4×4 matrix is,<table border="0" align="center" cellpadding="8"> <tr> <td align="left"> <table border="1" cellpadding="8"> <tr> <td align="center">S<sub>x</sub></td> <td align="center">0</td> <td align="center">0</td> <td align="center">T<sub>x</sub></td> </tr> <tr> <td align="center">0</td> <td align="center">S<sub>y</sub></td> <td align="center">0</td> <td align="center">T<sub>y</sub></td> </tr> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">S<sub>z</sub></td> <td align="center">T<sub>z</sub></td> </tr> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">0</td> <td align="center">1</td> </tr> </table> </td> <td align="right" rowspan="1"> = </td> <td align="left"> <table border="1" cellpadding="8"> <tr> <td align="center">1</td> <td align="center">0</td> <td align="center">0</td> <td align="center">0</td> </tr> <tr> <td align="center">0</td> <td align="center">1</td> <td align="center">0</td> <td align="center">0</td> </tr> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">1</td> <td align="center">0</td> </tr> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">0</td> <td align="center">1</td> </tr> </table> </td> </tr> </table> and the equivalent '''<matrix>''' instruction — which results from concatenating the four rows of 4 numbers to create a single row of 16 numbers — should be, <table border="0" align="center" cellpadding="8"><tr><td align="center"><matrix>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</matrix></td></tr></table></li> <li>For '''ID2''': there are no associated rotation matrices; the translation vector is (T<sub>x</sub>,T<sub>y</sub>,T<sub>z</sub>) = (0, 45, 45); and, by default, the scaling is (S<sub>x</sub>,S<sub>y</sub>,S<sub>z</sub>) = (1, 1, 1). Hence, the relevant 4×4 matrix is,<table border="0" align="center" cellpadding="8"> <tr> <td align="left"> <table border="1" cellpadding="8"> <tr> <td align="center">S<sub>x</sub></td> <td align="center">0</td> <td align="center">0</td> <td align="center">T<sub>x</sub></td> </tr> <tr> <td align="center">0</td> <td align="center">S<sub>y</sub></td> <td align="center">0</td> <td align="center">T<sub>y</sub></td> </tr> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">S<sub>z</sub></td> <td align="center">T<sub>z</sub></td> </tr> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">0</td> <td align="center">1</td> </tr> </table> </td> <td align="right" rowspan="1"> = </td> <td align="left"> <table border="1" cellpadding="8"> <tr> <td align="center">1</td> <td align="center">0</td> <td align="center">0</td> <td align="center">0</td> </tr> <tr> <td align="center">0</td> <td align="center">1</td> <td align="center">0</td> <td align="center">45</td> </tr> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">1</td> <td align="center">45</td> </tr> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">0</td> <td align="center">1</td> </tr> </table> </td> </tr> </table> and the equivalent '''<matrix>''' instruction should be, <table border="0" align="center" cellpadding="8"><tr><td align="center"><matrix>1 0 0 0 0 1 0 45 0 0 1 45 0 0 0 1</matrix></td></tr></table></li> <li>For '''ID29''': the translation vector is (T<sub>x</sub>,T<sub>y</sub>,T<sub>z</sub>) = (120, 0, 0); the scaling, as with the other two cubes, is (S<sub>x</sub>,S<sub>y</sub>,S<sub>z</sub>) = (1, 1, 1); and, this time, there is an associated rotation matrix. Specifically, the rotation matrix is,<table border="0" align="center" cellpadding="8"> <tr> <td align="center">R(α,β,γ)</td> <td align="center">=</td> <td align="left">R<sub>z</sub>(-90) × R<sub>x</sub>(-90) × R<sub>y</sub>(-90)</td> <td align="center">=</td> <td align="left"> <table border="1" cellpadding="8"> <tr> <td align="center">cos(-90)</td> <td align="center">-sin(-90)</td> <td align="center">0</td> </tr> <tr> <td align="center">sin(-90)</td> <td align="center">cos(-90)</td> <td align="center">0</td> </tr> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">1</td> </tr> </table> </td> <td align="right" rowspan="1"> × </td> <td align="left"> <table border="1" cellpadding="8"> <tr> <td align="center">1</td> <td align="center">0</td> <td align="center">0</td> </tr> <tr> <td align="center">0</td> <td align="center">cos(-90)</td> <td align="center">-sin(-90)</td> </tr> <tr> <td align="center">0</td> <td align="center">sin(-90)</td> <td align="center">cos(-90)</td> </tr> </table> </td> <td align="right" rowspan="1"> × </td> <td align="left"> <table border="1" cellpadding="8"> <tr> <td align="center">cos(-90)</td> <td align="center">0</td> <td align="center">sin(-90)</td> </tr> <tr> <td align="center">0</td> <td align="center">1</td> <td align="center">0</td> </tr> <tr> <td align="center">-sin(-90)</td> <td align="center">0</td> <td align="center">cos(-90)</td> </tr> </table> </td> </tr> <tr> <td align="center" colspan="3"> </td> <td align="center">=</td> <td align="center"> <table border="1" cellpadding="8"> <tr> <td align="center">0</td> <td align="center">+1</td> <td align="center">0</td> </tr> <tr> <td align="center">-1</td> <td align="center">0</td> <td align="center">0</td> </tr> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">1</td> </tr> </table> </td> <td align="right" rowspan="1"> × </td> <td align="center"> <table border="1" cellpadding="8"> <tr> <td align="center">1</td> <td align="center">0</td> <td align="center">0</td> </tr> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">+1</td> </tr> <tr> <td align="center">0</td> <td align="center">-1</td> <td align="center">0</td> </tr> </table> </td> <td align="right" rowspan="1"> × </td> <td align="center"> <table border="1" cellpadding="8"> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">-1</td> </tr> <tr> <td align="center">0</td> <td align="center">1</td> <td align="center">0</td> </tr> <tr> <td align="center">+1</td> <td align="center">0</td> <td align="center">0</td> </tr> </table> </td> </tr> <tr> <td align="center" colspan="3"> </td> <td align="center">=</td> <td align="center"> <table border="1" cellpadding="8"> <tr> <td align="center">0</td> <td align="center">+1</td> <td align="center">0</td> </tr> <tr> <td align="center">-1</td> <td align="center">0</td> <td align="center">0</td> </tr> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">1</td> </tr> </table> </td> <td align="right" rowspan="1"> × </td> <td align="center"> <table border="1" cellpadding="8"> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">-1</td> </tr> <tr> <td align="center">+1</td> <td align="center">0</td> <td align="center">0</td> </tr> <tr> <td align="center">0</td> <td align="center">-1</td> <td align="center">0</td> </tr> </table> </td> <td align="right" rowspan="1"> </td> <td align="center"> </td> </tr> <tr> <td align="center" colspan="3"> </td> <td align="center">=</td> <td align="center"> <table border="1" cellpadding="8"> <tr> <td align="center">+1</td> <td align="center">0</td> <td align="center">0</td> </tr> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">+1</td> </tr> <tr> <td align="center">0</td> <td align="center">-1</td> <td align="center">0</td> </tr> </table> </td> <td align="right" rowspan="1"> </td> <td align="center"> </td> <td align="right" rowspan="1"> </td> <td align="center"> </td> </tr> </table> Hence, the relevant '''4×4''' matrix is, <table border="0" align="center" cellpadding="8"> <tr> <td align="left"> <table border="1" cellpadding="8"> <tr> <td align="center" colspan="3" rowspan="3">R(α, β, γ) × M<sub>scale</sub></td> <td align="center">T<sub>x</sub></td> </tr> <tr> <td align="center">T<sub>y</sub></td> </tr> <tr> <td align="center">T<sub>z</sub></td> </tr> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">0</td> <td align="center">1</td> </tr> </table> </td> <td align="right" rowspan="1"> = </td> <td align="left"> <table border="1" cellpadding="8"> <tr> <td align="center">+1</td> <td align="center">0</td> <td align="center">0</td> <td align="center">120</td> </tr> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">+1</td> <td align="center">0</td> </tr> <tr> <td align="center">0</td> <td align="center">-1</td> <td align="center">0</td> <td align="center">0</td> </tr> <tr> <td align="center">0</td> <td align="center">0</td> <td align="center">0</td> <td align="center">1</td> </tr> </table> </td> </tr> </table> and the equivalent '''<matrix>''' instruction should be, <table border="0" align="center" cellpadding="8"><tr><td align="center"><matrix>1 0 0 120 0 0 1 0 0 -1 0 0 0 0 0 1</matrix></td></tr></table></li> </ul> Indeed, we were able to exactly duplicate the cube trio configuration depicted above in the ''Example #5'' projected 2D image when we replaced the lines of code within the '''<library_visual_scenes>''' subsection of the ''Example #5'' .dae file with the following lines of code: <pre> <library_visual_scenes> <visual_scene id="ID1"> <node name="SketchUp"> <node id="ID2" name="instance_0"> <matrix>1 0 0 0 0 1 0 45 0 0 1 45 0 0 0 1</matrix> <instance_node url="#ID3" /> </node> <node id="ID28" name="instance_1"> <matrix>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</matrix> <instance_node url="#ID3" /> </node> <node id="ID29" name="instance_2"> <matrix>1 0 0 120 0 0 1 0 0 -1 0 0 0 0 0 1</matrix> <instance_node url="#ID3" /> </node> </node> </visual_scene> </library_visual_scenes> </pre> This demonstrates that, as conjectured above, the location and orientation of each of the three spawned cubes can be specified by using either (A) the explicit commands, '''<translate>''' and '''<rotate>''', or (B) the consolidated '''<matrix>''' command. Finally, ''Example #6'' demonstrates how a few small changes in the arguments of the '''ID2''' and '''ID29''' '''<matrix>''' commands can change the cubes into, respectively, flattened or elongated solid rectangles. <table border="0" align="center" width="80%" cellpadding="5"> <tr><th align="center" colspan="3">Example #6 — Incorporating Scaling into '''<matrix>''' Commands</th></tr> <tr><td align="left" colspan="2"> <div style="height: 300px; width: 700px; overflow: scroll;"> <pre> <library_visual_scenes> <visual_scene id="ID1"> <node name="SketchUp"> <node id="ID2" name="instance_0"> <matrix>2 0 0 0 0 1 0 45 0 0 2 45 0 0 0 1</matrix> <instance_node url="#ID3" /> </node> <node id="ID28" name="instance_1"> <matrix>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</matrix> <instance_node url="#ID3" /> </node> <node id="ID29" name="instance_2"> <matrix>1 0 0 120 0 0 1 0 0 -3 0 0 0 0 0 1</matrix> <instance_node url="#ID3" /> </node> </node> </visual_scene> </library_visual_scenes> </pre> </div> </td> <td align="center" rowspan="1" bgcolor="lightgrey">[[File:ColladaMatrix22_image.png|250px|ColladaMatrix22_image]]</td> </tr> </table>
Summary:
Please note that all contributions to JETohlineWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
JETohlineWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Tiled Menu
Table of Contents
Old (VisTrails) Cover
Appendices
Variables & Parameters
Key Equations
Special Functions
Permissions
Formats
References
lsuPhys
Ramblings
Uploaded Images
Originals
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information