Basically I was scaling the scene by using a value I call ppi(Pixels per Inch). I take the screen width using this.settings.getWidth(); and then would divide it by values until I felt I was big enough. then during creation I would multiply each value I am reading in. I am basically taking data and creating a world through that.
[java]b[i] = new Box(new Vector3f((p.displayX.get(i) + p.displayWidth.get(i) /2f)*ppi
,startY - (p.displayY.get(i) + p.displayHeight.get(i)/2f)*ppi
,(p.displayDepth.get(i)/2f)*ppi)
,(p.displayWidth.get(i)/2f)*ppi, (p.displayHeight.get(i)/2f)*ppi, (p.displayDepth.get(i)/2f)*ppi); [/java]
Is this the wrong approach? Is there a better way to “scale” things?
Like I said once the objects got too large I had to increase the FrustumFar(). When doing that I sometimes had to increase the camera speed. It still seems as if the objects are the same size, it seems that has to do with how the camera might be zooming, or how I am dealing with this overall.
I saw in the ParallelProjection project that
[java] float aspect = (float) cam.getWidth() / cam.getHeight();
cam.setFrustum(-1000, 1000, -aspect * frustumSize, aspect * frustumSize, frustumSize, -frustumSize);
inputManager.addListener(this, "Size+", "Size-");
inputManager.addMapping("Size+", new KeyTrigger(KeyInput.KEY_W));
inputManager.addMapping("Size-", new KeyTrigger(KeyInput.KEY_S));
}
public void onAnalog(String name, float value, float tpf) {
// Instead of moving closer/farther to object, we zoom in/out.
if (name.equals("Size-"))
frustumSize += 0.3f * tpf;
else
frustumSize -= 0.3f * tpf;
float aspect = (float) cam.getWidth() / cam.getHeight();
cam.setFrustum(-1000, 1000, -aspect * frustumSize, aspect * frustumSize, frustumSize, -frustumSize);
}[/java]
I’m using the normal flyByCamera settings, I was told I needed to create a new “Appstate” if I wanted to make my own FlyByCamera. In this example they change W and S, but I thought that wont override it? In my example I try to remap a few keys, but nothing happens.
[java]public void keyEvents()
{
inputManager.addMapping("Forward", new KeyTrigger(KeyInput.KEY_UP));
inputManager.addMapping("Back", new KeyTrigger(KeyInput.KEY_DOWN));
inputManager.addListener(analogListener, new String[]{“Forward”, “Back”});
}
private AnalogListener analogListener = new AnalogListener()
{
@Override
public void onAnalog(String name, float value, float tpf) {
if (name.equals("Forward"))
{
cam.setLocation(new Vector3f(cam.getLocation().x,cam.getLocation().y, cam.getLocation().z-(value * flyCam.getMoveSpeed())));
}
if (name.equals("Back"))
{
cam.setLocation(new Vector3f(cam.getLocation().x,cam.getLocation().y, cam.getLocation().z+(value * flyCam.getMoveSpeed())));
}
cam.update();
cam2.update();
}
};
public void cam()
{
flyCam.setMoveSpeed(10000);
flyCam.setRotationSpeed(10);
flyCam.setDragToRotate(true);
flyCam.registerWithInput(inputManager);
// Setup second view
Quaternion q = new Quaternion();
cam2.setViewPort(0.75f, 1.0f, 0.0f, 0.25f);
// cam2.setRotation(q.fromAngleAxis(FastMath.PI/2 , new Vector3f(1,0,0)));
cam.setLocation(new Vector3f(0,0,1000));
cam2.setLocation(new Vector3f(15,-15,40));
cam.setFrustumFar(100000);
System.out.println(cam.getFrustumFar() + "far");
System.out.println(cam.getFrustumNear() + "near");
System.out.println(cam.getFrustumBottom() + "bot");
System.out.println(cam.getFrustumTop() + "top");
System.out.println(cam.getFrustumLeft() + "left");
System.out.println(cam.getFrustumRight() + "right");
cam2.update();
ViewPort view2 = renderManager.createMainView("Bottom Left", cam2);
view2.setClearFlags(true, true, true);
view2.attachScene(rootNode);
[/java]
Sorry for all of the System prints, I just found out about the better use of the Logger last night :).
If we look at those values
100000.0 far
1.0 near
-0.41421357 bot
0.41421357 top
-0.7363797 left
0.7363797 right
It’s very time for everything but Far. In the example above it’s much bigger. Whenever I tried to change things besides Far it would always send me somewhere distant and I couldn’t see my scene. Is there a better tutorial on Frustum, or do you have any information that you could explain? I appreciate anything.