This discussion is archived
2 Replies Latest reply: Apr 13, 2013 12:36 PM by KonradZuse RSS

PhongMaterial.setMaterial "bug" with MeshView and multiple TriangleMesh's

KonradZuse Explorer
Currently Being Moderated
Basically I am creating a group of TriangleMesh's by using 1 mesh, creating a new instance of the view each time, and just setting the coordinates to create a group that has stacks high, wide, and deep.

In the code I was originally trying to do
(if w % 2 ==0) 
{
p.setDiffuseColor(Color.RED)
}
{
else
{
//blue
}
This resulted in only displaying the second color in this case, or the first color if w%2 != 0, which was weird.


I then got into this next issue with trying to set both the wide and the high.
 protected final void populate()
                {
                    for(int w = 0; w < wide; w++)
                    {
                       MeshView meshV = new MeshView(this.mesh);

                           p.setDiffuseColor(Color.AQUA);
                        
                      
                        meshV.setMaterial(p);
                        
                         super.getChildren().add(meshV);
                         
                    }

                    for(int h = 0; h < high; h++)
                    {
                       MeshView meshV = new MeshView(this.mesh);
                      

                           p.setDiffuseColor(Color.ANTIQUEWHITE);
                   
                        meshV.setMaterial(p);
 super.getChildren().add(meshV);

                }
if try setting the material in both loops I will get all of the MeshV's to be ANTIQUEWHITE. if I get rid of the second setMaterial I will have the first set ANTIQUEWHITE and the second gray. vise-versa results in the first being gray, and the second ANTIQUEWHITE.


Now to me this seems as if it's setting everything with just that 1 setMaterial, but I don't know why if I'm creating a new instance every time. if it was the same MeshV, maybe, but in this case it's weird... I have no real use for manipulating the MeshView later on, I just need to create the Meshs and then set their distance apart, which the code for that isn't shown above.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points