/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { List <IGH_Goo> X = new List <IGH_Goo>(); if (!DA.GetDataList(0, X)) { return; } ThreeJS tJS = new ThreeJS(); tJS.SetHeader(new Header()); tJS.SetFooter(new Footer()); int i = 0; List <wMesh> Meshes = new List <wMesh>(); foreach (IGH_Goo Obj in X) { wMesh M = new wMesh(); Obj.CastTo(out M); fMesh tMesh = new fMesh(M); tMesh.BuildThreeGeometry(i); tJS.AddGeometry(tMesh); i += 1; } tJS.Assemble(); DA.SetData(0, tJS); }
private void OpenGLControl_OpenGLDraw() { // Get the OpenGL instance that's been passed to us. ObjectGL = ControlGL.OpenGL; // Clear the color and depth buffers. ObjectGL.ClearColor(1.0f, 1.0f, 1.0f, 1.0f); ObjectGL.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); ObjectGL.Enable(OpenGL.GL_DEPTH_TEST); // Reset the modelview matrix. ObjectGL.LoadIdentity(); // Move the geometry into a fairly central position. ObjectGL.Translate(0.0f, 0.0f, -3.0f); // Start drawing triangles. wMesh Mesh = Meshes[0]; SetMesh(Mesh); // Flush OpenGL. ObjectGL.Flush(); }
public wMeshToRhMesh(wMesh inputMesh) { foreach (wVertex v in inputMesh.Vertices) { this.Vertices.Add(new Point3d(v.X, v.Y, v.Z)); } foreach (wFace f in inputMesh.Faces) { this.Faces.AddFace(new MeshFace(f.A, f.B, f.C)); } this.FaceNormals.ComputeFaceNormals(); this.Normals.ComputeNormals(); this.Normals.UnitizeNormals(); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { // Declare variables IGH_Goo X = null; // Access the input parameters if (!DA.GetData(0, ref X)) { return; } wMesh M = new wMesh(); X.CastTo(out M); x3Dviewer LayerObject = new x3Dviewer(M); DA.SetData(0, LayerObject.OutputBitmap); }
private void OpenGLControl_OpenGLDraw() { // Get the OpenGL instance that's been passed to us. ObjectGL = ControlGL.OpenGL; // Clear the color and depth buffers. ObjectGL.ClearColor(1.0f, 1.0f, 1.0f, 1.0f); ObjectGL.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT | OpenGL.GL_STENCIL_BUFFER_BIT); // Reset the modelview matrix. ObjectGL.LoadIdentity(); ObjectGL.Translate(0, 0, -10.0); // Start drawing triangles. wMesh Mesh = Meshes[0]; SetMesh(Mesh); // Flush OpenGL. ObjectGL.Flush(); }
public void SetMesh(wMesh Mesh) { ObjectGL.Begin(OpenGL.GL_TRIANGLES); foreach (wFace F in Mesh.Faces) { wVertex V = Mesh.Vertices[F.A]; wColor C = Mesh.Colors[F.A]; ObjectGL.Color((float)((double)C.R / 255.0), (float)((double)C.G / 255.0), (float)((double)C.B / 255.0)); ObjectGL.Vertex(V.X, V.Y, V.Z); V = Mesh.Vertices[F.B]; C = Mesh.Colors[F.B]; ObjectGL.Color((float)((double)C.R / 255.0), (float)((double)C.G / 255.0), (float)((double)C.B / 255.0)); ObjectGL.Vertex(V.X, V.Y, V.Z); V = Mesh.Vertices[F.C]; C = Mesh.Colors[F.C]; ObjectGL.Color((float)((double)C.R / 255.0), (float)((double)C.G / 255.0), (float)((double)C.B / 255.0)); ObjectGL.Vertex(V.X, V.Y, V.Z); } ObjectGL.End(); ObjectGL.Disable(OpenGL.GL_CULL_FACE); }
public fMesh(wMesh InputMesh) { Mesh = InputMesh; }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { string ID = this.Attributes.InstanceGuid.ToString(); string name = new GUIDtoAlpha(Convert.ToString(ID + Convert.ToString(this.RunCount)), false).Text; int C = this.RunCount; wObject WindObject = new wObject(); pElement Element = new pElement(); bool Active = Elements.ContainsKey(C); var pCtrl = new pMeshViewer(name); if (Elements.ContainsKey(C)) { Active = true; } //Check if control already exists if (Active) { if (Elements[C] != null) { WindObject = Elements[C]; Element = (pElement)WindObject.Element; pCtrl = (pMeshViewer)Element.ParrotControl; } } else { pCtrl.SetProperties(); Elements.Add(C, WindObject); } //Set Unique Control Properties List <IGH_Goo> X = new List <IGH_Goo>(); List <IGH_Goo> Y = new List <IGH_Goo>(); IGH_Goo U = null; if (Params.Input[1].VolatileDataCount < 1) { UpdateLightInput(1); } //if (Params.Input[2].VolatileDataCount < 1) { UpdateCameraInput(2); } if (!DA.GetDataList(0, X)) { return; } if (!DA.GetDataList(1, Y)) { return; } if (!DA.GetData(2, ref U)) { return; } wCamera V = new wCamera(); U.CastTo(out V); List <wMesh> Meshes = new List <wMesh>(); foreach (IGH_Goo Obj in X) { wMesh M = new wMesh(); Obj.CastTo(out M); Meshes.Add(M); } pCtrl.SetMeshes(Meshes); List <wLight> Lights = new List <wLight>(); foreach (IGH_Goo Obj in Y) { wLight L = new wLight(); Obj.CastTo(out L); Lights.Add(L); } pCtrl.SetLights(Lights); pCtrl.BuildScene(); pCtrl.SetCamera(V); pCtrl.SetNavigation(HasNavigation); pCtrl.SetGizmo(HasGizmo); pCtrl.SetCoordinateSystem(HasCoordinates); //if (V.IsPreset) { pCtrl.ZoomExtents(1.0); } if (ZoomExtents) { pCtrl.ZoomExtents(1.0); ZoomExtents = false; } //Set Parrot Element and Wind Object properties if (!Active) { Element = new pElement(pCtrl.Element, pCtrl, pCtrl.Type); } WindObject = new wObject(Element, "Parrot", Element.Type); WindObject.GUID = this.InstanceGuid; WindObject.Instance = C; Elements[this.RunCount] = WindObject; DA.SetData(0, WindObject); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Mesh M = new Mesh(); Plane P = Plane.WorldXY; IGH_Goo X = null; if (Params.Input[2].VolatileDataCount < 1) { UpdateMaterial(2); } if (!DA.GetData(0, ref M)) { return; } if (!DA.GetData(1, ref P)) { return; } if (!DA.GetData(2, ref X)) { return; } X.CastTo(out Shader); wShader Sh = new wShader(); Sh.DiffuseColor = new wColor(Shader.Diffuse); Sh.SpecularColor = new wColor(Shader.Specular); Sh.SpecularValue = Shader.Shine; Sh.EmissiveColor = new wColor(Shader.Emission); Sh.Transparency = (1.0 - Shader.Transparency); Sh.SetDiffuseTransparency(); M.Faces.ConvertQuadsToTriangles(); M.Normals.ComputeNormals(); if (M.VertexColors.Count != M.Vertices.Count) { M.VertexColors.CreateMonotoneMesh(System.Drawing.Color.LightGray); } wMesh MeshObject = new wMesh(); MeshObject.Material = Sh; for (int i = 0; i < M.Vertices.Count; i++) { MeshObject.AddVertex(M.Vertices[i].X, M.Vertices[i].Y, M.Vertices[i].Z, i, new wColor(M.VertexColors[i])); MeshObject.AddNormal(M.Normals[i].X, M.Normals[i].Y, M.Normals[i].Z, i); } for (int i = 0; i < M.Faces.Count; i++) { MeshObject.AddTriangularFace(M.Faces[i].A, M.Faces[i].B, M.Faces[i].C, i); MeshObject.AddFaceNormal(M.FaceNormals[i].X, M.FaceNormals[i].Y, M.FaceNormals[i].Z, i); } for (int i = 0; i < M.TopologyEdges.Count; i++) { MeshObject.AddEdges(M.TopologyVertices.MeshVertexIndices(M.TopologyEdges.GetTopologyVertices(i).I)[0], M.TopologyVertices.MeshVertexIndices(M.TopologyEdges.GetTopologyVertices(i).J)[0]); } DA.SetData(0, MeshObject); }
private void wMeshToRhMesh(wMesh msh) { throw new NotImplementedException(); }