public void ReSendObject(SObject obj) { SCamera cCam = obj as SCamera; SSphere cSphere = obj as SSphere; SLight cLight = obj as SLight; ICuttableToTriangles cICuttableToTriangles = obj as ICuttableToTriangles; if (cCam != null) { cCam.SendToShader(basicProgramID, "uCamera"); } else if (cSphere != null) { int id = spheres.FindIndex(x => x == cSphere); cSphere.SendToShader(basicProgramID, "spheres[" + id + "]"); } else if (cLight != null) { int id = lights.FindIndex(x => x == cLight); cLight.SendToShader(basicProgramID, "spheres[" + id + "]"); } else if (cICuttableToTriangles != null) { List <STriangle> trigs = cICuttableToTriangles.GetTriangles(); for (int i = 0; i < trigs.Count; i++) { int id = triangles.FindIndex(x => x == trigs[i]); trigs[i].SendToShader(basicProgramID, "triangles[" + id + "]"); } } }
static void SplitObjects(List <SObject> objects, out SCamera cam, out List <SSphere> spheres, out List <STriangle> triangles, out List <SLight> lights) { spheres = new List <SSphere>(); triangles = new List <STriangle>(); lights = new List <SLight>(); cam = null; for (int i = 0; i < objects.Count; i++) { SCamera cCam = objects[i] as SCamera; SSphere cSphere = objects[i] as SSphere; SLight cLight = objects[i] as SLight; ICuttableToTriangles cICuttableToTriangles = objects[i] as ICuttableToTriangles; if (cCam != null) { cam = cCam; } else if (cSphere != null) { spheres.Add(cSphere); } else if (cLight != null) { lights.Add(cLight); } else if (cICuttableToTriangles != null) { triangles.AddRange(cICuttableToTriangles.GetTriangles()); } } }