Graphics Applying Actions 2001 08 22 cgvr korea

  • Slides: 20
Download presentation
Graphics Applying Actions 강신진 2001. 08. 22 cgvr. korea. ac. kr 1 Graphics Lab

Graphics Applying Actions 강신진 2001. 08. 22 cgvr. korea. ac. kr 1 Graphics Lab @ Korea University

Contents n n n n n CGVR Inventor Actions General Model Applying an Action

Contents n n n n n CGVR Inventor Actions General Model Applying an Action Rendering Calculating a Bounding Box Accumulating a Transformation Matrix Writing to a File Searching for a Node Picking cgvr. korea. ac. kr 2 Graphics Lab @ Korea University

Inventor Actions n CGVR Available Action List Using This Action You Can Perform This

Inventor Actions n CGVR Available Action List Using This Action You Can Perform This Task So. Get. Bounding. Box. Action Compute a 3 D bounding box So. Get. Matrix. Acion Compute a transformation matrix So. Write. Action Write Scene graph to a file So. Search. Action Search for paths to specific nodes So. Handle. Event. Action Allow object to handle an event So. Ray. Pick. Action Pick object in the scene graph along a ray So. Call. Back. Action Traverse the scene graph and perform your own action using callback function So. GLRender. Action Draw, or render, the scene graph cgvr. korea. ac. kr 3 Graphics Lab @ Korea University

General Model n CGVR Initialize the action Sb. Viewport. Region region(300, 200); So. GLRender.

General Model n CGVR Initialize the action Sb. Viewport. Region region(300, 200); So. GLRender. Action render. Action(region); n Set up special parameters for the action So. GLRender. Action render. Action(region, TRUE); n Apply the action to a node render. Action->apply(root) n Obtain the result of the action, if possible cgvr. korea. ac. kr 4 Graphics Lab @ Korea University

Applying an Action n CGVR Action Application Node n Path list n n Traversal

Applying an Action n CGVR Action Application Node n Path list n n Traversal state Internal class to store transient state elements n Inventor database management n cgvr. korea. ac. kr 5 Graphics Lab @ Korea University

Rendering - Execution n CGVR Execution of So. GLRender. Action n If the node

Rendering - Execution n CGVR Execution of So. GLRender. Action n If the node is a group >>Visit each children n If the node is a property group >>Replace a value of traversal state n If the node is derived from So. Transformation >>Modify the current transformation n If the node is shape node >>Draw shape using the current element cgvr. korea. ac. kr 6 Graphics Lab @ Korea University

Rendering - Transparency n Setting the Transparency Quality n n CGVR set. Transparency. Type()

Rendering - Transparency n Setting the Transparency Quality n n CGVR set. Transparency. Type() Transparency Levels SCREEN_DOOR o ADD o DELAYED_ADD o SORTED_OBJECT_ADD o BLEND o DELAYED_BLEND o SORTED_OBJECT_BLEND o cgvr. korea. ac. kr 7 Graphics Lab @ Korea University

Rendering - Antialiasing n CGVR 2 Types of Antialiasing Smoothing n Using the Accumulation

Rendering - Antialiasing n CGVR 2 Types of Antialiasing Smoothing n Using the Accumulation Buffer n n Smoothing n n So. GLRender. Action : : set. Smoothing(Sb. Bool smooth) Accumulation Buffer n So. GLRender. Action : : set. Num. Passes(int num) cgvr. korea. ac. kr 8 Graphics Lab @ Korea University

Rendering - Off-screen Rendering n CGVR So. Off. Screen. Renderer Class n Render an

Rendering - Off-screen Rendering n CGVR So. Off. Screen. Renderer Class n Render an image into off-screen memory buffer To generate image for a Post. Script printer o To generate image for a Texture map o n So. Off. Screen. Renderer : : Set. Component(Components components) LUMIANCE o LUMIANCE_TRANSPARENCY o RGB_TRANSPARENCY o cgvr. korea. ac. kr 9 Graphics Lab @ Korea University

Rendering - Source n CGVR TEXTURE MAPPING Sb. Bool generate. Texture. Map (So. Node

Rendering - Source n CGVR TEXTURE MAPPING Sb. Bool generate. Texture. Map (So. Node *root, So. Texture 2 *texture, short texture. Width, short texture. Height) { Sb. Viewport. Region my. Viewport(texture. Width, texture. Height); // Render the scene So. Offscreen. Renderer *my. Renderer = new So. Offscreen. Renderer(my. Viewport); my. Renderer->set. Background. Color(Sb. Color(0. 3, 0. 3)); if (!my. Renderer->render(root)) { delete my. Renderer; return FALSE; } // Generate the texture->image. set. Value(Sb. Vec 2 s(texture. Width, texture. Height), So. Offscreen. Renderer: : RGB, my. Renderer->get. Buffer()); delete my. Renderer; return TRUE; } cgvr. korea. ac. kr 10 Graphics Lab @ Korea University

Rendering - Caching n Saving of an operation n n CGVR Don’t need to

Rendering - Caching n Saving of an operation n n CGVR Don’t need to traverse the scene graph every time So. Separator node has 2 field for caching n render caching: o n render. Caching(So. SFEnum) bounding-box caching bounding. Box. Caching(So. SFEnum) o So. SFEnum => AUTO, ON, OFF o n How Caching Working Check a valid cache existence n Ignore below scene graph and use cache(if C exists) n cgvr. korea. ac. kr 11 Graphics Lab @ Korea University

Calculating a Bounding Box n CGVR Create an instance of the action sb. Viewport.

Calculating a Bounding Box n CGVR Create an instance of the action sb. Viewport. Region vp. Reg; n vp. Reg. set. Window. Size(300, 200); n So. Get. Bounding. Box. Action bbox. Action(vp. Reg); n n Apply the Action n n bbox. Action. apply(root); Obtain Result So. Transform *my. Transform; n my. Transform->center = bbox. Action. get. Center(); n cgvr. korea. ac. kr 12 Graphics Lab @ Korea University

Accumulating a Transformation Matrix n Create an instance of the action n n CGVR

Accumulating a Transformation Matrix n Create an instance of the action n n CGVR so. Get. Matrix. Action mtx. Action Apply the Action n get. Matrix() get. Inverse() cgvr. korea. ac. kr 13 Graphics Lab @ Korea University

Writing to a File n CGVR So. Write. Action class is used So. Write.

Writing to a File n CGVR So. Write. Action class is used So. Write. Action my. Action; n Writing in binary with file pointer FILE *fp; my. Action. get. Output()->set. Binary(TRUE); my. Action. get. Output()->set. File. Pointer(fp); my. Action. apply(root); n Writing in ASCII my. Action. get. Output()->open. File(“file. iv”); my. Aciton. get. Output()->set. Binary(FALSE); my. Action. apply(root); my. Action. get. Output()->close. File(); cgvr. korea. ac. kr 14 Graphics Lab @ Korea University

Searching for a Node n CGVR Example So. Search. Action my. Search. Action. set.

Searching for a Node n CGVR Example So. Search. Action my. Search. Action. set. Type(So. Light: : get. Class. Trype. Id()); my. Search. Action. set. Interest (So. Search. Action: : FIRST); my. Search. Action. apply(root); If(my. Search. Action. get. Path() == NULL){ So. Direction. Light *my. Light = new So. Directional. Light; root->insert. Child(my. Light, 0); } cgvr. korea. ac. kr 15 Graphics Lab @ Korea University

Picking – 1 n CGVR So. Ray. Pick. Action is used n Find objects

Picking – 1 n CGVR So. Ray. Pick. Action is used n Find objects along a ray from the camera cgvr. korea. ac. kr 16 Graphics Lab @ Korea University

Picking – 2 n CGVR Specifying the Picking Ray Sb. Viewport. Region viewport(400, 300);

Picking – 2 n CGVR Specifying the Picking Ray Sb. Viewport. Region viewport(400, 300); Sb. Vec 2 s cursor. Position(250, 150); So. Ray. Pick. Action my. Pick. Action(viewport); my. Pick. Action. set. Ray(Sb. Vec 3 f(0. 0, 0. 0), //starting point Sb. Vec 3 f(0. 0, -1. 0)); //direction vector pick. Action->apply(root. Node); n Obtain result So. Path *path. To. Pick. Object; Const So. Pick. Point *my. Picked. Point = pick. Action. get. Picked. Point(); If(my. Picked. Point != NULL) path. To. Pickedobject = my. Picked. Point->get. Path(); cgvr. korea. ac. kr 17 Graphics Lab @ Korea University

Picking – 2 n So. Detail n n CGVR Have an additional information about

Picking – 2 n So. Detail n n CGVR Have an additional information about the pick Classes that store an So. Detail Class name Type of detail added So. Cube. Detail So. Cylinder. Detail So. Point. Set So. Point. Detail So. Cone. Detail cgvr. korea. ac. kr 18 Graphics Lab @ Korea University

Using the Pick Action n CGVR Writing the path to the Picked Object Sb.

Using the Pick Action n CGVR Writing the path to the Picked Object Sb. Bool write. Picked. Path (So. Node *root, const Sb. Viewport. Region &viewport, const Sb. Vec 2 s &cursor. Position) { So. Ray. Pick. Action(viewport); Pick. Action. set. Point(cursor. Position); Pick. Action. set. Radius(8. 0); Pick. Action. apply(root); const So. Picked. Point *my. Picked. Point = pick. Action. get. Picked. Point(); If(my. Picked. Point == NULL) return FALSE; So. Write. Action my. Write. Action; my. Wrtie. Action. apply(my. Picked. Point->getpath()); return TRUE; } cgvr. korea. ac. kr 19 Graphics Lab @ Korea University

Calling Back to the Application n CGVR So. Callback. Action n Method which is

Calling Back to the Application n CGVR So. Callback. Action n Method which is called whenever a specified node encountered during the traversal Void print. Spheres(So. Node *root) { So. Callback. Action my. Action; my. Action. add. Pre. Callback(So. Sphere: : get. Class. Type. Id(), print. Header. Callback, NULL); my. Action. add. Triangle. Callback(So. Sphere: : get. Class. Type. Id(), print. Triangle. Callback, NULL); my. Action. apply(root); } cgvr. korea. ac. kr 20 Graphics Lab @ Korea University