Hi everyone.
My situation is quite simple. I need to represent BoundingBoxes, and to do so, I simply used cubes. It made it really easy to manipulate it. But now, I need to have different colors for each of the faces of my cube. My first try consisted in simply creating six planes that I attached to a cube game object . This way, I can still use my cube GO to manipulate the BB and I was to lazy to think of a more efficient solution. Here is part of the code I used :
boundingBox = new GameObject();
// Face 1 : P1, P2, P3, P4
GameObject plane1 = GameObject.CreatePrimitive(PrimitiveType.Plane);
Material m1 = new Material(Shader.Find("Custom/Unlit"));
m1.color = color1;
plane1.renderer.material = m1;
plane1.transform.parent = boundingBox.transform;
plane1.transform.position = new Vector3(0.0f,0.0f,0.5f);
plane1.transform.localRotation = Quaternion.FromToRotation(new Vector3(0.0f,1.0f,0.0f),new Vector3(0.0f,0.0f,1.0f));
plane1.transform.localScale = new Vector3(0.1f,1.0f,0.1f);
...
It does work (I can see my cubes), but my application is now extremely slow. I guess that having to apply all the transformations of my BB on each of the plane requires a lot of computation time.
The efficient solution would be to simply draw polygons from my vertices. I now have Unity Pro, so I was wondering if there was a simple way to Call OpenGL function DrawPolygon …
Otherwise, what solution would be the best for my problem.
Thank’s guys.
Quentin.