Update
This commit is contained in:
parent
136d0905dd
commit
fdc9159bf7
14 changed files with 1859 additions and 1690 deletions
155
3d_model.md
155
3d_model.md
|
@ -6,13 +6,166 @@ In the world of computers (especially in [computer graphics](graphics.md), but a
|
|||
|
||||
TODO: classification, operations (subdivision, booleans, ...), texturing, animation, formats, ...
|
||||
|
||||
## Example
|
||||
|
||||
Let's take a look at a simple polygonal 3D model. The following is primitive, very [low poly](low_poly.md) model of a house, basically just a cube with roof:
|
||||
|
||||
```
|
||||
I
|
||||
.:..
|
||||
.' :':::..
|
||||
_-' H.' '. ''-.
|
||||
.' .:...'.......''..G
|
||||
.' ...'' : '. ..' :
|
||||
.::''......:.....'.-'' :
|
||||
E: : :F :
|
||||
: : : :
|
||||
: : : :
|
||||
: :......:.......:
|
||||
: .' D : .' C
|
||||
: .'' : -'
|
||||
: .'' : .'
|
||||
::'...............:'
|
||||
A B
|
||||
|
||||
```
|
||||
|
||||
In a computer it would firstly be represented by an array of vertices, e.g.:
|
||||
|
||||
```
|
||||
-2 -2 -2 (A)
|
||||
2 -2 -2 (B)
|
||||
2 -2 2 (C)
|
||||
2 -2 -2 (D)
|
||||
-2 2 -2 (E)
|
||||
2 2 -2 (F)
|
||||
2 2 2 (G)
|
||||
2 2 -2 (H)
|
||||
0 3 0 (I)
|
||||
```
|
||||
|
||||
Along with triangles (specified as indices into the vertex array, here with letters):
|
||||
|
||||
```
|
||||
ABC ACD (bottom)
|
||||
AFB AEF (front wall)
|
||||
BGC BFG (right wall)
|
||||
CGH CHD (back wall)
|
||||
DHE DEA (left wall)
|
||||
EIF FIG GIH HIE (roof)
|
||||
```
|
||||
|
||||
We see the model consists of 9 vertices and 14 triangles. Notice that the order in which we specify triangles follows the rule that looking at the front side of the triangle its vertices are specified clockwise (or counterclockwise, depending on chosen convention) -- sometimes this may not matter, but many 3D engines perform so called [backface culling](backface_culling.md), i.e. they only draw the front faces and there some faces would be invisible from the outside if their winding was incorrect, so it's better to stick to the rule if possible.
|
||||
|
||||
The following is our house model in obj format -- notice how simple it is (you can copy paste this into a file called `house.obj` and open it in Blender):
|
||||
|
||||
```
|
||||
# simple house model
|
||||
v 2.000000 -2.000000 -2.000000
|
||||
v 2.000000 -2.000000 2.000000
|
||||
v -2.000000 -2.000000 2.000000
|
||||
v -1.999999 -2.000000 -2.000000
|
||||
v 2.000001 2.000000 -2.000000
|
||||
v 1.999999 2.000000 2.000000
|
||||
v -2.000001 2.000000 2.000000
|
||||
v -2.000000 2.000000 -2.000000
|
||||
v -2.000001 2.000000 2.000000
|
||||
v 0.000000 3.000000 0.000000
|
||||
vn 1.0000 0.0000 0.0000
|
||||
vn -0.0000 0.0000 1.0000
|
||||
vn 0.0000 -1.0000 0.0000
|
||||
vn 0.0000 0.0000 -1.0000
|
||||
vn -1.0000 -0.0000 -0.0000
|
||||
vn -0.0000 0.8944 0.4472
|
||||
vn 0.4472 0.8944 0.0000
|
||||
vn 0.0000 0.8944 -0.4472
|
||||
vn -0.4472 0.8944 -0.0000
|
||||
s off
|
||||
f 6 2 5
|
||||
f 2 1 5
|
||||
f 6 9 3
|
||||
f 3 2 6
|
||||
f 4 1 3
|
||||
f 2 3 1
|
||||
f 5 1 8
|
||||
f 4 8 1
|
||||
f 8 4 9
|
||||
f 4 3 9
|
||||
f 9 6 10
|
||||
f 6 5 10
|
||||
f 8 10 5
|
||||
f 8 9 10
|
||||
```
|
||||
|
||||
And here is the same model again, now in collada format (it is an [XML](xml.md) so it's much more verbose, again you can copy paste this to a file `house.dae` and open it in Blender):
|
||||
|
||||
```
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<!-- simple house model -->
|
||||
<asset>
|
||||
<contributor> <author>drummyfish</author> </contributor>
|
||||
<unit name="meter" meter="1"/>
|
||||
<up_axis>Z_UP</up_axis>
|
||||
</asset>
|
||||
<library_geometries>
|
||||
<geometry id="house-mesh" name="house">
|
||||
<mesh>
|
||||
<source id="house-mesh-positions">
|
||||
<float_array id="house-mesh-positions-array" count="30">
|
||||
2 2 -2 2 -2 -2 -2 -2 -2 -2 2 -2
|
||||
2 2 2 2 -2 2 -2 -2 2 -2 2 2
|
||||
-2 -2 2 0 0 3
|
||||
</float_array>
|
||||
<technique_common>
|
||||
<accessor source="#house-mesh-positions-array" count="10" stride="3">
|
||||
<param name="X" type="float"/>
|
||||
<param name="Y" type="float"/>
|
||||
<param name="Z" type="float"/>
|
||||
</accessor>
|
||||
</technique_common>
|
||||
</source>
|
||||
<vertices id="house-mesh-vertices">
|
||||
<input semantic="POSITION" source="#house-mesh-positions"/>
|
||||
</vertices>
|
||||
<triangles material="Material-material" count="14">
|
||||
<input semantic="VERTEX" source="#house-mesh-vertices" offset="0"/>
|
||||
<p>
|
||||
5 1 4 1 0 4 5 8 2 2 1 5 3 0 2 1 2 0 4 0 7
|
||||
3 7 0 7 3 8 3 2 8 8 5 9 5 4 9 7 9 4 7 8 9
|
||||
</p>
|
||||
</triangles>
|
||||
</mesh>
|
||||
</geometry>
|
||||
</library_geometries>
|
||||
<library_visual_scenes>
|
||||
<visual_scene id="Scene" name="Scene">
|
||||
<node id="house" name="house" type="NODE">
|
||||
<translate sid="location">0 0 0</translate>
|
||||
<rotate sid="rotationZ">0 0 1 0</rotate>
|
||||
<rotate sid="rotationY">0 1 0 0</rotate>
|
||||
<rotate sid="rotationX">1 0 0 0</rotate>
|
||||
<scale sid="scale">1 1 1</scale>
|
||||
<instance_geometry url="#house-mesh" name="house"/>
|
||||
</node>
|
||||
</visual_scene>
|
||||
</library_visual_scenes>
|
||||
<scene> <instance_visual_scene url="#Scene"/> </scene>
|
||||
</COLLADA>
|
||||
```
|
||||
|
||||
TODO: other types of models, texturing etcetc.
|
||||
|
||||
## 3D Modeling: Learning It And Doing It Right
|
||||
|
||||
*WORK IN PROGRESS*
|
||||
|
||||
**Do you want to start 3D modeling?** Or do you already know a bit about it and **just want some advice to get better?** Then let us share a few words of advice here.
|
||||
|
||||
Nowadays as a [FOSS](foss.md) user you will most likely do 3D modeling with [Blender](blender.md) -- we recommended it to start learning 3D modeling as it is powerful, [free](free_software.md), gratis, has many tutorials etc. Do NOT use anything [proprietary](proprietary.md) no matter what anyone tells you! Once you know a bit about the art, you may play around with alternative programs or approaches (such as writing programs that generate 3D models etc.). However **as a beginner just start with Blender**, which is from now on in this article the software we'll suppose you're using.
|
||||
Let us preface with mentioning the **[hacker](hacking.md) chad way of making 3D models**, i.e. the [LRS](lrs.md) way 3D models should ideally be made. Remeber, **you don't need any program to create 3D models**, you can make 3D models perfectly fine without Blender or any similar program, and even without computers. Sure, a certain kind of highly artistic, animated, very high poly models will be very hard or impossible to make without an interactive tool like Blender, but you can still make very complex 3D models, such as e.g. that of a whole city, without any fancy tools. Of course people were making statues and similar kinds of "physical 3D models" for thousands of years -- sometimes it's actually simpler to make the model by hand out of clay and later scan it into the computer -- you may also make easily make a polygonal model out of paper, BUT even virtual 3D models can simply be made with pen and paper, it's just numbers, verices and triangles, very manageable if you keep it simple and well organized. You can directly write the models in text formats like obj or collada. First computer 3D models were actually made by hand, just with pen and paper, because there were simply no computers fast enough to even allow real time manipulation of 3D models; back then the modellers simply measured positions of someone object's "key points" (verices) in 3D space which can simply be done with tools like rulers and strings, no need for complex 3D scanners (but if you have a digital camera, you have a quite advanced 3D scanner already). They then fed the manually made models to the computer to visualize them, but again, you don't even need a computer to draw a 3D model, in fact there is a whole area called [descriptive geometry](descriptive_geometry.md) that's all about drawing 3D models on paper and which was used by engineers before computers came. Anyway, you don't have to go as far as avoiding computers of course -- if you have a programmable computer, you already have the luxury which the first 3D artists didn't have, a whole new world opens up to you, you can now make very complex 3D models just with your programming language of choice. Imagine you want to make the said 3D model of a city just using the [C](c.md) programming language. You can first define the terrain as [heightmap](heightmap.md) simply as a 2D array of numbers, then you write a simple code that will iterate over this array and converts it to the obj format (a very simple plain text 3D format, it will be like 20 lines of code) -- now you have the basic terrain, you can render it with any tool that can load 3D models in obj format (basically every 3D tool), AND you may of course write your own 3D visualizer, there is nothing difficult about it, you don't even have to use perspective, just draw it in orthographic projection (again, that will be probably like 20 lines of code). Now you may start adding houses to your terrain -- make a C array of vertices and another array of triangle indices, manually make a simple 3D model of a house (a basic shape will have fewer than 20 vertices, you can cut it out of paper to see what it will look like). That's your house geometry, now just keep making instances of this house and placing them on the terrain, i.e. you make some kind of struct that will keep the house transformation (its position, rotation and scale) and each such struct will represent one house having the geometry you created (if you later improve the house model, all houses will be updates like this). You don't have to worry about placing the houses vertically, their height will be computed automatically so they sit right on the terrain. Now you can update your model exporter to take into account the houses, it will output the obj model along with them and again, you can view this whole model in any 3D software or with your own tools. You can continue by adding trees, roads, simple materials (maybe just something like per triangle colors) and so on. This approach may actually even be superior for some projects just as scripting is superior to many GUI programs, you can collaborate on this model just like you can collaborate on any other text program, you can automatize things greatly, you'll be independent of proprietary formats and platforms etcetc. This is how 3D models would ideally be made.
|
||||
|
||||
OK, back to the mainstream now. Nowadays as a [FOSS](foss.md) user you will most likely do 3D modeling with [Blender](blender.md) -- we recommended it to start learning 3D modeling as it is powerful, [free](free_software.md), gratis, has many tutorials etc. Do NOT use anything [proprietary](proprietary.md) no matter what anyone tells you! Once you know a bit about the art, you may play around with alternative programs or approaches (such as writing programs that generate 3D models etc.). However **as a beginner just start with Blender**, which is from now on in this article the software we'll suppose you're using.
|
||||
|
||||
**Start extremely simple and learn bottom-up**, i.e. learn about fundamentals and low level concepts and start with very simple models (e.g. simple untextured low-poly shape of a house, box with a roof), keep creating more complex models by small steps. Do NOT fall into the trap of "quick and easy magic 3D modeling" such as sculpting or some "[smart](smart.md) [apps](app.md)" without knowing what's going on at the low level, you'll end up creating extremely ugly, inefficient models in bad formats, like someone wanting to create space rockets without learning anything about math or physics first. Remember to **practice, practice, practice** -- eventually you learn by doing, so try to make small projects and share your results on sites such as opengameart to get feedback and some mental satisfaction and reward for your effort. The following is an outline of possible steps you may take towards becoming an alright 3D artist:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue