When using MutiTexturing with GLSL,only the first texture can be accessed. The others cannot be visited. Why?
here is the code
import com.jme.app.BaseGame;
import com.jme.bounding.BoundingSphere;
import com.jme.image.Texture;
import com.jme.input.FirstPersonHandler;
import com.jme.input.InputHandler;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.light.PointLight;
import com.jme.math.FastMath;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.renderer.Camera;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Node;
import com.jme.scene.Spatial;
import com.jme.scene.shape.Sphere;
import com.jme.scene.state.GLSLShaderObjectsState;
import com.jme.scene.state.LightState;
import com.jme.scene.state.TextureState;
import com.jme.scene.state.ZBufferState;
import com.jme.system.DisplaySystem;
import com.jme.system.JmeException;
import com.jme.util.TextureManager;
import com.jme.util.Timer;
public class TextureMapping extends BaseGame
{
private Node rootNode;
protected Timer timer;
private Camera cam;
protected InputHandler input;
private int width, height, depth, freq;
private boolean fullscreen;
private Sphere sphere = new Sphere("sphere1",150,150,10);
private float angle = 0;
Quaternion quad=new Quaternion();
Quaternion rotQuat=new Quaternion();
@Override
protected void update(float interpolation)
{
// TODO Auto-generated method stub
timer.update();
interpolation = timer.getTimePerFrame();
input.update(interpolation);
// if escape was pressed, we exit
if (KeyBindingManager.getKeyBindingManager().isValidCommand("exit"))
{
finished = true;
}
if (interpolation < 1)
{
angle = angle + (interpolation * 0.5f);
if (angle > 360)
{
angle = 0;
}
}
quad.fromAngleAxis(-FastMath.PI/2,new Vector3f(1,0,0));
rotQuat.fromAngleAxis(angle, new Vector3f(0, 1, 0));
rotQuat.multLocal(quad);
sphere.setLocalRotation(rotQuat);
}
@Override
protected void render(float interpolation)
{
// TODO Auto-generated method stub
display.getRenderer().clearBuffers();
display.getRenderer().draw(rootNode);
}
@Override
protected void initSystem()
{
// TODO Auto-generated method stub
width = properties.getWidth();
height = properties.getHeight();
depth = properties.getDepth();
freq = properties.getFreq();
fullscreen = properties.getFullscreen();
try
{
display = DisplaySystem.getDisplaySystem(properties.getRenderer());
display.createWindow(width, height, depth, freq, fullscreen);
cam = display.getRenderer().createCamera(width, height);
}
catch (JmeException e)
{
e.printStackTrace();
System.exit(1);
}
//set the background to black
display.getRenderer().setBackgroundColor(ColorRGBA.black);
//initialize the camera
cam.setFrustumPerspective(45.0f, (float)width / (float)height, 1, 1000);
Vector3f loc = new Vector3f(0.0f, 0.0f, 35.0f);
Vector3f left = new Vector3f(-1.0f, 0.0f, 0.0f);
Vector3f up = new Vector3f(0.0f, 1.0f, 0.0f);
Vector3f dir = new Vector3f(0.0f, 0f, -1.0f);
// Move our camera to a correct place and orientation.
cam.setFrame(loc, left, up, dir);
/** Signal that we've changed our camera's location/frustum. */
cam.update();
/** Create a input controller. */