I want to fix the cam and all the geometry in the scene and then move with the mouse cursor :(( haw can I do that ???
Let me guess from the limited info:
flyCam.setEnabled(false)
look at com.jme3.input maybe
i know only how to do this by drag
[java]
flyCam.setDragToRotate(true);
flyCam.setMoveSpeed(0);
flyCam.setRotationSpeed(0);
[/java]
disabling:
[java]
flyCam.setEnabled(false);
[/java]
but maybe here is option do do this without drag
or just do it by yourself(checking mouse position)
[java]
inputManager.getCursorPosition()
[/java]
and:
[java]
cam.lookAt(vector, Vector3f.UNIT_Y);
[/java]
or if u mean move objects(not camera) by mouse then try ray to get object:
[java]
Vector3f origin = cam.getWorldCoordinates(inputManager.getCursorPosition(), 0.0f);
Vector3f direction = cam.getWorldCoordinates(inputManager.getCursorPosition(), 0.3f);
direction.subtractLocal(origin).normalizeLocal();
mouseRay = new Ray(origin, direction);
[/java]
and move it
wait i must understand what u mean…
ok
if u want a chess game so u need camera in fixed position yes?
its
[java]flyCam.setEnabled(false);[/java]
and you need to type object to move so (JUST CRATE YOUR OWN CHESS OBJECT LIST/ETC OR JUST CHECK ALL WORLD OBJECTS)
[java]
Vector3f origin = cam.getWorldCoordinates(inputManager.getCursorPosition(), 0.0f);
Vector3f direction = cam.getWorldCoordinates(inputManager.getCursorPosition(), 0.3f);
direction.subtractLocal(origin).normalizeLocal();
mouseRay = new Ray(origin, direction);
// so you must have list to check(or just check only your one object)
for (int i = 0; i < objectList.size(); i++) {
Node model = objectList.get(i);
CollisionResults results = new CollisionResults();
model.collideWith(mouseRay, results);
if (results.size() > 0) {
// so u know this object is on cursor just check if mouse was clicked
} else {
}
}
[/java]
but as i see u have done it…
clicking
[java] public void initKeys() {
inputManager.addMapping(“mouseMove”, new MouseAxisTrigger(0, true));
inputManager.addMapping(“mouseMove”, new MouseAxisTrigger(0, false));
inputManager.addMapping(“mouseMove”, new MouseAxisTrigger(1, true));
inputManager.addMapping(“mouseMove”, new MouseAxisTrigger(1, false));
inputManager.addListener(analogListener, “mouseMove”);
inputManager.addMapping(“MOUSE_W+”, new MouseAxisTrigger(2, false));
inputManager.addMapping(“MOUSE_W-”, new MouseAxisTrigger(2, true));
inputManager.addMapping(“LMB”, new MouseButtonTrigger(mouseInput.BUTTON_LEFT));
inputManager.addMapping(“RMB”, new MouseButtonTrigger(mouseInput.BUTTON_RIGHT));
inputManager.addMapping(“MMB”, new MouseButtonTrigger(mouseInput.BUTTON_MIDDLE));
inputManager.addMapping(“kea_q”, new KeyTrigger(keyInput.KEY_Q));
inputManager.addMapping(“kea_w”, new KeyTrigger(keyInput.KEY_W));
inputManager.addMapping(“kea_e”, new KeyTrigger(keyInput.KEY_E));
inputManager.addMapping(“kea_r”, new KeyTrigger(keyInput.KEY_R));
inputManager.addMapping(“kea_t”, new KeyTrigger(keyInput.KEY_T));
inputManager.addMapping(“kea_y”, new KeyTrigger(keyInput.KEY_Y));
inputManager.addMapping(“kea_u”, new KeyTrigger(keyInput.KEY_U));
inputManager.addMapping(“kea_i”, new KeyTrigger(keyInput.KEY_I));
inputManager.addMapping(“kea_o”, new KeyTrigger(keyInput.KEY_O));
inputManager.addMapping(“kea_p”, new KeyTrigger(keyInput.KEY_P));
inputManager.addMapping(“kea_a”, new KeyTrigger(keyInput.KEY_A));
inputManager.addMapping(“kea_s”, new KeyTrigger(KeyInput.KEY_S));
inputManager.addMapping(“kea_d”, new KeyTrigger(KeyInput.KEY_D));
inputManager.addMapping(“kea_f”, new KeyTrigger(KeyInput.KEY_F));
inputManager.addMapping(“kea_g”, new KeyTrigger(KeyInput.KEY_G));
inputManager.addMapping(“kea_h”, new KeyTrigger(KeyInput.KEY_H));
inputManager.addMapping(“kea_j”, new KeyTrigger(KeyInput.KEY_J));
inputManager.addMapping(“kea_k”, new KeyTrigger(KeyInput.KEY_K));
inputManager.addMapping(“kea_l”, new KeyTrigger(KeyInput.KEY_L));
inputManager.addMapping(“kea_z”, new KeyTrigger(KeyInput.KEY_Z));
inputManager.addMapping(“kea_x”, new KeyTrigger(KeyInput.KEY_X));
inputManager.addMapping(“kea_c”, new KeyTrigger(KeyInput.KEY_C));
inputManager.addMapping(“kea_v”, new KeyTrigger(KeyInput.KEY_V));
inputManager.addMapping(“kea_b”, new KeyTrigger(KeyInput.KEY_B));
inputManager.addMapping(“kea_n”, new KeyTrigger(KeyInput.KEY_N));
inputManager.addMapping(“kea_m”, new KeyTrigger(KeyInput.KEY_M));
inputManager.addMapping(“backspace”, new KeyTrigger(KeyInput.KEY_BACK));
inputManager.addMapping(“Rotate”, new KeyTrigger(KeyInput.KEY_SPACE), new MouseButtonTrigger(mouseInput.BUTTON_LEFT));
inputManager.addListener(actionListener, new String[]{“LMB”, “RMB”, “backspace”, “kea_q”, “kea_w”, “kea_e”, “kea_r”, “kea_t”, “kea_y”, “kea_u”, “kea_i”, “kea_o”, “kea_p”, “kea_a”, “kea_s”, “kea_d”, “kea_f”, “kea_g”, “kea_h”, “kea_j”, “kea_k”, “kea_l”, “kea_z”, “kea_x”, “kea_c”, “kea_v”, “kea_b”, “kea_n”, “kea_m”});
inputManager.addListener(analogListener, new String[]{“MMB”, “MOUSE_W+”, “MOUSE_W-”, “Left”, “Right”, “Rotate”});
}[/java]
and for you to check if clicked
[java] ActionListener actionListener = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals(“LMB”)) {
// here u know u clicked
// and if u have mouse over this object just hide it
}
if (name.equals(“RMB”)) {
// here u know u clicked second
// and if u have mouse over this object just show it / type to move it
}
}
};[/java]
and just hide/show object on click and move it… i will not write all for you
“i want ti fix the board and the cam and move with the mouse cursor” → “move with the mouse cursor” → what u want to move? camera? object?
if camera → i said before
if board → just use mouseray and position it
if both: just rotate camera and change board position to camera(moved on camera view vector in some distance)
tip:
[java] cam.getWorldCoordinates(inputManager.getCursorPosition(), 0.5f);[/java]
I want to fix the board and the cam and then move pieces (here box) with the mouse cursor