tutorial two cubes falling on a floor due to gravity

23
Tutorial Two Cubes Falling On A Floor Due To Gravity School of Electrical Engineering & Computer Science, National University of Sciences & Technology, Pakistan 1

Upload: smartlab123

Post on 03-Jul-2015

492 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Tutorial two cubes falling on a floor due to gravity

Tutorial Two Cubes Falling On A Floor Due To Gravity

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

Page 2: Tutorial two cubes falling on a floor due to gravity

What’s new

• This tutorial is the continuation of the First one.

• In this simulation exercise you will make two cubes fall due to Gravity on a static/rested non-translating floor.

Page 3: Tutorial two cubes falling on a floor due to gravity

Copy Previous Work

• Now select cube node and press Ctrl+c to copy that node along with whole graph Associated to it.

Page 4: Tutorial two cubes falling on a floor due to gravity

Copying the Previous work in thenew scene

• To Open New Scene File tab click on the New Tab on the top left corner under File.

• Click on the Root node to select it and press Ctrl+v to paste the cube node and its graph under Root node.

• This time don’t delete the by default provided components from the Root Node as they will be needed to resolve the Collision and Contact issues which will be experienced by us– as more then one object exists in the animation

– which will raise a possibility of collision/contact with each other.

Page 5: Tutorial two cubes falling on a floor due to gravity

Copying the Previous work in thenew scene

Page 6: Tutorial two cubes falling on a floor due to gravity

Copy the cube node

• Rename the cube node with cube 1.

• Copy the node.

• Select the Root Node.

• Paste the cube node on it.

• Go the newly pasted cube node.

– Rename it with cube 2.

Page 7: Tutorial two cubes falling on a floor due to gravity

Copy the cube node

Page 8: Tutorial two cubes falling on a floor due to gravity

Cube’s initial position’s translation

• Go to the transformation tab of the mechanical state object of the cube 1.

– Over write the already written 0, 0 and 0 in the blanks placed in front of translation of DOF (under Translation) with 0, 10 and 0.(it will translate the initial position of the object’s vertices, 10 units toward Y-axis)

• Do the same with the OglModel object of the cube1 node.(it will Translate the graphical model of the object 1 units in the Y-axis)

Page 9: Tutorial two cubes falling on a floor due to gravity

Cube1’s initial position’s translation

Page 10: Tutorial two cubes falling on a floor due to gravity

Cube2’s initial position’s translation

• Now in the same way as described in the last slide go to the Transformation tab of the Mechanical State Object and OglModel Object of the cube 2.

– Replace the by default written 0,0 and 0 with 10,10 and 0 (which will translate the object vertices and the Graphical Model to the 10 units in the X-axis and 10 units in the y axis).

Page 11: Tutorial two cubes falling on a floor due to gravity

Cube2’s initial position’s translation

Page 12: Tutorial two cubes falling on a floor due to gravity

Simulation Results till now

• Now click the run Sofa button and Animate it, you will see two cubes placed along side each other falling in parallel to each other due to gravitational force.

Page 13: Tutorial two cubes falling on a floor due to gravity

Adding the floor in thesimulation

• Now drag and drop another node on the Root node.– Name the new node as floor.

• Add Meshtopolgy and Mechanical State of Vec3d under the floor node.– In MeshTopology give C:\sofa\share\mesh\floor.obj in the

file topology.

• Add another GNode for the visual purpose under the floor node.– Name it floorVisual.

– Add the OglModel under new GNode.• Give file mesh, Path to the mesh/floor.obj

Page 14: Tutorial two cubes falling on a floor due to gravity

Adding the floor in thesimulation

Page 15: Tutorial two cubes falling on a floor due to gravity

Simulation Results before Collision implementation

• Now after this check out the animation you will see two cubes falling due to gravitational force and eventually passing through the floor.

• They did not bounce back or stopped while colliding with the floor because no collision model is added in any of the three objects.

• For this we will add another GNode dedicated for the collision model purpose. (like Visual node is dedicated for Visual issue handling).

Page 16: Tutorial two cubes falling on a floor due to gravity

Simulation Results before Collision implementation

Page 17: Tutorial two cubes falling on a floor due to gravity

Adding Collision Model

• Now add the TSphereModel object (placed in the drop down of the Collision Model present in the sofa component) in the collision node of both of the cube nodes.

• In a Same way add the TtriangleModel in the floor the collision node of the floor node.

Page 18: Tutorial two cubes falling on a floor due to gravity

Adding Collision Model

Page 19: Tutorial two cubes falling on a floor due to gravity

Force Field

• Now animate the simulation after clicking run sofa.

• After colliding with the floor, you will see cubes getting de-shaped like a spilled water on floor.– The reason behind this is the force applied/acting on one

vertices is not getting transferred to other vertices.

– So the vertices of the cube act like 8 different particles joint together with a zero tension wires.

• To avoid that we have to add a force field– It will transfer/project and relate the force of one vertices of

the object with the other one using some physical properties.

Page 20: Tutorial two cubes falling on a floor due to gravity

MeshSpringForceField

• For this purpose we will add the Mass Spring Force Field in both of the cubes.

• To do so Drag and drop MeshSpringForceField from the drop down of Force Field component.

• In Property1/3 change the stiffness to 1000.

– This will lessen the water spill over like property of the cube vertices by increasing the stiffness of virtual springs connecting the vertices of the object.

Page 21: Tutorial two cubes falling on a floor due to gravity

Adding MeshSpringForceField

Page 22: Tutorial two cubes falling on a floor due to gravity

Simulation Results After MeshSprtingForceField

• Now animate and see the change as none of the cubes will get spill like water as before.

Page 23: Tutorial two cubes falling on a floor due to gravity

Video