Class: TextureMappingData

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

Constant Summary

SCALE_A =
50.0

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (TextureMappingData) initialize

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

- (Object) face_list

Returns the value of attribute face_list



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

def face_list
  @face_list
end

- (Object) texture

Returns the value of attribute texture



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

def texture
  @texture
end

- (Object) transform

Returns the value of attribute transform



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

def transform
  @transform
end

Instance Method Details

- (Object) begin_work



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

def begin_work
  @transform_begin = @transform
  self
end

- (Object) commit



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

def commit
  @transform_begin = nil
  self
end

- (Object) swing_step(dx, dy)



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

- (Object) update



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

def update
  changed
  notify_observers
  self
end