- Home /
GL.MultMatrix multiple instances drawing
I was modifying a script I found on the forums for drawing an object's wireframe, but tyis line was giving me trouble:
GL.MultMatrix(transform.localToWorldMatrix);
It was causing the wireframe to be drawn rotated and off scaled from the original model. I removed the line and it started to draw on top of the model like it was supposed to, however now in the background it seems to draw the object multiple times in different locations. What is actually going on is something with the camera matrix because once I move to get a closer look at the multiple objects, they disappear and new ones 'spawn' further out. Here is the OnRenderObject method:
void OnRenderObject()
{
meshRenderer.material.color = backgroundColor;
lineMaterial.SetPass(0);
//GL.PushMatrix();
//GL.MultMatrix(transform.localToWorldMatrix);
GL.Begin(GL.LINES);
for (int i = 0; i < lines.Length / 3; i++)
{
lineColor = new Color(Random.Range(0, 40f / 255f), Random.Range(0.6f, 1f), Random.Range(0.5f, 1f), currentAlpha);
GL.Color(lineColor);
GL.Vertex(lines[i * 3]);
GL.Vertex(lines[i * 3 + 1]);
GL.Vertex(lines[i * 3 + 1]);
GL.Vertex(lines[i * 3 + 2]);
GL.Vertex(lines[i * 3 + 2]);
GL.Vertex(lines[i * 3]);
}
GL.End();
//GL.PopMatrix();
}
Comment