the field concept and dependency graphs - uni-weimar.delopa1693/master/wise1516/field_concept... ·...

48
The Field Concept and Dependency Graphs Tim Weißker

Upload: lemien

Post on 27-Jun-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

The Field Concept

and Dependency Graphs

Tim Weißker

Recap: Scene Graphs

hierarchical representation

of the elements of a scene

(and their properties) to

be rendered

2

simplified scene graph for a motorcycle

The Field Concept and Dependency Graphs 06.11.2015

Recap: Scene Graphs

hierarchical representation

of the elements of a scene

(and their properties) to

be rendered

the field concept defines

every node of the scene

graph being a field container

3

simplified scene graph for a motorcycle

The Field Concept and Dependency Graphs 06.11.2015

Recap: Scene Graphs

hierarchical representation

of the elements of a scene

(and their properties) to

be rendered

the field concept defines

every node of the scene

graph being a field container

But what does that mean?

4

simplified scene graph for a motorcycle

The Field Concept and Dependency Graphs 06.11.2015

Definitions

field

more complex form of an attribute

represents object state information

input and output fields

easy serialization and distribution

5 The Field Concept and Dependency Graphs 06.11.2015

Examples

6

avango avango.gua

SFBool SFMatrix4

SFInt SFVec3

SFFloat SFVec4

[…] […]

Fields

The Field Concept and Dependency Graphs 06.11.2015

Definitions

7

field container

collection of fields

evaluate() method called when one field changes

The Field Concept and Dependency Graphs 06.11.2015

Definitions

8

field container

collection of fields

evaluate() method called when one field changes

example:

The Field Concept and Dependency Graphs 06.11.2015

Increment

Input : SFInt

Output : SFInt

evaluate()

class Increment(avango.script.Script):

Input = avango.SFInt()

Output = avango.SFInt()

def evaluate(self):

self.Output.value = self.Input.value + 1

Input : SFInt

Output : SFInt

evaluate()

def evaluate(self):

self.Output.value = self.Input.value + 1

method evaluate()

a field container’s evaluate() method executes max. three steps

in the following order

Definitions

9 The Field Concept and Dependency Graphs 06.11.2015

Input : SFInt

Output : SFInt

evaluate()

def evaluate(self):

self.Output.value = self.Input.value + 1

method evaluate()

a field container’s evaluate() method executes max. three steps

in the following order

read values from local input fields

Definitions

10 The Field Concept and Dependency Graphs 06.11.2015

Input : SFInt

Output : SFInt

evaluate()

def evaluate(self):

self.Output.value = self.Input.value + 1

method evaluate()

a field container’s evaluate() method executes max. three steps

in the following order

read values from local input fields

calculate new values derived from the read values

Definitions

11 The Field Concept and Dependency Graphs 06.11.2015

Input : SFInt

Output : SFInt

evaluate()

def evaluate(self):

self.Output.value = self.Input.value + 1

method evaluate()

a field container’s evaluate() method executes max. three steps

in the following order

read values from local input fields

calculate new values derived from the read values

write the results to the output fields

Definitions

12 The Field Concept and Dependency Graphs 06.11.2015

Input : SFInt

Output : SFInt

evaluate()

def evaluate(self):

self.Output.value = self.Input.value + 1

method evaluate()

a field container’s evaluate() method executes max. three steps

in the following order

read values from local input fields

calculate new values derived from the read values

write the results to the output fields

to increase reuse, no external data should be accessed

Definitions

13 The Field Concept and Dependency Graphs 06.11.2015

Examples

14

avango avango.gua

SFBool SFMatrix4

SFInt SFVec3

SFFloat SFVec4

[…] […]

avango.gua

TransformNode

GeometryNode

PointLightNode

Classes derived from avango.script.Script

Fields

Field Containers

The Field Concept and Dependency Graphs 06.11.2015

Implementing a field container

15 The Field Concept and Dependency Graphs 06.11.2015

class Container(avango.script.Script):

Implementing a field container

16 The Field Concept and Dependency Graphs 06.11.2015

class Container(avango.script.Script):

#declaration of fields, e.g.

sf_mat = avango.gua.SFMatrix4()

Implementing a field container

17 The Field Concept and Dependency Graphs 06.11.2015

class Container(avango.script.Script):

#declaration of fields, e.g.

sf_mat = avango.gua.SFMatrix4()

def __init__(self):

self.super(Container).__init__()

Implementing a field container

18 The Field Concept and Dependency Graphs 06.11.2015

class Container(avango.script.Script):

#declaration of fields, e.g.

sf_mat = avango.gua.SFMatrix4()

def __init__(self):

self.super(Container).__init__()

def my_constructor(PARAMETER1, PARAMETER2, …):

#initialize variables, parameters, etc.

Implementing a field container

19 The Field Concept and Dependency Graphs 06.11.2015

class Container(avango.script.Script):

#declaration of fields, e.g.

sf_mat = avango.gua.SFMatrix4()

def __init__(self):

self.super(Container).__init__()

def my_constructor(PARAMETER1, PARAMETER2, …):

#initialize variables, parameters, etc.

def evaluate(self):

#perform update when fields change

Evaluation policies

20 The Field Concept and Dependency Graphs 06.11.2015

class Container(avango.script.Script):

#declaration of fields, e.g.

sf_mat = avango.gua.SFMatrix4()

def __init__(self):

self.super(Container).__init__()

def my_constructor(PARAMETER1, PARAMETER2, …):

#initialize variables, parameters, etc.

def evaluate(self):

#perform update when fields change

Evaluation policies

21

evaluate()

called when at least one of the fields changes

The Field Concept and Dependency Graphs 06.11.2015

Evaluation policies

22 The Field Concept and Dependency Graphs 06.11.2015

class Container(avango.script.Script):

#declaration of fields, e.g.

sf_mat = avango.gua.SFMatrix4()

def __init__(self):

self.super(Container).__init__()

self.always_evaluate(True)

def my_constructor(PARAMETER1, PARAMETER2, …):

#initialize variables, parameters, etc.

def evaluate(self):

#perform update every frame

Evaluation policies

23

evaluate()

called when at least one of the fields changes

self.always_evaluate(True)

forces evaluation every frame regardless of field changes

The Field Concept and Dependency Graphs 06.11.2015

Evaluation policies

24 The Field Concept and Dependency Graphs 06.11.2015

class Container(avango.script.Script):

#declaration of fields, e.g.

sf_mat = avango.gua.SFMatrix4()

def __init__(self):

self.super(Container).__init__()

def my_constructor(PARAMETER1, PARAMETER2, …):

#initialize variables, parameters, etc.

@field_has_changed(sf_mat)

def sf_mat_changed(self):

#perform update when sf_mat changed

Evaluation policies

25

evaluate()

called when at least one of the fields changes

self.always_evaluate(True)

forces evaluation every frame regardless of field changes

@field_has_changed(SFFoo)

only evaluated when SFFoo changes

function name can vary

The Field Concept and Dependency Graphs 06.11.2015

Dependencies

sometimes it is the case that an output field of one field

container forms the input of another one (e.g. sensors)

26 The Field Concept and Dependency Graphs 06.11.2015

Dependencies

sometimes it is the case that an output field of one field

container forms the input of another one (e.g. sensors)

field connections: the value of a field is copied into

another one after evaluation

27 The Field Concept and Dependency Graphs 06.11.2015

Dependency

Field connection

Node A

Input : type

Output : type

evaluate()

Node B

Input : type

Output : type

evaluate()

Dependencies

sometimes it is the case that an output field of one field

container forms the input of another one (e.g. sensors)

field connections: the value of a field is copied into

another one after evaluation

b.Input.connect_from(a.Output)

28 The Field Concept and Dependency Graphs 06.11.2015

Dependency

Field connection

Node A

Input : type

Output : type

evaluate()

Node B

Input : type

Output : type

evaluate()

Dependencies

problem:

if node B is evaluated before

node A, the input of B is not

specified

29 The Field Concept and Dependency Graphs 06.11.2015

Node A

Input : type

Output : type

evaluate()evaluateDependency()

Node B

Input : type

Output : type

evaluate()evaluateDependency()

Dependencies

problem:

if node B is evaluated before

node A, the input of B is not

specified

solution: evaluateDependency() method

is called on all unevaluated field containers

recursively calls same method on all dependent field containers

then calls evaluate() on itself

returns when recognizing a loop (warning message)

30 The Field Concept and Dependency Graphs 06.11.2015

Node A

Input : type

Output : type

evaluate()evaluateDependency()

Node B

Input : type

Output : type

evaluate()evaluateDependency()

Feedback propagation

although evaluateDependency() checks and ignores cyclic

dependencies, they are sometimes unavoidable

31 The Field Concept and Dependency Graphs 06.11.2015

Feedback propagation

although evaluateDependency() checks and ignores cyclic

dependencies, they are sometimes unavoidable

let‘s suppose we want to move a figure in a virtual

environment using an input device (e.g. joystick)

32 The Field Concept and Dependency Graphs 06.11.2015

Feedback propagation

33 The Field Concept and Dependency Graphs 06.11.2015

KeyboardInput

sf_move_left : SFBool

sf_move_right : SFBool

sf_jump : SFBool

sf_move_vec : SFVec3

evaluate()

Feedback propagation

34 The Field Concept and Dependency Graphs 06.11.2015

KeyboardInput

sf_move_left : SFBool

sf_move_right : SFBool

sf_jump : SFBool

sf_move_vec : SFVec3

evaluate()

Accumulator

sf_move_vec : SFVec3

sf_mat : SFMatrix4

evaluate()

Feedback propagation

35

Combining the last

and relative

transformation

matrix in one

The Field Concept and Dependency Graphs 06.11.2015

KeyboardInput

sf_move_left : SFBool

sf_move_right : SFBool

sf_jump : SFBool

sf_move_vec : SFVec3

evaluate()

Accumulator

sf_move_vec : SFVec3

sf_mat : SFMatrix4

evaluate()

Feedback propagation

36

Combining the last

and relative

transformation

matrix in one

The Field Concept and Dependency Graphs 06.11.2015

KeyboardInput

sf_move_left : SFBool

sf_move_right : SFBool

sf_jump : SFBool

sf_move_vec : SFVec3

evaluate()

Accumulator

sf_move_vec : SFVec3

sf_mat : SFMatrix4

evaluate()

GroundFollowing

sf_mat : SFMatrix4

sf_corrected_mat :

SFMatrix4

evaluate()

Feedback propagation

37

Combining the last

and relative

transformation

matrix in one

Corrects the

transformation

matrix with respect

to collisions

The Field Concept and Dependency Graphs 06.11.2015

KeyboardInput

sf_move_left : SFBool

sf_move_right : SFBool

sf_jump : SFBool

sf_move_vec : SFVec3

evaluate()

Accumulator

sf_move_vec : SFVec3

sf_mat : SFMatrix4

evaluate()

GroundFollowing

sf_mat : SFMatrix4

sf_corrected_mat :

SFMatrix4

evaluate()

Feedback propagation

38

Combining the last

and relative

transformation

matrix in one

Corrects the

transformation

matrix with respect

to collisions

The Field Concept and Dependency Graphs 06.11.2015

KeyboardInput

sf_move_left : SFBool

sf_move_right : SFBool

sf_jump : SFBool

sf_move_vec : SFVec3

evaluate()

Accumulator

sf_move_vec : SFVec3

sf_mat : SFMatrix4

evaluate()

GroundFollowing

sf_mat : SFMatrix4

sf_corrected_mat :

SFMatrix4

evaluate()

Feedback propagation

39

Combining the last

and relative

transformation

matrix in one

Corrects the

transformation

matrix with respect

to collisions

problem: the output of GroundFollowing is required as an

input in the next frame to be rendered

The Field Concept and Dependency Graphs 06.11.2015

KeyboardInput

sf_move_left : SFBool

sf_move_right : SFBool

sf_jump : SFBool

sf_move_vec : SFVec3

evaluate()

Accumulator

sf_move_vec : SFVec3

sf_mat : SFMatrix4

evaluate()

GroundFollowing

sf_mat : SFMatrix4

sf_corrected_mat :

SFMatrix4

evaluate()

Feedback propagation

40

solution: weak field connection

The Field Concept and Dependency Graphs 06.11.2015

KeyboardInput

sf_move_left : SFBool

sf_move_right : SFBool

sf_jump : SFBool

sf_move_vec : SFVec3

evaluate()

Accumulator

sf_move_vec : SFVec3

sf_mat : SFMatrix4

evaluate()

GroundFollowing

sf_mat : SFMatrix4

sf_corrected_mat :

SFMatrix4

evaluate()

Feedback propagation

41

solution: weak field connection

is ignored during dependency evaluation

the corresponding value however is propagated in the next

frame accum.sf_mat.connect_weak_from(gf.sf_corrected_mat)

The Field Concept and Dependency Graphs 06.11.2015

KeyboardInput

sf_move_left : SFBool

sf_move_right : SFBool

sf_jump : SFBool

sf_move_vec : SFVec3

evaluate()

Accumulator

sf_move_vec : SFVec3

sf_mat : SFMatrix4

evaluate()

GroundFollowing

sf_mat : SFMatrix4

sf_corrected_mat :

SFMatrix4

evaluate()

Transform nodes in the scenegraph

42 The Field Concept and Dependency Graphs 06.11.2015

TransformNode

Name : SFString

Parent : SFNode

Children : MFNode

Transform : SFMatrix4

WorldTransform :

SFMatrix4

evaluate()

Node

Summary

43

every node of the scene graph and classes derived from avango.script.Script are called field container

The Field Concept and Dependency Graphs 06.11.2015

Summary

44

every node of the scene graph and classes derived from avango.script.Script are called field container

state of a field container is defined by state of the fields

easy serialization

easy network distribution within AVANGO

The Field Concept and Dependency Graphs 06.11.2015

Summary

45

every node of the scene graph and classes derived from avango.script.Script are called field container

state of a field container is defined by state of the fields

easy serialization

easy network distribution within AVANGO

within a field container, no external data is accessed

dependencies are realized with field connections

loose coupling between field container instances

easily reusable ( component-based design)

The Field Concept and Dependency Graphs 06.11.2015

Summary

46

every node of the scene graph and classes derived from avango.script.Script are called field container

state of a field container is defined by state of the fields

easy serialization

easy network distribution within AVANGO

within a field container, no external data is accessed

dependencies are realized with field connections

loose coupling between field container instances

easily reusable ( component-based design)

feedback propagation using weak field connections

The Field Concept and Dependency Graphs 06.11.2015

References

Kuck, R., Wind, J., Riege, K., Bogen, M.: Improving the

AVANGO VR/AR Framework – Lessons Learned, Paper from

the 5th GI VR/AR workshop, 2008

Fröhlich, B., Bernstein, A.C.: Avango –Virtual Reality

Framework, Virtual Reality lecture, 2011

Avango: http://www.avango.org/

Autodesk Maya Documentation: http://docs.autodesk.com

Guacamole simple example (VR Cluster):

/opt/avango/master/examples/simple_example

47 The Field Concept and Dependency Graphs 06.11.2015

The End

48

Thank you for your attention!

In your next assignment, you will

build your first own dependency graph.

Have fun

The Field Concept and Dependency Graphs 06.11.2015