26
Tutorial Falling Cube School of Electrical Engineering & Computer Science, National University of 1

First Tutorial - Falling cube

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: First Tutorial - Falling cube

Tutorial Falling Cube

School of Electrical Engineering & Computer Science, National University of Sciences & Technology, Pakistan 1

Page 2: First Tutorial - Falling cube

Muhammad Muddassir Malik 2

Run Sofa Modeler• After installing sofa• Go to the bin folder at installed location and double

click the Modeler

Page 3: First Tutorial - Falling cube

Muhammad Muddassir Malik 3

Modeler• After double clicking a Modeler a GUI window will

open up as shown below, with sofa components on its left side and scene graph on its right.

Page 4: First Tutorial - Falling cube

Muhammad Muddassir Malik 4

• There you will see root node already added.– This node will control the global behavior of the

simulation.– Majority of them are used to control the Collisions and

the responses between two or more objects during the simulation.• In our current exercise there is only one object so all of them

are not needed.

– All new nodes will be added under it and consequently properties added to it will effect upon all other nodes.

Page 5: First Tutorial - Falling cube

Muhammad Muddassir Malik 5

Deleting the unwanted nodes• Delete all of the already placed properties root node by

selecting them and pressing the delete button (as they are not required in our current exercise)

Page 6: First Tutorial - Falling cube

Muhammad Muddassir Malik 6

Adding a node• Then you have to add a node under whom whole

properties for a physical entity is going to be placed.• For this you have to drag and drop GNode (placed

almost at left bottom of the Modeler under Sofa Components) on Root node.

Page 7: First Tutorial - Falling cube

Muhammad Muddassir Malik 7

Adding a node

Page 8: First Tutorial - Falling cube

Muhammad Muddassir Malik 8

Name the node• To name the node double click on the node and

overwrite your desired name in object name blank of property 1/2 tab. In this example we will name it cube and then press the ok button.

Page 9: First Tutorial - Falling cube

Muhammad Muddassir Malik 9

Mesh topology• First of all to define and/or load the topology our

object’s mesh we have to add the MeshTopology component.

• MeshToplogy define the topology and the relation of one vertices with the other.

• Drag and Drop MeshTopology (lying in Topology drop down of the sofa components) on the cube node.

Page 10: First Tutorial - Falling cube

Muhammad Muddassir Malik 10

Mesh topology

Page 11: First Tutorial - Falling cube

Muhammad Muddassir Malik 11

Loading the Mesh• Now we need to load and link the mesh of our object.• Three easy ways to link and/or load the mesh with the topology are– Load the mesh with in MeshTopolgy object.(practiced in this

exercise)– Link the already Loaded Mesh (loaded through a loader e.g.

MeshObjLoader)– Define the position of vertices in the mechanical object.

• To load the mesh file double click the MeshTopolgy Object and it will open up a new Window.

• In Property 1/3, under file topology Click on the three dots like … in front filename of the object and browse it to the location of your intended object file (which is C:\sofa\share\mesh\cube.obj in our current case).

Page 12: First Tutorial - Falling cube

Muhammad Muddassir Malik 12

Loading the Mesh

Page 13: First Tutorial - Falling cube

Muhammad Muddassir Malik 13

Mechanical state• To define the mechanical properties and degree of

freedom you will have to add mechanicalObject.– Here in Mechanical state of Rigid type object can only act

in a non-deformable way.– While Vec3d type objects could act in both deformable

and non-deformable way.– LaparoscopicRigid3 act same as Rigid type but with a pivot

in its center.– Here 3d means three dimensional degrees of freedom

with precision of double and 3f means 3 dimensional degree of freedom with precision of float.

Page 14: First Tutorial - Falling cube

14

Adding MechanicalObject• Click Mechanical State to open the drop down– there you will find another drop down on the right side• click to open that dropdown and select Vec3d from it

• Drag and drop MechanicalObject with Vec3d option on the node present in the scene graph.

Muhammad Muddassir Malik

Page 15: First Tutorial - Falling cube

Muhammad Muddassir Malik 15

Adding Mass to the object• To define the mass of the object you have to add a Mass

component.• Click on the Mass option (Just above Mechanical State) in

sofa components to have a look at the available mass options in a drop down form.

• Select the Uniform Mass (simplest) of Vec3d for the current exercise others will be used in relatively complex type of exercises.– Make sure it is of same type as of MechanicalObject which is

Vec3d in our current case.• Drag and drop it on the cube node.

Page 16: First Tutorial - Falling cube

Muhammad Muddassir Malik 16

Adding Mass to the object

Page 17: First Tutorial - Falling cube

Muhammad Muddassir Malik 17

Adding Solvers• Now to solve all of the equations running behind the

intended simulation we have to add some mathematical solver.

• For the instance you will have to add an ode solver followed by a linear solver for our current exercise.

• Resultant of our ODE solver are the Linear equations which are further efficiently solved by Linear Solver.

• For that you will have to drag and drop EulerImplicitSolver from ode solver and CGLinearSolver from Linear Solver.

Page 18: First Tutorial - Falling cube

Muhammad Muddassir Malik 18

Adding Solvers

Page 19: First Tutorial - Falling cube

Muhammad Muddassir Malik 19

Visual node• Afterwards we will put another GNode in our cube

Node to handle the graphical display.• For that we will again drag and drop GNode on cube

node and name it cubeVisual.

Page 20: First Tutorial - Falling cube

Muhammad Muddassir Malik 20

Visual Model• We will now have to place a graphical display

modeler in the node.• For that we will drag and drop the OglModel from

the VisualModel dropdown.• In the property 2/4 of OglModel we will browse file

mesh the location of the intended show model which is C:\sofa\share\mesh\cube.obj in our current case.

Page 21: First Tutorial - Falling cube

Muhammad Muddassir Malik 21

OglModel

Page 22: First Tutorial - Falling cube

Muhammad Muddassir Malik 22

Mapping• Now to map our graphical model on the mechanical

object we will use a mapping function.• For this purpose you will have to drag and drop

BarycentricMapping from the mapping dropdown of the sofa component to the Visual Node.

Page 23: First Tutorial - Falling cube

Muhammad Muddassir Malik 23

Adding Barycentric Mapping

Page 24: First Tutorial - Falling cube

24

Run sofa• Now you are done with your development of first

exercise i.e. falling cube due to gravitational force. • Click the run in sofa button, lying on the to middle

of the modeler screen.

Muhammad Muddassir Malik

Page 25: First Tutorial - Falling cube

25

Animate• It will open up another GUI window.• There you have to click the animate button to run

the animation.

Muhammad Muddassir Malik

Page 26: First Tutorial - Falling cube

Muhammad Muddassir Malik 26

Video