KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > buchuki > ensmer > input > Rotator


1 /*
2  * Copyright 2004 Dusty Phillips
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package com.buchuki.ensmer.input;
17
18 import com.buchuki.ensmer.EnsmerManager;
19 import com.buchuki.ensmer.SelectionManager;
20 import javax.vecmath.*;
21 import com.buchuki.ensmer.input.command.*;
22 import com.buchuki.ensmer.input.command.navigation.*;
23 import com.buchuki.ensmer.input.event.*;
24 import java.awt.event.KeyEvent JavaDoc;
25
26
27 /**
28  * Class to process manipulation mode events. The events in this module move the
29  * selected objects about the scene via calls to the SelectionManager class.
30  *
31  * @author Dusty Phillips [dusty@buchuki.com]
32  */

33 public class Rotator implements InputProcessor, Transformable3D {
34     
35     /**
36      * Construct the Navigator. Sets up the available commands.
37      *
38      * @param accelerator the Accelerator to manage the acceleration of the user
39      */

40     public Rotator(Accelerator accelerator) {
41         CommandMap map = InputManager.getCommandMap();
42         
43         Command rotateForwardBack =
44         new RotateCommand(this, accelerator, 0.01f, RotateCommand.Axis.X);
45         Command rotateLeftRight =
46         new RotateCommand(this, accelerator, 0.01f, RotateCommand.Axis.Y);
47         Command rotateUpDown =
48         new RotateCommand(this, accelerator, 0.1f, RotateCommand.Axis.Z);
49         
50         map.addCommand(this, rotateForwardBack, new VerticalMouseMoveEvent(-1));
51         map.addCommand(this, rotateForwardBack, new VerticalMouseMoveEvent(1));
52         map.addCommand(this, rotateLeftRight, new HorizontalMouseMoveEvent(-1));
53         map.addCommand(this, rotateLeftRight, new HorizontalMouseMoveEvent(1));
54         map.addCommand(this, rotateUpDown, new MouseWheelEvent());
55     }
56     
57     /**
58      * Process an EnsmerInputEvent that occurs. The navigator looks up the
59      * possible actions in the CommandMap and acts on them.
60      *
61      * @param event the event that needs to be processed by the navigator
62      */

63     public void processInput(EnsmerInputEvent event) {
64         CommandMap map = InputManager.getCommandMap();
65         map.interpretEvent(this, event);
66     }
67     
68     /**
69      * Move the user by the relative amount given
70      *
71      * @param matrix the relative matrix to be applied to the user movement
72      */

73     public void moveTransform(Matrix4f matrix) {
74         SelectionManager sel = EnsmerManager.instance().getSelectionManager();
75         sel.setSelectedObjectPositions(matrix, false);
76     }
77 }
78
79
Popular Tags