Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > Static Variables? and Lights on Textured Objects?
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 20th June 06:28
External User
 
Posts: 1
Default Static Variables? and Lights on Textured Objects?



two problems.... the first is my main one, as my lecturer doesnt have a
solution for this and is annoying him also.


the problem is i have a java3d scene, 4 polygon walls, put a texture on
them. add a single light. but the walls appear as if they are lit up,
bright as day.

i looked it up and found out about "lighting normals", in a quadarray,
but im having the same problem with a textured box. anyway know how to
set up a texture to be affected by light also?

example wall code:

Color3f ambient = new Color3f(0.0f, 0.0f, 0.0f);
Color3f emissive = new Color3f(0.0f, 0.0f, 0.0f);
Color3f diffuse = new Color3f(0.0f, 0.0f, 0.0f);
Color3f specular = new Color3f(0.0f, 0.0f, 0.0f);
float shininess = 0.1f;
Material wallmat = new Material(ambient, emissive, diffuse,
specular, shininess);

Vector3f polygonxnormal = new Vector3f(1f,0f,0f);
Vector3f polygonynormal = new Vector3f(0f,1f,0f);
Vector3f polygonznormal = new Vector3f(0f,0f,1f);

Appearance wallAppearance = new Appearance();
wallAppearance.setTexture(texwall);
wallAppearance.setMaterial(wallmat);

QuadArray westwall = new QuadArray (4,QuadArray.COORDINATES |
QuadArray.NORMALS | GeometryArray.TEXTURE_COORDINATE_2);
westwall.setCoordinate (0, new Point3f (0f, 0f, 0f));
westwall.setCoordinate (1, new Point3f (0f, 0f, -200f));
westwall.setCoordinate (2, new Point3f (0f, 6f, -200f));
westwall.setCoordinate (3, new Point3f (0f, 6f, 0f));

westwall.setTextureCoordinate (0, new Point2f(0f,0f));
westwall.setTextureCoordinate (1, new Point2f(50f,0f));
westwall.setTextureCoordinate (2, new Point2f(50f,1f));
westwall.setTextureCoordinate (3, new Point2f(0f,1f));


westwall.setNormal(0,polygonxnormal);
westwall.setNormal(1,polygonxnormal);
westwall.setNormal(2,polygonxnormal);
westwall.setNormal(3,polygonxnormal);


example box code:

Appearance boxapp = new Appearance();
texbox.setBoundaryModeS(Texture.CLAMP);
texbox.setBoundaryModeT(Texture.CLAMP);
boxapp.setTexture(texbox);

ambient = new Color3f(0.0f, 0.0f, 1f);
emissive = new Color3f(0.0f, 0.0f, 0.0f);
diffuse = new Color3f(0f, 0f, 0f);
specular = new Color3f(0f, 0f, 0f);
shininess = 0f;

Material boxmat = new Material(ambient, emissive, diffuse,
specular, shininess);

boxapp.setMaterial(boxmat);


for (int i=0; i<numberofobstacles; i++) {
obstacles.addChild(createObstacles(boxapp));
}


the second problem im having is probably much easier.


can print to the console, like "box hit by viewpoint".
but what i want to do, is update a "score" variable in RunGame (i.e
RunGame.score++) in a thread that keeps checking the varaible to see if
its changed, and if it has, updatea a JTextArea.
but since RunGame created Collision, Collision cant call a method in
RunGame.

i realise this is a static problem, but i dont understand them too
well. how could i access the "score" variable from Collision.java AND
RunGame.java.

thanks for any help in advance,
duncan
  Reply With Quote


  sponsored links


2 20th June 06:28
dunctait
External User
 
Posts: 1
Default Static Variables? and Lights on Textured Objects?



got the static variable workin thanks... but the java3d problem is
still a problem..

thanks
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666