1\documentclass[a4paper]{article}
2\usepackage[latin1]{inputenc}
3\usepackage[T1]{fontenc}
4\usepackage{a4wide}
5\usepackage{hyperref}
6\newcommand{\filename}[1]{\texttt{#1}}
7\newcommand{\cmd}[1]{\texttt{#1}}
8
9\title{Scenery3d - Walkable 3D Models in Stellarium} \author{Georg
10Zotti\thanks{\url{Georg.Zotti@univie.ac.at},
11\url{http://astrosim.univie.ac.at}}\  \ and Florian Schaukowitsch}
12\date{April 10, 2015; last updated \today}
13\begin{document}
14\maketitle
15
16\section{Introduction}
17\label{sec:Introduction}
18
19
20Have you ever wished to be able to walk through Stonehenge or other
21ancient building structures described as being constructed with
22astronomical orientation in mind, and experience such orientation in a
233D virtual environment that also provides a good sky simulation?
24
25The Stellarium Scenery3d plugin allows you to see architectural 3D models
26embedded in a landscape combined with the excellent representation of the sky
27provided by Stellarium. You can walk around, check for (or
28demonstrate) possible astronomical alignments of ancient architecture, see
29sundials and other shadow casters in action, etc.
30
31\section{Usage}
32\label{sec:Usage}
33
34
35You activate the plugin with the \emph{circular enclosure} button at screen
36bottom or by pressing [Ctrl+3]. The other button with circular enclosure and
37tool icon (or [Ctrl+Shift+3]) opens the settings dialog. Once loaded and
38displaying, you can walk around pressing [Ctrl] plus cursor keys. Change eye
39height with [Ctrl]+[PgUp]/[PgDn] keys. Adding [Shift] key increases speed by 10,
40[Alt] by 5 (pressing both keys multiplies by 50!). If you release [Ctrl] before
41the cursor key, animation will continue. (Press [Ctrl]+any cursor key to stop
42moving.)\footnote{I (GZ) had to change keyboard handling in the
43main program, somewhat breaking the plugin concept.}
44
45Further key bindings exist which can be configured using the Stellarium default
46key-binding interface. Some options are also available in the Scenery3d dialog.
47For example, coordinate display can be enabled. If your models are georeferenced
48in a true geographical coordinate grid, e.g. UTM or Gauss-Krueger, you will
49especially like this, and this makes the plugin usable for scientific purposes.
50Display shows grid name, Easting, Northing, Altitude of ground, and eye height
51above ground.
52
53Other features include a virtual ``torchlight'', which can be enabled to give
54additional local illumination around the viewer to help to see in the dark.
55Interesting points of view can be saved and restored later by the user,
56including a description of the view. Scene authors can also distribute
57predefined viewpoints in their scene.
58
59The plugin also simulates the shadows of the scene's objects cast by
60the Sun, Moon and even Venus (only 1 shadow caster used at a time, you
61will never see shadows cast by Venus in moonlight), so you could use
62it for examining sundials, or analyze and simulate light-and-shadow
63interactions in archeological structures.
64
65\section{Hardware Requirements \& Performance}
66\label{sec:HardwareRequirements}
67
68In order to work with the non-linear projection models in Stellarium,
69this plugin uses a trick to create the foreground renderings: it
70renders the scene into the six planes of a so-called cubemap, which is
71then correctly reprojected onto the sides of a cube, depending on the
72current projection settings. Your graphics card must be able to do
73this, i.e. it must support the OpenGL extension called
74\texttt{EXT\_framebuffer\_object}. Typical modern 3D cards (by NVidia
75or ATI/AMD) support this extension. In case your graphics hardware
76does not suppport it, the plugin will still work, but you are limited
77to perspective projection.
78
79You can influence rendering quality, but also speed, using the plugin's
80GUI, which provides some options such as enabling the use
81of shadows, bumpmapping (provides more realistic surface lighting) or
82configuring the sizes of the textures used
83for the cubemap or shadowmaps. Larger values there improve the quality,
84but require faster hardware and more video memory for smooth results.
85
86Because the ``cubemap trick'' requires quite a large amount of performance (in
87essence, the scene has to be rendered 6 times), there are some options available
88that try to reduce this burden. The first option is to change the type of the
89``cubemap''. The most compatible setting is \emph{6 textures}, which seems to
90work best on older integrated Intel GPUs. The recommended default is the second
91setting, \emph{Cubemap}, which uses a more modern OpenGL feature and generally
92works a bit faster than \emph{6 textures} on more modern graphics cards. Finally,
93the \emph{Geometry shader} option tries to render all 6 cube faces at once. This
94requires a more recent GPU + drivers (at least OpenGL 3.2 must be supported),
95the setting is disabled otherwise. Depending on your hardware and the scene's
96complexity, this method may give a speedup or may be slower, you must find this out yourself.
97
98Another option prevents re-rendering of the cubemap if nothing relevant has
99changed. You can define the interval (in Stellarium's simulation time) in which
100nothing is updated in the GUI. You can still rotate the camera without causing a
101re-draw, giving a subjective performance that is close to Stellarium's
102performance without Scenery3d. When moving, the cubemap will be updated. You can
103enable another option that only causes 1 or 2 sides of the cubemap to be updated
104while you move, giving a speedup but causing some parts of the image to be
105outdated and discontinuous. The cubemap will be completed again when you stop
106moving.
107
108Shadow rendering may also cause quite a performance impact. The \emph{Simple
109shadows} option can speed this up a lot, at the cost of shadow quality
110especially in larger scenes. Another performance/quality factor is shadow
111filtering. The sharpest (and fastest) possible shadows are achieved with
112filtering \emph{Off}, but depending on shadowmap resolution and scene size the
113shadows may look quite ``blocky''. \emph{Hardware} shadow filtering is usually
114very fast, but may not improve appearance a lot. Therefore, there are additional
115filter options available, the \emph{High} filter option is relatively expensive.
116Finally, the \emph{PCSS} option allows to approximate the increase of solar and lunar shadow
117penumbras relative to the distance from their shadow casters, i.e. shadows are
118sharp near contact points, and more blurred further away. This again requires
119quite a bit of performance, and only works if the shadow filter option is set to
120\emph{Low} or \emph{High} (without \emph{Hardware}).
121
122The configuration GUI shows tooltips for most of its settings, which can explain
123what a setting does. All settings are saved automatically, and restored when you
124reopen Stellarium.
125
126
127\subsection{Performance notes}
128\label{sec:Performance}
129
130On reasonably good hardware
131%2012: (tested on a notebook PC with NVidia M9800 GTS),
132% models up to 100.000 triangles are fluent, up to 250.000 are still ``interactive''.
133% we have 2015, and a much faster implementation!
134(tested on a notebook PC with NVidia M580 GTS), models with about
135500.000 triangles are fluent with shadows and bumpmaps.  On very small
136hardware like single-board computers with native OpenGL ES2, models
137may be limited to 64k vertices (points).  If display is too slow,
138switch to perspective projection: all other projections require almost
139sixfold effort!  You should also prefer the ``lazy'' cubemap mode,
140where the scene is only rendered in specific timesteps or
141when movement happens.
142
143
144\section{Model Configuration}
145\label{sec:ModelConfiguration}
146
147The model format supported in Scenery3d is Wavefront .OBJ, which is
148pretty common for 3D models.  You can use several modeling programs to
149build your models. Software such as Blender, Maya, 3D Studio
150Max etc.\ can export OBJ.
151
152A simple to use and cost-free modeling program is Google Sketchup, commonly
153used to create the 3D buildings seen in Google Earth. It can be used
154to create georeferenced models.  OBJ is not a native export format for
155the standard version of Google Sketchup. If you are not willing to
156afford Sketchup Pro, you have to find another way to export a textured
157OBJ model.
158
159
160\begin{table}[t]
161  \centering
162\begin{tabular}{rl}
163Geometry&Yes\\Lights&Yes\\Clay&No\\Photomatched&Yes\\DefaultUVs&No\\Instanced&No
164\end{tabular}
165\caption{Kerkythea Export Settings}
166  \label{fig:KerkytheaExportSettings}
167\end{table}
168
169One good exporter is available in the Kerkythea renderer project\footnote{
170Available at \url{http://www.kerkythea.net/cms/}}.  You need
171\filename{SU2KT~3.17}
172or better, and \filename{KT2OBJ~1.1.0} or better.  Deselect any selection, then
173export your model to the Kerkythea XML format with settings shown in
174\ref{fig:KerkytheaExportSettings}.
175(Or, with selection enabled, make sure settings are No-Yes-Yes-No-Yes-No-No.)
176You do not have to launch Kerkythea unless you want to create nice renderings of
177your model.
178Then, use the \filename{KT2OBJ} converter to create an OBJ.  You can delete the
179XML after the conversion.  Note that some texture coordinates may not be
180exported correctly. The setting Photomatched:Yes seems now to have
181corrected this issue, esp. with distorted/manu\-ally shifted textures.
182
183Another free OBJ exporter has been made available by
184TIG: \filename{OBJexporter.rb}\footnote{Available from
185\url{http://forums.sketchucation.com/viewtopic.php?f=323&t=33448}}.
186This is the only OBJ exporter capable of handling large TIN landscapes
187($>450.000$ triangles).
188As of version 2.6 it seems to be the best OBJ exporter available for Sketchup.
189
190%As of version 1.6 it appears to have valid texture coordinates, but I have
191%experienced problems with black faces which need more
192%investigation. Maybe you can combine two OBJ files with another 3D
193%editor after creating individual OBJs if this is a problem.
194
195This exporter swaps Y/Z coordinates, but you can add a key to the config file to
196correct swapped axes, see below. Other exporters may also provide coordinates in
197any order of X, Y, Z -- all those can be properly configured.
198
199Another (almost) working alternative: \filename{ObjExporter.rb} by author
200Honing.  Here, export with settings 0xxx00. This will not create a
201\filename{TX...} folder but dump all textures in the same directory as the OBJ
202and MTL files. Unfortunately, currently some material assignments seem to be
203bad.
204
205Yet another exporter, \filename{su2objmtl}, does also not provide good texture
206coordinates and cannot be recommended at this time.
207
208\subsection{Notes on OBJ file format limitations}
209\label{sec:OBJlimitations}
210
211The OBJ format supported is only a subset of the full OBJ format: Only
212(optionally textured) triangle meshes are supported, i.e., only lines containing
213statements: \cmd{mtllib}, \cmd{usemtl}, \cmd{v}, \cmd{vn}, \cmd{vt}, \cmd{f}
214(with three elements only!), \cmd{g}. Negative vertex numbers (i.e., a
215specification of relative positions) are not supported.
216
217A further recommendation for correct illumination is that all vertices should
218have vertex normals. Sketchup models exported with the Kerkythea or TIG plugins
219should have correct normals. If your model does not provide them, default
220normals can be reconstructed from the triangle edges, resulting in a faceted
221look.
222
223If possible, the model should also be triangulated, but the current loader may
224also work with non-triangle geometry.
225%% TODO: GZ: Does that mean Quads, or higher-level polygons?
226The correct use of objects ('o') and
227groups ('g') will improve performance: it is best if you pre-combine all objects
228that use the same material into a single one. The loader will try to optimize it
229anyways if this is not the case, but can do this only partly (to combine 2
230objects with the same material into 1, it requires them to follow directly after
231each other in the OBJ). A simple guide to use Blender for this task follows:
232
233\begin{itemize}
234\item Import from Wavefront (.obj) - you may need to change the forward/up axes for correct orientation, try -Y for forward and Z for up
235\item Select an object which has a shared material
236\item Press Shift+L and select 'By Material'
237\item Select 'Join' in the left (main) tool window
238\item Repeat for other objects that have shared materials
239\item Export the .obj, making sure to select the same forward/up axes as in the import, also make sure ``Write Normals'', ``Write Materials'' and ``Include UVs'' are checked
240\end{itemize}
241
242For transparent objects (with a 'd' or 'Tr' value, alpha testing does NOT need this), this recommendation does NOT hold: for optimal results, each separate transparent object should be exported as a separate ``OBJ object''. This is because they need to be sorted during rendering to achieve correct transparency. If the objects are combined already, you can separate them using Blender:
243
244\begin{itemize}
245\item Import .obj (see above)
246\item Select the combined transparent object
247\item Enter ``Edit'' mode with TAB and make sure everything is selected (press A if not)
248\item Press P and select ``By loose parts'', this should separate the object into its unconnected regions
249\item Export .obj (see above), also check ``Objects as OBJ Objects''
250\end{itemize}
251
252\begin{table}[b]
253\begin{tabular}{llll}
254Parameter           &Default      &Range           & Meaning\\
255\cmd{Ka}            &set to \cmd{Kd} values & $0\dots1$ each& R/G/B Ambient color\\
256\cmd{Kd}            &0.8 0.8 0.8  & $0\dots1$ each & R/G/B Diffuse color\\
257\cmd{Ke}            &0.0 0.0 0.0  & $0\dots1$ each & R/G/B Emissive color\\
258\cmd{Ks}            &0.0 0.0 0.0  & $0\dots1$ each & R/G/B Specular color\\
259\cmd{Ns}            &8.0          & $0\dots\infty$ & shinyness \\
260\cmd{d} or \cmd{Tr} &1.0          & $0\dots1$      & opacity \\
261\cmd{bAlphatest}    &0            & 0 or 1         & perform alpha test \\
262\cmd{bBackface}     &0            & 0 or 1         & render backface \\
263\cmd{map\_Kd}       & (none)      & filename       & texture map to be mixed with Ka, Kd \\
264\cmd{map\_Ke}       & (none)      & filename       & texture map to be mixed with Ke \\
265\cmd{map\_bump}     & (none)      & filename       & normal map for surface roughness
266\end{tabular}
267\caption{MTL parameters evaluated}
268\label{tab:MTL}
269\end{table}
270
271The MTL file specified by ``mtllib'' contains the material parameters. The
272minimum that should be specified is either \cmd{map\_Kd} or a \cmd{Kd} line
273specifying color values used for the respective faces. But there are other
274options in MTL files, and the supported parameters and defaults are listed in
275Table~\ref{tab:MTL}.
276
277If no ambient color is specified, the diffuse color values are taken for the
278ambient color. An optional emissive term \cmd{Ke} can be added, which is
279modulated to only be visible during nighttime. This also requires the
280landscape's self-illumination layer to be enabled. It allows to model
281self-illuminating objects such as street lights, windows etc. It can optionally
282also be modulated by the emissive texture \cmd{map\_Ke}.
283
284If a value for \cmd{Ks} is specified, specularity is evaluated using the
285\href{https://en.wikipedia.org/wiki/Phong_reflection_model}{Phong reflection
286model} with \cmd{Ns} as the exponential shininess constant. Larger shininess
287means smaller specular highlights (more metal-like appearance). Specularity is
288not modulated by the texture maps.
289
290If a value for \cmd{d} or \cmd{Tr} exists, alpha blending is enabled for this
291material. This simulates transparency effects. Transparency can be further
292controlled using the alpha channel of the \cmd{map\_Kd} texture.
293
294A simpler and usually more performant way to achieve simple ``cutout''
295transparency effects is alpha-testing, by setting \cmd{bAlphatest} to 1. This
296simply discards all pixels of the model where the alpha value of the
297\cmd{map\_Kd} is below the \cmd{transparency\_threshold} value from
298\filename{scenery3d.ini}, making ``holes'' in the model. This also produces
299better shadows for such objects. If required, alpha testing can be combined with
300``real'' blending-based transparency.
301
302Sometimes, exported objects only have a single side (``paper wall''), and are only visible
303from one side when looked at in Scenery3d. This is caused by an optimization
304called \href{https://en.wikipedia.org/wiki/Back-face_culling}{back-face
305culling}, which skips drawing the back sides of objects because they are usually
306not visible anyway. If possible, avoid such ``thin'' geometry, this will also
307produce better shadows on the object. As a workaround, you can also set
308\cmd{bBackface} to 1 to disable back-face culling for this material.
309
310The optional \cmd{map\_bump} enables the use of a tangent-space
311\href{https://en.wikipedia.org/wiki/Normal_mapping}{normal maps}, which provides
312a dramatic improvement in surface detail under illumination.
313
314\subsection{Configuring OBJ for Scenery3d}
315\label{sec:Configuring}
316
317The walkaround in your scene can use a ground level (piece of terrain)
318on which the observer can walk. The observer eye will always stay ``eye
319height'' above ground. Currently, there is no collision detection with
320walls implemented, so you can easily walk through walls, or jump on
321high towers, if their platform or roof is exported in the ground
322layer. If your model has no explicit ground layer, walk will be on the
323highest surface of the scenery layer.  If you use the special name
324\texttt{NULL} as ground layer, walk will be above \texttt{zero\_ground\_height} level.
325
326Technically, if your model has cavities or doors, you should export
327your model twice. Once, just the ground plane, i.e. where you will
328walk. Of course, for a temple or other building, this includes its
329socket above soil, and any steps, but pillars should not be included.
330This plane is required to compute
331eye position above ground. Note that it is not possible to walk in
332several floors of a building, or in a multi-plane staircase. You may
333have to export several ``ground'' planes and configure several scenery
334directories for those rare cases. For optimal performance, the ground
335model should consist of as few triangles as you can tolerate.
336
337The second export includes all visible model parts, and will be used for
338rendering. Of course, this requires the ground plane again, but also
339all building elements, walls, roofs, etc.
340
341If you have not done so by yourself, it is recommended to separate
342ground and buildings into Sketchup layers
343(or similar concepts in whichever editor you are using)
344in order to easily switch the model to the right state prior to exporting.
345
346Filename recommendations:
347\begin{verbatim}
348<Temple>.skp        Name of a Sketchup Model file.
349                    (The "<>" brackets signal "use your own name here!")
350                    The SKP file is not used by Scenery3d, but you may want
351                    to leave it in the folder for later improvements.
352<Temple>.obj        Model in OBJ format.
353<Temple>_ground.obj Ground layer, if different from Model file.
354\end{verbatim}
355
356OBJ export may also create folders \verb|TX_<Temple>| and
357\verb|TX_<Temple>_ground|. You can delete the \verb|TX_<Temple>_ground| folder,
358\verb|<Temple>_ground.obj| is just used to compute vertical height.
359
360Stellarium uses a directory to store additional data per-user. On Windows, this
361defaults to \verb|C:\Documents and Settings\<username>\Application Data\Stellarium|,
362but you can use another directory by using the command-line
363argument \cmd{--user-dir <USERDATA>}. We will refer to this directory. Put the
364OBJ, MTL and TX directories into a directory, \\
365\verb|<USERDATA>/Stellarium/scenery3d/<Temple>|, and add a text file
366called \texttt{scenery3d.ini} (This name is mandatory!) with content described as
367follows.
368
369% A Sketchup plugin "Write scenery3d.ini for Stellarium" will write this
370% file. Locate the directory where the .obj file(s) reside(s), and store
371% scenery3d.ini there. If you have other modelers and models, or if your
372% model is not georeferenced in Sketchup, write the file yourself and
373% use the following format.
374%
375% TBD GZ: Release this Sketchup export plugin?
376
377\begin{verbatim}
378
379[model]
380name=<Temple>                Unique ID within all models in scenery3d directory.
381                             Recommendation: use directory name.
382landscape=<landscapename>    Name of an available Stellarium landscape.
383\end{verbatim}
384This is required if the landscape file includes geographical
385coordinates and your model does not: First, the location coordinates
386of the \filename{landscape.ini} file are used, then location coordinates given here.
387The landscape also provides the background image of your scenery. - If
388you want a zero-height (mathematical) horizon, use the provided
389landscape called \filename{Zero Horizon}.
390\begin{verbatim}
391scenery=<Temple>.obj         The complete model, including visible ground.
392ground=<Temple>_ground.obj   Optional: separate ground plane. (NULL for zero altitude.)
393description=<Description>    A basic scene description (including HTML tags)
394\end{verbatim}
395The \filename{scenery3d.ini} may contain a simple scene description, but it is
396recommended to use the \emph{localizable} description format: in the scene's
397directory (which contains \filename{scenery3d.ini}) create files in the format
398\filename{description.<lang\_code>.utf8} which can contain arbitrary
399\cmd{UTF-8}-encoded HTML content. \cmd{<lang\_code>} stands for the ISO 639
400language code.
401\begin{verbatim}
402author=<Your Name yourname@yourplace.com>
403copyright=<Copyright Info>
404
405obj_order=XYZ      | Use this if you have used an exporter which swaps Y/Z coordinates.
406                   | Defaults to XYZ, other options: XZY, YZX, YXZ, ZXY, ZYX
407camNearZ=0.3       This defines the distance of the camera near plane, default 0.3.
408                   Everything closer than this value to the camera can not be
409                   displayed. Must be larger than zero. It may seem tempting
410                   to set this very small, but this will lead to accuracy issues.
411                   Recommendation is not to go under 0.1
412camFarZ=10000      Defines the maximal viewing distance, default 10000.
413shadowDistance=<val>  The maximal distance shadows are displayed. If left out, the
414                      value from camFarZ is used here. If this is set to a smaller
415                      value, this may increase the quality of the shadows that are
416                      still visible.
417shadowSplitWeight=0..1 Decimal value for further shadow tweaking. If you require
418                       better shadows up close, try setting this to higher values.
419                       The default is calculated using a heuristic that incorporates
420                       scene size.
421
422[general]
423\end{verbatim}
424The general section defines some further import/rendering options.
425% GZ TBD: Why do we need ground normals?
426%
427\begin{verbatim}
428transparency_threshold=0.5   Defines the alpha threshold for alpha-testing,
429                             as described in section 4.1. Default 0.5
430scenery_generate_normals=0   Boolean, if true normals are recalculated by the
431                             plugin, instead of imported. Default false
432ground_generate_normals=0    Boolean, same as above, for ground model. Default
433                             false.
434
435[location]
436\end{verbatim}
437Optional section to specify geographic longitude $\lambda$, latitude $\varphi$,
438and altitude. Required if\\ \verb|coord/convergence_angle=from_grid|, else
439location is inherited from landscape.
440\begin{verbatim}
441planet = Earth
442latitude = +48d31'30.4"      ; Required if coord/convergence_angle=from_grid
443longitude = +16d12'25.5"     ; "--"
444altitude =from_model|<int>   ;
445\end{verbatim}
446altitude (for astronomical computations) can be computed from the model:  if
447\verb|from_model|, it is computed as $(z_{min}+z_{max})/2+\mathtt{orig\_H}$,
448i.e. from the model bounding box centre height.
449
450\begin{verbatim}
451display_fog = 0
452atmospheric_extinction_coefficient = 0.2
453atmospheric_temperature = 10.0
454atmospheric_pressure = -1
455light_pollution = 1
456
457[coord]
458\end{verbatim}
459
460Entries in the \verb|[coord]| section are again optional, default to zero when
461not specified, but are
462required if you want to display meaningful eye coordinates in your
463survey (world) coordinate system, like UTM or Gauss-Kr\"uger.
464
465\begin{verbatim}
466grid_name=<string>
467\end{verbatim}
468Name of grid coordinates, e.g. \texttt{``UTM 33 U (WGS 84)''},
469\texttt{``Gauss-Kr\"uger M34''} or \texttt{``Relative to <Center>''} This name is
470only displayed, there is no evaluation of its contents.
471
472\begin{verbatim}
473orig_E=<double> | (Easting)  East-West-distance to zone central meridian
474orig_N=<double> | (Northing) North distance from Equator
475orig_H=<double> | (Height)   Altitude above Mean Sea Level of model origin
476\end{verbatim}
477These entries describe the offset, in metres, of the model coordinates relative
478to coordinates in a geographic grid, like Gauss-Kr\"uger. If you have your model
479vertices specified in grid coordinates, do not specify \verb|orig_...| data, but
480please definitely add \verb|start_...| data, below.
481
482Note that using grid coordinates without offset for the vertices is
483usually a bad idea for real-world applications like surveyed sites in
484UTM coordinates. Coordinate values are often very large numbers
485(ranging into millions of meters from equator and many thousands from
486the zone meridian). If you want to assign millimetre values to model
487vertices, you will hit numerical problems with the usual
488single-precision floating point arithmetic. Therefore we can specify
489this offset which is only necessary for coordinate display.
490
491\begin{verbatim}
492convergence_angle=from_grid|<double>
493grid_meridian=<double>|+<int>d<int>'<float>"
494\end{verbatim}
495Typically, digital elevation models and building structures built on those are
496survey-grid aligned, so true geographical north will not coincide with grid
497north, the difference is known as meridian convergence.
498\begin{equation}
499\gamma(\lambda, \varphi)=\arctan(\tan(\lambda-\lambda_0)\sin\varphi)
500\end{equation}
501This amount can be given in \verb|convergence_angle| (degrees), so
502that your model will be rotated clockwise by this amount around
503the vertical axis to be aligned with True North\footnote{%
504  \url{http://en.wikipedia.org/wiki/Transverse_Mercator_projection}}\footnote{Note that Sketchup's \emph{georeferencing dictionary} provides a NorthAngle entry, which is $360-\mathtt{convergence\_angle}$.}.
505
506\verb|grid_meridian| Central
507meridian $\lambda_0$ of grid zone, e.g.\ for UTM or Gauss-Kr\"uger,
508 is only required to compute convergence angle if
509\verb|convergence_angle="from_grid"|
510
511\begin{verbatim}
512zero_ground_height=<double>
513\end{verbatim}
514height of terrain outside \filename{<Temple>\_ground.OBJ}, or if \verb|ground=NULL|.
515Allows smooth approach from outside.  This value is relative to the model
516origin, or typically close to zero, i.e.,  use a Z value in model coordinates,
517not world coordinates! (If you want the terrain height surrounding your model to
518be \verb|orig_H|, use 0, not the correct mean height above sea level!)  Defaults
519to minimum of height of ground level (or model, resp.) bounding box.
520
521\begin{verbatim}
522start_E=<double>
523start_N=<double>
524start_H=<double>     /* only meaningful if ground==NULL, else H is derived from ground */
525start_Eye=<double>   /* default: 1.65m */
526start_az_alt_fov=<az_deg>,<alt_deg>,<fov_deg> /* initial view direction and field of view.*/
527\end{verbatim}
528\verb|start_...| defines the view position to be set after loading the scenery.
529Defaults to center of model boundingbox.
530
531It is advisable to use the grid coordinates of the location of the panoramic
532photo ("landscape") as \verb|start_...| coordinates, or the correct coordinates
533and some carefully selected \texttt{start\_az\_alt\_fov} in case of certain view
534corridors (temple axes, \ldots).
535
536\subsection{Predefined views}
537You can also distribute some predefined views with your model in a
538\filename{viewpoints.ini} file. See the provided ``Sterngarten'' scene for an
539example. These entries are not editable by the user through the interface. The
540user can always save his own views, they will be saved into the file
541\filename{userviews.ini} in the user's Stellarium user directory, and are editable.
542
543\begin{verbatim}
544[StoredViews]
545size=<int>              Defines how many entries are in this file.
546                        Prefix each entry with its index!
5471/label=<string>        The name of this entry
5481/description=<string>  A description of this entry (can include HTML)
5491/position=<x,y,z,h>    The x,y,z grid coordinates (like orig_* or start_*
550                        in scenery3d.ini) + the current eye height
5511/view_fov=<az_deg,alt_deg,fov_deg>  The view direction + FOV
552                                    (like start_az_alt_fov in scenery3d.ini)
553; an example for the second entry (note the 2 at the beginning of each line!)
5542/label       = Signs
5552/description = Two signs that describe the Sterngarten
5562/position    = 593155.2421280354,5333348.6304404084,325.7295809038,0.8805893660
5572/view_fov    = 84.315399,-8.187078,83.000000
558\end{verbatim}
559
560\subsection{Concatenating OBJ files}
561\label{sec:concatenating}
562
563Some automated workflows may involve tiled landscape areas, e.g. to
564overcome texture limitations or triangle count limits in simpler tools
565like Sketchup. In this case you can create separate meshes in the same
566coordinate system, but you need to concatenate them. in Blender, import
567the OBJ files (File/Import/Wavefront .obj), select them and press
568Ctrl-J to join them, then export to a single OBJ
569(File/Export/Wavefront .obj)%
570\footnote{http://blender.stackexchange.com/questions/3352/merging-multiple-obj-files}.
571
572Verify the new model loads correctly, e.g. in Meshlab!
573
574\subsection{Working with non-georeferenced OBJ files}
575\label{sec:NonGeoreferenced}
576
577
578There exists modeling software which produces nice models, but without
579concept of georeference. One spectacular example is AutoDesk PhotoFly,
580a cloud application which delivers 3D models from a bunch of photos
581uploaded via its program interface. This ``technological preview'' is
582in version 2 and free of cost as of mid-2011.
583
584The problem with these models is that you cannot assign surveyed
585coordinates to points in the model, so either you can georeference the
586models in other applications, or you must find the correct
587transformation matrix.  Importing the OBJ in Sketchup may take a long
588time for detailed photo-generated models, and the texturing may
589suffer, so you can cut the model down to the minimum necessary e.g.\ in
590Meshlab, and import just a stub required to georeference the model in
591Sketchup.
592
593Now, how would you find the proper orientation? The easiest chance
594would be with a structure visible in the photo layer of Google
595Earth. So, start a new model and immediately "add location" from the
596Google Earth interface. Then you can import the OBJ with TIG's importer
597plugin.  If the imported model looks perfect, you may just place the
598model into the Sketchup landscape and export a complete landscape just
599like above. If not, or if you had to cut/simplify the OBJ to be able
600to import it, you can rotate/scale the OBJ (it must be grouped!). If
601you see a shadow in the photos, you may want to set the date/time of
602the original photos in the scene and verify that the shadows created by
603Sketchup illuminating the model match those in the model's photo
604texture. When you are satisfied with placement/orientation, you create
605a \filename{scenery3d.ini} like above with the command
606\cmd{Plugins->ASTROSIM/Stellarium scenery3d helpers->Create scenery3d.ini}.
607
608Then, you select the OBJ group, open \cmd{Windows->Ruby Console} and call
609\cmd{Plugins->ASTROSIM/Stellarium scenery3d helpers->Export transformation
610of selected group (e.g., from PhotoFly import)}.
611
612On the Ruby console, you will find a line of numbers (the $4\times4$
613transformation matrix) which you copy/paste (all in one line!) into the
614\filename{[model]} section in \filename{scenery3d.ini}.
615\begin{verbatim}
616obj2grid_trafo=<a11>,<a12>,<a13>,<a14>,<a21>,<a22>,<a23>,<a24>,
617               <a31>,<a32>,<a33>,<a34>,<a41>,<a42>,<a43>,<a44>
618\end{verbatim}
619You edit the \filename{scenery3d.ini} to use your full (unmodified)
620PhotoFly model and, if you don't have a panorama, take \filename{Zero Horizon}
621landscape as (no-)background. It depends on the model if you want to
622be able to step on it, or to declare \verb|ground=NULL| for a
623constant-height ground. Run Stellarum once and adjust the
624\verb|start_N|, \verb|start_E| and \verb|zero_ground_height|.
625
626\subsubsection{Rotating OBJs with recognized survey points}
627\label{sec:RotatingOBJ}
628
629If you have survey points measured in a survey grid plus a photomodel
630with those points visible, you can use Meshlab to find the model
631vertex coordinates in the photo model, and some other program like
632CoordTrans in the JavaGraticule3D suite to find either the matrix
633values to enter in \filename{scenery3d.ini} or even rotate the OBJ
634points. However, this involves more math than can be described here;
635if you came that far, you likely know the required steps.  Here it
636really helps if you know how to operate automatic text processors like
637AWK.
638
639\section*{Authors and Acknowledgements}
640\label{Acknowledgments}
641
642
643Scenery3d was conceived by Georg Zotti for the ASTROSIM project. A first prototype was
644implemented originally in 2010/2011 by Simon Parzer and Peter Neubauer as
645student work supervised by Michael Wimmer (TU Wien).
646Models for accuracy tests (Sterngarten, Testscene), and later improvements in
647integration, user interaction, .ini option handling, OBJ/MTL loader bugfixes and
648georeference testing by Georg Zotti.
649
650Andrei Borza in 2011/12 further improved
651rendering quality (shadow mapping, normal mapping) and speed.
652
653In 2014/15,
654Florian Schaukowitsch adapted the code to work with Qt 5 and the current
655Stellarium 0.13 codebase, replaced the renderer with a more efficient, fully
656shader-based system, implemented various performance, quality and usability
657enhancements, and did some code cleanup. Both Andrei and Florian were again
658supervised by Michael Wimmer.
659
660This work has been originally created during the ASTROSIM project supported 2008-2012 by
661the Austrian Science Fund (FWF) under grant number P~21208-G19.
662
663\end{document}
664
665