Hi all,
i’m pulling an image off a mjpeg stream to a game server then shipping the image bytes out to my gaming client in 2 messages. i’m able to re assemble the bytes into a byte buffer but i’m riding the struggle bus on getting the image to show up in game. I think im getting reall close since i get a bunch of pixels that flicker about.
when i set:
[java]gameClient.getWebcamViewerAppState().getImageTexture().setImage(new Image(jmeformat,640,480, readBuffer.duplicate()));[/java]
to 640, 480 i get :
and when i set it to
[java]gameClient.getWebcamViewerAppState().getImageTexture().setImage(new Image(jmeformat,100,100, readBuffer.duplicate()));[/java]
100x100 i get:
Here is the full code:
[java]
public class ClientListener implements MessageListener<Client>{
private GameClient gameClient;
private ByteBuffer readBuffer;
private int currentImage = 0;
final public Format jmeformat = Format.RGBA8;
public ClientListener(GameClient gameClient){
this.gameClient = gameClient;
readBuffer = ByteBuffer.allocateDirect((6404804));
}
public void messageReceived(Client source, Message message) {
if(message instanceof WebcamMessage){
WebcamMessage webcamMessage = (WebcamMessage) message;
if(webcamMessage.getPart() == 0){
readBuffer.put(webcamMessage.getImageData());
currentImage = webcamMessage.getImageNumber();
}else if(webcamMessage.getPart() == 1 && currentImage == webcamMessage.getImageNumber()){
readBuffer.put(webcamMessage.getImageData());
if(gameClient.getWebcamViewerAppState().getImageTexture() != null)
gameClient.getWebcamViewerAppState().getImageTexture().setImage(new Image(jmeformat,100,100, readBuffer.duplicate()));
readBuffer.clear();
}
}
}
}
[/java]
I’m kind of punting here and guessing the correct jme Format, the image is supposed to be 640x480. Any insight would be helpfull.
Thanks in advance
-Allman