My first model, some questions

Hi all. I would like to get into game development as a hobby and after a bit of scouting around I decided I wanted to give JME a try. Although I know a tiny little bit of Java I am still a complete and utter n00b at this so I will likely be asking some very n00b questions here and for that I apologize beforehand. Also sorry for being somewhat longwinded. :S

I started out by reading a bit of the jMonkeyEngine 3.0 Beginner’s Guide. After about 50 pages or so I decided to quickly skim ahead a bit to the part where creating and loading 3D models is explained, I believe somewhere around page 94. Following the advice of the guide I installed Blender and after a day or two of wrestling with that I managed to create the model I was looking for. It is a fairly simple model of the smallest Lego piece, a flat 1x1. So basically it’s a square box-shaped object with a smaller square box-shape cut out at the bottom to provide room for the knob of another piece and it has a cylinder on top to form the knob which consists of 16 vertices around. Blender tells me this model consists of 74 triangles. After following some Blender tutorials I managed to add a material and colour to it and after trying out lots of settings I was able to render a relatively decent picture considering it was a first try.

I was trying to follow the part of the JME guide that explains how to add a texture to the model (pages 96 and 97) so I began by detaching the material I already had. The first step of the guide tells me that I need to be in edit-mode and the object has to be selected so that it has an orange outline. Now when I select the object in edit-mode by pressing the a-key I don’t get the orange outline but rather the whole object turns orange meaning all the vertices/edges/panels are selected. When I switch to object-mode however I do get the orange outline which looks similar to the example picture so I figured perhaps this is a little mistake in the guide. In any case I managed to add a new material to it and rename both the mesh and the material to the same name like the guide told me to do. The next task is to select Unwrap - Smart UV Project from the Mesh Tools panel and accept the defaults, which I did. For this I indeed had to be in edit-mode otherwise there is no Mesh Tools panel. The next step is what’s giving me trouble. I manage to switch the 3D View to the UV/Image View and what I should see according to the guide is my 3D mesh broken down into flat 2D pieces. However all I get to see is a grid of grey boxes. I have tried zooming in and zooming out as far as I could but I could still see nothing but a grid of grey boxes. I tried shift+c to see if that might help but that didn’t do a thing. So this is the point where I am unable to follow the guide any further. Does anybody have an idea about what could be going wrong here? Am I forgetting something or messing something up? I am using Blender version 2.69 which is currently I believe the latest build.

I moved on to the next step which was to export my model to both Ogre 3D and Wavefront. The Ogre 3D export gave me an error. It tells me “ReferenceError: StructRNA of type Mesh has been removed”. The Wavefront export however proceeded without a problem. I used the Wavefront model to follow the Just Testing part of loading a model in the guide. Then I converted that model to a .3jo file and put it in the assets/models folder. Later I found a code example here and I used the one with the lighting to load my model and test. I shall include my simpleInitApp() method here.

public void simpleInitApp() {
Spatial lego = assetManager.loadModel(“Models/Lego/lego_flat_1x1.j3o”);
Material mat = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);
mat.setBoolean(“UseMaterialColors”, true);
mat.setColor(“Ambient”, ColorRGBA.Blue);
mat.setColor(“Diffuse”, ColorRGBA.Blue);
DirectionalLight sun = new DirectionalLight();
sun.setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)));

When I ran this code the first time the on screen analytics told me it was running at around 700 frames per second, this was without any movement. When I tried zooming out and rotating with the keyboard I saw the frames per second go down significantly even dropping well under 100 frames per second. At this point I was getting worried because my intention is to eventually use this model as a terrain tile and if the engine already seems to have trouble rendering one of these objects how is it ever going to manage a whole lot of them. This is when I decided to sign up for this forum so I could ask you some questions about this. However I just tried running the code again and this time it didn’t show any of the trouble it had before. In fact the amount of frames per second went up to over 1000 and even higher than 1200 at one point. I wasn’t running many programs during the first test and on the second test I was actually running one additional program namely Blender. While the questions I previously intended to ask are no longer applicable I think I now have a couple of new ones.

How can it be that the result of the first test was so different from the result of the second test?

Is it at all a realistic goal to use a 74 triangle object as a terrain tile?

Considering the way I modeled the object, loaded it into JME and set a colour and material to it, do you see any obvious ways this can be improved upon to increase performance or make it easier?

I intend to eventually give each tile a colour and material based on the type of material it is made off. For example green for grass, brown for earth, something transparant for water and glass or something that looks like metal. It seems to make sense to me to write a class for the tiles and load the materials and colours upon construction of the tiles.

Would that way of working have a significant influence on performance and would this be in a positive or a negative way?

Are there any tips you could give me now to put me on track of the best way to implement this so that I may not have to start from scratch later on?

I know that the best way to learn is to make mistakes but I also know making a lot of mistakes can put a dent in motivation. I try to google what I can but sometimes it is just easier to ask questions directly instead of reading a bunch of pages of topics that are somewhat similar but not quite what you’re looking for. Also sometimes I am a bit lazy, but please don’t tell anyone. Oops I shouldn’t have said that. By the way, I am working on an Inspiron of about 6 years old with a 2.0GHz Core2Duo in it with 4GB of RAM and a GeForce 8600M GT with 256MB on board, in case anyone was wondering.

I once again apologize for my longwindedness and I hope some of you can answer some of my questions. I look forward to spending a lot of time learning to work with JME and I hope this forum will prove to be an interesting and fun community. Not to mention a shining beacon in the dark days of inexperience and errors of unknown origin. Thanks for reading. Hope I don’t get too many :google:. :wink: