Space Partitions CS 6500 Adv Computer Graphics ChunFa

  • Slides: 16
Download presentation
Space Partitions CS 6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003

Space Partitions CS 6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003

Today’s Short Film Arnold CS 6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003

Today’s Short Film Arnold CS 6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003

Announcement • Proxy Settings for accessing SIGGRAPH papers online. • Two paper presentations each

Announcement • Proxy Settings for accessing SIGGRAPH papers online. • Two paper presentations each on March 18 & 25. – 3/18: Portal paper and BSP paper. – Read the papers before class. • Volunteers wanted for paper presentations on April 8 CS 6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003

Common Operations in 3 D • Line/object intersection – Given a ray or line,

Common Operations in 3 D • Line/object intersection – Given a ray or line, which object will it intersect? • View frustum culling • Collision detection CS 6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003

Sorting/Indexing in 3 D • Sequential search is too slow for large models. •

Sorting/Indexing in 3 D • Sequential search is too slow for large models. • How about storing them in a 3 D array? – Size will be overwhelming • Think “hierarchy” CS 6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003

Octree • Divide the space in halves in X/Y/Z. – Always split in the

Octree • Divide the space in halves in X/Y/Z. – Always split in the middle. – You may also consider them as splitting in X, then in Y, then in Z. • If too many objects are in a partition, divide them again (recursively). CS 6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003

K-D Tree • More flexible than octree: – Not always splitted in the middle.

K-D Tree • More flexible than octree: – Not always splitted in the middle. – Split in X, then in Y, then in Z, or any order. CS 6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003

Kd-tree Example 4 6 1 10 8 2 11 3 13 2 4 12

Kd-tree Example 4 6 1 10 8 2 11 3 13 2 4 12 5 8 9 5 1 3 7 9 6 10 7 11 12 Figure Source: CS 638 slides by Stephen Chenney, University of Wisconsin – Madison, CS 6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 13

BSP Trees • From the paper by Fuchs et al, “On visible surface generation

BSP Trees • From the paper by Fuchs et al, “On visible surface generation by a priori tree structures” SIGGRAPH 80. • Binary Space Partition trees – A sequence of cuts that divide a region of space into two • Cutting planes can be of any orientation CS 6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003

Drawing Order from BSP Trees • BSP tress can be used to order polygons

Drawing Order from BSP Trees • BSP tress can be used to order polygons from back to front, or visa-versa – Descend tree with viewpoint – Things on the same side of a splitting plane as the viewpoint are always in front of things on the far side • Can draw from back to front – Gives the correct order for rendering transparent objects with a z-buffer, and by far the best way to do it • Can draw front to back too. CS 6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003

BSP Example 1 1 2 2 A 3 3 6 C 5 B A

BSP Example 1 1 2 2 A 3 3 6 C 5 B A 4 out 5 7 B 6 C D 4 8 8 out D out Figure Source: CS 638 slides by Stephen Chenney, University of Wisconsin – Madison, 7 CS 6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003

OBB Tree • OBB stands for Oriented Bounding Box. • OBB is a rectangular

OBB Tree • OBB stands for Oriented Bounding Box. • OBB is a rectangular bounding box at an arbitrary orientation. • Asymptotically faster for close proximity situations. CS 6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003

Off Topics… CS 6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003

Off Topics… CS 6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003

Mouse Interaction in Assignment 1 • You may write your own like this: x

Mouse Interaction in Assignment 1 • You may write your own like this: x -= mouse_ref_x; y -= mouse_ref_y; xf = (float) x/width; yf = (float) y/height; angle = 90* xf; M = rotation 3 D(axis_Y, angle); angle = 90* yf; M = rotation 3 D(axis_X, angle) * M; CS 6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003

Or You May Use GLH • So you don’t have to reinvent the wheel.

Or You May Use GLH • So you don’t have to reinvent the wheel. • Open. GL Helper Library http: //home. earthlink. net/~eberkain/GLH. html • Used in some NVIDIA SDK Demos. CS 6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003

Example Code • #include <glh_glut. h> • glut_simple_mouse_interactor camera, object, *current_interactor; current_interactor = &camera;

Example Code • #include <glh_glut. h> • glut_simple_mouse_interactor camera, object, *current_interactor; current_interactor = &camera; glut_add_interactor( current_interactor); CS 6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003