Class: Disp3D::SceneGraph

Inherits:
Object
  • Object
show all
Defined in:
lib/scene_graph.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSceneGraph

Returns a new instance of SceneGraph.



7
8
9
# File 'lib/scene_graph.rb', line 7

def initialize()
  @root_node = NodeCollection.new()
end

Instance Attribute Details

#root_nodeObject

Returns the value of attribute root_node.



5
6
7
# File 'lib/scene_graph.rb', line 5

def root_node
  @root_node
end

Instance Method Details

#add(node) ⇒ Object



16
17
18
# File 'lib/scene_graph.rb', line 16

def add(node)
  @root_node.add(node)
end

#bounding_boxObject



24
25
26
# File 'lib/scene_graph.rb', line 24

def bounding_box
  return @root_node.box
end

#centerObject



28
29
30
31
32
# File 'lib/scene_graph.rb', line 28

def center
  bb = self.bounding_box
  return nil if bb.nil?
  return bb.center
end

#gl_display(current_view) ⇒ Object



11
12
13
14
# File 'lib/scene_graph.rb', line 11

def gl_display(current_view)
  NodePathDB.init
  @root_node.draw(current_view)
end

#open(&block) ⇒ Object



20
21
22
# File 'lib/scene_graph.rb', line 20

def open(&block)
  @root_node.open(&block)
end

#radiusObject



34
35
36
37
38
39
40
# File 'lib/scene_graph.rb', line 34

def radius
  bb = self.bounding_box
  return 0 if bb.nil?
  length = bb.length
  orth_length = Math.sqrt( length[0]*length[0] + length[1]*length[1] + length[2]*length[2] )
  orth_length/2.0
end