package pylos.view;

import pylos.Pylos;
import pylos.model.Ball;

import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Sphere;

public class BallGraphics {
	Ball model;
	public final static float DIAMETER = 1.38f;
	public float x, y, z;
	Geometry geometry;

	public BallGraphics(Ball model) {
		this.model = model;
	}

	public void setPosition(float x, float y, float z) {
		this.x = x;
		this.y = y;
		this.z = z;
	}

	public void move() {
		geometry.move(x, y, z);
	}

	public void create() {
		Sphere s = new Sphere(50, 50, DIAMETER / 2);
		geometry = new Geometry("Ball #" + model.i + " (" + model.owner.side + ")", s);
		Material mat = new Material(Pylos.view.getAssetManager(), "Common/MatDefs/Misc/SolidColor.j3md");
		mat.setColor("Color", ColorRGBA.randomColor());
		geometry.setMaterial(mat);
	}
}

@@ -58,16 +58,42 @@
 el.Ball;
+%0Aimport pylos.model.Model;
 %0A%0Aimport
@@ -589,16 +589,32 @@
 ate() %7B%0A
+%09%09Material mat;%0A
 %09%09Sphere
@@ -652,16 +652,16 @@
 R / 2);%0A
-
 %09%09geomet
@@ -736,25 +736,55 @@
 , s);%0A%09%09
-Material 
+if (model.owner == Model.player1) %7B%0A%09%09%09
 mat = ne
@@ -844,31 +844,30 @@
 efs/
-Misc/SolidColor
+Light/Lighting
 .j3md%22);
 %0A%09%09m
@@ -866,58 +866,151 @@
 d%22);
+ 
 %0A%09%09
-mat.setColor(%22Color%22
+%7D else %7B%0A%09%09%09mat = new Material(Pylos.view.getAssetManager()
 , 
+%22
 Co
-lorRGBA.randomColor());
+mmon/MatDefs/Light/Lighting.j3md%22);%0A%09%09%09mat.setFloat(%22Shininess%22, 0.5f);%0A%09%09%7D
 %0A%09%09g

Set new material for balls