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!
===From COLLADA Release Notes=== A useful ''Cube.dae'' example can be found in Appendix A of the PDF-formatted document titled, [https://www.khronos.org/files/collada_spec_1_4.pdf COLLADA — Digital Asset Schema Release 1.4.1] — Specification (2<sup>nd</sup> Edition), March 2008. I was able to execute/display this file using my Mac's Preview app after trimming it down a bit. (When I tried to "copy" then "paste" this text file into my Mac's ''vi'' editor, it did not initially execute properly in the Preview app, so I removed some lines of the ''xml'' code in an effort to debug my file. (I was guided in this effort by having access to a separately constructed example <xml> model file, named "cube001.dae", that was kindly sent to me by Shyam Barange, the developer of '''3D model Viewer'''.) Much of this ''trimming'' may not have been necessary because, in the end, I realized that the essential spacings between integer vertex values and integer normal values in the ''polygons'' specification had disappeared during the copy-and-paste operation.) Here is my version of this executable COLLADA (.dae) file, created 2 September 2019; on my Mac, the filename is: '''/Dropbox/3Dviewers/Cube/ThirdCube/AppendA06Works.dae''' <table border="0" align="center" width="80%"> <tr><th align="center">Example #1 — Extracted from COLLADA release notes (modified here)</th></tr> <tr><td align="left"> <div style="height: 400px; width: 100%; overflow: scroll;"> <pre> <?xml version="1.0" encoding="utf-8"?> <COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1"> <asset> <created>2005-11-14T02:16:38Z</created> <modified>2005-11-15T11:36:38Z</modified> <revision>1.0</revision> </asset> <library_effects> <effect id="whitePhong"> <profile_COMMON> <technique sid="phong1"> <phong> <diffuse> <color>0.8 0.0 0.8 1.0</color> </diffuse> </phong> </technique> </profile_COMMON> </effect> </library_effects> <!-- --> <library_materials> <material id="whiteMaterial"> <instance_effect url="#whitePhong"/> </material> </library_materials> <library_geometries> <geometry id="box" name="box"> <mesh> <source id="box-Pos"> <float_array id="box-Pos-array" count="24"> -0.5 0.5 0.5 0.5 0.5 0.5 -0.5 -0.5 0.5 0.5 -0.5 0.5 -0.5 0.5 -0.5 0.5 0.5 -0.5 -0.5 -0.5 -0.5 0.5 -0.5 -0.5 </float_array> <technique_common> <accessor source="#box-Pos-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="box-0-Normal"> <float_array id="box-0-Normal-array" count="18"> 1.0 0.0 0.0 -1.0 0.0 0.0 0.0 1.0 0.0 0.0 -1.0 0.0 0.0 0.0 1.0 0.0 0.0 -1.0 </float_array> <technique_common> <accessor source="#box-0-Normal-array" count="6" stride="3"> <param name="X" type="float"/> <param name="Y" type="float"/> <param name="Z" type="float"/> </accessor> </technique_common> </source> <vertices id="box-Vtx"> <input semantic="POSITION" source="#box-Pos"/> </vertices> <!-- The 6 separate polygons define the 6 sides of the "cube"; hence, each polygon will have 4 vertices and 4 associated normals. As identified in this xml file, the vertices + associated normal for each side/polygon are listed between the <p></p> notation; the vertex number and associated normal are interleaved such that the normal is offset by "1". For example, the first of the 6 sides/polygons is defined by connecting vertices: 0 -> 2 -> 3 -> 1 -> back to 0; while all four normals are assigned the direction/number "4". --> <polygons count="6" material="WHITE"> <input semantic="VERTEX" source="#box-Vtx" offset="0"/> <input semantic="NORMAL" source="#box-0-Normal" offset="1"/> <p>0 4 2 4 3 4 1 4</p> <p>0 2 1 2 5 2 4 2</p> <p>6 3 7 3 3 3 2 3</p> <p>0 1 4 1 6 1 2 1</p> <p>3 0 7 0 5 0 1 0</p> <p>5 5 7 5 6 5 4 5</p> </polygons> </mesh> </geometry> </library_geometries> <library_visual_scenes> <visual_scene id="DefaultScene"> <node id="Box" name="Box"> <translate> 0 0 3</translate> <rotate> 0 0 1 0</rotate> <rotate> 0 1 0 0</rotate> <rotate> 1 0 0 0</rotate> <scale> 1 1 0.2</scale> <instance_geometry url="#box"> <bind_material> <technique_common> <instance_material symbol="WHITE" target="#whiteMaterial"/> </technique_common> </bind_material> </instance_geometry> </node> </visual_scene> </library_visual_scenes> <scene> <instance_visual_scene url="#DefaultScene"/> </scene> </COLLADA> </pre> </div> </td></tr></table> While I was able to view this file successfully within the Preview app on my Mac, it did not display at all on either of the above-identified 3D viewers that I had installed on my Galaxy S8+. As I discovered, the primary issue had to do with ''how'' the set of eight vertices were being connected in order to define the model's polygons. In the '''Example #1''' <xml> code, the '''polygons''' instruction is used to define six 4-sided polygons. Evidently neither of the Galaxy S8+ viewers understands this '''polygons''' instruction. When I used, instead, the '''triangles''' instruction to define twelve 3-sided polygons, both of these viewers displayed a 3D object. Here is the relevant, modified executable COLLADA (.dae) file; on my Mac, the filename is: '''/Dropbox/3Dviewers/Cube/ThirdCube/AppendA08Works.dae''' <table border="0" align="center" width="80%"> <tr><th align="center" colspan="2">Example #2 — Basically the same as Example #1, but with <triangles> replacing <polygons></th></tr> <tr><td align="left"> <div style="height: 400px; width: 700px; overflow: scroll;"> <pre> <?xml version="1.0" encoding="utf-8"?> <COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1"> <asset> <created>2005-11-14T02:16:38Z</created> <modified>2005-11-15T11:36:38Z</modified> <revision>1.0</revision> </asset> <library_effects> <effect id="whitePhong"> <profile_COMMON> <technique sid="phong1"> <phong> <diffuse> <color>0.1 0.9 0.1 1.0</color> </diffuse> </phong> </technique> </profile_COMMON> </effect> </library_effects> <!-- --> <library_materials> <material id="whiteMaterial"> <instance_effect url="#whitePhong"/> </material> </library_materials> <library_geometries> <geometry id="box" name="box"> <mesh> <source id="box-Pos"> <float_array id="box-Pos-array" count="24"> 0.5 0.5 -0.5 0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 0.5 -0.5 0.5 0.5 0.5 0.5 -0.5 0.5 -0.5 -0.5 0.5 -0.5 0.5 0.5 </float_array> <technique_common> <accessor source="#box-Pos-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="box-0-Normal"> <float_array id="box-0-Normal-array" count="18"> 0.0 0.0 -1.0 0.0 0.0 1.0 1.0 0.0 0.0 0.0 -1.0 0.0 -1.0 0.0 0.0 0.0 1.0 0.0 </float_array> <technique_common> <accessor source="#box-0-Normal-array" count="6" stride="3"> <param name="X" type="float"/> <param name="Y" type="float"/> <param name="Z" type="float"/> </accessor> </technique_common> </source> <vertices id="box-Vtx"> <input semantic="POSITION" source="#box-Pos"/> </vertices> <triangles count="12" material="WHITE"> <input semantic="VERTEX" source="#box-Vtx" offset="0"/> <input semantic="NORMAL" source="#box-0-Normal" offset="1"/> <p>0 0 2 0 3 0 7 1 5 1 4 1 4 2 1 2 0 2 5 3 2 3 1 3 2 4 7 4 3 4 0 5 7 5 4 5 0 0 1 0 2 0 7 1 6 1 5 1 4 2 5 2 1 2 5 3 6 3 2 3 2 4 6 4 7 4 0 5 3 5 7 5</p> </triangles> </mesh> </geometry> </library_geometries> <library_visual_scenes> <visual_scene id="DefaultScene"> <node id="Box" name="Box"> <translate> 0 0 3</translate> <rotate> 0 0 1 0</rotate> <rotate> 0 1 0 0</rotate> <rotate> 1 0 0 0</rotate> <scale> 1 1 0.2</scale> <instance_geometry url="#box"> <bind_material> <technique_common> <instance_material symbol="WHITE" target="#whiteMaterial"/> </technique_common> </bind_material> </instance_geometry> </node> </visual_scene> </library_visual_scenes> <scene> <instance_visual_scene url="#DefaultScene"/> </scene> </COLLADA> </pre> </div> </td> <td align="center" bgcolor="lightgrey">[[File:AppendA08Works.png|250px|AppendA08Works]]</td> </tr></table> Here are a few additional items of note regarding ''Example #2'': <ul> <li>I set the <color> value to (R, G, B, alpha) = (0.1, 0.9, 0.1, 1), so the resulting "cube" is colored green.</li> <li>I set the coordinate <scale> factors to (X, Y, Z) = (1, 1, 0.2), so the resulting "cube" is actually a solid rectangle that is substantially flatter in the Z-direction than in the other two directions.</li> <li>While the '''Preview''' app on the Mac and the '''COLLADA Viewer''' on the Galaxy S8+ both displayed a flattened, green solid rectangle as depicted here to the right of the ''Example #2'' <xml> model file, the '''3D Model Viewer''' displayed a white cube instead.</li> </ul> We played with the <xml> code a bit more, changing individual instructions and/or changing various attribute values in an effort to better understand the consequences. The '''Example #3''' <xml> code, shown immediately below, includes many of these alterations; on my Mac the filename is: '''/Dropbox/3Dviewers/Cube/FourthCube/AppendD13.dae'''. Both the '''Preview''' app on the Mac and the '''COLLADA Viewer''' on my Galaxy S8+ generated the red, solid rectangular model depicted here to the right of the ''Example #3'' <xml> model file. The '''3D Model Viewer''' displayed a red, rather than a white, object, which we count as a measure of success; but the displayed 3D object was still an equal-sided cube. In evolving from the <xml> code displayed here as ''Example #2'' to the <xml> code labeled ''Example #3'', the following two changes appear to have been necessary in order for the '''3D Model Viewer''' to display a red — rather than a white — cube: <ul> <li>In both ''Example #2'' code locations where the attribute "WHITE" appears, we substituted the attribute "whiteMaterial". </li> <li>In ''Example #3'', the <visual_scene> includes what appears to be a key additional instruction, namely, <matrix sid="transform">.</li> </ul> <table border="0" align="center" width="80%"> <tr><th align="center" colspan="2">Example #3 — Basically the same as Example #2, but after playing with various code modifications</th></tr> <tr><td align="left"> <div style="height: 400px; width: 700px; overflow: scroll;"> <pre> <?xml version="1.0" encoding="utf-8"?> <COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1"> <asset> <created>2005-11-14T02:16:38Z</created> <modified>2005-11-15T11:36:38Z</modified> <revision>1.0</revision> <unit meter="0.0254" name="inch" /> <up_axis>Z_UP</up_axis> </asset> <library_effects> <effect id="whitePhong"> <profile_COMMON> <technique sid="phong1"> <phong> <diffuse> <color>0.8 0.2 0.2 1.0</color> </diffuse> </phong> </technique> </profile_COMMON> </effect> </library_effects> <!-- --> <library_materials> <material id="whiteMaterial"> <instance_effect url="#whitePhong"/> </material> </library_materials> <library_geometries> <geometry id="box" name="box"> <mesh> <source id="box-Pos"> <float_array id="box-Pos-array" count="24"> 0.0 1.0 1.0 1.0 1.0 1.0 0.0 0.0 1.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 </float_array> <technique_common> <accessor source="#box-Pos-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="box-0-Normal"> <float_array id="box-0-Normal-array" count="18"> 1.0 0.0 0.0 -1.0 0.0 0.0 0.0 1.0 0.0 0.0 -1.0 0.0 0.0 0.0 1.0 0.0 0.0 -1.0 </float_array> <technique_common> <accessor source="#box-0-Normal-array" count="6" stride="3"> <param name="X" type="float"/> <param name="Y" type="float"/> <param name="Z" type="float"/> </accessor> </technique_common> </source> <vertices id="box-Vtx"> <input semantic="POSITION" source="#box-Pos"/> </vertices> <triangles count="12" material="whiteMaterial"> <input semantic="VERTEX" source="#box-Vtx" offset="0"/> <input semantic="NORMAL" source="#box-0-Normal" offset="1"/> <p>0 4 2 4 3 4 0 4 3 4 1 4 4 5 5 5 7 5 4 5 7 5 6 5 0 3 4 3 6 3 0 3 6 3 2 3 3 2 7 2 5 2 3 2 5 2 1 2 2 1 6 1 7 1 2 1 7 1 3 1 0 0 1 0 5 0 0 0 5 0 4 0</p> </triangles> <!-- <polygons count="6" material="whiteMaterial"> <input semantic="VERTEX" source="#box-Vtx" offset="0"/> <input semantic="NORMAL" source="#box-0-Normal" offset="1"/> <p>0 4 2 4 3 4 1 4</p> <p>0 2 1 2 5 2 4 2</p> <p>6 3 7 3 3 3 2 3</p> <p>0 1 4 1 6 1 2 1</p> <p>3 0 7 0 5 0 1 0</p> <p>5 5 7 5 6 5 4 5</p> </polygons> --> </mesh> </geometry> </library_geometries> <library_visual_scenes> <visual_scene id="DefaultScene"> <node id="Box" name="Box"> <!-- <translate> 0 0.5 0.5</translate> <rotate> 0 0 0 0</rotate> <rotate> 0 0 0 0</rotate> <rotate> 0 0 0 0</rotate> <scale> 1 0.2 0.1</scale> <matrix sid="transform">1 0 0 0 0 0.292 0 0 0 0 1 1.026 0 0 0 1</matrix> --> <rotate> 0 0 1 0</rotate> <rotate> 0 1 0 45</rotate> <rotate> 1 0 0 0</rotate> <scale> 0.05 0.2 0.1</scale> <matrix sid="transform">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</matrix> <instance_geometry url="#box"> <bind_material> <technique_common> <instance_material symbol="whiteMaterial" target="#whiteMaterial"/> </technique_common> </bind_material> </instance_geometry> </node> </visual_scene> </library_visual_scenes> <scene> <instance_visual_scene url="#DefaultScene"/> </scene> </COLLADA> </pre> </div> </td> <td align="center" bgcolor="lightgrey">[[File:AppendD13.png|250px|AppendD13]]</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