@pspeed said:
How have you setup the minimap? There are several very distinct answers depending on which of several approaches you've used.
I guess the Original Convo has been forgotten :P.
I’m using the second viewport/second cam as my mini map, then as we did earlier get the distance from the scene to the cam so we can have the scene in the entire second viewport.
I figured that I could just find out the location either by.
Clicking in the second cam, then shooting a ray down from the plane of the came, to the terrain.Once it hits the terrain it should know it’s position, but that’s based on my first cam then.
I tried things like taking the difference of the start( which is cam2.setViewPort(0.75f, 1.0f, 0.0f, 0.25f)
so bottom right cam.
In the mouse picking example, which I believe I mentioned above it takes the screen coordinate, and transforms it into a world coordinate. When I try to do the worldcoordinate of my cam2, for some reason it constantly is the same value, no matter where I clicked, it was weird.
I figured the ray would be the easiest approach, I also thought about that the top left edge is technically 0,0 in my scene, and that 0,0 of cam2 should equal cam1, but when cam2 is at the bottom right which in my screen’s case is 1920x1080 then it would be that value and not that value/4, value/4 (which is the size of my viewport, 25% each way).
I think I’m a bit confused on how the screencoordinates change to worldcoordinates(since the way I did it wasn’t changing it doesn’t make sense).
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:mouse_picking
[java]private AnalogListener analogListener = new AnalogListener() {
public void onAnalog(String name, float intensity, float tpf) {
if (name.equals(“pick target”)) {
// Reset results list.
CollisionResults results = new CollisionResults();
// Convert screen click to 3d position
Vector2f click2d = inputManager.getCursorPosition();
Vector3f click3d = cam.getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 0f).clone();
Vector3f dir = cam.getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 1f).subtractLocal(click3d).normalizeLocal();
// Aim the ray from the clicked spot forwards.
Ray ray = new Ray(click3d, dir);
// Collect intersections between ray and all nodes in results list.
rootNode.collideWith(ray, results);
// (Print the results so we see what is going on:)
for (int i = 0; i < results.size(); i++) {
// (For each “hit”, we know distance, impact point, geometry.)
float dist = results.getCollision(i).getDistance();
Vector3f pt = results.getCollision(i).getContactPoint();
String target = results.getCollision(i).getGeometry().getName();
System.out.println(“Selection #” + i + ": " + target + " at " + pt + “, " + dist + " WU away.”);
}
// Use the results – we rotate the selected geometry.
if (results.size() > 0) {
// The closest result is the target that the player picked:
Geometry target = results.getClosestCollision().getGeometry();
// Here comes the action:
if (target.getName().equals(“Red Box”)) {
target.rotate(0, -intensity, 0);
} else if (target.getName().equals(“Blue Box”)) {
target.rotate(0, intensity, 0);
}
}
} // else if …
}
};[/java]
I figured this example would work out with some edits, but so far not so good…
I should be able to get the screen position of the second cam, convert it to world coordinates, then shoot the ray down and convert to cam1’s coordinates, but I guess I’m a bit confused on it all…
Thanks…