Shape reuse

Hello I'm new with JME (3D programming) and I have problem:



It is possible to create one shape and place it in lot of diferent places? For example if I have tree (shape) it would be stupid  to create 1000 trees. Please somebody help me.

Check out TestSharedNode.java in the jmetest.renderer branch.



-Prime

Thanks for fast reply, I've missed this example;)



Unfortunately I have 2more problems:


  1. Performance - I've created Node and added to it 400trees as a SharedNode which were created from .obj model.  I've added ZBufferState as follows


   ZBufferState zState2 = display.getRenderer().createZBufferState();
   zState2.setFunction(ZBufferState.TestFunction.LessThanOrEqualTo);
        zState2.setEnabled(true);
        rootNode.setRenderState(zState2);


In my point of view game renderer all trees within frustrumview even if trees are besides hills or homes... how can I change it?

2. Object loading - my tree (created in Blender) in game has "blue sphere". I supposed that I made mistake during exporting project to .obj. How to solve it?


please help me;)

Well first one is easy, load like 1 different tree objects, and then devide the trees in groups



abcd

efgh

ijkl

If you are standing at f h,i,j,k,l can be culled then.



The blues sphere is it happening in combination with transparent textures? There were some other treads about, but I nevr really cared much since I don#t use trees myself ^^ :slight_smile:

Many thanks Empire Phoenix I've done as you suggested. Performance rises but it is stil not enought;D

I also found answer for second question, I've unchecked one option in Blender and everything is ok:)



I'm going to bed it's enought for today…


latino said:

Performance rises but it is stil not enought;D

Locking spatials you dont move/change anymore also brings significant performance increases.
normen said:

Locking spatials you dont move/change anymore also brings significant performance increases.


I've already locked those nodes but the problem is with tree - it has to many tris. I have to made new, much simple tree, then I will put it in farest places on map. Actual tree I will put in places which player would go.

Lock at the screen, and amaizing performace:)
[img [/img]

Oh I have one more problem i dont know how to change direction of a camera... When I'm starting game camera faces on the hills(west), how to change it to face north??
My code...


cam.setFrustum(1.0f, 900.0f, -0.45f, 0.45f, 0.4125f, -0.4125f); // ust kamery zakres widzenia
    cam.setFrustumPerspective(45.0f,(float) display.getWidth() / (float) display.getHeight(), 1, 900);
    cam.setLocation(new Vector3f(-470, terrain.getHeight(-470,580)+10, 580));
    cam.setDirection(new Vector3f(0.5f,0,0.5f)); // dziwny efekt zamazania
    cam.setLeft(new Vector3f(0.5f,0,-0.5f));
    cam.update();


Don't make leafs as single quads, combine several into one, look here:



http://yorik.uncreated.net/tutorials/treemaking.html

Empire Phoenix said:

Don't make leafs as single quads, combine several into one, look here:

http://yorik.uncreated.net/tutorials/treemaking.html


Bookmarking that :)  Nice link!