How to do simple shading of a solid color sphere?

Hello:  I know the basic of OpenGL and is new to jME3. Now it is simple math to calculate a bunch of vertex-coordinates and vertex-normals for objects such as a sphere and torus. Using the raw OpenGL syntax, it is straight forward to render such object by providing the coordinates, colors, normals, and texture-coordinates at each vertex.

I understand jME is a high-level 3D game engine, objects are meant to be more interesting than the kind I just mentioned.  But can I still do the the same basic raw OpenGL stuff?

I played with TestSphere and saw a bunch of solid red spheres. There is no shading at all. Can someone please explain how to do the simple shading of a solid color sphere?  I'll appreciate if you can show me the right way to do it in JME3 (using material?) and the way from scratch (such as from a triangle strip, pls skip any math) because I want to generate some object/texture procedurally.  :slight_smile:

You will have to create a j3md and j3m file, for the syntax you can have a look at the j3md and shader files in the jMonkeyEngine3.jar (if using jMP in the Project Explorer just expand "Libraries", then "jMonkeyEngine3.jar and then the "Common" folder). We are working on more documentation for this topic right now, check back in the wiki from time to time.



Check TestSimpleLighting test, it shows shading on a teapot, you can apply the same effect to a sphere.


Thanks for the jME and the suggestions. I did played with the j3md and j3m file in the "Common" folder and didn't get anywhere. I can get the basic light shading on spheres, but can't set the material to orange.  I guess I'll have to wait for more documentation.  :frowning:

Key binding seems to cause my programs to behave strangely. I just discovered that a single key press produces multiple key binding, that seems a very strange design.  Are we suppose to set up a flag to catch the key binding from a real key press, and ignore the subsequent key bindings? But then do we have "key unbinding" (associated to key release) to reset the flag, so as to ready for second real key presss?  :?

Another thing, I wrote a very simple app and run it in window mode, the frame rate is about 400. If I set flyCam.setDragToRotate(false), then the frame rate is still about 400, but as soon as I move the cursor outside the window, the framerate jumps to about 2000! If I run it in full-screen mode, the frame rate is about 1000 in all these described circumstances.