Class: TextureMappingData

Inherits:
Object show all
Includes:
Observable
Defined in:
lib/ext/projector/projector.rb

Constant Summary collapse

SCALE_A =
50.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTextureMappingData

Returns a new instance of TextureMappingData.



127
128
129
130
131
132
133
134
135
# File 'lib/ext/projector/projector.rb', line 127

def initialize
  @texture = nil
  @transform = Matrix3d::identity
  @transform *= Matrix3d::rotate(+20.0, Vector[1.0, 0.0, 0.0, 1.0])
  @transform *= Matrix3d::rotate(+30.0, Vector[0.0, 1.0, 0.0, 1.0])
  @transform *= Matrix3d::rotate(+90.0, Vector[0.0, 0.0, 1.0, 1.0])
  @face_list = []
  @transform_begin = nil
end

Instance Attribute Details

#face_listObject

Returns the value of attribute face_list.



122
123
124
# File 'lib/ext/projector/projector.rb', line 122

def face_list
  @face_list
end

#textureObject

Returns the value of attribute texture.



122
123
124
# File 'lib/ext/projector/projector.rb', line 122

def texture
  @texture
end

#transformObject

Returns the value of attribute transform.



122
123
124
# File 'lib/ext/projector/projector.rb', line 122

def transform
  @transform
end

Instance Method Details

#begin_workObject



143
144
145
146
# File 'lib/ext/projector/projector.rb', line 143

def begin_work
  @transform_begin = @transform
  self
end

#commitObject



155
156
157
158
# File 'lib/ext/projector/projector.rb', line 155

def commit
  @transform_begin = nil
  self
end

#swing_step(dx, dy) ⇒ Object



148
149
150
151
152
153
# File 'lib/ext/projector/projector.rb', line 148

def swing_step(dx, dy)
  a = Math::sqrt(dx * dx + dy * dy) * SCALE_A
  a > a * Float::EPSILON or return self
  self.transform = Matrix3d::rotate(a, Vector[dy, dx, 0.0, 1.0]) * @transform_begin
  self
end

#updateObject



137
138
139
140
141
# File 'lib/ext/projector/projector.rb', line 137

def update
  changed
  notify_observers
  self
end