HiAll,
I have a main class A(extends simplegame) , a class B
I initialise class B in class A
[java] private void createObjects(){
float xInit = currentWorld.getLocalTranslation().x;
float xExtent = ((BoundingBox) currentWorld.getWorldBound()).getXExtent();
// b=new Box(Vector3f.ZERO,1,1,1);
//blue = new Geometry("Box", b);
//Material mat1 = new Material(assetManager,
// "Common/MatDefs/Misc/Unshaded.j3md");
//mat1.setColor("Color", ColorRGBA.Blue);
//blue.setMaterial(mat1);
//blue.move(-(xInit+xExtent),0.5f,0);
tempS = c.getCar(currentWorld, assetManager);
rootNode.attachChild(tempS);
}
private void initializeObjects() {
//Vector3f newObjectVector=currentWorld.getLocalTranslation();
c=new Car();
}[/java]
In class B i add a custom control to the object
[java]Spatial getCar(Spatial currentWorld, AssetManager assetManager ) {
this.currentWorld = currentWorld;
//myControl=new myControl();
System.out.println("Am i here? really?");
float xInit = currentWorld.getLocalTranslation().x;
float xExtent = ((BoundingBox) currentWorld.getWorldBound()).getXExtent();
Box b = new Box(Vector3f.ZERO, 1, 1, 1);
Geometry blue = new Geometry("Box", b);
Material mat1 = new Material(assetManager,
"Common/MatDefs/Misc/Unshaded.j3md");
mat1.setColor("Color", ColorRGBA.Blue);
blue.setMaterial(mat1);
blue.move(-(xInit+xExtent),0.5f,0);
blue.addControl(new myControl());
return blue;
}[/java]
Now in the custom control UPDATE loop i need to get one variable(Node) to check collision. Or at least i need to get the controlled object class variable ( Car c in this case)
is it possible? if yes how?
PS I tried passing some object in custom control constructor but it doesnt work.