Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Java 3D / December 2006

Tip: Looking for answers? Try searching our database.

Static Variables? and Lights on Textured Objects?

Thread view: 
dunctait@hotmail.com - 09 Dec 2006 13:41 GMT
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.
im driving the viewpoint around, using a keylistener i wrote. each box
has a collision detector (created in RunGame and added to the box) that
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
dunctait - 09 Dec 2006 20:56 GMT
got the static variable workin thanks... but the java3d problem is
still a problem..

thanks

> two problems.... the first is my main one, as my lecturer doesnt have a
> solution for this and is annoying him also.
[quoted text clipped - 80 lines]
> thanks for any help in advance,
> duncan


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.