Note: This image is NOT being update inside the simpleUpdate(float fpf) method:
this is image that I am trying to create, there you will see the distortion:
Bellow is the code:
package mygame.MyScenes;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
import com.jme3.util.SkyFactory;
/**
*
* @author FusionCCD
*/
public class MyTerrainScene extends SimpleApplication {
public static void main(String[] args){
MyTerrainScene app = new MyTerrainScene();
app.start();
}
RtsCam myCam;
Node targetPool = new Node("Targetable");
//Node chessTable = new Node("ChessTable");
Vector3f blockSize = new Vector3f(10f, 1f, 10f);
@Override
public void simpleInitApp() {
flyCam.setEnabled(false);
Spatial mySky = SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", false);
mySky.setName("Sky");
mySky.setQueueBucket(RenderQueue.Bucket.Sky);
mySky.setCullHint(Spatial.CullHint.Never);
Spatial myTerrain = assetManager.loadModel("Scenes/myTerrainScene.j3o");
Material myTerrainMats = new Material(assetManager, "Common/MatDefs/Misc/ColoredTextured.j3md");
myTerrainMats.setTexture("ColorMap", assetManager.loadTexture("Textures/dirt.jpg"));
myTerrain.setMaterial(myTerrainMats);
myTerrain.setName("Ground");
myCam = new RtsCam(RtsCam.UpVector.Y_UP);
myCam.setDistance(350);
stateManager.attach(myCam);
boolean alternate = false;
for(int z = 1; z <= 8; z++){
for(int x = 1; x <= 8; x++){
Geometry block = new Geometry("Bx"+x+":"+z, new Box(blockSize.x, blockSize.y, blockSize.z));
Vector3f v = blockSize.mult(new Vector3f(x, 0, -z));
block.setLocalTranslation(-50+v.x, v.y, v.z);
if(!alternate){
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.DarkGray);
block.setMaterial(mat);
alternate = !alternate;
} else {
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.White);
block.setMaterial(mat);
alternate = !alternate;
}
targetPool.attachChild(block);
}
alternate = !alternate;
}
targetPool.attachChild(myTerrain);
rootNode.attachChild(mySky);
rootNode.attachChild(targetPool);
}
@Override
public void simpleUpdate(float tpf){
myCam.update(tpf);
}
public void chessTableScale(float scale){
blockSize = blockSize.scaleAdd(scale, blockSize);
}
}
Since this is my first time doing graphics with JME3, I cannot figure out where is the distortion is coming from.
is it from the fact that you are trying to draw rectangles over the texture of the terrain.
I have no idea.
Can someone help me figure this out.
Maybe I am missing some piece of code.
This happens even after I remove the Sky and the Terrain objects