4 <title>Sixth 3D - 3D engine</title>
5 <!-- 2020-01-29 K 21:30 -->
7 <meta name="viewport" content="width=device-width, initial-scale=1">
8 <meta name="generator" content="Org-mode">
9 <meta name="author" content="Svjatoslav Agejenko">
10 <link href="https://bootswatch.com/3/darkly/bootstrap.min.css" rel="stylesheet">
11 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
12 <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>
13 <style type="text/css">
14 footer {background-color: #111 !important;}
15 pre {background-color: #111; color: #ccc;}
17 <style type="text/css">
18 /* org mode styles on top of twbs */
35 background-color: #f5f5f5;
62 display: inline-block;
74 .bs-docs-sidebar.affix {
77 @media (min-width: 768px) {
83 /* All levels of nav */
84 .bs-docs-sidebar .nav > li > a {
91 .bs-docs-sidebar .nav > li > a:hover,
92 .bs-docs-sidebar .nav > li > a:focus {
95 text-decoration: none;
96 background-color: transparent;
97 border-left: 1px solid #A1283B;
99 .bs-docs-sidebar .nav > .active > a,
100 .bs-docs-sidebar .nav > .active:hover > a,
101 .bs-docs-sidebar .nav > .active:focus > a {
105 background-color: transparent;
106 border-left: 2px solid #A1283B;
109 /* Nav: second level (shown on .active) */
110 .bs-docs-sidebar .nav .nav {
111 display: none; /* Hide by default, but at >768px, show it */
112 padding-bottom: 10px;
114 .bs-docs-sidebar .nav .nav > li > a {
121 .bs-docs-sidebar .nav .nav > li > a:hover,
122 .bs-docs-sidebar .nav .nav > li > a:focus {
125 .bs-docs-sidebar .nav .nav > .active > a,
126 .bs-docs-sidebar .nav .nav > .active:hover > a,
127 .bs-docs-sidebar .nav .nav > .active:focus > a {
132 /* Nav: third level (shown on .active) */
133 .bs-docs-sidebar .nav .nav .nav {
134 padding-bottom: 10px;
136 .bs-docs-sidebar .nav .nav .nav > li > a {
143 .bs-docs-sidebar .nav .nav .nav > li > a:hover,
144 .bs-docs-sidebar .nav .nav .nav > li > a:focus {
147 .bs-docs-sidebar .nav .nav .nav > .active > a,
148 .bs-docs-sidebar .nav .nav .nav > .active:hover > a,
149 .bs-docs-sidebar .nav .nav .nav > .active:focus > a {
154 /* Show and affix the side nav when space allows it */
155 @media (min-width: 992px) {
156 .bs-docs-sidebar .nav > .active > ul {
159 /* Widen the fixed sidebar */
160 .bs-docs-sidebar.affix,
161 .bs-docs-sidebar.affix-bottom {
164 .bs-docs-sidebar.affix {
165 position: fixed; /* Undo the static from mobile first approach */
168 .bs-docs-sidebar.affix-bottom {
169 position: absolute; /* Undo the static from mobile first approach */
171 .bs-docs-sidebar.affix .bs-docs-sidenav,.bs-docs-sidebar.affix-bottom .bs-docs-sidenav {
176 @media (min-width: 1200px) {
177 /* Widen the fixed sidebar again */
178 .bs-docs-sidebar.affix-bottom,
179 .bs-docs-sidebar.affix {
184 <script type="text/javascript">
188 $('.bs-docs-sidebar li').first().addClass('active');
190 $(document.body).scrollspy({target: '.bs-docs-sidebar'});
192 $('.bs-docs-sidebar').affix();
197 <div id="content" class="container">
198 <div class="row"><div class="col-md-9"><h1 class="title">Sixth 3D - 3D engine</h1>
200 <div id="outline-container-sec-1" class="outline-2">
201 <h2 id="sec-1"><span class="section-number-2">1</span> General</h2>
202 <div class="outline-text-2" id="text-1">
204 <li>This is a subproject of parent project: <a href="https://www3.svjatoslav.eu/projects/sixth/">Sixth</a>.
207 <li>This program is free software: you can redistribute it and/or modify
208 it under the terms of the <a href="https://www.gnu.org/licenses/lgpl.html">GNU Lesser General Public License</a> as
209 published by the Free Software Foundation, either version 3 of the
210 License, or (at your option) any later version.
215 <li>Svjatoslav Agejenko
217 <li>Homepage: <a href="https://svjatoslav.eu">https://svjatoslav.eu</a>
219 <li>Email: <a href="mailto://svjatoslav@svjatoslav.eu">mailto://svjatoslav@svjatoslav.eu</a>
224 <li><a href="https://www.svjatoslav.eu/projects/">Other software projects hosted at svjatoslav.eu</a>
229 <div id="outline-container-sec-1-1" class="outline-3">
230 <h3 id="sec-1-1"><span class="section-number-3">1.1</span> Source code</h3>
231 <div class="outline-text-3" id="text-1-1">
233 <li><a href="https://www2.svjatoslav.eu/gitweb/?p=sixth-3d.git;a=snapshot;h=HEAD;sf=tgz">Download latest snapshot in TAR GZ format</a>
236 <li><a href="https://www2.svjatoslav.eu/gitweb/?p=sixth-3d.git;a=summary">Browse Git repository online</a>
239 <li>Clone Git repository using command:
240 <pre class="example">
241 git clone https://www2.svjatoslav.eu/git/sixth-3d.git
246 <li>See <a href="https://www3.svjatoslav.eu/projects/sixth-3d/apidocs/">JavaDoc</a>.
253 <div id="outline-container-sec-2" class="outline-2">
254 <h2 id="sec-2"><span class="section-number-2">2</span> Project description</h2>
255 <div class="outline-text-2" id="text-2">
257 <li>See: <a href="https://www3.svjatoslav.eu/projects/sixth-3d-demos/">demos of current 3D engine capabilities</a>
262 <a href="#sec-2-1">In software</a>, <a href="#sec-2-2">pure Java</a> realtime 3D rendering engine. With the final
263 goal of becoming a platform for buildng 3D user interfaces and
264 interactive data visualization for <a href="https://www3.svjatoslav.eu/projects/sixth/">project Sixth</a>.
268 Sixth 3D can be also used as standalone <a href="#sec-4">3D engine in your project</a>.
272 <div id="outline-container-sec-2-1" class="outline-3">
273 <h3 id="sec-2-1"><a id="ID-d03013e5-931b-40ca-bc4b-e4b3f23b9a4e" name="ID-d03013e5-931b-40ca-bc4b-e4b3f23b9a4e"></a><span class="section-number-3">2.1</span> Justification for software rendering</h3>
274 <div class="outline-text-3" id="text-2-1">
276 3D rendering is done in software, 100% pure Java on CPU. At least for
277 now. Modern CPU cores count keeps growing and therefore rendering by
278 CPU is not as expensive as it used to be for the old single core
283 CPU rendering performance is already good enough to implement usable
284 3D UI at sufficient detail level, resolution and frame rate.
288 Also CPU rendering allows to freely test different rendering and
289 optimization algorithms and retains complete control of every rendered
294 <div id="outline-container-sec-2-2" class="outline-3">
295 <h3 id="sec-2-2"><a id="ID-a11f7150-1b25-4ca4-a3c3-8c8bd1352bd4" name="ID-a11f7150-1b25-4ca4-a3c3-8c8bd1352bd4"></a><span class="section-number-3">2.2</span> Justification for Java</h3>
296 <div class="outline-text-3" id="text-2-2">
298 <li>It is easy to refactor and experiment with.
301 <li>Easy portability and installation. No need to deal with platform
302 specific dependencies.
305 <li>It scales well to handle great complexity.
307 <li>Allows to implement clever performance optimizations (instead of
308 going for GPU offered brute-force rendering approach).
313 <li>No limitations imposed by:
315 <li>requirement for decent GPU
317 <li>GPU missing features
319 <li>GPU missing/incomplete/buggy drivers
321 <li>OpenGL specification
326 <li>It is fast enough thanks to:
328 <li>Java virtual machine just-in-time compiler.
330 <li>Growing CPU cores count.
335 <li>As a result it is easy to run on various hardware platforms and
343 <div id="outline-container-sec-3" class="outline-2">
344 <h2 id="sec-3"><span class="section-number-2">3</span> API documentation</h2>
345 <div class="outline-text-2" id="text-3">
347 <li>See <a href="https://www3.svjatoslav.eu/projects/sixth-3d/apidocs/">JavaDoc</a>.
352 Note: due to a lack of time, there is still big room for improvement
357 So far best resource is to download and explore source code for:
360 <li>3D engine (<a href="https://www3.svjatoslav.eu/projects/sixth-3d/graphs/">generated code graphs</a> (generated using <a href="https://www3.svjatoslav.eu/projects/javainspect/">JavaInspect</a>))
362 <li>For API usage examples, see <a href="https://www3.svjatoslav.eu/projects/sixth-3d-demos/">demos</a>
367 <div id="outline-container-sec-4" class="outline-2">
368 <h2 id="sec-4"><a id="ID-08f71987-90af-40dc-bb65-bac87db9e652" name="ID-08f71987-90af-40dc-bb65-bac87db9e652"></a><span class="section-number-2">4</span> Instructions to embed Sixth-3D in your project</h2>
369 <div class="outline-text-2" id="text-4">
371 Maven *pom.xml* file snippet:
373 <div class="org-src-container">
375 <pre class="src src-xml"><<span style="color: #A6E22E;">dependencies</span>>
377 <<span style="color: #A6E22E;">dependency</span>>
378 <<span style="color: #A6E22E;">groupId</span>>eu.svjatoslav</<span style="color: #A6E22E;">groupId</span>>
379 <<span style="color: #A6E22E;">artifactId</span>>sixth-3d</<span style="color: #A6E22E;">artifactId</span>>
380 <<span style="color: #A6E22E;">version</span>>1.1</<span style="color: #A6E22E;">version</span>>
381 </<span style="color: #A6E22E;">dependency</span>>
383 </<span style="color: #A6E22E;">dependencies</span>>
385 <<span style="color: #A6E22E;">repositories</span>>
387 <<span style="color: #A6E22E;">repository</span>>
388 <<span style="color: #A6E22E;">id</span>>svjatoslav.eu</<span style="color: #A6E22E;">id</span>>
389 <<span style="color: #A6E22E;">name</span>>Svjatoslav repository</<span style="color: #A6E22E;">name</span>>
390 <<span style="color: #A6E22E;">url</span>>http://www2.svjatoslav.eu/maven/</<span style="color: #A6E22E;">url</span>>
391 </<span style="color: #A6E22E;">repository</span>>
393 </<span style="color: #A6E22E;">repositories</span>>
398 For API usage examples, see <a href="https://www3.svjatoslav.eu/projects/sixth-3d-demos/">demos</a>.
402 <div id="outline-container-sec-5" class="outline-2">
403 <h2 id="sec-5"><span class="section-number-2">5</span> <span class="label label-primary TODO">TODO</span> features to add</h2>
404 <div class="outline-text-2" id="text-5">
406 <li>read this as example, and apply improvements/fixes where applicable:
407 <a href="http://blog.rogach.org/2015/08/how-to-create-your-own-simple-3d-render.html">http://blog.rogach.org/2015/08/how-to-create-your-own-simple-3d-render.html</a>
410 <li>Partial region/frame repaint: when only one small object changed on
411 the scene, it would be faster to re-render that specific area.
414 <li>Once partial rendering works, in would be easy to add multi-core
415 rendering support. So that each core renders it's own region of the
419 <li>Antialiazing. Would improve text readability. If antialiazing is too
420 expensive for every frame, it could be used only for last frame
421 before animations become still and waiting for user input starts.
425 <div id="outline-container-sec-5-1" class="outline-3">
426 <h3 id="sec-5-1"><span class="section-number-3">5.1</span> Render only visible polygons</h3>
427 <div class="outline-text-3" id="text-5-1">
429 <li>This would significantly reduce RAM <-> CPU traffic.
432 <li>General algorithm description:
434 <li>For each horizontal scanline:
436 <li>sort polygon edges from left to right
438 <li>while iterating and drawing pixels over screen X axis (left to
439 right) track next appearing/disappearing polygons.
441 <li>For each polygon edge update Z sorted active polygons list.
443 <li>Only draw pixel from the top-most polygon.
445 <li>Only if polygon area is transparent/half-transparent add
446 colors from the polygons below.
457 <li>As a bonus, this would allow to track which polygons are really
458 visible in the final scene for each frame.
461 <li>Such information allows further optimizations:
464 <li>Dynamic geometry simplification:
466 <li>Dynamically detect and replace invisible objects from the
467 scene with simplified bounding box.
470 <li>Dynamically replace boudnig box with actual object once it
476 <li>Dynamically unload unused textures from RAM.
486 </div><div class="col-md-3"><nav id="table-of-contents">
487 <div id="text-table-of-contents" class="bs-docs-sidebar">
489 <li><a href="#sec-1">1. General</a>
491 <li><a href="#sec-1-1">1.1. Source code</a></li>
494 <li><a href="#sec-2">2. Project description</a>
496 <li><a href="#sec-2-1">2.1. Justification for software rendering</a></li>
497 <li><a href="#sec-2-2">2.2. Justification for Java</a></li>
500 <li><a href="#sec-3">3. API documentation</a></li>
501 <li><a href="#sec-4">4. Instructions to embed Sixth-3D in your project</a></li>
502 <li><a href="#sec-5">5. features to add</a>
504 <li><a href="#sec-5-1">5.1. Render only visible polygons</a></li>
511 <footer id="postamble" class="">
512 <div><p class="author">Author: Svjatoslav Agejenko</p>
513 <p class="date">Created: 2020-01-29 K 21:30</p>
514 <p class="creator"><a href="http://www.gnu.org/software/emacs/">Emacs</a> 26.1 (<a href="http://orgmode.org">Org-mode</a> 9.1.9)</p>