Need Help on minimal project setup

Hi,

I started with sdk and first steps work fine so far.

My plans may sound boring, as I don’t plan to create a game. Just want a canvas, where I can show some 3D-models created on my own and move that around.
No mesh import, just created on the fly.
First test were promising.

My real project is an eclipse-project, but I don’t want to include all libs from jme3. So I did not follow the setup-steps from jme-Wiki related to eclipse.

But I followed the hard steps for manual setup of commandline usage.
Which means, I copied “some” libs from jme3 into my projects lib directory and added them to the projects build-path (in projects properties). Additionally I exported the jme3 libs.

I started with the testCanvas tutorial.

Currently I have jme3-core.jar and jme3-desktop.jar attached to my eclipse project.

testCanvas import compiled without problems, but when I try to start it, I get NoClassDefFoundError for JmeFormatter.
I guess, that eclipse uses the attached libs for runtime-classpath too, so I have no idea, where to start searching.

A quick grep showed, that JmeFormatter is part of jme3-core.jar - so it should get found.

What have I overlooked?
Any hint is appreciated!

I can’t really comment on the specific way you’ve gone about it, but there are a lot easier ways. At a guess it’s classpath related. JME pulls in some transient dependencies that probably aren’t in your classpath.

You can create a project in any IDE - or none at all - though the latter will probably be annoyingly elaborate for most.

The easiest and quickest way is to create a new gradle project in any IDE and provide the required libraries in the build script. The link below shows the minimum required steps to get up and running.

Hi,

thank you for your attention!

May be. But I’m not interested in “easy”. Easy will bloat my harddisks and my mind …
I like to know what’s going on. Therefore I don’t use gradle. I’m stil an ant-user :slight_smile:

That was the hint, that helped my find the reason!
I added the jars from lwjgl and now the apps work as expected :slight_smile:

May I ask another question?
Is there a way to invert mouse controls?
The mouse it attached to the camera, but I’d like to simulate the object gripping and moving around …

And does this editor has a preview function?

The default camera controls use FlyCam - which is great for a lot of test cases, but you probably want a custom camera if you delve any further. I think what you’re describing is something like the FocusCamera I made.

First disable the flycam by either setting flyCam.setEnabled(false) in your simpleInit method or overriding the constructor to something like:

private MyMainClass {
    super(new StatsAppState())
}

And then add this camera controller instead - If I remember, it’s just a single class.

I’m not entirely sure what you mean by “preview” function, but for the SDK @Darkchaos is the man with the answers.

Hi,

thank you for the code-link!
Great stuff. Love it!
I love that verbose coding!

I inverted the mouse buttons and created a separate speed setting for translations …
… now its close to what I want :slight_smile:

Your code is great for learning about internals. So will stay at it to get to understand bit more about focussing and the like.

Is there a way to calculate initial zoom factor based on the models size? When I wonna show an elefant, I might need another zoom factor as on showing a fly.
My models are quite different in size and I only know the size after creating it …

LOL, I was talking about this forum editor (javascript at the bottom of the browser - not related to jme3).

Hi,

thanks for the preview :smiley:

… don’t know - your CameraSettings behave different in my app, than in your Main-class. I checked all twice - can’t see any difference - beside that I have only one geometry.
I changed the strings for Mouse_Move_Up and Mouse_Move_Down but it looks like none of the strings is used in my app. It works fine from your Main-class.
I realized, that the mapping is set up in function onEnable - looks like implicit calling does not work.
… but as the function is protected - I can’t call it on my own (without breaking your concept), and I don’t know enuf to break it.

Here’s some old code I have that positions the camera so it fully includes a bounding box in its view frustum. Not sure if it’s 100% correct but it should be a starting point.

private static final float s_camFov       = 30;
private static final float s_camElevation = 40 * FastMath.DEG_TO_RAD;

private void updateCamera()
{
    BoundingBox bbox = (BoundingBox)_rootNode.getWorldBound();
    if(bbox == null)
        return;
    
    float extent = bbox.getXExtent();
    if(bbox.getYExtent() > extent)
        extent = bbox.getYExtent();
    if(bbox.getZExtent() > extent)
        extent = bbox.getZExtent();

    // Calculate camera distance where BoundingBox is fully visible
    float dist = extent / (float)Math.tan(s_camFov*0.5 * FastMath.DEG_TO_RAD);
    _cam.setLocation(new Vector3f(0, dist * (float)Math.sin(s_camElevation), dist * (float)Math.cos(s_camElevation)));
    float y = bbox.getCenter().y * 0.666f;
    _cam.lookAt(new Vector3f(0, y, 0), Vector3f.UNIT_Y);
}

You’re supposed to add it to the appStateManager.

FocusCameraState focusCameraState = new FocusCameraState();
stateManager.attach(focusCameraState);

// set a spatial to focus on.
focusCameraState.setFocusPoint(mySpatial);

Hi,

@1000ml
Thank you for your help!

Of cause it is.
I did it following your sequence:

  • disable FlyCamera
  • create FocusCamera
  • attach it to stateManager
  • setFocusPoint to existing Geometry

The point is, the app behaves as if no settings have been changed. And it does not change anything, if I change the strings in FocusCamera class.

Could it be, that other settings have precedence?

Just to repeat it: my environment is like testCanvas from awt-package, which is not related to jme3 class tree, but uses another Class that itself extends SimpleApplication.
So I added the FocusCamera to that class, that extends SimpleApplication.
The “caller” application uses AppSettings …
I gonna strip that class down to the absolute minimum …
… but thats work in progress - or better said: I’m just stumbling around …