summaryrefslogtreecommitdiff
path: root/test/src
diff options
context:
space:
mode:
Diffstat (limited to 'test/src')
-rw-r--r--test/src/main.rb65
1 files changed, 29 insertions, 36 deletions
diff --git a/test/src/main.rb b/test/src/main.rb
index 31affb8..2c8bdcc 100644
--- a/test/src/main.rb
+++ b/test/src/main.rb
@@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-ROTATION_SPEED = Math::PI/45;
+CAMERA_ROTATION_SPEED = Math::PI/45;
+BOX_ROTATION_SPEED = Math::PI/180;
TRANSLATION_SPEED = 0.5;
def init()
@@ -20,54 +21,43 @@ def init()
$model = CandyGear::Model.new("models/cube.cgmodel", $texture);
$instances = [
- CandyGear::Model::Instance.new(
- $model,
- 5.0, 0.0, 0.0,
- 0.0, 0.0, 0.0),
- CandyGear::Model::Instance.new(
- $model,
- -5.0, 0.0, 0.0,
- 0.0, 0.0, 0.0),
- CandyGear::Model::Instance.new(
- $model,
- 0.0, 5.0, 0.0,
- 0.0, 0.0, 0.0),
- CandyGear::Model::Instance.new(
- $model,
- 0.0, -5.0, 0.0,
- 0.0, 0.0, 0.0),
- CandyGear::Model::Instance.new(
- $model,
- 0.0, 0.0, 5.0,
- 0.0, 0.0, 0.0),
- CandyGear::Model::Instance.new(
- $model,
- 0.0, 0.0, -5.0,
- 0.0, 0.0, 0.0)
+ CandyGear::Vector3D.new(5.0, 0.0, 0.0),
+ CandyGear::Vector3D.new(-5.0, 0.0, 0.0),
+ CandyGear::Vector3D.new(0.0, 5.0, 0.0),
+ CandyGear::Vector3D.new(0.0, -5.0, 0.0),
+ CandyGear::Vector3D.new(0.0, 0.0, 5.0),
+ CandyGear::Vector3D.new(0.0, 0.0, -5.0)
];
+ $instances_rotation = CandyGear::Rotation3D.new(0.0, 0.0, 0.0);
- $camera = CandyGear::Camera.new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
- $camera.use();
+ $camera_position = CandyGear::Vector3D.new(0.0, 0.0, 0.0);
+ $camera_rotation = CandyGear::Rotation3D.new(0.0, 0.0, 0.0);
+ CandyGear.camera_position = $camera_position
+ CandyGear.camera_rotation = $camera_rotation;
end
def key_down(key)
case key
when CandyGear::Key::I
- $camera.rotate(ROTATION_SPEED, 0.0, 0.0);
+ $camera_rotation.rotate(CAMERA_ROTATION_SPEED, 0.0);
when CandyGear::Key::K
- $camera.rotate(-ROTATION_SPEED, 0.0, 0.0);
+ $camera_rotation.rotate(-CAMERA_ROTATION_SPEED, 0.0);
when CandyGear::Key::J
- $camera.rotate(0.0, ROTATION_SPEED, 0.0);
+ $camera_rotation.rotate(0.0, CAMERA_ROTATION_SPEED);
when CandyGear::Key::L
- $camera.rotate(0.0, -ROTATION_SPEED, 0.0);
+ $camera_rotation.rotate(0.0, -CAMERA_ROTATION_SPEED);
when CandyGear::Key::E
- $camera.translate_by_rotation(0.0, 0.0, -TRANSLATION_SPEED);
+ $camera_position.translate(
+ CandyGear::Vector3D.new(0.0, 0.0, -TRANSLATION_SPEED), $camera_rotation);
when CandyGear::Key::D
- $camera.translate_by_rotation(0.0, 0.0, TRANSLATION_SPEED);
+ $camera_position.translate(
+ CandyGear::Vector3D.new(0.0, 0.0, TRANSLATION_SPEED), $camera_rotation);
when CandyGear::Key::S
- $camera.translate_by_rotation(-TRANSLATION_SPEED, 0.0, 0.0);
+ $camera_position.translate(
+ CandyGear::Vector3D.new(-TRANSLATION_SPEED, 0.0, 0.0), $camera_rotation);
when CandyGear::Key::F
- $camera.translate_by_rotation(TRANSLATION_SPEED, 0.0, 0.0);
+ $camera_position.translate(
+ CandyGear::Vector3D.new(TRANSLATION_SPEED, 0.0, 0.0), $camera_rotation);
end
end
@@ -77,5 +67,8 @@ end
def quit() = CandyGear.quit();
def tick()
- $instances.each {|i| i.draw();};
+ $instances_rotation.rotate(0.0, BOX_ROTATION_SPEED);
+ $instances.each do |i|
+ $model.draw(i, $instances_rotation);
+ end
end