#+TITLE: 3D Synthezier
* (document settings) :noexport:
** use dark style for TWBS-HTML exporter
#+HTML_HEAD:
#+HTML_HEAD:
#+HTML_HEAD:
#+HTML_HEAD:
* General
- This software is part of [[../../../../index.html][QBasic apps package]].
- This program is free software: you can redistribute it and/or modify
it under the terms of the [[https://www.gnu.org/licenses/lgpl.html][GNU Lesser General Public License]] as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
- Program author:
- Svjatoslav Agejenko
- Homepage: http://svjatoslav.eu
- Email: mailto://svjatoslav@svjatoslav.eu
- [[https://www.svjatoslav.eu/projects/][Other software projects hosted at svjatoslav.eu]]
** Source code
- [[https://www2.svjatoslav.eu/gitweb/?p=qbasicapps.git;a=snapshot;h=HEAD;sf=tgz][Download latest snapshot in TAR GZ format]]
- [[https://www2.svjatoslav.eu/gitweb/?p=qbasicapps.git;a=summary][Browse Git repository online]]
- Clone Git repository using command:
: git clone https://www2.svjatoslav.eu/git/qbasicapps.git
* Operating principle
Parses scene definition language and creates 3D world based on
it. Result will be in a [[https://en.wikipedia.org/wiki/Wavefront_.obj_file][wavefront obj file]], witch can be then
visualized using external renderer.
Basic concept of defining scene is:
- Simple and primitive objects are created on point and polygon level.
- More complex ones can be created my combinig already existing ones,
while applying various transformations on them.
Objects with all its subobjects can be rotated, mirrored or resized
omong any axis. Generator has built in cache for data input and output
to minimize file access.
* System requirements
| software | tested version |
|----------+----------------|
| DOS | 6.22 |
| QBasic | 4.5 |
* Installation
+ Unpack ZIP file in any folder.
+ update include path inside bin/3dparse.bas
*** Directory layout
+ bin
+ 3dparse.bas - 3D generator main executable
+ city1.3d - city with square-like buildings
+ city2.3d - city with hexangular buildings
+ result.mtl - shared material library
+ *.bat - quick launch scripts
+ include - 3D objects used to compose the scene
* Scene description language
(read examples...)
** here
: here
defines new segment
** p
: p x y z
defines new point
** f
: f p1 p2 p3 p4
defines new polygon, p4 may be unused
** warn
: warn
displays warning message, and wait for key
** end
: end
terminates parser
** mtl
: mtl material
selects material
** mtlrnd
: mtlrnd material ...
selects random material from list
** obj
: obj object xz45 xy20 x+3 y*2
includes sub object, can be rotated moved or resized, across X Y Z. If
object name begin vith ~ then it will be loaded from current
directory. if object name ends with ~ then object will be parsed
directly from file, and not chached, to allow loading of greater than
500 lines files.
[[file:rotation.png]]
** rnd
: rnd p^1^2^3 p^7^2^1
select random command to execute, ^ will be converted to spaces.
** #
: # whatever text
comment
** out
: out file
specify output file name, must be first command
** set
: set variable contents
set variable contents, variable must be number, contents can be
string. max variables is 100. first is 0.
** variables usage
: anycommand %1 anything
inserts variable 1 contents info line
** cmp
: cmp flag string1 string2
compares strings, and inserts TRUE to flag, if they are equal, else inserts FALSE. max 9 falgs, 0 first. Each subobject has its own flags.
** ?
: ?flag anycommand
executes command if flag is true.
exapmle: ?3 obj car z*2 xy45
** dum
: dum
dummy function, does notheing
* Usage
Make sure you have QB binaries in your PATH. Execute
: bin/city1.bat
or
: bin/city2.bat
to generate example cities. After parsing is finished, appropriate
*.obj files will appear in the bin directory holding generated scene.
Visualize scene with your favourite renderer.
* Examples
Download Blender files:
| file | size |
|------------------------+--------|
| [[file:rectangular city.blend][rectangular city.blend]] | 3.6 MB |
| [[file:hexagonal city.blend][hexagonal city.blend]] | 21 MB |
They were produced by importing generated [[https://en.wikipedia.org/wiki/Wavefront_.obj_file][wavefront obj files]] into
[[https://www.blender.org/][Blender]].
** Rectangular city
[[file:rectangular city, 1.jpeg]]
[[file:rectangular city, 2.jpeg]]
[[file:rectangular city, 3.jpeg]]
** Hexagonal city
[[file:hexagonal city, 1.jpeg]]
[[file:hexagonal city, 2.jpeg]]
[[file:hexagonal city, 3.jpeg]]