ELMO ELMO Loves Manipulating Objects Jeffrey Cua Stephen Lee - - PowerPoint PPT Presentation

elmo
SMART_READER_LITE
LIVE PREVIEW

ELMO ELMO Loves Manipulating Objects Jeffrey Cua Stephen Lee - - PowerPoint PPT Presentation

ELMO ELMO Loves Manipulating Objects Jeffrey Cua Stephen Lee jmc2108 sl2285 Erik Peterson John Waugh edp2002 jrw2005 December 21, 2004 Language Goals Accessibility Comprehensible for non-programmer Avoid direct matrix


slide-1
SLIDE 1

ELMO

December 21, 2004 Stephen Lee sl2285 Jeffrey Cua jmc2108 Erik Peterson edp2002 John Waugh jrw2005 ELMO Loves Manipulating Objects

slide-2
SLIDE 2

Language Goals

slide-3
SLIDE 3

Accessibility

  • Comprehensible for non-programmer

– Avoid direct matrix manipulation – Main commands (move, scale, etc) should be ‘human readable’ – Still make it similar to popular programming languages (Java/C) so the wheel doesn’t have to be re-invented.

slide-4
SLIDE 4

Funky Functions

  • In C++, one can have defaults, but only in

limited way

void foo(int i=0, int j=0);

  • When calling foo, can’t give j a value without giving one to i

as well

  • In ELMO, any input can have a default, and you

specify which are overridden.

– Call foo like so: foo(j=99); – More verbose syntax, but defaults are more useful, and encourages good naming of function inputs. ∫ ex = f(un)

slide-5
SLIDE 5

References

  • Any variable can use referencing via the “=&”
  • perator

int a =& b; a+=5; //changes b foo(j=&a); //pass a to foo by reference a =& 22; //a no longer refers to b

  • The “=&” operator can be used anywhere ‘=’

would be

slide-6
SLIDE 6

Scene Graphs

  • Scene graphs allow
  • rganization of 3D

transforms through hierarchical grouping.

  • Easy to build up

composite transforms using groups-within- groups

slide-7
SLIDE 7

Sugary Syntax

  • Vector syntax:

vector vec = <1,2,3>;

  • Random number syntax:

float r = [a..b/2];

  • Typical transform commands:

rotate g around <1,0,0> by 15 deg; move obj along obj.X by 5;

slide-8
SLIDE 8

Not Quite C

  • No switch statements
  • for and foreach are the only

iteration constructs

  • Functions must be declared

before they’re used

  • No custom data types

(struct/union)

  • No external definitions

– all code must be in one .elmo file

slide-9
SLIDE 9

Language Implementation

slide-10
SLIDE 10

Top-Level

slide-11
SLIDE 11

Walker

slide-12
SLIDE 12

Group Statements

slide-13
SLIDE 13

Class Structure

slide-14
SLIDE 14

Expressions

slide-15
SLIDE 15

Grouper

Hierarchy & Tree Structure

i n g

slide-16
SLIDE 16

ELMOGroup nodes compose trees in the scene forest

slide-17
SLIDE 17

// each group has a single parent ELMOGroup _parent; // born to parent ELMOGroup( ELMOGroup parent ) { ... _parent = parent; } // adoption by parent setParent( ELMOGroup parent ) { _parent = parent; } // default to orphan ELMOGroup() { ... _parent = null; }

slide-18
SLIDE 18

attach( ELMOGroup a ) { if (a._parent==null && !isAncestor(a)) { ... a.setParent( this ); } } isAncestor( ELMOGroup a ) { if (this == a) { return true; } else if (_parent == null) { return false; } else { return _parent.isAncestor(a); } }

slide-19
SLIDE 19

// parent disowns you remove( ELMOGroup a ) { ... a.setParent( null ); } getInheritedTM() { ELMOMatrix t = ELMOMatrix.ID(); ELMOGroup g = _parent; while( g != null ) { t = ELMOMatrix.mult( t, g.getTransformationMatrix() ); g = g.getParent(); } return t; } // you get a car removeWithInheritance( ELMOGroup a ) { ... a.setParent( null ); ELMOMatrix t = this.getInheritedTM(); a.multiply( t ); }

slide-20
SLIDE 20

Making ELMO Sing:

A Quick Tutorial

Perl Sucks

slide-21
SLIDE 21

Importing OBJ files

//imports and assigns sphere.obj to object //sphere

  • bject sphere = "tests/sphere.obj";

//prints filename print sphere; //copies sphere to sphere2

  • bject sphere2 = sphere;
slide-22
SLIDE 22

Transforming an Object

// moves sphere along x-axis by 3 units move sphere along <1,0,0> by 3; // rotates sphere around axis by PI/6 radians rotate sphere around axis by PI/6; // scales sphere around origin by 90% scale sphere around <0,0,0> by 0.9;

slide-23
SLIDE 23

Creating/Calling a function

// creates function named curl void curl ( int counter, object sphere, vector axis ) { //<insert body here> } // calls function curl setting the following args curl( counter=10, sphere=sphere, axis=<0,1,0> );

slide-24
SLIDE 24

Exporting

stamp sphere; stamp sends sphere to an object buffer that will hold it until the program finishes and flushes the contents to a file.

slide-25
SLIDE 25

Recursion

void curl ( int counter, object sphere, vector axis ) { stamp sphere; if ( counter != 0 ) { counter --; rotate sphere around axis by PI/6; move sphere along axis by 4; scale sphere around <0,0,0> by 0.9; curl( counter=counter, sphere=&sphere, axis=axis ); } }

slide-26
SLIDE 26

Putting it all together

  • bject sphere = "tests/sphere.obj";

print sphere;

  • bject sphere2 = sphere;

move sphere along <1,0,0> by 3; move sphere2 along <1,0,0> by -3; int counter = 20;

slide-27
SLIDE 27

Creating a quick compound Object

curl( counter=counter, sphere=sphere, axis= <0,1,0> ); curl( counter=counter, sphere=sphere2, axis= <0,1,0> ); curl( counter=counter, sphere=sphere, axis= <0,0,1> ); curl( counter=counter, sphere=sphere2, axis= <0,0,1> ); curl( counter=counter, sphere=sphere, axis= <0,-1,0> ); curl( counter=counter, sphere=sphere2, axis= <0,-1,0> ); curl( counter=counter, sphere=sphere, axis= <0,0,-1> ); curl( counter=counter, sphere=sphere2, axis= <0,0,-1> );

slide-28
SLIDE 28
slide-29
SLIDE 29

Output

slide-30
SLIDE 30

Damn Straight!