Skip to content

Commit

Permalink
resynchronize chapter code snippets with code
Browse files Browse the repository at this point in the history
  • Loading branch information
EkkiD committed Nov 5, 2014
1 parent b9ccaac commit 30c00ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
15 changes: 6 additions & 9 deletions modeller/chapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,9 @@ class Viewer(object):
sphere_node.color_index = 3
self.scene.add_node(sphere_node)
sphere_node_2 = Sphere()
sphere_node_2.translate(-2, 0, -2)
sphere_node_2.color_index = 1
self.scene.add_node(sphere_node_2)
hierarchical_node = SnowFigure()
hierarchical_node.translate(-2, 0, -2)
self.scene.add_node(hierarchical_node)
def init_interaction(self):
""" init user interaction and callbacks """
Expand Down Expand Up @@ -173,9 +172,7 @@ Finally, `glFlush` signals to the graphics driver that we are ready for the buff
""" The render pass for the scene """
self.init_view()
# Enable lighting and color
glEnable(GL_LIGHTING)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
# Load the modelview matrix from the current state of the trackball
Expand Down Expand Up @@ -216,7 +213,6 @@ Finally, `glFlush` signals to the graphics driver that we are ready for the buff
glTranslated(0, 0, -15)
``````````````````````````````````````````

### What to Render: The Scene
Now that we've initialized the rendering pipeline to handle drawing in the world coordinate space, what are we going to render? Recall that our goal is
to have a design consisting of 3D models. We need a data structure to contain the design, and we need use this data structure to render the design.
Expand Down Expand Up @@ -711,7 +707,7 @@ the currently selected node.

`````````````````````````````````````````` {.python}
# class Scene
def rotate_color(self, forwards):
def rotate_selected_color(self, forwards):
""" Rotate the color of the currently selected node """
if self.selected_node is None: return
self.selected_node.rotate_color(forwards)
Expand All @@ -720,7 +716,7 @@ Each node stores its current color. The `rotate_color` function simply modifies

`````````````````````````````````````````` {.python}
# class Node
def rotate_selected_color(self, forwards):
def rotate_color(self, forwards):
self.color_index += 1 if forwards else -1
if self.color_index > color.MAX_COLOR:
self.color_index = color.MIN_COLOR
Expand Down Expand Up @@ -843,6 +839,7 @@ Finally, we translate the new node by the calculated vector.
new_node = None
if shape == 'sphere': new_node = Sphere()
elif shape == 'cube': new_node = Cube()
elif shape == 'figure': new_node = SnowFigure()
self.add_node(new_node)
Expand Down
2 changes: 1 addition & 1 deletion modeller/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Cube(Primitive):
""" Cube primitive """
def __init__(self):
super(Cube, self).__init__()
self.call_list = G_OBJ_CUBE
self.call_list = G_OBJ_CUBE


class HierarchicalNode(Node):
Expand Down

0 comments on commit 30c00ad

Please sign in to comment.