Trouble with Variable and running the Program

Hi,



in the current stage of my program I want to switch on a light (not in the game…it's a lamp on the table). For this I use the X10 devices which are controlled through the powerline. In the program you can switch the lamp on or off with the key "L". That works very good. Now I want to show the user with a text when he can switch the light. Only in a close area in front of the light switch on the wall the key functions.

But when I use my TextStatus-Variable the code doesn't function anymore. Somehow jME ignores the code after the modification of the variable. :?



Maybe some of you can help me to fix this problem.



This is the misterious code:



/***** Light Control ******/


You are creating two Text objects here.  Try reusing the first one you create and make use of the .print(String) method.

Hi,



Thx for your hint. I've changed it. But the problem that I cannot clear the displayed text still exists.



I've tried it like this:



if((prevLoc.x >= 13) && (prevLoc.x <= 22) && (prevLoc.z <= 59) && (prevLoc.z >= 47) && (TextStatus == true)){

I would print out your prevLoc to make sure you are really getting what you think.  Also, when does TextStatus get set to false so that the second if will ever eval to true?  At least in the code, you've commented that out inside the first conditional.

hi,



the prevLoc is ok (I think), because I get the console outputs of "Hallo" and "Halloechen".



At the beginning of my program I initialze the variable : boolean TextStatus = true; and I forgot to delete the // , sorry…but I've done this because when I change the value the program ignores the if-statements where I switch lamp on or off. And I can press "L" and nothing happens. I placed some Systemouput-commands in the if-statements to check the correct program run…and nothing is displayed in the console. It's very strange, because in this code segment:



if ((KeyBindingManager.getKeyBindingManager().isValidCommand("Lights",true)) ) {

Can you post a full test example?  I'll track down your issue.

Hi,



here is the main part of my code. The rest only contains the loading of the models and the thirdperson handler with the chase camera.



import java.io.BufferedInputStream;

import java.io.ByteArrayInputStream;

import java.io.ByteArrayOutputStream;

import java.io.IOException;

import java.net.URL;

import java.util.HashMap;

import jmetest.input.TestThirdPersonController;

import com.jme.app.SimpleGame;

import com.jme.scene.Node;

import com.jme.scene.Text;

import com.jme.scene.shape.Box;

import com.jme.scene.state.TextureState;

import com.jme.image.Texture;

import com.jme.input.ChaseCamera;

import com.jme.input.KeyBindingManager;

import com.jme.input.KeyInput;

import com.jme.input.ThirdPersonHandler;

import com.jme.math.Vector3f;

import com.jme.util.LoggingSystem;

import com.jme.util.TextureManager;

import com.jmex.model.XMLparser.JmeBinaryReader;

import com.jmex.model.XMLparser.JmeBinaryWriter;

import com.jmex.model.XMLparser.XMLtoBinary;

import com.jmex.model.util.ModelLoader;

import com.jme.scene.state.LightState;

import com.jme.system.DisplaySystem;

import com.jme.light.LightNode;

import com.jme.light.PointLight;

import com.jme.light.SpotLight;

import com.jme.renderer.ColorRGBA;

import com.jme.bounding.BoundingBox;

import com.jme.input.InputSystem;

import com.jme.input.joystick.JoystickInput;

import com.jpeterson.x10.Gateway;

import com.jpeterson.x10.GatewayException;

import com.jpeterson.x10.SerialGateway;

import com.jpeterson.x10.Transmitter;

import com.jpeterson.x10.event.AddressEvent;

import com.jpeterson.x10.event.AllLightsOffEvent;

import com.jpeterson.x10.event.AllLightsOnEvent;

import com.jpeterson.x10.event.AllUnitsOffEvent;

import com.jpeterson.x10.event.BrightEvent;

import com.jpeterson.x10.event.DimEvent;

import com.jpeterson.x10.event.OffEvent;

import com.jpeterson.x10.event.OnEvent;

import com.jpeterson.x10.event.X10Event;



//****************************************************************

public class LaborXML_X10 extends SimpleGame{

private Transmitter transmitter;

You're doing a lot of object creation inside methods…  For example, you create a brand new Text object inside the update method which is creating tons of extra Text objects to be added to the scene.  Also, your Lamp method is creating an additional SpotLight object everytime you call it.  This is leading to multiple SpotLights, some on, some off, being added to the lightState.



What you need to do is only create these things 1 time in simpleInitGame.  Then NEVER EVER CREATE THEM AGAIN.  :)  Instead, you can disable them, clear them, etc.  Look for every time the word "new" is used and think to yourself, do I want a new XXXX?  Or am I trying to edit something already in the scene.



Also, please note that calling print(String) clears whatever is currently in a Text object, so there is no need to call it with a lot of spaces to "clear" out your old text.



I can not fully test things without some of the code you make reference to, but that should be enough to get you started.  Just fixing the object creation got my fps up from 50-60 (and falling) to a stable 1,000+.

ok, thanks a lot. I've changed the code and now I have a better frame rate (100+… maybe it depends on my pc???) and I can switch the table lamp in the real and virtual world on or off. Thanks!!!

I also did not have your scenegraph, so that makes a big difference.  Glad to hear things are working now, sounds like an interesting project!

Yes it is. The next steps are to implement a video texture, which is displayed on the virtual tv and also on the tv in the real world. I have an application to run a video file on a canvas but at this time I don't know how to implement it in my programm (it runs in parallel to the labor program).



Perhaps you know a code to run a video file as a texture in my program? I searched in this forum, but I didn't find an answer.