<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>XML3D.ORG &#187; FAQ</title>
	<atom:link href="/category/faq/feed/" rel="self" type="application/rss+xml" />
	<link>http://xml3d.org</link>
	<description>Interactive 3D graphics in the DOM</description>
	<lastBuildDate>Fri, 07 Mar 2014 16:23:48 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.8.1</generator>
	<item>
		<title>How can I monitor the performance of my XML3D application?</title>
		<link>http://xml3d.org/2012/06/how-can-i-monitor-the-performance-of-my-xml3d-application/</link>
		<comments>http://xml3d.org/2012/06/how-can-i-monitor-the-performance-of-my-xml3d-application/#comments</comments>
		<pubDate>Fri, 15 Jun 2012 11:47:01 +0000</pubDate>
		<dc:creator><![CDATA[Rainer Jochem]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[FAQ]]></category>
		<category><![CDATA[fps]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[webgl]]></category>
		<category><![CDATA[xml3d]]></category>

		<guid isPermaLink="false">http://xml3d.org/?p=889</guid>
		<description><![CDATA[<p>A nice way is to use the stats counter from: http://github.com/mrdoob/stats.js/</p> <p>In the WebGL version, one can use the framedrawn event to update the counter, e.g:</p> var stats = new Stats(); stats.domElement.style.position='absolute'; stats.domElement.style.left='0px'; stats.domElement.style.top='0px'; var targetElement = ... targetElement.style.position='realtive'; targetElement.appendChild(stats.domElement); var myxml3d = document.getElementById("myxml3d"); myxml3d.addEventListener("framedrawn", function(e) { stats.update(); }, false); <p>In the native version, one <span style="color:#777"> . . . &#8594; Read More: <a href="/2012/06/how-can-i-monitor-the-performance-of-my-xml3d-application/">How can I monitor the performance of my XML3D application?</a></span>]]></description>
				<content:encoded><![CDATA[<p>A nice way is to use the stats counter from: <a href="http://github.com/mrdoob/stats.js/">http://github.com/mrdoob/stats.js/</a></p>
<p>In the WebGL version, one can use the framedrawn event to update the counter, e.g:</p>
<pre>var stats = new Stats(); 

stats.domElement.style.position='absolute';
stats.domElement.style.left='0px';
stats.domElement.style.top='0px'; 

var targetElement = ...
targetElement.style.position='realtive';
targetElement.appendChild(stats.domElement); 

var myxml3d = document.getElementById("myxml3d");
myxml3d.addEventListener("framedrawn", function(e) { stats.update(); }, false);</pre>
<p>In the native version, one could use the &#8220;onframe&#8221; attribute to trigger the update, I didn&#8217;t test is yet. Both callbacks are in-official as they could be used to do timing attacks.</p>
<p>In Google Chrome you can also activate a FPS-Counter in chrome://flags/</p>
<p>Please be aware that this measures not just the rendering, but the overall performance of the webpage.</p>
]]></content:encoded>
			<wfw:commentRss>http://xml3d.org/2012/06/how-can-i-monitor-the-performance-of-my-xml3d-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chromium XML3D updated</title>
		<link>http://xml3d.org/2011/05/chromium-xml3d-updated/</link>
		<comments>http://xml3d.org/2011/05/chromium-xml3d-updated/#comments</comments>
		<pubDate>Fri, 27 May 2011 09:14:35 +0000</pubDate>
		<dc:creator><![CDATA[Rainer Jochem]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[FAQ]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[xml3d-chromium]]></category>

		<guid isPermaLink="false">http://xml3d.org/?p=447</guid>
		<description><![CDATA[<p>There is a new version of chromium-xml3d for Windows and Ubuntu available. Apart from several bugfixes (including XML3DRotation::toMatrix) the new version contains other changes, most notably:</p> Faster OpenGL rasterization on GPU (now it is the default) Most recent changes from the original Chromium project <p>Due to some security constraints the browser needs to be run <span style="color:#777"> . . . &#8594; Read More: <a href="/2011/05/chromium-xml3d-updated/">Chromium XML3D updated</a></span>]]></description>
				<content:encoded><![CDATA[<p>There is a new version of chromium-xml3d for Windows and Ubuntu available. Apart from several bugfixes (including XML3DRotation::toMatrix) the new version contains other changes, most notably:</p>
<ul>
<li>Faster OpenGL rasterization on GPU (now it is the default)</li>
<li>Most recent changes from the original Chromium project</li>
</ul>
<p><span id="more-447"></span>Due to some security constraints the browser needs to be run with disabled sandbox. Please use chrome.bat instead of chrome.exe. Also our OpenGL implementation currently doesn&#8217;t have shadows, or reflections support. Transparency is also only partially implemented. However, since the OpenGL version is much faster than ray-tracing we have decided to enable it by default anyway. To restore the previous ray-tracing functionality you can use the following undocumented flag on your scenes:</p>
<pre>&lt;xml3d renderer="rtpie"...</pre>
<p>Remember that this is not part of the specification, but rather a temporary way to fix things. Also this flag can not be changed after the scene is displayed, so currently one cannot dynamically change between ray-tracing or rasterization.</p>
]]></content:encoded>
			<wfw:commentRss>http://xml3d.org/2011/05/chromium-xml3d-updated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML3D Cinema4D exporter plug-in</title>
		<link>http://xml3d.org/2011/05/xml3d-cinema4d-exporter-plug-in/</link>
		<comments>http://xml3d.org/2011/05/xml3d-cinema4d-exporter-plug-in/#comments</comments>
		<pubDate>Wed, 11 May 2011 11:27:45 +0000</pubDate>
		<dc:creator><![CDATA[Rainer Jochem]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[FAQ]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[cinema 4d]]></category>
		<category><![CDATA[exporter]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[modelling]]></category>

		<guid isPermaLink="false">http://xml3d.org/?p=399</guid>
		<description><![CDATA[<p>In addition to our blender exporter, we now offer an XML3D exporter plug-in for Maxon&#8217;s Cinema4D R12. As usual it is available on github under the following URL: https://github.com/xml3d/Cinema4D-Exporter.</p> <p></p> Installation: <p>Copy the xml3dExporter and xml3dMouseEventTag directories to your &#60;Cinema4D_Install&#62;/plugins directory:</p> <p></p> <p>Restart Cinema4D. You will find it in the Python menu under Plugins-&#62;XML3DExporter</p> <p></p> <span style="color:#777"> . . . &#8594; Read More: <a href="/2011/05/xml3d-cinema4d-exporter-plug-in/">XML3D Cinema4D exporter plug-in</a></span>]]></description>
				<content:encoded><![CDATA[<p>In addition to our <a title="XML3D Blender exporter" href="/2011/03/xml3d-blender-exporter/">blender exporter</a>, we now offer an XML3D exporter plug-in for <a title="Maxon Cinema4D" href="http://www.maxon.net/de/products.html" target="_blank">Maxon&#8217;s Cinema4D R12</a>. As usual it is available on github under the following URL: <a title="Cinema4D exporter plug-in" href="https://github.com/xml3d/Cinema4D-Exporter" target="_blank">https://github.com/xml3d/Cinema4D-Exporter</a>.</p>
<p><span id="more-399"></span></p>
<h2>Installation:</h2>
<p>Copy the <em>xml3dExporter</em> and <em>xml3dMouseEventTag</em> directories to your <em>&lt;Cinema4D_Install&gt;/plugins </em>directory<em>:</em></p>
<p><a href="/wp-content/uploads/2011/05/C4dPluginsDir.png"><img class="alignnone size-medium wp-image-408" title="C4dPluginsDir" src="/wp-content/uploads/2011/05/C4dPluginsDir-300x138.png" alt="" width="300" height="138" /></a></p>
<p>Restart Cinema4D. You will find it in the <em>Python</em> menu under <em>Plugins-&gt;XML3DExporter</em></p>
<p><a href="/wp-content/uploads/2011/05/Bildschirmfoto-2011-05-11-um-11.56.56.png"><img class="alignnone size-medium wp-image-403" title="Exporting to XML3D" src="/wp-content/uploads/2011/05/Bildschirmfoto-2011-05-11-um-11.56.56-300x169.png" alt="Exporting to XML3D" width="300" height="169" /></a></p>
<hr />
<h2>Usage:</h2>
<ul>
<li> Create your scene.<em> </em></li>
<li>To add some XML3D mouse events to a object, right-click on the object and select <em>Python Tags -&gt; XML3DMouseEventTag<br />
</em> <a href="/wp-content/uploads/2011/05/Bildschirmfoto-2011-05-11-um-11.56.36.png"><img class="alignnone size-medium wp-image-401" title="Adding XML3D mouse event tag" src="/wp-content/uploads/2011/05/Bildschirmfoto-2011-05-11-um-11.56.36-300x164.png" alt="Adding XML3D mouse event tag" width="300" height="164" /></a></li>
<li>You can then fill in the events in the attribute window<br />
<a href="/wp-content/uploads/2011/05/Bildschirmfoto-2011-05-11-um-11.56.50.png"><img class="alignnone size-medium wp-image-402" title="Editing XML3D mouse event tag" src="/wp-content/uploads/2011/05/Bildschirmfoto-2011-05-11-um-11.56.50-300x127.png" alt="Editing XML3D mouse event tag" width="300" height="127" /></a></li>
</ul>
<ul>
<li>When you are ready to export, go to <em>Python-&gt;Plugins-&gt;XML3DExporter</em></li>
<li>Pick the size of the display window the XML3D element should have</li>
<li> Tick the <em>Embed into XHTML</em> if you want to directly display in XML3D-enabled browser</li>
<li> Hit <em>Export</em> and pick the filename to store your scene and hit <em>Save</em>.</li>
<li> While exporting, a progress bar at the bottom of Cinema4D shows you the progress of the operation.<br />
<a href="/wp-content/uploads/2011/05/Bildschirmfoto-2011-05-11-um-11.57.13.png"><img class="alignnone size-medium wp-image-404" title="Select export options" src="/wp-content/uploads/2011/05/Bildschirmfoto-2011-05-11-um-11.57.13-300x194.png" alt="Select export options" width="300" height="194" /></a></li>
</ul>
<ul>
<li> Successful export is announced on the status bar with message <em>Exporting completed: 3.5 seconds</em>.</li>
<li> If you do <strong>not</strong> see the message, something went haywire. In this case, go to <em>Python-&gt;Console</em> to activate the debug console. Check the messages there. To submit a bug, send a snapshot of the console to the <a href="https://mail.cg.uni-saarland.de/cgi-bin/mailman/listinfo/xml3d-public">mailing list</a>.</li>
</ul>
<h3>Working with instances</h3>
<p>If a small set of rules is kept, the plugin can correctly export  instances from Cinema4D. We highly recommend using this feature as much  as possible, as it can save a lot of disk space and loading time.</p>
<p>There are several ways, how you can create instances in Cinema4D:</p>
<ul>
<li> using the <em>Duplicate Tool</em></li>
<li> using MoGraph&#8217;s <em>Cloner Object</em></li>
<li> probably some other, we are not aware of.</li>
</ul>
<p>The important thing is that instances are correctly exported if and  only if they appear as Cinema4D instance objects. The instance object  has the green &#8220;shadow cube&#8221; icon and looks like this:</p>
<p><a href="/wp-content/uploads/2011/05/C4dInstance.png"><img class="alignnone size-full wp-image-416" title="C4dInstance" src="/wp-content/uploads/2011/05/C4dInstance.png" alt="" width="212" height="222" /></a></p>
<p>Such an object is a link to some other object as can be seen under the <em>Object</em> tab in Attributes, when the instance is selected:</p>
<p><a href="/wp-content/uploads/2011/05/C4dInstance_link.png"><img class="alignnone size-full wp-image-415" title="C4dInstance_link" src="/wp-content/uploads/2011/05/C4dInstance_link.png" alt="" width="202" height="250" /></a></p>
<p>In this case we can see that instance <tt>Cube.0</tt> links to the object <tt>Cube</tt>. When you are using the <em>Duplicate Tool</em>, everything works out of the box. The <em>Duplicate Tool</em> creates exactly such instances and no additional care is needed.</p>
<p>With the <em>Cloner Object</em> more care is needed, as without  special preparations, it will not create any exportable instances. To  force it do so, you have to:</p>
<ul>
<li>Tell it to create so-called <strong>Render Instances</strong></li>
</ul>
<p><a href="/wp-content/uploads/2011/05/CloneInstance.png"><img class="alignnone size-full wp-image-417" title="CloneInstance" src="/wp-content/uploads/2011/05/CloneInstance.png" alt="" width="200" height="299" /></a></p>
<ul>
<li> Turn the <em>Cloner Object</em> to an editable using the <strong>Make Editable Object</strong> button.</li>
</ul>
<p><a href="/wp-content/uploads/2011/05/EditableButton.png"><img class="alignnone size-full wp-image-420" title="EditableButton" src="/wp-content/uploads/2011/05/EditableButton.png" alt="" width="54" height="46" /></a></p>
<p>Before these two steps your <em>Cloner Object</em> in Objects List looked like this:</p>
<p><a href="/wp-content/uploads/2011/05/ClonerBefore.png"><img class="alignnone size-full wp-image-419" title="ClonerBefore" src="/wp-content/uploads/2011/05/ClonerBefore.png" alt="" width="199" height="74" /></a></p>
<p>and after it should look like this:</p>
<p><a href="/wp-content/uploads/2011/05/ClonerAfter.png"><img class="alignnone size-full wp-image-418" title="ClonerAfter" src="/wp-content/uploads/2011/05/ClonerAfter.png" alt="" width="192" height="103" /></a></p>
<p>Notice that now Cinema4D instances show up again and will thus get correctly exported. <em>Cloner Objects</em> can be generally nested, so you need to repeat these steps on every level of the <em>Cloner Object</em>,  where instantiation is desired. This allows you to have fine control  over the level of instantiation. For example consider the following  scene:</p>
<p><a href="/wp-content/uploads/2011/05/MultiLevelCloner.png"><img class="alignnone size-medium wp-image-423" title="MultiLevelCloner" src="/wp-content/uploads/2011/05/MultiLevelCloner-300x226.png" alt="" width="300" height="226" /></a></p>
<p>Single seat is the core geometry and four levels of instancing are available:</p>
<ul>
<li> Two single seats form a double seat</li>
<li> Two double seats form a quad seat</li>
<li> Two quad seats form a row</li>
<li> Number of rows form the whole cabin</li>
</ul>
<p>Now, if we tick <strong>Render Instances</strong> on all levels as suggested above, will will really get full instantiation, e.g. the only actual geometry will be a single seat:</p>
<p><a href="/wp-content/uploads/2011/05/MultiLevel_fullInstances.png"><img class="alignnone size-full wp-image-421" title="MultiLevel_fullInstances" src="/wp-content/uploads/2011/05/MultiLevel_fullInstances.png" alt="" width="269" height="246" /></a></p>
<p>This is optimal as far as file size goes, but it will create deep  transformation hierarchies, which may be not so good for the ray  tracer. An alternative is for example to tick the <strong>Render Instance</strong> only on the top two levels and on the bottom ones leave it unchecked. After <strong>Make Editable</strong> on ALL levels, we will get a structure like this:</p>
<p><a href="/wp-content/uploads/2011/05/MultiLevel_partial.png"><img class="alignnone size-medium wp-image-422" title="MultiLevel_partial" src="/wp-content/uploads/2011/05/MultiLevel_partial-176x300.png" alt="" width="176" height="300" /></a></p>
<p>You can see that now four seats are formed by actual geometry and  only this quadruple is instanced to a row and rows instanced to a  cabin. This increased the amount of real geometry by a factor of four  but decreased the nesting level by a factor of two.</p>
<hr />
<h2>Developer Information:</h2>
<p>This chapter contains information about the programming internals of the plugins and is intended for future developers and extenders of the plugins.</p>
<h3><span class="editsection"><a title="Edit section: Cinema4D Plugin Architecture" href="/index.php?title=DCToolsExp&amp;action=edit&amp;section=17"></a></span><span id="Cinema4D_Plugin_Architecture" class="mw-headline">Cinema4D Plugin Architecture </span></h3>
<p>Cinema4D provides several ways for writing plugins. The most comprehensive one is the C++SDK, which is directly shipped with all Cinema4D versions. The most easiest and nearly as comprehensive as the C++SDK one is Py4D. Plugins can be written in Python programming language. Py4D is a community project and can be installed as plugin (v0.9.99883) for Cinema4D R11.5. The installation is not necessary for versions &gt;= R12, because these versions are directly shipped with Py4D (&gt;= v0.9.99883). Melange and C.O.F.F.E.E. are two more approaches to write plugins.<br />
In the following I will focus on Py4D.</p>
<h4><span class="editsection"> </span><span id="Plugin_types" class="mw-headline">Plugin types </span></h4>
<p>The Py4D API provides several static methods to register the individual plugins. For more details about the parameter, please have a look at the API documentation (see  section: Helpful Links).</p>
<ul>
<li> <strong>ToolData</strong>: RegisterToolPlugin()</li>
<li> <strong>CommandData</strong>: RegisterCommandPlugin()</li>
<li> <strong>MessageData</strong>: RegisterMessagePlugin()</li>
<li> <strong>BitmapSaverData</strong>: RegisterBitmapSaverPlugin()</li>
<li> <strong>BitmapLoaderData</strong>: RegisterBitmapLoaderPlugin()</li>
<li> <strong>TagData</strong>: RegisterTagPlugin()</li>
<li> <strong>ObjectData</strong>: RegisterObjectPlugin()</li>
<li> <strong>SceneLoaderData</strong>: RegisterSceneLoaderPlugin()</li>
<li> <strong>SceneSaverData</strong>: RegisterSceneSaverPlugin()</li>
</ul>
<h4><span class="editsection"> </span><span id="Basic_steps_for_creating_a_plugin_.28e.g._CommandData_plugin.29" class="mw-headline">Basic steps for creating a plugin (e.g. CommandData plugin) </span></h4>
<ul>
<li> Create new file: <strong>TestPlugin.pyp</strong></li>
<li> Insert definition of extended CommandData class:</li>
</ul>
<pre>import c4d
class XML3DCommandData(c4d.plugins.CommandData):
    def Execute(self, doc):
        return True</pre>
<ul>
<li> Define <em><strong>unique</strong></em> plugin id:</li>
</ul>
<pre>PLUGIN_ID_EXPORTER = 1193733</pre>
<ul>
<li> Define entry point and register plugin:</li>
</ul>
<pre>if __name__ == "__main__":
    c4d.plugins.RegisterCommandPlugin(id=PLUGIN_ID_EXPORTER, str="XML3DExporter",help="XML3D Exporter",info=0, dat=XML3DCommandData())</pre>
<ul>
<li> Create a new folder <strong>TestPlugin/</strong> in <strong>$(C4D_INSTALL_DIR)/plugins/</strong></li>
<li> Put <strong>TestPlugin.pyp</strong> into <strong>$(C4D_INSTALL_DIR)/plugins/TestPlugin/</strong></li>
<li> Launch Cinema4D. It scans the <strong>plugins/</strong> folder for <em>*.pyp</em> files and executes the code in the main part, which we used to call the appropriate function to register our plugin.</li>
</ul>
<h3><span class="editsection"> </span><span id="General_Exporters_Architecture" class="mw-headline">General Exporters Architecture </span></h3>
<p>The exporter plugins are implemented as CommandData plugins. The advantage over implementing the exporters as SceneSaverData is that we can build our own gui. In the following I will explain the core modules of the exporters. I will therefore sometimes refer to the XML3DExporter as example.</p>
<h4><span class="editsection"> </span><span id="Module:_XML3DExporterGUI" class="mw-headline">Module: XML3DExporterGUI </span></h4>
<p>There are two possibilities to build a gui. Either we define the whole gui as parts in a bunch of resource files or we build it programmatically in our application.<br />
As in every high level programming language or library we can programmatically build the gui by plugging objects into containers and calling the appropiate methods. I refer at this point to the API (see Helpful Links). Just one information: We have to derive our own gui from c4d.gui.GeDialog</p>
<pre>class XML3DExporterGUI(c4d.gui.GeDialog):</pre>
<p>After the user filled in all necessary field and clicked the &#8216;Submit&#8217;-button, the system calls the method <em>Command()</em>. The system passes an id to the method to indicate the type of the fired user event. The following code fragment shows this process:</p>
<pre>def Command(self, id, msg):
    if id == 10321:
        self.Close()
    elif id == 10311:
        self.export()
    return True</pre>
<h4><span class="editsection"> </span><span id="Module:_XML3DCommandData" class="mw-headline">Module: XML3DCommandData </span></h4>
<p>The plugin registration is done in the same way as described above. We pass an object of type XML3DCommandData to the method RegisterCommandPlugin. The method <strong>XML3DCommandData::Execute()</strong> will be<br />
automatically called as soon as the user activates the plugin. The method then fires up the gui to capture the export properties.</p>
<pre>class XML3DCommandData(c4d.plugins.CommandData):
    def Execute(self, doc):
        dialog = XML3DExporterGUI()
        return self.dialog.Open(False, pluginid=PLUGIN_ID_EXPORTER, defaulth=200, defaultw=340)</pre>
<h4><span id="Storing_the_export_properties" class="mw-headline">Storing the export properties </span></h4>
<p>The input fields of the export dialog are always filled with the last entered data. This avoids breaking the work flow. Cinema4D therefore provides the static method <strong>SetWorldPluginData()</strong>. We can store any<br />
property, together with its index in the container, in this container. Cinema4D automatically writes the content of this container to a predefined path when shutting down.</p>
<pre>def storeSettings(self):
    if self.settings is None:
        self.settings = c4d.BaseContainer()
    self.settings.SetString(0, self.targetPath)
    self.settings.SetString(1, self.GetString(self.panelWidth))
    self.settings.SetString(2, self.GetString(self.panelHeight))
    self.settings.SetBool(3, self.GetBool(self.embedIntoXHTML))
    self.settings.SetLong(4, self.GetLong(self.exportStrategy))
    result = c4d.plugins.SetWorldPluginData(PLUGIN_ID_EXPORTER, self.settings, False)
    return result</pre>
<h4><span id="Reading_the_export_properties" class="mw-headline">Reading the export properties </span></h4>
<p>The method <strong>GetWorldPluginData()</strong> composes the counterpart to <strong>SetWorldPluginData()</strong>. During launch, Cinema4D reads all previously stored container.</p>
<pre>def readSettings(self):
    self.settings = c4d.plugins.GetWorldPluginData(PLUGIN_ID_EXPORTER)
        if self.settings is None:
            return False
        else:
            self.targetPath = self.settings.GetString(0)
            self.SetString(self.panelWidth, self.settings.GetString(1))
            self.SetString(self.panelHeight, self.settings.GetString(2))
            self.SetBool(self.embedIntoXHTML, self.settings.GetBool(3))
            self.SetLong(self.exportStrategy, self.settings.GetLong(4))
            return True</pre>
<h4><span id="Invoking_the_exporter" class="mw-headline">Invoking the exporter </span></h4>
<p>The exporter expects an object of type <strong>BaseDocument</strong>. A BaseDocument contains all information about the scene. The active document (there can be many scenes opened at the same time) can be retrieved with the following line of code:</p>
<pre>scene = c4d.documents.GetActiveDocument()</pre>
<p>The most important methods of BaseDocument are:</p>
<ul>
<li> <strong>c4d.documents.BaseDocument.GetFirstObject():</strong> This method returns an object of type BaseObject, in fact the first one in the scene graph. The following code fragment shows how to recursively traverse the scene graph to find an object of type <em>Oenvironment</em>:</li>
</ul>
<pre>def findWorldAmbient(self, obj):
    while obj != None:
        if obj.GetType() == c4d.Oenvironment:
            objContainer = obj.GetDataInstance()
            ambColor = obj[c4d.ENVIRONMENT_AMBIENT]
            ambStrength = obj[c4d.ENVIRONMENT_AMBIENTSTRENGTH]
            self.ambientWorld = ambColor * ambStrength
            break
        else:
            self.findWorldAmbient(obj.GetDown())
            obj = obj.GetNext()</pre>
<ul>
<li> <strong>c4d.documents.BaseDocument.GetFirstMaterial():</strong> Alongside the scene graph, Cinema4D also manages a material graph, which can be traversed in the same way as the scen graph.</li>
<li> <strong>c4d.documents.BaseDocument.Polygonize():</strong> Polygonizing a scene means making all objects editable. <em>Warning: Some objects will be removed from the scene graph.</em></li>
</ul>
<h3><span id="Best_Practices" class="mw-headline">Best Practices </span></h3>
<ul>
<li> Measuring code execution time:</li>
</ul>
<pre>start = c4d.GeGetMilliSeconds()
...
elapsed = c4d.GeGetMilliSeconds() - start</pre>
<ul>
<li> Visualize overall progress:</li>
</ul>
<pre>c4d.StatusSetText("Exporting scene graph...")
c4d.StatusSetBar(0)</pre>
<ul>
<li> Print type of BaseObject:</li>
</ul>
<pre>def getTypeAsString(self, obj):
    if obj.GetType() == c4d.Opolygon:
        return "Polygon"
    elif obj.GetType() == c4d.Olight:
        return "Light"
    elif obj.GetType() == c4d.Ocamera:
        return "Camera"
    elif obj.GetType() == c4d.Oinstance:
        return "Instance"
    elif obj.GetType() == c4d.Oenvironment:
        return "Environment"
    elif obj.GetType() == c4d.Onull:
        return "Null"
    else:
        return "Unknown"</pre>
<ul>
<li> Materials do not have an ambient term (for several reasons). It is possible to insert a global ambient term by adding an object of type <em>Environment</em> to the scene graph (see section <em>Invoking the Exporter</em>).</li>
<li> Mesh data is stored in multi-index format. A face contains three indexes to the vertices of that face and three (probably) different indexes to the normals of that face. If the exported format expects single-index meshes, one have transform the multi-index meshes to single-index meshes by hand. Cinema4D do <strong>not</strong> provide a mechanism for this.</li>
</ul>
<p>This mechanism is implemented in XML3DExporter::writeDataObject().</p>
<ul>
<li> Creating smooth vertex normals: Cinema4D provides an easy way to get smooth vertex normals:</li>
</ul>
<pre>normals = obj.CreatePhongNormals()</pre>
<p>This method only returns a valid normal array if the object has an attached phong tag.</p>
<ul>
<li> Unique object/material names: Cinema4D allows for non-unique object/material names. A possible solution to this might be renaming all objects/materials such that their names are unique.</li>
</ul>
<h3><span id="Source_Code_Documentation" class="mw-headline"> Source Code Documentation </span></h3>
<p>The code of the exporters is documented using the Python <em>docstrings</em> with the <em>epytext</em> markup. This markup allows for generating HTML cross-linked output similar to <em>JavaDoc</em> or <em>Doxygen</em>. You can of course always view the documentation in your Python console using the in-built <tt>help()</tt> functionality.</p>
<p>Latest HTML documentation can be found here:</p>
<ul>
<li><a class="external text" rel="nofollow" href="http://graphics.cg.uni-saarland.de/fileadmin/cguds/projects/URay/public/Cinema4DExporters_docs_html_22_03_2011.zip">Exporters v0.1 HTML Docs 22_03_2011</a></li>
</ul>
<p>To generate and view the HTML documentation yourself from the code, follow the <tt>HOWTO-DOC.txt</tt> file, or:</p>
<ol>
<li> Install Epydoc (<a class="external free" rel="nofollow" href="http://epydoc.sourceforge.net/">http://epydoc.sourceforge.net/</a>)</li>
<li> Change directory to <tt>Cinema4D/R11.5/docs</tt> or <tt>Cinema4D/R12/docs</tt></li>
<li>
<pre>python "PYTHON_INSTALL_FOLDER/Scripts/epydoc.py" --config epydoc.cfg</pre>
</li>
<li> Open <tt>html/index.html</tt></li>
</ol>
<h4><span id="Troubleshooting_the_documentation_generation" class="mw-headline"> Troubleshooting the documentation generation </span></h4>
<ul>
<li> If the epydoc installation cannot find your python installation, make sure you have matching binary version. Epydoc requires 32bit version of Python. On a 64bit system, you can have side-by-side installation of 64bit and 32bit Python.</li>
<li> If you have multiple python installations, make sure to call the correct &#8220;python&#8221;, e.g. the one where epydoc is installed.</li>
</ul>
<p>&nbsp;</p>
<p>If you have any further questions, please refer to our <a href="https://mail.cg.uni-saarland.de/cgi-bin/mailman/listinfo/xml3d-public">mailing list</a>.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://xml3d.org/2011/05/xml3d-cinema4d-exporter-plug-in/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WebGL Best Practice</title>
		<link>http://xml3d.org/2011/05/webgl-best-practice/</link>
		<comments>http://xml3d.org/2011/05/webgl-best-practice/#comments</comments>
		<pubDate>Wed, 11 May 2011 09:14:50 +0000</pubDate>
		<dc:creator><![CDATA[Rainer Jochem]]></dc:creator>
				<category><![CDATA[FAQ]]></category>
		<category><![CDATA[webgl]]></category>

		<guid isPermaLink="false">http://xml3d.org/?p=665</guid>
		<description><![CDATA[<p>If you intend to create XML3D scenes that also run with WebGL, it&#8217;s necessary to follow some basic rules:</p> Add the necessary JS scripts in the header section of the XHTML document: &#60;script src="/xml3d/script/xml3d.js" type="text/javascript"/&#62; <p>This should be the first script reference in the header section. If you want to be able to run the <span style="color:#777"> . . . &#8594; Read More: <a href="/2011/05/webgl-best-practice/">WebGL Best Practice</a></span>]]></description>
				<content:encoded><![CDATA[<p>If you intend to create XML3D scenes that also run with WebGL, it&#8217;s necessary to follow some basic rules:</p>
<ol>
<li> Add the necessary JS scripts in the header section of the XHTML document:
<pre>&lt;script src="/xml3d/script/xml3d.js" type="text/javascript"/&gt;</pre>
<p>This should be the first script reference in the header section. If you want to be able to run the scene without internet connection, just copy the script to your local drive. There is a version number in the header section, thus you can update the file regularly. The script will also add a default scene controller. If you want to use your own camera controller, you can disable this by adding:</p>
<pre>&lt;navigation mode="none"/&gt;</pre>
<p>to your scene.</li>
<li>Add the default CSS style to the document:
<pre>&lt;link href="/xml3d/script/xml3d.css" media="all" rel="stylesheet" type="text/css"/&gt;</pre>
<p>This will prevent all the numbers to be displayed before the initialization of the scene.</li>
</ol>
<p>Something you have to consider, if you want to use XML3D interaction elements  (onmouseover etc.) with WebGL:</p>
<p>If you use an image from outside the HTML page&#8217;s origin as a texture (e.g. image from a different website), the canvas is flagged as confidential and the scripts can&#8217;t use readPixels anymore. It&#8217;s using the SOP (<a href="http://en.wikipedia.org/wiki/Same_origin_policy">http://en.wikipedia.org/wiki/Same_origin_policy</a>). But readPixels is needed to get the necessary information.</p>
<p>Local access to files (file:// protocol) fail the same-origin check and thus it&#8217;s not possible to test XML3D/WebGL interaction locally.</p>
<p>To do so, you can either modify your browsers security behaviour (not recommended) or install a local web server and access your local files via http://localhost/&#8230; We can recommend Tomcat server, as it is case-sensitive even on Windows and thus you don&#8217;t face this issue when you upload your scene to a Linux server.<br />
That&#8217;s all, have fun with WebGL!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://xml3d.org/2011/05/webgl-best-practice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get started with XML3D</title>
		<link>http://xml3d.org/2011/03/how-to-get-started-with-xml3d/</link>
		<comments>http://xml3d.org/2011/03/how-to-get-started-with-xml3d/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 09:42:01 +0000</pubDate>
		<dc:creator><![CDATA[Rainer Jochem]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[FAQ]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[first steps]]></category>

		<guid isPermaLink="false">http://xml3d.org/?p=372</guid>
		<description><![CDATA[Here are some easy steps to get started with XML3D! <span style="color:#777"> . . . &#8594; Read More: <a href="/2011/03/how-to-get-started-with-xml3d/">How to get started with XML3D</a></span>]]></description>
				<content:encoded><![CDATA[<p>Here are some easy steps to get started with XML3D:</p>
<ol>
<li>Download a WebGL capable browser, e.g.
<ul>
<li><a title="Firefox 4.0" href="http://www.mozilla.com/en-US/firefox/new/" target="_blank">Firefox 4.0</a></li>
<li><a title="Google Chrome 10" href="http://www.google.com/chrome/" target="_blank">Google Chrome 10</a></li>
</ul>
</li>
<li>Try our <a title="XML3D examples" href="http://graphics.cs.uni-sb.de/fileadmin/cguds/projects/xml3d/iX/" target="_blank">online examples</a></li>
</ol>
<p>That&#8217;s it &#8211; you are now using XML3D!</p>
<p>If you want to create your own XML3D content, proceed with the following steps:</p>
<ol>
<li>Get <a title="Blender" href="http://www.blender.org/" target="_blank">Blender</a> 2.49  and download the <a title="XML3D Blender exporter" href="https://github.com/xml3d" target="_blank">XML3D-exporter</a> plugin. Copy the plugin into the scripts directory of your blender installation (please refer to the <a href="http://wiki.blender.org/index.php/Doc:Manual/Extensions/Python/Scripts_guidelines" target="_blank">blender documentation</a> for your operating system). We are currently working on exporters for other modeling software as well.</li>
<li>Export your model and open the resulting xhtml document in a WebGL capable browser.</li>
</ol>
<p>Alternatively you can create XML3D documents manually with the help of the <a href="/tutorial/" target="_blank">tutorial</a> and <a href="http://graphics.cs.uni-sb.de/fileadmin/cguds/projects/xml3d/specification/current/" target="_blank">specification</a>. Just include the <a href="http://graphics.cs.uni-sb.de/fileadmin/cguds/projects/xml3d/script/xml3d.js" target="_blank">xml3d.js</a> into your document to have it rendered with WebGL. If you need further assistance, don&#8217;t hesitate to ask the <a href="https://mail.cg.uni-saarland.de/cgi-bin/mailman/listinfo/xml3d-public" target="_blank">mailing list</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://xml3d.org/2011/03/how-to-get-started-with-xml3d/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
