Images Numériques
3D: Blender + Virtual Choreographer
Licence 1 (option S2), Université Paris 11
Christian Jacquemin (Université Paris 11 et LIMSI-CNRS)
http://perso.limsi.fr/jacquemi/
3D Modelling with Blender
BLENDER INTRO
Blender main features
Blender
is the free open source 3D content creation suite, available for all major
operating systems under the
GNU General Public License
.
Multiplatform application for 3D modelling, animation, and rendering. Offers
facilities such as physics and particles, imaging and compositing, and real-time 3D
game creation.
BLENDER TIPS
On-line Blender Tutorials
Blender Wiki
Documentation Volume I -
User Guide
Documentation Volume II -
Reference Guide
Blender 3D: Noob to Pro/Modeling a Simple Person
, Wikibooks
Jeff Chastine -
Using Blender
Slides
AIG-3D.ps
Page 2
BLENDER TIPS
View control
NumPad keys for view control in model screen: the whole set
Keypad
View
Keypad
View
Keypad
View
0
Camera
view
1
Front view
2
Rotate 15
deg to
downward
3
Side view
4
Rotate 15
deg to left
6
Rotate 15
deg to right
7
Top view
8
Rotate 15
deg to
upward
BLENDER TIPS
View control
Mouse and keystroke control
Middle button
: rotation around the scene
Shift middle button
: translation of the scene
Num keypad /
: only shows the selected object
Mouse wheel
or
Control middle button
or
Num keypad + or -
: zoom
in/out
Shift-B
: defines view rectangle (targeted zoom)
Screen control
Control left/right arrow
: jumps between screens (basically animation,
model, material, sequence, and scripting)
Right click on window edge
: split or join windows
BLENDER TIPS
There are two important modes in Blender:
Object mode
: select an object, access its properties, move it around...
Edit mode
: after selecting an object, access and modify its edges, vertices,
normals...
Object edition/selection
Tab
: shifts between
Object mode
(object positioning, grouping, properties) and
Edit mode
(vertex or edge positioning, splitting, deleting...).
Right button
: object selection in
Object mode
, vertex or edge selection in
Edit
mode
.
Shift Right button
: selection extension
A
: select/deselect all objects in the
Object Mode
.
A
: select/deselect all vertices of an object in the
Edit Mode
.
B
: Rectangular select tool.
BB
: Circle Select tool in
Edit mode
.
BLENDER TIPS
Before displacing one or more object, you must first first select them with the right
button. (Selected objects are outlined in pink)
Object translation
G (grab)
: translation perpendicular to the view direction
Left mouse click
: confirms the move
Right mouse click
: cancels the move
Middle mouse click
: translation parallel to the local coordinate axes
G-X
: X translation (local coordinates)
Alt G
: clears all the translations applied to the object
Object rotation
R (rotation)
: rotation around the view direction
Left mouse click
: confirms the rotation
Right mouse click
: cancels the rotation
Middle mouse click
: rotation around the local coordinate axes
R-X
: X rotation (local coordinates)
Alt R
: clears all the rotations applied to the object
BLENDER TIPS
Object Scale
S (scale)
: scale along the 3 axes
Left mouse click
: confirms the scaling
Right mouse click
: cancels the scaling
S-X
: Constrains the scaling to the X axis (local coordinates)
Alt S
: clears the all the scalings applied to the object
BLENDER TIPS
Mesh Separation
To divide an object into a separate object
.
While in Edit Mode use the Circle Select tool (BB) (or Box Select Tool (B)) to
select the parts that are to be separated.
Press the Space Bar and select Edit > Vertices > Separate, and then take the
"Selected" option.
Mesh Join
To make a single object out of several
.
In the Object Mode, Select several objects by selection extension.
Press the Space Bar and select Object > Join Objects to make a single object
out of several.
BLENDER TIPS
Mesh smoothing
Choice between smooth and faceted rendering
.
In the Object mode, by clicking either Set Smooth or Set Solid in the Link and
Materials panel of the Edit buttons [F9].
Normal control
Normal drawing and inversion
.
In the Edit mode, Normal drawing by clicking either Draw normals or Draw
Vnormals in the Mesh Tools 1 panel of the Edit buttons [F9].
In the Edit mode, Normal inversion by clicking Flip Norm in the Mesh Tools
panel of the Edit buttons [F9].
AIG-3D.ps
Page 6
3D Animation with VirChor
VIRCHOR INTRO
Virtual Choreographer main features
Virtual Choreographer
(
VirChor
) is an open source real time 3D engine that relies
on an XML-based definition of 3D scenes with graphic and sonic components.
VirChor offers facilities such as high dimension particle systems through GPGPU,
MPEG4 facial and skeletal character animation, vertex and pixel shader support,
audio source localization, and collision detection.
VirChor
is available for all major operating systems under the
GNU General Public
License
.
Some resources:
Documentation:
Html on-line documentation
Tutorial (Wai Kit Chan):
tutorial web site
VIRCHOR BASICS
Sample scene obtained from Blender
Basic Blender scene made of three objects, one user, one viewpoint and one light
(
Three_Cubes.blend
) can be exported to VirChor format through Python script
(
exportVC-IN.py
)
Interactive rendering of the scene in VirChor (2 exported files
Three_Cubes.xml
&
Three_Cubes_scene.xml
and a configuration file
ThreeCubes.conf
)
Command:
VirChor ThreeCubes.conf Three_Cubes_scene.xml
VIRCHOR BASICS
Camera motion through mouse
You can move inside the coordinate system of each user through mouse control
left mouse click
: move forwards
shift left mouse click
: move backwards
left mouse click + side drag
: move sidewards
Object mouse-based interaction
Objects can be
dragged'n dropped
through mouse right button
(The
draggable
attribute of the
node
tag must be
true
)
Objects they can be
passively selected
through mouse over
(The
testable
attribute of the
node
tag must be
true
)
Objects they can be
actively selected
through mouse click
(The
interactable
attribute of the
node
tag must be
true
)
AIG-3D.ps
Page 8
V
ir
C
h
o
r
s
c
r
ip
ts
VIRCHOR SCRIPTS
Script triggers:keystroke and mouse
Keystroke (see
Keystroke modification of geometry
)
Mouse: when the mouse enters the bounding box of a
testable
object, it
receives a
sensor-mouse-in
message.
Three_Cubes_scene8.xml
and
Three_Cubes8.xml
<node id="ON_button" >
<script id="ON_button_script"> <command>
<trigger type="message_event" value="sensor-mouse-in" />
<action>
<set_node_attribute_value displayed="true"/> <target type="single_node" value="#Lamp" /> </action> </command> </script> <quad id="ON_button" > .... </quad> </node>
VIRCHOR SCRIPTS
Script triggers: sensors
Sensors: when a sensor enters the bounding box of a
testable
object, it sends a
message to this object. This message is used here to hide another one.
Three_Cubes_scene9.xml
and
Three_Cubes9.xml
The sensor is a sister node of
Cube.001
:
<node id="sensor_Cube.001">
<touchSensor id="sensor_Cube.001" x1="0.0" y1="0.0" z1="0.0"
message_in="sensor-Cube-in"
message_out="sensor-Cube-out"/>
AIG-3D.ps
Page 10
VIRCHOR SCRIPTS
Script triggers: UDP messages
UDP messages are network messages exchanged between applications.
They are sent by the interface to position 3D objects in space.
Three_Cubes_scene10.xml
and
Three_Cubes10.xml
/translate Lamp_translation -4.276 -6.566 1.135
They are received by the
aliasScript
located on the
root
node:
<aliasScript>
<command pattern="/translate s f f f">
<action>
<set_node_attribute_value operator="=">
<transformation x="({$2})" y="({$3})" z="({$4})" /> </set_node_attribute_value>
<target type="single_node" value="#({$1})" /> </action>
</command> </aliasScript>
VIRCHOR SCRIPTS
UDP message triggers
The same messages can be sent from a
PureData
interface such as the patch
Three_Cubes_ControlPD10.pd
, or any other tool that combines graphical interface
and network messages (
java
,
PyGTK
,
Max/MSP
...)
VIRCHOR SCRIPTS
Message emission
Conversely, internal or external messages can be sent by VirChor
External messages
UDP messages can be sent to external applications through the
<send_message_udp>
command :
<action>
<send_message_udp value="/tr ({$Camera_translation:x})" />
<target type="single_host" value="udp_client" />
</action>
VIRCHOR SCRIPTS
Internal messages
Internal messages are sent to a node script through the
<send_message>
command
:
<command>
<trigger type="message_event" value="sensor-mouse-in" /> <action>
<send_message value="/color 1.0 0.0 0.0"/>
<target type="multiple_nodes" value="#Cube*" /> </action>
</command>
The targets are all the nodes with an ID prefixed by
Cube
that implement a trigger
for the
/color
message.
VIRCHOR SCRIPTS
Automatic trigger: cyclic trigger
Cyclic triggers are fired at regular time intervals and can be used to implement
engines.
Three_Cubes_scene12.xml
and
Three_Cubes12.xml
<command>
<trigger type="cyclic_time" begin="0" period="0.000002"/>
<action> <set_node_attribute_value operator="+="> <transformation x="({$root:translationx_step})" y="({$root:translationy_step})" z="({$root:translationz_step})" /> </set_node_attribute_value>
<target type="single_node" value="#Cube.002_transl" /> </action>
</command>
This command translates a cube by a regular step at each frame.
VIRCHOR SCRIPTS
Automatic trigger: deadline trigger
Deadline triggers are fired at a defined time step and can be used to implement
predefined animations.
Three_Cubes_scene12b.xml
and
Three_Cubes12.xml
<command>
<trigger type="time_limit" value="3"/>
<action>
<set_node_attribute_value operator="+="> <transformation z="3" />
</set_node_attribute_value>
<target type="multiple_nodes" value="#Cube*transl" />
</action> </command>
This command modifies the cube translations
Cube*transl
by adding 3 to the
z
AIG-3D.ps
Page 12
VIRCHOR SCRIPTS
Automatic trigger: initialization script
The initialization script contains commands that are executed at launch time.
Three_Cubes_scene13.xml
and
Three_Cubes12.xml
<initializationScript id="beginning_script"> <command> <action> <write_message value="Welcome" /> </action> <action delay="1">
<write_message value="to the cubic world!" /> </action> <action delay="2"> <write_message value="" /> </action> </command> </initializationScript>
Successive messages can be triggered by delaying the actions.
VIRCHOR SCRIPTS
Automatic trigger: termination script
The termination script contains commands that are executed at exit time.
It can be used to inform companion applications that VirChor is exiting.
<terminationScript id="termination_script">
<command> <action>
<send_message_udp value="/end"/>
<target type="single_host" value="udp_client" /> </action>
</command> </terminationScript>
VirChor interpolators
VIRCHOR INTERPOLATORS
Interpolators: transformation interpolators
A transformation interpolator blends two transformations according to a time
function defined by the <schedule> subtag.
Here, the time function is periodic and controlled by a sinus curve.
Three_Cubes_scene14.xml
and
Three_Cubes14.xml
<node id="Cube.001_interp_transl">
<interpolator id="Cube.001_interp_transl" type="transformation"
size="2">
<schedule begin="0" dur="2" repeatCount="100" mode="sinus-periodic"/>
<transformation id="Cube.001_transl_ini" geometry="translation" x="-8" y="0.0" z="5" />
<transformation id="Cube.001_transl_end" geometry="translation" x="-8" y="0.0" z="10" />
VIRCHOR INTERPOLATORS
Interpolators: update script
The update script of an interpolator can be used to control another animation such
as the color of another cube.
The expression
{$Cube.001_interp_transl:z}
represents the current
z
value of
the interpolated transformation.
<schedule begin="0" dur="2" repeatCount="100"
mode="sinus-periodic" before="hide" fill="hide">
<updateScript> <command> <action> <set_material_attribute_value operator="="> <emission r="(0.2*({$Cube.001_interp_transl:z}-5))" /> </set_material_attribute_value>
<target type="single_node" value="#Cube" /> </action>
</command>
</updateScript>
</schedule>
VIRCHOR INTERPOLATORS
Interpolators: object interpolators
An object interpolator updates all the parameters of the source and target objects
according to a time function defined by the <schedule> subtag.
Here, the objects are two meshes with the same number of geometrical
components (vertices, faces, and normals).
Three_Cubes_scene15.xml
and
Three_Cubes15.xml
<node id="Cube_interpolator">
<interpolator id="Cube_interpolator" type="node" size="2">
<schedule begin="0" dur="10" repeatCount="1" mode="linear" fill="freeze" ini="1" end="2"/>
<node id="Cube_1">
<subdivision id="Cube_1" levels="1" level0_vertices="8" ... > ...
</subdivision> </node>
<node id="Cube_2">
<subdivision id="Cube_2" levels="1" level0_vertices="8" ... > </subdivision>
AIG-3D.ps
Page 14
VIRCHOR INTERPOLATORS
Interpolators: scalar and table interpolators
Scalar interpolators
and associated scripts (update and completion) can control
any attributes in a scene description.
Three_Cubes_scene16.xml
and
Three_Cubes16.xml
<scalar id="fade_in" type="float" >
<interpolator id="fade_in" type="scalar" size="2"> <schedule begin="10" dur="20"
repeatCount="1" mode="sinus" fill="freeze" >
<updateScript> <command> <action> <set_material_attribute_value operator="="> <diffuse a="({$root:fade_in})" /> </set_material_attribute_value>
<target type="single_node" value="#Cube" /> </action>
</command>
</updateScript>
<scalar id="fade_in_src" type="float" value="0"/>
<scalar id="fade_in_target" type="float" value="1"/>
</interpolator> </scalar>
VIRCHOR INTERPOLATORS
Interpolators: scalar and table interpolators
Table interpolators
can be used to control simultaneously several values.
Three_Cubes_scene16b.xml
and
Three_Cubes16.xml
<!-- table defined by interpolation between 9 tables -->
<table id="interp_mat" type="float" size="3" >
<interpolator id="interp_mat" type="table" size="9">
<schedule begin="5" dur="50" repeatCount="1" mode="linear" fill="freeze" > <updateScript>
<command>
<!-- defines the emission of an object --> <action> <set_material_attribute_value operator="="> <emission r="({$root:interp_mat[1]})" g="({$root:interp_mat[2]})" b="({$root:interp_mat[3]})" /> </set_material_attribute_value>
<target type="single_node" value="#Cube" /> </action>
</command> </updateScript> </schedule>
VIRCHOR INTERPOLATORS
Interpolators: scalar and table interpolators (cont'd)
<!-- 9 tables that correspond to 9 emission colors --> <table id="interp_mat_1" type="float" size="3" value="( 0.0 , 0.0 , 0.0 )"/>
<table id="interp_mat_2" type="float" size="3" value="( 1.0 , 0.0 , 0.0 )"/>
<table id="interp_mat_3" type="float" size="3" value="( 0.0 , 1.0 , 0.0 )"/>
<table id="interp_mat_4" type="float" size="3" value="( 0.0 , 0.0 , 1.0 )"/>
<table id="interp_mat_5" type="float" size="3" value="( 1.0 , 1.0 , 0.0 )"/>
<table id="interp_mat_6" type="float" size="3" value="( 1.0 , 0.0 , 1.0 )"/>
<table id="interp_mat_7" type="float" size="3" value="( 0.0 , 1.0 , 1.0 )"/>
<table id="interp_mat_8" type="float" size="3" value="( 1.0 , 1.0 , 1.0 )"/>
<table id="interp_mat_8" type="float" size="3" value="( 0.0 , 0.0 , 0.0 )"/>
</interpolator>
</table>
VirChor transformations
VIRCHOR TRANSFORMATIONS
Three basic transformations
Translation:
A translation geometry is defined by three attributes (
x
,
y
,
z
)
<node id="Cube.002_transl">
<transformation id="Cube.002_transl" geometry="translation" x="3" y="4" z="1" />
Rotation:
A rotation geometry is defined by four attributes (
angle
in degrees, and axis
x
,
y
,
z
). Rotations can also be defined by quaternions.
<node id="Cube.002_rotation">
<transformation id="Cube.002_transl" geometry="rotation" angle="90" x="0" y="0" z="1" />
Scale
A scale geometry is defined by three attributes (
x
,
y
,
z
)
VIRCHOR TRANSFORMATIONS
Transformation tag embedding define scene graphs
<node id="Cube.002_transl">
<transformation id="Cube.002_transl" geometry="translation"
x="3" y="4" z="1" /> <node id="Cube.002_rot">
<transformation id="Cube.002_rot" geometry="rotation"
x="1.0" y="0.0" z="0.0" angle="90.0" /> <node id="Cube.002_scale">
<transformation id="Cube.002_scale" geometry="scale"
x="1.0" y="1.0" z="-1.0" /> <node id="Cube.002">
<subdivision id="Cube.004" levels="1" >
... </subdivision> </node> </node> </node> </node>
AIG-3D.ps
Page 16
VIRCHOR TRANSFORMATIONS
Ellipse transformation
An
ellipse transformation
is defined by geometrical properties (
xyz
center and
ab
axis lengths) and a time function (
<schedule>
).
Three_Cubes_scene18.xml
and
Three_Cubes18.xml
<node id="Camera_ellipse_transf" >
<transformation id="Camera_ellipse_transf"
geometry="ellipse-transformation"
with_roll="false">
<schedule begin="0" dur="5" repeatCount="1000000" mode="linear"
fill="freeze"/> <ellipse id="Camera_ellipse"
a="15" b="-15" x="0" y="10" z="0" /> </transformation>
VIRCHOR TRANSFORMATIONS
Sample ellipse transformation
Drives a lamp and a camera.
<!-- transforms a xz plane ellipse transf into a xy plane ellipse transf --> <node id="Ellipse_rot">
<transformation id="Ellipse_rot" geometry="rotation" x="1" y="0" z="0" angle="90" /> <!-- ellipse translation --> <node id="Camera_ellipse_transf" interactable="true" testable="true" > <transformation id="Camera_ellipse_transf" geometry="ellipse-transformation" with_roll="false">
<schedule begin="0" dur="5" repeatCount="1000000" mode="linear" fill="freeze"/>
<ellipse id="Camera_ellipse"
a="15" b="-15" x="0" y="10" z="0" /> </transformation>
VIRCHOR TRANSFORMATIONS
Sample ellipse transformation (cont'd)
<!-- camera pitch rotation --> <node id="Camera_rot">
<transformation id="Camera_rot" geometry="rotation" x="0" y="0" z="1" angle="30" /> <!-- camera yaw rotation -->
<node id="Camera_rot">
<transformation id="Camera_rot" geometry="rotation" x="0" y="1" z="0" angle="90" /> <!-- head lamp bound to camera -->
<node id="Lamp">
<light id="Lamp" type="light" constant_attenuation="0.0" linear_attenuation="0.1"> ... </light> </node> <!-- camera --> <node id="Camera"> <viewpoint id="Camera"/> </node> </node> </node> </node> </node>
VIRCHOR TRANSFORMATIONS
Path transformation
A
path transformation
is defined by the four control points of a Bezier curve
(
<bezier>
) and a time function (
<schedule>
).
Three_Cubes_scene19.xml
and
Three_Cubes19.xml
<node id="Path_transf_camera">
<transformation id="Path_transf_camera" geometry="path-transformation" size="1" with_roll="true">
<schedule begin="3" dur="10" repeatCount="1" mode="linear"
fill="freeze"/>
<path id="path camera" size="1" width="0.2" segments="300">
<bezier size="4" location="1"
x1="25" y1="0" z1="30" x2="15" y2="-5" z2="15" x3="5" y3="15" z3="3" x4="-4" y4="3" z4="3" n_x="0" n_y="0" n_z="1"/> </path> </transformation>
AIG-3D.ps
Page 18
VirChor environment
VIRCHOR ENVIRONMENT
Parameters
Parameters are defined at compilation time and cannot be modified.
Definition:
<set id="nbAlignedQuads" value="10"/>
Access:
<quad x1="(10*{#nbAlignedQuads})" z1="-200" y1="-10" ... />
VIRCHOR ENVIRONMENT
Variables
Variables are defined at execution time and can be modified by scripts.
Scalars
Definition:
<node id="root" >
<scalar id="translation_step" type="float" value="0.01" />
Access:
<set_node_attribute_value operator="+=">
<transformation x="{$root:translation_step}" />
</set_node_attribute_value>
Modification:
<set_node_scalar_value id="translation_step" value="0.01" operator="+="/>
<target type="single_node" value="#root" />
VIRCHOR ENVIRONMENT
Variables
A variable can be used in combination with a translation in a
cyclic_time
trigger to
define a motion speed.
Three_Cubes_scene20.xml
and
Three_Cubes20.xml
(keystrokes
A
and
B
)
Keystrokes A and B decrease and increase the translation step,
The cyclic_time triggered command decrements or increments the translation
by the translation step.
VIRCHOR ENVIRONMENT
Tables
Tables are collections of scalars.
Tables
Definition:
<node id="root" >
<table id="delay" type="float" size="3" value="(-0.523,-0.469,-0.168)" />
Access: indices start from 1
<quad y3="({$root:delay[1]}*20.0 - 10.0)"
y4="({$root:delay[2]}*20.0 - 10.0)" />
Modification: a table of size
n
can be used to modify another table of the same
size
<set_node_table_value id="delay" value="({@root:increment})" operator="+="/>
<target type="single_node" value="#root" />
VIRCHOR ENVIRONMENT
Configuration file
The configuration file is used to define the external parameters such as
the size and number of displays,
the parameters of the UDP connections (incoming and outcoming),
the framerate and the time increment,
the output to images or to a video film...
VIRCHOR ENVIRONMENT
Companion documentations
Virtual Choreographer Reference Guide
Wai Kit Chan Tutorial
Download
Download from Sourceforge
AIG-3D.ps
Page 20
PROJECTION EN PERSPECTIVE 1/4
Définition
L'image d'un point M par une projection en perspective sur le plan P de centre O
est l'intersection de la droite OM avec le plan P.
Une projection en perspective dont le centre de projection est à l'infini est une
projection parallèle.
PROJECTION EN PERSPECTIVE 2/4
Point de fuite
Si une droite D coupe le plan de projection,
il existe un point F, appelé
point de fuite
appartenant à la projection de toute
droite parallèle à D.
On différencie les projections en perspective par le nombre de points de fuite pour
les directions des axes du repère
(le nombre d'intersections des axes de coordonnées avec le plan).
en général deux points de fuite (caméra verticale non parallèle à un des axes),
le troisième point de fuite n'augmente pas significativement le réalisme.
PROJECTION EN PERSPECTIVE 3/4
Propriétés géométriques des projections en
perspective
Les projections ne conservent pas le parallélisme des droites non parallèles au
plan de projection.
La taille d'un objet est inversement proportionnelle à sa distance au point de
projection :
|p(M) p(M')| =
d
0. 1/
d
. |MM'|
PROJECTION EN PERSPECTIVE 4/4
Trois exemples de projections en perspective
Projection
sur un des plans du repère
d'un cube dont les
arêtes sont
parallèles aux axes du repère
avec un seul point de fuite (1),
cube plein avec deux points de fuite (2)
et cube plein avec trois points de fuite (3).
PROJECTION PARALLÈLE 1/5
Définition
L'image d'un point M par une projection parallèle sur le plan P d'axe D est
l'intersection de la droite parallèle à D passant par M avec le plan P.
PROJECTION PARALLÈLE 2/5
Deux types de projections parallèles
projection orthographique
lorsque la direction de projection est
perpendiculaire
au plan de projection,
projection oblique
sinon.
Propriétés géométriques des projections parallèles
Les projections parallèles conservent le parallélisme des droites.
Les projections parallèles conservent les rapports des distances selon une
direction donnée.
PROJECTION PARALLÈLE 3/5
Quelques projections orthographiques
Projections selon les axes
Vues
de face, de profil
et
de dessus
.
Angles et distances dans les plans parallèles aux plans du repère sont
conservés.
PROJECTION PARALLÈLE 4/5
Quelques projections orthographiques (suite)
Projections axonométriques
selon un plan qui coupe les axes.
Les distances sont modifiées dans un rapport constant sur chaque axe.
Si le plan de projection fait le même angle avec les trois axes, il s'agit d'une
projection
isométrique
.
AIG-3D.ps
Page 22
PROJECTION PARALLÈLE 5/5
Projection cavalière
La direction de projection fait un
angle de 45°
avec le plan de projection.
Les longueurs sont conservées sur les trois axes.