- does the gun have multiple nodes inside it ? maybe if its a single node it wont have a problem ?
- any screenshot ?
Thanks kidney, but that is the exact thing that I used to do
I had that exact line in my mainclass before
Scaling it would be possible, but sad. It would be more fun to have the possebility to work with layers…
With multiple nodes, then I think i say no.
Its one mesh loaded once from assetmanager. But the mesh is splited up and animated with diffrent bones in blender.
As for screenshot:
I made and textured that DB shotgun, tell me what you think of it too

Addez said:
I made and textured that DB shotgun, tell me what you think of it too ;)
Hehe. The colors looks painted by hand, it's just a diffuse map ok?
Lawls
I know, but its good to be me
Also, the texture used was not really commercial so I will create my own when I get the foundation of the game going
Can you try it with the gun being “single”, not splitted up in blender. can you merge its parts in blender ?
It looks the shotgun’s geometries aren’t been rendered in correct order.
Ah yea they are merged. ctrl+j so its only one mesh.
recalculate the face normals outside in blender by selecting all verticies (ctrl+a) and ctrl+alt+t ( i think ).
Already did that
Tho It did change a bit when I recalculated again.
But still some parts are too messed up…
If you have triangles overlapping then it will be very difficult to get this to work merely with depth buffer trickery.
If the player can really walk in such a way that they can stick their gun through a wall then you may have to do this with a viewport. You can add a new main viewport and then it will be rendered under the GUI layer but on top of your scene. You have to manage your own root node for the viewport, though. The one that you will attach your gun, too. It won’t be quite as convenient as the normal scene.
…however, the nice thing is that the camera for that viewport won’t move when the other one does… so you won’t have to do anything special to keep the gun in view.
I do this with a custom AppState in Mythruna for object editor. If you get really stuck figuring it out then I might be able to post my OverlayAppState code.
- so from what i understood from pspeed if you remove the overlapping vertices, propably with Boolean.Subtract / pressing delete button on vertices it will be solved.
- if your gun doesnt move then use an image instead.
Yes, if you can somehow arrange your geometry so that no triangles overlap then you might get away with it. As long as you never turn the gun… in which case then use an image.
Or, you can just setup a custom viewport and do whatever complicated geometry you want, turn it, shake it, rotate it, whatever. With the added benefit of not having to move your gun to some position relative to the main camera.
A viewport app state would be something like this… I’m having to clean some things out I depend on in my own code but hopefully it’s close:
[java]
public class ViewPortState extends AbstractAppState {
private Camera cam;
private ViewPort view;
private Node root;
public ViewPortState() {
}
public Node getRoot() {
return root;
}
public Camera getCamera() {
return cam;
}
@Override
protected void initialize( Application app )
{
root = new Node( “Viewport Root” );
root.setCullHint(CullHint.Never);
Camera originalCam = app.getCamera();
cam = new Camera(originalCam.getWidth(), originalCam.getHeight());
view = app.getRenderManager().createMainView( getName() + " ViewPort", cam);
view.setEnabled(true);
view.setClearFlags(false, true, false);
view.attachScene( root );
// You can leave this out or change it if you have different lighting needs
DirectionalLight light = new DirectionalLight();
light.setDirection( new Vector3f( 1, 0.2f, -1.5f ).normalizeLocal() );
root.addLight(light);
root.updateLogicalState(1);
root.updateGeometricState();
}
@Override
public void render(RenderManager rm) {
root.updateGeometricState();
}
@Override
public void update( float tpf ) {
root.updateLogicalState(tpf);
}
}[/java]
I’ve left out the setEnabled() because I have a base class that makes that nicer in my own code and I think it is obvious.
Once added, from anywhere in your app that you can access the state manager then you can easily look-up this class and get the root node. It’s self-managing once attached.
That is EXACLY what I want to do
But Im a bit stuck at an error:
java.lang.IllegalStateException: Scene graph is not properly updated for rendering.
Make sure scene graph state was not changed after
rootNode.updateGeometricState() call.
Problem spatial name: Root
To make another viewport I did this:
[java]Camera cam_n = MainClass.getCam().clone();
cam_n.setLocation(new Vector3f(0,0,0));
cam_n.setRotation(new Quaternion());
ViewPort view_n = MainClass.getRender().createMainView("View of camera #n", cam_n);
view_n.attachScene(root);
root.attachChild(gun);[/java]
I feel like Im missing to register the new view port or something. Didnt find any instructions in wiki on how to do this so
Im hoping you know the answer? :/
Did you use my app state?
You have to maintain the state of your own root node when you have your own viewport. And that app state will take care of it for you.
Somewhere in your app setup, call getStateManager().attach( new ViewPortState() );
Then you can use getStateManager().getState( ViewPortState.class ).getRootNode() to get its root node.
And app state is the easiest way to do the junk required on update() and render() for an ViewPort.
Lol! Sorry
I didnt know there was 2 pages on this post and read only your reply on the first
Ill try to use your code now Thanks
That is awsome It actually works!!
But theres one problem… The viewport doesnt make any sence.
I add a 1x1x1 square. then I set the local translation to 1,0,3
Then the red square covers half of my screen nomather what I do. Good!
But if I set the local translation to 1,0,3.00000001f
Then the square is not visible at all! The screen has no red on it at all!
How can such small thing change it all?
The problem with this is that I cant find where to place my gun as it is never in view. Thats why I tried to find whats infront of the new cam using this square. But having this problem would make it impossible to find my gun I think
You can set the viewport’s camera to point wherever you want. By default, I think it looks down the positive Z axis or something. You could debug or print out the values to see or just set them to something that makes sense for you.
Ahh!
Add cam.setFrustumFar(1000); to that class and it all works out
Thanks alot