void SetMaterial(MSceneObject mo, string sMaterialID) { if (sMaterialID == null) { sMaterialID = MMaterial.DEFAULT_MATERIAL; } //MSceneObject mo = (MSceneObject)MScene.ModelRoot.FindModuleByInstanceID(e.InstanceID); MObject o = MScene.MaterialRoot.FindModuleByName(sMaterialID); MMaterial mat = null; if (o != null && o.Type == MObject.EType.Material) { mat = (MMaterial)o; if (mat != null) { mo.SetMaterial(mat); mat.MaterialID = sMaterialID; } } if (MassiveTools.IsURL(sMaterialID)) { mat = (MMaterial) new MMaterial("URLShader"); MShader DefaultShader = (MShader)MScene.MaterialRoot.FindModuleByName(MShader.DEFAULT_SHADER); mat.AddShader(DefaultShader); mat.ReplaceTexture(Globals.TexturePool.GetTexture(sMaterialID)); mat.MaterialID = sMaterialID; MScene.MaterialRoot.Add(mat); mo.SetMaterial(mat); mo.material.Setup(); } }
protected void btnEditar_Click(object sender, EventArgs e) { try { IMateriales iMat = new MMaterial(); DATOS.Material material = new DATOS.Material { codigo_mat = txtCodigomat.Text.ToUpper(), descripcion = txtDescrip.Text.ToUpper(), cantidad = Convert.ToInt32(txtCantidad.Text), unidad = txtUnidad.Text.ToUpper(), }; iMat.ActualizarMaterial(material); mensaje.Visible = true; mensajeError.Visible = false; textoMensaje.InnerHtml = "Material actualizado"; textoMensajeError.InnerHtml = string.Empty; } catch (Exception) { mensaje.Visible = false; mensajeError.Visible = true; textoMensaje.InnerHtml = string.Empty; textoMensajeError.InnerHtml = "Material no actualizado"; } }
private void Network_TextureHandler(object sender, Massive.Events.TextureEvent e) { MSceneObject mo = (MSceneObject)MScene.ModelRoot.FindModuleByInstanceID(e.InstanceID); MObject o = MScene.MaterialRoot.FindModuleByName(e.TextureID); if (o != null && o.Type == MObject.EType.Material) { MMaterial mat = (MMaterial)o; mo.SetMaterial(mat); } else { if (MassiveTools.IsURL(e.TextureID)) { MMaterial mat = (MMaterial) new MMaterial("URLShader"); MShader DefaultShader = (MShader)MScene.MaterialRoot.FindModuleByName(MShader.DEFAULT_SHADER); mat.AddShader(DefaultShader); mat.ReplaceTexture(Globals.TexturePool.GetTexture(e.TextureID)); MScene.MaterialRoot.Add(mat); mo.SetMaterial(mat); mo.material.Setup(); MMessageBus.ChangedTexture(this, e.InstanceID, e.TextureID); } else { Console.WriteLine("Object " + e.InstanceID + " was null"); MMessageBus.Error(this, "Could not find Material:" + e.TextureID); } } }
public void Render(Matrix4x4 matrix) { Material mat = null; switch (entityStatus) { case MEntityStatus.DEFAULT: mat = MMaterial.GetDefaultPointMat(); break; case MEntityStatus.ACTIVE: mat = MMaterial.GetActivePointMat(); break; case MEntityStatus.SELECT: mat = MMaterial.GetSelectPointMat(); break; case MEntityStatus.SPECIAL: mat = MMaterial.GetSpecialPointMat(); break; case MEntityStatus.TRANSPARENT: mat = null; break; default: Debug.Log("MPoint: unkown entity status: " + entityStatus); break; } if (mat != null && mesh != null) { Graphics.DrawMesh(mesh, matrix, mat, 0); } }
protected void Page_Load(object sender, EventArgs e) { IMateriales iMateriales = new MMaterial(); if (Session["SesRol"] != null) { var rol = Session["SesRol"]; if (Convert.ToInt32(rol) == 1) { dgvCodMat.Visible = true; dgvCodMatLectura.Visible = false; dgvCodMat.DataSource = iMateriales.ListarMaterial(); dgvCodMat.DataBind(); dgvCodMat.HeaderRow.Cells[2].Text = "Código"; dgvCodMat.HeaderRow.Cells[3].Text = "Descripción"; dgvCodMat.HeaderRow.Cells[4].Text = "Cantidad"; dgvCodMat.HeaderRow.Cells[5].Text = "Unidad del artículo"; } if (Convert.ToInt32(rol) == 2 | Convert.ToInt32(rol) == 3) { dgvCodMat.Visible = false; dgvCodMatLectura.Visible = true; dgvCodMatLectura.DataSource = iMateriales.ListarMaterial(); dgvCodMatLectura.DataBind(); dgvCodMatLectura.HeaderRow.Cells[0].Text = "Código"; dgvCodMatLectura.HeaderRow.Cells[1].Text = "Descripción"; dgvCodMatLectura.HeaderRow.Cells[2].Text = "Cantidad"; dgvCodMatLectura.HeaderRow.Cells[3].Text = "Unidad del artículo"; } } }
public ObjectCuttingState(SceneManager sceneManager, GameObject quad) { this.sceneManager = sceneManager; rightTriggerPressed = new VRTK.ControllerInteractionEventHandler(RightTriggerPressed); rightGripPressed = new VRTK.ControllerInteractionEventHandler(RightGripPressed); this.quad = quad; this.faceMat = MMaterial.GetShadingFaceMat(); this.edgeEffectMat = MMaterial.GetShadingEdgeMat(); }
void SetupMaterials() { MShader BasicShader = new MShader("BasicShader"); BasicShader.Load("default_v.glsl", "default_f.glsl", "Terrain\\eval.glsl", "Terrain\\control.glsl" ); BasicShader.Bind(); BasicShader.SetInt("material.diffuse", MShader.LOCATION_DIFFUSE); BasicShader.SetInt("material.specular", MShader.LOCATION_SPECULAR); BasicShader.SetInt("material.multitex", MShader.LOCATION_MULTITEX); BasicShader.SetInt("material.normalmap", MShader.LOCATION_NORMALMAP); BasicShader.SetInt("material.shadowMap", MShader.LOCATION_SHADOWMAP); MShader BoneShader = new MShader("AnimatedShader"); string sVertFile = "Animation\\animated_vs.glsl"; string sFragPath = "Animation\\animated_fs.glsl"; BoneShader.Load(sVertFile, sFragPath, "", "" ); BoneShader.Bind(); BoneShader.SetInt("material.diffuse", MShader.LOCATION_DIFFUSE); BoneShader.SetInt("material.specular", MShader.LOCATION_SPECULAR); BoneShader.SetInt("material.multitex", MShader.LOCATION_MULTITEX); BoneShader.SetInt("material.normalmap", MShader.LOCATION_NORMALMAP); BoneShader.SetInt("material.shadowMap", MShader.LOCATION_SHADOWMAP); foreach (KeyValuePair <string, MBuildingBlock> k in Blocks) { MBuildingBlock b = k.Value; if (b.Type == "MMaterial") { MMaterial MATM = new MMaterial(b.MaterialID); MATM.AddShader(BasicShader); MATM.SetDiffuseTexture(Globals.TexturePool.GetTexture(b.Path)); MScene.MaterialRoot.Add(MATM); } else if (b.Type == "MBoneMaterial") { MMaterial MATM = new MMaterial(b.MaterialID); MATM.AddShader(BoneShader); MATM.SetDiffuseTexture(Globals.TexturePool.GetTexture(b.Path)); MScene.MaterialRoot.Add(MATM); } } }
public override void Setup() { base.Setup(); Widget = Helper.CreateModel(MScene.Overlay, "NavigationWidget", @"Models\arrow02.3ds", Vector3d.Zero); MMaterial mat = new MMaterial("WidgetMaterial"); mat.AddShader((MShader)MScene.MaterialRoot.FindModuleByName(MShader.DEFAULT_SHADER)); mat.SetDiffuseTexture(Globals.TexturePool.GetTexture("Textures\\arrow02.png")); Widget.AddMaterial(mat); Widget.transform.Scale = new Vector3d(1, 1, 1); Widget.Enabled = true; }
private void ShaderEditorForm_Load(object sender, EventArgs e) { ShaderCombo.Items.Clear(); foreach (MObject mo in MScene.MaterialRoot.Modules) { if (!(mo is MMaterial)) { continue; } MMaterial m = (MMaterial)mo; ShaderCombo.Items.Add(m); ShaderCombo.ValueMember = "Name"; } }
public void getDrawRequestsShaded(MDrawRequest request, MDrawInfo info, MDrawRequestQueue queue, MDrawData data) { // Need to get the material info // MDagPath path = info.multiPath; // path to your dag object M3dView view = info.view; // view to draw to MMaterial material = base.material(path); M3dView.DisplayStatus displayStatus = info.displayStatus; // Evaluate the material and if necessary, the texture. // material.evaluateMaterial(view, path); bool drawTexture = true; if (drawTexture && material.materialIsTextured) { material.evaluateTexture(data); } request.material = material; bool materialTransparent = false; material.getHasTransparency(ref materialTransparent); if (materialTransparent) { request.isTransparent = true; } // create a draw request for wireframe on shaded if // necessary. // if ((displayStatus == M3dView.DisplayStatus.kActive) || (displayStatus == M3dView.DisplayStatus.kLead) || (displayStatus == M3dView.DisplayStatus.kHilite)) { MDrawRequest wireRequest = info.getPrototype(this); wireRequest.setDrawData(data); getDrawRequestsWireframe(wireRequest, info); wireRequest.token = (int)DrawShapeStyle.kDrawWireframeOnShaded; wireRequest.displayStyle = M3dView.DisplayStyle.kWireFrame; queue.add(wireRequest); } }
public override void Setup() { pickmaterial = new MMaterial("ScreenPick"); pickmaterial.shader = new MShader("ScreenPickShader"); pickmaterial.shader.Load("default_v.glsl", "pick_select_f.glsl", "Terrain\\eval.glsl", "Terrain\\control.glsl"); Add(pickmaterial); outlinematerial = new MMaterial("OutlineMaterial"); outlinematerial.shader = new MShader("OutlineShader"); outlinematerial.shader.Load("default_v.glsl", "outline_f.glsl", "Terrain\\eval.glsl", "Terrain\\control.glsl"); Add(outlinematerial); }
public override void SetMaterial(MMaterial m) { base.SetMaterial(m); foreach (MObject mo in Modules) { if (mo is MAnimatedMesh) { MAnimatedMesh mao = (MAnimatedMesh)mo; mao.SetMaterial(material); } } //foreach( MAnimatedMesh mesh in Meshes) //{ // mesh.SetMaterial(material); // } }
protected void Page_Load(object sender, EventArgs e) { string valor = string.Concat(Request.QueryString["id"]); txtIDOrden.Text = valor; txtIDOrden.ReadOnly = true; var fech = DateTime.Now; txtFecha.Text = Convert.ToString(fech); if (Session["SesRol"] != null) { var rol = Session["SesRol"]; try { if (Convert.ToInt32(rol) == 1) { IMateriales iMateriales = new MMaterial(); dgvMateriales.DataSource = iMateriales.ListarMaterial(); dgvMateriales.DataBind(); dgvMateriales.HeaderRow.Cells[1].Text = "Código"; dgvMateriales.HeaderRow.Cells[2].Text = "Descripción"; dgvMateriales.HeaderRow.Cells[3].Text = "Cantidad en Stock"; dgvMateriales.HeaderRow.Cells[4].Text = "Unidad del artículo"; TESTConfig.ListaItems = TESTConfig.ListaItems.OrderBy(x => x.codigo_mat).ToList(); dgvListaPedido.DataSource = TESTConfig.ListaItems; dgvListaPedido.DataBind(); } if (Convert.ToInt32(rol) == 2 | Convert.ToInt32(rol) == 3) { Response.Redirect("~/Default.aspx"); } } catch (Exception) { throw; } } else { Response.Redirect("~/Login.aspx"); } }
void CheckPick(Point p, bool DoubleClick = false, bool RightClick = false) { GL.Enable(EnableCap.DepthTest); GL.ClearColor(Color.Black); GL.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit); MScene.ScreenPick.RenderPick(MScene.ModelRoot); //_glcontrol.SwapBuffers(); Vector3d p3d = new Vector3d(p.X, _glcontrol.Height - p.Y, 0); int index = _Scene.GetPick(p3d); //Log("Pick id:" + index + " @" + p.ToString()); if (index != -1) { //Console.WriteLine("Clicked:" + index); MObject mobj = MScene.ModelRoot.FindModuleByIndex(index, null); if (mobj == null) { return; } if (!mobj.Renderable) { return; } MSceneObject mo = (MSceneObject)mobj; if (mo != null) { if ((mo.Type == MObject.EType.Mesh) && (mo.Parent.Renderable)) { mo = (MSceneObject)mo.Parent; } else { return; } //Console.WriteLine("Pick id:" + index + " @" + p.ToString() + " Owner:" + mo.OwnerID); if (mo.OwnerID == null) { MMessageBus.Status(this, "ID: + " + mo.Index + " Object " + mo.Name + " with ID:" + mo.InstanceID + " has no owner"); } else if (!mo.OwnerID.Equals(Globals.UserAccount.UserID)) { MMessageBus.Status(this, "ID:" + mo.Index + " Object " + mo.Name + "," + mo.InstanceID); } // else { mo.OnClick(DoubleClick, RightClick); MMessageBus.Select(this, new SelectEvent(mo)); MMaterial m = (MMaterial)mo.FindModuleByType(EType.Material); MMessageBus.Status(this, "Selected:" + mo.TemplateID + "," + mo.InstanceID); } } MScene.SelectedObject = mo; } else { MScene.SelectedObject = null; } }
public override void getDrawRequests(MDrawInfo info, bool objectAndActiveOnly, MDrawRequestQueue queue) { apiSimpleShape shapeNode = surfaceShape as apiSimpleShape; if (shapeNode == null) { return; } // This call creates a prototype draw request that we can fill // in and then add to the draw queue. // MDrawRequest request = info.getPrototype(this); MDrawData data; MVectorArray geomPtr = shapeNode.controlPoints; // Stuff our data into the draw request, it'll be used when the drawing // actually happens getDrawData(geomPtr, out data); request.setDrawData(data); // Decode the draw info and determine what needs to be drawn // M3dView.DisplayStyle appearance = info.displayStyle; M3dView.DisplayStatus displayStatus = info.displayStatus; switch (appearance) { case M3dView.DisplayStyle.kWireFrame: { request.token = (int)DrawShapeStyle.kDrawWireframe; M3dView.ColorTable activeColorTable = M3dView.ColorTable.kActiveColors; M3dView.ColorTable dormantColorTable = M3dView.ColorTable.kDormantColors; switch (displayStatus) { case M3dView.DisplayStatus.kLead: request.setColor(LEAD_COLOR, (int)activeColorTable); break; case M3dView.DisplayStatus.kActive: request.setColor(ACTIVE_COLOR, (int)activeColorTable); break; case M3dView.DisplayStatus.kActiveAffected: request.setColor(ACTIVE_AFFECTED_COLOR, (int)activeColorTable); break; case M3dView.DisplayStatus.kDormant: request.setColor(DORMANT_COLOR, (int)dormantColorTable); break; case M3dView.DisplayStatus.kHilite: request.setColor(HILITE_COLOR, (int)activeColorTable); break; default: break; } queue.add(request); break; } case M3dView.DisplayStyle.kGouraudShaded: { // Create the smooth shaded draw request // request.token = (int)DrawShapeStyle.kDrawSmoothShaded; // Need to get the material info // MDagPath path = info.multiPath; // path to your dag object M3dView view = info.view; // view to draw to MMaterial material = base.material(path); // Evaluate the material and if necessary, the texture. // material.evaluateMaterial(view, path); bool drawTexture = true; if (drawTexture && material.materialIsTextured) { material.evaluateTexture(data); } request.material = material; bool materialTransparent = false; material.getHasTransparency(ref materialTransparent); if (materialTransparent) { request.isTransparent = true; } queue.add(request); // create a draw request for wireframe on shaded if // necessary. // if ((displayStatus == M3dView.DisplayStatus.kActive) || (displayStatus == M3dView.DisplayStatus.kLead) || (displayStatus == M3dView.DisplayStatus.kHilite)) { MDrawRequest wireRequest = request; wireRequest.setDrawData(data); wireRequest.token = (int)DrawShapeStyle.kDrawWireframeOnShaded; wireRequest.displayStyle = M3dView.DisplayStyle.kWireFrame; M3dView.ColorTable activeColorTable = M3dView.ColorTable.kActiveColors; switch (displayStatus) { case M3dView.DisplayStatus.kLead: wireRequest.setColor(LEAD_COLOR, (int)activeColorTable); break; case M3dView.DisplayStatus.kActive: wireRequest.setColor(ACTIVE_COLOR, (int)activeColorTable); break; case M3dView.DisplayStatus.kHilite: wireRequest.setColor(HILITE_COLOR, (int)activeColorTable); break; default: break; } queue.add(wireRequest); } break; } case M3dView.DisplayStyle.kFlatShaded: request.token = (int)DrawShapeStyle.kDrawFlatShaded; break; default: break; } // Add draw requests for components // if (!objectAndActiveOnly) { // Inactive components // if ((appearance == M3dView.DisplayStyle.kPoints) || (displayStatus == M3dView.DisplayStatus.kHilite)) { MDrawRequest vertexRequest = request; vertexRequest.setDrawData(data); vertexRequest.token = (int)DrawShapeStyle.kDrawVertices; vertexRequest.setColor(DORMANT_VERTEX_COLOR, (int)M3dView.ColorTable.kActiveColors); queue.add(vertexRequest); } // Active components // if (shapeNode.hasActiveComponents) { MDrawRequest activeVertexRequest = request; activeVertexRequest.setDrawData(data); activeVertexRequest.token = (int)DrawShapeStyle.kDrawVertices; activeVertexRequest.setColor(ACTIVE_VERTEX_COLOR, (int)M3dView.ColorTable.kActiveColors); MObjectArray clist = shapeNode.activeComponents; MObject vertexComponent = clist[0]; // Should filter list activeVertexRequest.component = vertexComponent; queue.add(activeVertexRequest); } } }
public override void draw(MDrawRequest request, M3dView view) // // From the given draw request, get the draw data and determine // which quadric to draw and with what values. // { MDrawData data = request.drawData(); quadricGeom geom = data.geometry() as quadricGeom; DrawShapeStyle token = (DrawShapeStyle)request.token; bool drawTexture = false; view.beginGL(); if ((token == DrawShapeStyle.kDrawSmoothShaded) || (token == DrawShapeStyle.kDrawFlatShaded)) { OpenGL.glEnable((uint)OpenGL.GL_POLYGON_OFFSET_FILL); // Set up the material // MMaterial material = request.material; material.setMaterial(request.multiPath, request.isTransparent); // Enable texturing // drawTexture = material.materialIsTextured; if (drawTexture) { OpenGL.glEnable((uint)OpenGL.GL_TEXTURE_2D); } // Apply the texture to the current view // if (drawTexture) { material.applyTexture(view, data); } } IntPtr qobj = GLUFunctionInvoker.gluNewQuadric(); switch (token) { case DrawShapeStyle.kDrawWireframe: case DrawShapeStyle.kDrawWireframeOnShaded: GLUFunctionInvoker.gluQuadricDrawStyle(qobj, GLU_LINE); break; case DrawShapeStyle.kDrawSmoothShaded: GLUFunctionInvoker.gluQuadricNormals(qobj, GLU_SMOOTH); GLUFunctionInvoker.gluQuadricTexture(qobj, GLtrue); GLUFunctionInvoker.gluQuadricDrawStyle(qobj, GLU_FILL); break; case DrawShapeStyle.kDrawFlatShaded: GLUFunctionInvoker.gluQuadricNormals(qobj, GLU_FLAT); GLUFunctionInvoker.gluQuadricTexture(qobj, GLtrue); GLUFunctionInvoker.gluQuadricDrawStyle(qobj, GLU_FILL); break; } switch (geom.shapeType) { case (short)DrawShapeType.kDrawCylinder: GLUFunctionInvoker.gluCylinder(qobj, geom.radius1, geom.radius2, geom.height, geom.slices, geom.stacks); break; case (short)DrawShapeType.kDrawDisk: GLUFunctionInvoker.gluDisk(qobj, geom.radius1, geom.radius2, geom.slices, geom.loops); break; case (short)DrawShapeType.kDrawPartialDisk: GLUFunctionInvoker.gluPartialDisk(qobj, geom.radius1, geom.radius2, geom.slices, geom.loops, geom.startAngle, geom.sweepAngle); break; case (short)DrawShapeType.kDrawSphere: default: GLUFunctionInvoker.gluSphere(qobj, geom.radius1, geom.slices, geom.stacks); break; } // Turn off texture mode // if (drawTexture) { OpenGL.glDisable((uint)OpenGL.GL_TEXTURE_2D); } view.endGL(); }
public static MSceneObject LoadTemplate(string TemplateID) { MBuildingBlock bb = MBuildParts.GetBlock(TemplateID); if (bb == null) { Console.WriteLine("WARNING: MSpawnHandler.LoadTemplate " + TemplateID + " not found in blocks"); return(null); } MSceneObject o = null; if (bb.Type == MBuildParts.MAnimatedModel) { o = Helper.CreateAnimatedModel(MScene.TemplateRoot, TemplateID, bb.Model, Vector3d.Zero); MAnimatedModel man = (MAnimatedModel)o; man.BoneOffset = MassiveTools.VectorFromArray(bb.BoneOffset); } if (bb.Type == MBuildParts.MModel) { o = Helper.CreateModel(MScene.TemplateRoot, TemplateID, bb.Model, Vector3d.Zero); } MMaterial mat = (MMaterial)MScene.MaterialRoot.FindModuleByName(bb.MaterialID); if (mat == null) { Console.WriteLine("MSpawnHandler.LoadTemplate " + bb.MaterialID + " was null"); } o.SetMaterial(mat); Vector3d size = MassiveTools.VectorFromArray(bb.Size); MPhysicsObject.EShape shape = GetShape(bb.PhysicsShape); if (shape != MPhysicsObject.EShape.NULL) { MPhysicsObject mpo = new MPhysicsObject(o, TemplateID + "_physics", bb.Weight, shape, true, size); mpo.SetSleep(5); mpo.SetFriction(0.5); if (shape != MPhysicsObject.EShape.Sphere) { mpo.SetAngularFactor(0.0, 0.0, 0.0); mpo.SetDamping(0.5, 0.5); mpo.SetRestitution(0.5); } else { mpo.SetDamping(0.1, 0.1); mpo.SetRestitution(0.8); } } o.TemplateID = TemplateID; o.InstanceID = TemplateID; o.IsTransparent = bb.IsTransparent; o.transform.RotationOffset = Quaterniond.FromEulerAngles(MassiveTools.VectorFromArray(bb.RotationOffset)); o.Setup(); AddSubmodules(bb, o); return(o); }
///////////////////////////////////////////////////////////////////// // // Overrides // ///////////////////////////////////////////////////////////////////// public override void getDrawRequests(MDrawInfo info, bool objectAndActiveOnly, MDrawRequestQueue queue) // // Description: // // Add draw requests to the draw queue // // Arguments: // // info - current drawing state // objectsAndActiveOnly - no components if true // queue - queue of draw requests to add to // { // Get the data necessary to draw the shape // MDrawData data = new MDrawData(); apiMesh meshNode = (apiMesh)surfaceShape; apiMeshGeom geom = meshNode.meshGeom(); if ((null == geom) || (0 == geom.faceCount)) { MGlobal.displayInfo("NO DrawRequest for apiMesh"); return; } // This call creates a prototype draw request that we can fill // in and then add to the draw queue. // MDrawRequest request = getDrawRequest(info); // info.getPrototype(this); getDrawData(geom, out data); request.setDrawData(data); // Decode the draw info and determine what needs to be drawn // M3dView.DisplayStyle appearance = info.displayStyle; M3dView.DisplayStatus displayStatus = info.displayStatus; // Are we displaying meshes? if (!info.objectDisplayStatus(M3dView.DisplayObjects.kDisplayMeshes)) { return; } // Use this code to help speed up drawing. // inUserInteraction() is true for any interaction with // the viewport, including object or component TRS and camera changes. // userChangingViewContext() is true only when the user is using view // context tools (tumble, dolly, track, etc.) // if (info.inUserInteraction || info.userChangingViewContext) { // User is using view context tools so // request fast draw and get out // request.token = (int)DrawToken.kDrawRedPointAtCenter; queue.add(request); return; } switch (appearance) { case M3dView.DisplayStyle.kWireFrame: { request.token = (int)DrawToken.kDrawWireframe; int activeColorTable = (int)M3dView.ColorTable.kActiveColors; int dormantColorTable = (int)M3dView.ColorTable.kDormantColors; switch (displayStatus) { case M3dView.DisplayStatus.kLead: request.setColor(LEAD_COLOR, activeColorTable); break; case M3dView.DisplayStatus.kActive: request.setColor(ACTIVE_COLOR, activeColorTable); break; case M3dView.DisplayStatus.kActiveAffected: request.setColor(ACTIVE_AFFECTED_COLOR, activeColorTable); break; case M3dView.DisplayStatus.kDormant: request.setColor(DORMANT_COLOR, dormantColorTable); break; case M3dView.DisplayStatus.kHilite: request.setColor(HILITE_COLOR, activeColorTable); break; default: break; } queue.add(request); break; } case M3dView.DisplayStyle.kGouraudShaded: { // Create the smooth shaded draw request // request.token = (int)DrawToken.kDrawSmoothShaded; // Need to get the material info // MDagPath path = info.multiPath; // path to your dag object M3dView view = info.view; // view to draw to MMaterial material = base.material(path); // If the user currently has the default material enabled on the // view then use the default material for shading. // if (view.usingDefaultMaterial) { material = MMaterial.defaultMaterial; } // Evaluate the material and if necessary, the texture. // material.evaluateMaterial(view, path); bool drawTexture = true; if (drawTexture && material.materialIsTextured) { material.evaluateTexture(data); } request.material = material; // request.setDisplayStyle( appearance ); bool materialTransparent = false; material.getHasTransparency(ref materialTransparent); if (materialTransparent) { request.isTransparent = true; } queue.add(request); // create a draw request for wireframe on shaded if // necessary. // if ((displayStatus == M3dView.DisplayStatus.kActive) || (displayStatus == M3dView.DisplayStatus.kLead) || (displayStatus == M3dView.DisplayStatus.kHilite)) { MDrawRequest wireRequest = getDrawRequest(info); // info.getPrototype(this); wireRequest.setDrawData(data); wireRequest.token = (int)DrawToken.kDrawWireframeOnShaded; wireRequest.displayStyle = M3dView.DisplayStyle.kWireFrame; int activeColorTable = (int)M3dView.ColorTable.kActiveColors; switch (displayStatus) { case M3dView.DisplayStatus.kLead: wireRequest.setColor(LEAD_COLOR, activeColorTable); break; case M3dView.DisplayStatus.kActive: wireRequest.setColor(ACTIVE_COLOR, activeColorTable); break; case M3dView.DisplayStatus.kHilite: wireRequest.setColor(HILITE_COLOR, activeColorTable); break; default: break; } queue.add(wireRequest); } break; } case M3dView.DisplayStyle.kFlatShaded: request.token = (int)DrawToken.kDrawFlatShaded; queue.add(request); break; case M3dView.DisplayStyle.kBoundingBox: request.token = (int)DrawToken.kDrawBoundingBox; queue.add(request); break; default: break; } // Add draw requests for components // if (!objectAndActiveOnly) { // Inactive components // if ((appearance == M3dView.DisplayStyle.kPoints) || (displayStatus == M3dView.DisplayStatus.kHilite)) { MDrawRequest vertexRequest = getDrawRequest(info); // info.getPrototype(this); vertexRequest.setDrawData(data); vertexRequest.token = (int)DrawToken.kDrawVertices; vertexRequest.setColor(DORMANT_VERTEX_COLOR, (int)M3dView.ColorTable.kActiveColors); queue.add(vertexRequest); } // Active components // if (((MPxSurfaceShape)surfaceShape).hasActiveComponents) { MDrawRequest activeVertexRequest = getDrawRequest(info); // info.getPrototype(this); activeVertexRequest.setDrawData(data); activeVertexRequest.token = (int)DrawToken.kDrawVertices; activeVertexRequest.setColor(ACTIVE_VERTEX_COLOR, (int)M3dView.ColorTable.kActiveColors); MObjectArray clist = ((MPxSurfaceShape)surfaceShape).activeComponents; MObject vertexComponent = clist[0]; // Should filter list activeVertexRequest.component = vertexComponent; queue.add(activeVertexRequest); } } }
private void ShaderCombo_SelectedIndexChanged(object sender, EventArgs e) { CurrentMaterial = (MMaterial)ShaderCombo.SelectedItem; LoadShader(); }
public void drawShaded(MDrawRequest request, M3dView view) // // Description: // // Shaded drawing routine // // Arguments: // // request - request to be drawn // view - view to draw into // { MDrawData data = request.drawData(); apiMeshGeom geom = (apiMeshGeom)data.geometry(); if (geom == null) { return; } view.beginGL(); OpenGL.glEnable(OpenGL.GL_POLYGON_OFFSET_FILL); // Set up the material // MMaterial material = request.material; material.setMaterial(request.multiPath, request.isTransparent); // Enable texturing ... // // Note, Maya does not enable texturing if useDefaultMaterial is enabled. // However, you can choose to ignore this in your draw routine. // bool drawTexture = material.materialIsTextured && !view.usingDefaultMaterial; if (drawTexture) { OpenGL.glEnable(OpenGL.GL_TEXTURE_2D); } // Apply the texture to the current view // if (drawTexture) { material.applyTexture(view, data); } // Draw the polygons // int vid = 0; uint uv_len = geom.uvcoords.uvcount(); for (int i = 0; i < geom.faceCount; i++) { OpenGL.glBegin(OpenGL.GL_POLYGON); for (int v = 0; v < geom.face_counts[i]; v++) { MPoint vertex = geom.vertices[geom.face_connects[vid]]; MVector normal = geom.normals[geom.face_connects[vid]]; if (uv_len > 0) { // If we are drawing the texture, make sure the coord // arrays are in bounds. if (drawTexture) { int uvId1 = geom.uvcoords.uvId(vid); if (uvId1 < uv_len) { float tu = 0.0f; float tv = 0.0f; geom.uvcoords.getUV(uvId1, ref tu, ref tv); OpenGL.glTexCoord2f(tu, tv); } } } OpenGL.glNormal3f((float)normal[0], (float)normal[1], (float)normal[2]); OpenGL.glVertex3f((float)vertex[0], (float)vertex[1], (float)vertex[2]); vid++; } OpenGL.glEnd(); } // Turn off texture mode // if (drawTexture) { OpenGL.glDisable(OpenGL.GL_TEXTURE_2D); } view.endGL(); }