MEngine Advanced
Upcoming SlideShare
Loading in...5
×
 

MEngine Advanced

on

  • 350 views

These are some more advanced concepts in the dynamic polymorphic object design paradigm

These are some more advanced concepts in the dynamic polymorphic object design paradigm

Statistics

Views

Total Views
350
Views on SlideShare
347
Embed Views
3

Actions

Likes
0
Downloads
0
Comments
0

1 Embed 3

http://www.linkedin.com 3

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • You don’t have to touch the camera’s display list when you are messing with individual elements of the HUD object.
  • Functors allow
  • The parameter list typically contains a single CObject, the ‘this’ object. If it contained more objects, the functor would operate on those objects, too.
  • High level functor operation
  • High level functor operation

MEngine Advanced MEngine Advanced Presentation Transcript

  • MEngine Advanced Concepts
  • List Objects
    • Make a CLinkList into a CObject
    • Now lists can be manipulated like CObjects!
  • Oh God no. Why?
    • A list of lists is useful
    • Passing a list as an argument to a function is useful
    • List of lists allows a tree to have branches as well as leaves
    • Don’t need to add lists together when we have a list of lists. Just traverse the elements of the list of lists.
  • Examples of List Objects
    • Small display list for a HUD element
    • List of triangles in an Octree leaf
    • Arguments to a functor (later advanced concept)
    • Camera display lists
    • List of global lists available
    • List of menu lists (future architecture)
  • HUD element example HUD Display List HUD Display List A = Shell_dragonWidget A B = Green Dragon Icon B A = Shell_dragonWidget A C C = Red Dragon Icon
  • HUD Display List HUD element example continued Camera Display List E F G H A A = Shell_dragonWidget C C = Red Dragon Icon
  • Camera Display List G Complex Menu Display List C E D B F J M Z A H Complex Subelement Mini-Display List
  • Functors
    • Functions can be made into CObjects
    • Now functions can be manipulated like CObjects!
    • Procedural programming? So last millenium!
    • C++ Object-Oriented? No, it’s STATICALLY Object-Oriented
    • That’s why they use ‘static’ 8 million times
  • CObject Functors are added to each individual CObject Functor List F1 F2
  • Functor Calling Conventions
    • Other arguments passed depends upon how the Functor is constructed and what arguments it needs
    CObj Automatic Argument List
    • Each Functor has a default argument list
    CObj Functor List Fn
    • Each Cobject has its own list of Functors
    • The first argument in the Argument List is the Cobject itself. This allows the global Functor to access the ‘this’ pointer.
  • Getting a Functor CObj CObj Functor List F1 F2 CFunctor *pFunc = CObj->FindFunctor(“F2”); OR CFunctor *pFunc = CObj->FindFunctor(cobj_functor_type); F2
  • Execute the Functor
    • Functors operate in 2 ways
      • On a list attached to the functor itself (parameter list)
      • On a list provided to the functor
  • Why does Functor execute have 2 different modes of operation?
    • A Functor with an arglist performs a binary operation (ie. C = A+B, “Attach”)
    • A Functor without an arglist performs a unary operation using its parameter list as its arguments (ie. A = -A, “Render”, “Instantiate”, “Materialize”, “Animate”)
    • The Functor’s operation is performed on each CObject in the list.
  • Warning: NO SAFETY CHECKS
    • Functor operations are very versatile.
    • You can write code to violate the argument passing conventions.
    • Please don’t!
    • If you don’t like my conventions, make new ones. But keep some sort of convention, otherwise it will get crazy.
  • Apply Functor: “Render” to the Camera Display List Camera Display List G Complex Menu Display List C E J M Z A H Complex Subelement Mini-Display List
  • Low Level Functor Operation
    • pCamera->ExecuteFunctor(“Render”, NULL, pCamera->GetDisplayList());
    • Or: pCamera-> ForEachArgExecuteFunctor(cobj_reserved_functor_render, NULL, pCamera->GetDisplayList());
  • Apply Functors “Animate”, “Transform”, and “Render” Animated Frame List Transform Frame List Camera Display List A C D E F G H
  • I, Voltron, highly recommend Functors. You can attach or detach them from your classes to change your functionality dynamically as the situation demands. I can tell you from experience that it was a bitch getting all these different robot lion heads to interface properly in C++. But with functors, I didn’t have to care about the interface! I just say, “Left Arm fire!” or “Right Arm Detach!”