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 + "]"); } } }
public Form1() { InitializeComponent(); Application.Idle += Idle; trackBar1.ValueChanged += view.ChangeCamRotation; cube = (SCube)view.objects.Find(x => x.GetType() == typeof(SCube)); sphere = (SSphere)view.objects.Find(x => x.GetType() == typeof(SSphere)); inMatId.Maximum = inSphereMat.Maximum = inCubeMat.Maximum = view.materials.Count - 1; inMatId.Minimum = inSphereMat.Minimum = inCubeMat.Minimum = 0; inCubePosX.Text = cube.position.X.ToString(); inCubePosY.Text = cube.position.Y.ToString(); inCubePosZ.Text = cube.position.Z.ToString(); inCubeMat.Value = cube.materialID; inSpherePosX.Text = sphere.position.X.ToString(); inSpherePosY.Text = sphere.position.Y.ToString(); inSpherePosZ.Text = sphere.position.Z.ToString(); inSphereRad.Text = sphere.radius.ToString(); inSphereMat.Value = sphere.materialID; inMatId_ValueChanged(null, null); }
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()); } } }