Thanks for answering, that's good to know.
I do not understand why jMe treats my quad as if it is out of the view frustum.
I am using parallel projection, I've written code to draw a Quad moved from (0,0,0) 200 units to the right,
and the user can position the mouse at edges of the screen in order to strafe above the plane that the quad is on.
When strafing to the right - the quad disappears at once - as if jMe thinks it's out of the view frustum…
package gui;
import java.net.URL;
import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.image.Texture;
import com.jme.input.AbsoluteMouse;
import com.jme.input.InputHandler;
import com.jme.input.action.InputAction;
import com.jme.input.action.InputActionEvent;
import com.jme.math.Vector2f;
import com.jme.math.Vector3f;
import com.jme.scene.Spatial.CullHint;
import com.jme.scene.Spatial.LightCombineMode;
import com.jme.scene.shape.Quad;
import com.jme.scene.state.BlendState;
import com.jme.scene.state.TextureState;
import com.jme.util.TextureManager;
public class CopyOfMain extends SimpleGame {
private Vector2f pos;
private float zoom;
private boolean onTheMove;
private AbsoluteMouse am;
public static void main(String[] args) {
CopyOfMain app = new CopyOfMain();
app.setConfigShowMode(ConfigShowMode.AlwaysShow);
app.start();
}
private void updateCamera() {
float left = pos.x - zoom*display.getWidth();
float right = pos.x + zoom*display.getWidth();
float top = pos.y - zoom*display.getHeight();
float bottom = pos.y + zoom*display.getHeight();
float near = -0.1f;
float far = 2;
cam.setFrustum(near, far, left, right, top, bottom);
cam.update();
}
protected void simpleInitGame() {
zoom = 1;
pos = new Vector2f(0,0);
cam.setParallelProjection(true);
cam.setLocation(new Vector3f(0,0,1));
updateCamera();
onTheMove = false;
int accumX = 0;
URL url = CopyOfMain.class.getClassLoader().getResource("images/dr.jpg");
Texture texture = TextureManager.loadTexture(url, Texture.MinificationFilter.Trilinear, Texture.MagnificationFilter.Bilinear);
TextureState ts = display.getRenderer().createTextureState();
ts.setEnabled(true);
ts.setTexture(texture);
Quad q = new Quad("myQuad", 400, 400);
rootNode.attachChild(q);
q.setRenderState(ts);
q.setLightCombineMode(LightCombineMode.Off);
q.updateRenderState();
q.setLocalTranslation(200, 0, 0);
q.setModelBound(new BoundingBox());
q.updateModelBound();
q.setCullHint(CullHint.Never);
// Controls init
input.removeAllFromAttachedHandlers();
// Create a new mouse. Restrict its movements to the display screen.
am = new AbsoluteMouse("The Mouse", display.getWidth(), display.getHeight());
// Get a picture for my mouse.
TextureState ts2 = display.getRenderer().createTextureState();
URL cursorLoc = CopyOfMain.class.getClassLoader().getResource("resources/cursor1.png" );
Texture t = TextureManager.loadTexture(cursorLoc, Texture.MinificationFilter.BilinearNearestMipMap, Texture.MagnificationFilter.Bilinear);
ts2.setTexture(t);
am.setRenderState(ts2);
// Make the mouse's background blend with what's already there
BlendState as = display.getRenderer().createBlendState();
as.setBlendEnabled(true);
as.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
as.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha);
as.setTestEnabled(true);
as.setTestFunction(BlendState.TestFunction.GreaterThan);
am.setRenderState(as);
rootNode.attachChild(am);
am.setLocalTranslation(new Vector3f(display.getWidth()/2, display.getHeight()/2, 0.5f));
// am.setUsingDelta(false);
am.registerWithInputHandler( input );
//create an action to show axis activity
InputAction axisAction = new InputAction() {
public void performAction( InputActionEvent evt ) {
Vector3f mPos = am.getHotSpotPosition();
float x = mPos.x;
float y = mPos.y;
if (x<100 || x>display.getWidth()-100 || y<100 || y>display.getHeight()-100)
onTheMove = true;
else
onTheMove = false;
}
};
//register it with all devices and all axes of these
input.addAction(axisAction, InputHandler.DEVICE_MOUSE, InputHandler.BUTTON_NONE, 0, false ); // x axis
input.addAction(axisAction, InputHandler.DEVICE_MOUSE, InputHandler.BUTTON_NONE, 1, false ); // y axis
}
protected void simpleUpdate() {
if (onTheMove) {
Vector2f mPos = new Vector2f(am.getHotSpotPosition().x, am.getHotSpotPosition().y);
Vector2f scrCenter = new Vector2f(display.getWidth()/2, display.getHeight()/2);
Vector2f dir = mPos.subtractLocal(scrCenter).normalizeLocal().multLocal(0.5f);
pos.addLocal(dir);
updateCamera();
}
}
}
This may also be a place to ask about another difficulty I'm having - when the game starts, the mouse is positioned at the middle of the screen, but upon the tiniest movement it goes to (0,0) as if it was actually there to begin with.