Why does my scene never appear to get "larger" does cam grow relative to scene?

Hello all!

I basically am creating a walkthrough and wanted to scale the sizes of the wall relative to real life, but every time I increase the size it seems as if it’s always be relatively the same size as it was before. You can see the differences in sizes of bigger objects and smaller objects if you mess around, but it doesn’t get as big as I would like it to be.

It seemed at first as if setting the Frustum bigger, and then the camera move speed would make it seems relative, but I’m not too sure now. Does the Frustrum play a role in that? What is the difference between the FrustumPerspective, and the normal “Plane?”

how do you scale our scene , how much?

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.

I kind of see what youre doing. but its actually not needed. You dont need to scale your game world based on the screen size. Youre just trying to work with some boxes, imagine trying to turn this in to an actual game filled with stuff thats going on (movement directions, jump heights, attack ranges, etc)

The scene should be modeled based on a constant unit. 1 unit of jme space is meant to be 1 meter. but you can decide to use your own units, as long as all objects in the scene are using the same units…

Youre right to look in to modifying camera settings to adjust what the player can see. For instance players with wider aspect ratios might be able to see more of the world than you wish at once… but dont modify the world itself to solve this. modify the camera and viewport settings.

<cite>@icamefromspace said:</cite> I kind of see what youre doing. but its actually not needed. You dont need to scale your game world based on the screen size. Youre just trying to work with some boxes, imagine trying to turn this in to an actual game filled with stuff thats going on (movement directions, jump heights, attack ranges, etc)

The scene should be modeled based on a constant unit. 1 unit of jme space is meant to be 1 meter. but you can decide to use your own units, as long as all objects in the scene are using the same units…

Youre right to look in to modifying camera settings to adjust what the player can see. For instance players with wider aspect ratios might be able to see more of the world than you wish at once… but dont modify the world itself to solve this. modify the camera and viewport settings.

The person who I’m working with wanted a pixels per inch based on screen size, but honestly it shouldn’t matter at all, and I believe the engine itself would do all that for us…

I am using 1 foot as my unit.

I will check out the camera, I was thinking about the viewport, but it seems that’s only for showing how much of my Scene I want. I want to be able to increase the size of everything, but I can see how the viewport might make everything bigger… I will check this out, thanks a lot!

How does pixels per inch have any bearing on the scene graph? I’m highly confused by what you are trying to do here and why :s

<cite>@zarch said:</cite> How does pixels per inch have any bearing on the scene graph? I'm highly confused by what you are trying to do here and why :s

The person I’m working with scaled everything in their program based on that variable, that’s all, it has nothing to with this, it was only there to use as a scale value, but seeing as Jmonkey Cam doesn’t like scaling…

All I am trying to do is make my scene larger, without the Camera scaling with it. Every time I make thing sbigger, the camera looks at everything the same. If I make the scale 1 or 10000000 everything looks the same at the end, which apparently is a viewport issue according to the user above, so I am going to try that, unless you have something better?

@KonradZuse said: The person I'm working with scaled everything in their program based on that variable, that's all, it has nothing to with this, it was only there to use as a scale value, but seeing as Jmonkey Cam doesn't like scaling...

All I am trying to do is make my scene larger, without the Camera scaling with it. Every time I make thing sbigger, the camera looks at everything the same. If I make the scale 1 or 10000000 everything looks the same at the end, which apparently is a viewport issue according to the user above, so I am going to try that, unless you have something better?

No. You are doing something strange.

If you setLocalScale(5), your scene will look 5x bigger.

But I’m not exactly sure (along with others) what the end effect is that you want. The way you are going about it is strange enough that we cannot guess.

<cite>@pspeed said:</cite> No. You are doing something strange.

If you setLocalScale(5), your scene will look 5x bigger.

But I’m not exactly sure (along with others) what the end effect is that you want. The way you are going about it is strange enough that we cannot guess.

I’m sorry, I’m creating a walkthrough type application, think of Doom, where you walk through areas. As I increase the size of everything and I go through my path it seems small. When I increase the size 100 fold it looks exactly the same.

If I zoom in I can only get to a certain point, and the objects aren’t big at all. You can see in both cases they are basically the same. What I change in each case is the size, the frustum, and the speed so I can move faster, but it just allows me to see the bigger objects in the frustum, and be able to move through them. When I had the outer white layer bigger than the smaller colored objects you could see the size difference when scaled, since they weren’t on top of each other, but next to each other in space.

I know it sounds really weird, and confusing so I am sorry ifexplained it well, I’m just really confused.

The ViewPort was not what I’m looking for.

You say “you scale, change the viewport, and change the speed” basically… well, if you do that then things are of course going to feel the same.

let’s pretend that I scale my office up 100x… then I scale my camera up 100x… then I move 100x faster. Then effectively, nothing has changed.

So you will have to be super-specific because it sounds like you are either not communicating well or you have created your own problem by changing too many things at once.

Or maybe we don’t understand what “bigger” means. To me it means “larger on the screen”… in which case, JUST setting the local scale of the root node will give you that.

Hence why i said youre not supposed to try and scale the game to fit the window :smiley:

If your scene is 5 units wide, and your camera’s fustrum is such that it cans see 5 units wide. then you’ll see the same thing regardless of how big your window is.

I’m guessing the person he’s working with his normally a web developer. This sort of concern is common when making webapps and such because dimensions when making web pages are in pixels (and the length of 1 pixel is different from monitor to monitor)

1 Like

Thanks icame, I went to check out the frustum is more detail and I believe this is what I’m looking for, thanks again. I was only modifying the “far” but wasn’t sure how I should work the others, messing around yielded results.