Module 7: Working with Solid Primitives

advertisement
Module 7: Working with Solid Primitives
Module contents
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
Overview
Solid primitives
Using Units
Strata 3D coordinate and object coordinate systems
Use of solid primitives in 3D modeling
Basic solid primitives in 3D modeling
Computer Solid Geometry mathematical background
Computer Solid Geometry in 3D
Procedural modeling
Classroom exercises
Learning outcomes
Upon completing this module you will be able to:





Identify computer graphics primitives, so called solid primitives
Know how to use primitives to construct more complex objects
Know what means computer solid geometry (CSG)
Use CSG to develop customized objects
Have some basic idea about procedural modeling
1. Overview
In this module we will learn how to build more complex objects by using some basic
primitives. The idea looks the same like this when kids are creating constructions by using
simple cubes. You need to produce a number of simple objects like spheres, cubes, cylinders
etc., put them in right place and glue all of them. Meanwhile you can paint them or just leave
in natural color.
Before you start your creations first revise the Strata 3D coordinate system. This will help you
in your construction work.
2. Solid primitives
The example that we have developed last time has given you some idea how to create 3D
complex object, save it, render, etc. This was a good start. Now we have to think and talk how
to build more complex objects. How complex? Well, you may think about modeling a table
that is quite simple or modeling a temple and this could be quite time consuming and
complicated job. Of course each time you have a chance to simplify your construction or
make it more detailed and precise. So, let us start from basic components.
1
Using solid primitives we can develop objects
that are very sophisticated like the staircase
shown in the picture. This picture was developed
in Strata 3D.
Can you identify some of the basic components
of this scene?
Fig. 1 Strata 3D Staircase model
Fig. 2. Using very basic set of primitives we can model quite complex objects
All basic objects that we use to create more complex objects we call solid primitives. Each
graphics program has a slightly different set of solid primitives but in general the core set has
always the same functionality. Here is the most frequently used set of solid primitives: sphere,
2
cube, cylinder, pyramid, and cone. In many computer programs you can find a lot more of
primitives, but the above set is just enough to create many constructions.
3. Using Units
Before we start any 3D creation we have to decide what means one unit in our model. In 3D
modeling programs 1 unit can be considered as 1 inch, 1 meter, 1 yard, 1 km, etc. We shall
use the most appropriate units for our model. We shall not model buildings using 1 unit = 1
inch, but rather use meters. At the same time we shall not model jewelry using meters or
kilometers as units.
Key concept
Before developing any 3D model first decide
what means one unit in your model. This can
be meter, cm, km or anything else what is
convenient for the given model.
4. Strata 3D coordinate and object coordinate systems
Strata 3D uses typical right-handed coordinate system. Each object has also its own
coordinate system that is identical to Strata 3D coordinate system.


Hint 1: when you create object in Strata 3D it is usually rotated, scaled and
translated already. You need to check size, rotation and location of the object
in the object properties panel.
Hint 2: note that location, rotation of the object can be defined in the world
coordinates or in local (object) coordinates. For location is more convenient
to use world coordinates, for rotation sometimes local object coordinates are
more convenient.
3
5. Use of solid primitives in 3D modeling
While creating complex 3D object it is important to know where to start and how progress with
all tasks from the beginning to the final picture. The purpose of the enclosed below example is
to show such creation step by step. With more complex objects rules will be the same.
3D scene development scenario
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
Create the right interpretation of units in your model
Develop the ground
Choose basic primitives
Scale basic primitives to an appropriate size
Add basic texture to a primitive so you can easier identify it on the scene
Place primitives in the right place
Apply CSG operations
Check the whole design from each side
Add proper lights
Place camera in the right place
Test everything again and again
Replace basic textures with the right ones
Obtain the final scene and render it.
Example: Construction of a table
In this example I show step by step how one may create a table. This is quite simple example
and not all steps from the above scenario are necessary. The order of steps can be slightly
different, but major tasks are always in the above order. Observe, we shall add the right
textures in the very last moment if this is possible. The reason for this is that - rendering
scenes with some textures is much slower than without them. For example try to render a
glass or metallic objects. You will see how slow this can be.
1. Start with a single
box. Make it long about
0.8 of unit. This will
be the first leg of the
table. The leg hangs
somewhere in the
space. You have to add
to your construction a
good base.
4
2. Add any color to
the leg and a ground
with a simple color. At
this stage any ground
with a pattern will make
the rest of the work more
difficult.
3. Copy existing leg
and paste it as 3 other
table legs. Place them
into proper places.
4. Make another box,
make it flat and use it as
the table top.
5
5. Add texture to
each table element, at
this stage you may
combine all elements
into one object (see later
about union)
6. Add other
elements of the
environment (carpets,
lights, etc.) and your
table looks quite good.
6. Basic solid primitives in 3D modeling
Sphere is the most popular solid primitive in 3D
modeling. Later you will see a number of objects using a sphere.
6
Box is another primitive quite frequently used for 3D
modeling. We used it for our table.
Rounded box, this is something between sphere and
box. Rounded boxes are not used so frequently like
spheres or boxes.
Cylinder is another useful primitive. Cylinders can be used with ending
caps or without them. In last case we will obtain a pipe or a tube.
7
Cone can be used with ending cap or without it. We
can also cut cone from the top.
Prism with square or rectangle base.
Torus primitive is available in some more sophisticated
modeling packages and graphics modeling languages.
Torus is not available is Strata 3D as a primitive. We
have to build it using lathe construction.
8
7. Computer Solid Geometry mathematical background
For mathematically inclined it is quite obvious that all shapes in 3D can be treated as sets of
points and in such case we can apply to them standard operations on sets. Here they are:
UNION of sets is a set containing all points of sets taken to the union. In mathematical
notation union is expressed as
1, 2, 3 a, b, ca, b, c, 1, 2, 3
1, 2, 3 a, b, c 1, 3, ba, b, c, 1, 2, 3
INTERSECTION of two sets is a set that contains only common points of both sets. In
mathematical notation sets can be expressed as follows:
1, 2, 3 2, 3, 42, 3
1, 2, 3 a, b, c 1, 3, b
DIFFERENCE of two sets is another set operation. Difference of two sets contains all
elements of set 1 that are not elements of the set 2.
9
1, 2, 3 2, 3, 41
1, 2, 3 5, 6, 71, 2, 3
RULES for doing more complex set operations are similar to those for operations on
numbers, however there are also some significant differences. More complicated set
expressions can be calculated like in the enclosed examples:
1, 2, 3, c 
2, 4, 6 a, b, c c, 2

1, 2, 3, c 2, 4, 6 
1, 2, 3, c a, b, c c, 2
8. Computer Solid Geometry in 3D
Now, when you are familiar with these basic set operations, we can see how they work in
computer graphics. Just imagine that any object in 3D shall be considered as a set of points.
From this point of view the rest looks quite simple.
Union of two objects in 3D
Union of a sphere and box. Both objects have different
textures.
10
Union of a sphere and box. Here the same texture was
applied to the whole union.
Intersection of two objects in 3D
Intersection of a sphere and a box.
Intersection of two objects with different textures can
produce quite strange effects.
11
Difference of a two objects in 3D
Difference of a sphere and a cylinder produces an
interesting hollow object.
Using multiple intersections and differences can produce
a very complicated objects.
12
Combining CSG operations
Artistic creations usually use CSG operations,
advanced textures and special lights.
9. Procedural modeling
Procedural modeling is a technique of building complicated 3D objects with hundred or
thousands objects.
Procedural modeling is available in most of the 3D graphics modeling languages. In
interactive 3D modeling programs we can obtain a procedural modeling if these packages
contain a scripting language. Pictures enclosed below show models obtained with the help of
a programming language POV-Ray. In this language we can use programming constructions
like:
if ... then ... else ...
while ... do
repeat ... until
or recursive procedures and functions. The random function can be sometimes very useful.
Example showing the use of #while .. #end directive
together with the random number generator. (POV-Ray)
13
Generation of 1000 spheres with the use of random
number generator and while instruction. (POV-Ray)
Example showing the use of #switch directive to
generate 2000 objects. Their color, shape and
location are determined by random numbers.(POV-Ray)
Picture obtained by a recursive macro. This way we can
create a number of 3D fractals. (POV-Ray)
14
Macros can be used to calculate interpolated positions,
size and colors of spheres. (POV-Ray)
10. Classroom exercises
Exercise 1: Develop a scene with the Rubik cube. At this stage you do not need to
bother about different colors on each side of cubes. Just apply any texture to each box.
Exercise 2: Look at the enclosed picture. It uses very few primitives and CSG operations.
Try to develop this scene in Strata 3D. Here are dimensions of some objects:




sphere - radius 1;
box external size - 2x2x2,
box bars - 0.25 x 0.25 x 2
cylinder - height 1, external radius 6, internal radius 5.8
Exercise 3: Develop a model of a staircase. You may start with a simple staircase with
say 10 steps and then modify it to obtain a more sophisticated shape.
15
Download