protected override void SetupDrawAttributes(UWB_DrawHelper drawHelper) { base.SetupDrawAttributes(drawHelper); drawHelper.setColor2(mShadingColor); drawHelper.setShadeMode(mShadeMode); drawHelper.setFillMode(mFillMode); }
protected override void DrawPrimitive(eLevelofDetail lod, UWB_DrawHelper draw_helper) { draw_helper.pushModelTransform(); { m_xaxis.Draw(lod, draw_helper); } draw_helper.popModelTransform(); UWB_XFormInfo yrot = new UWB_XFormInfo(); yrot.UpdateRotationZByDegree(-90.0f); draw_helper.pushModelTransform(); { yrot.setupModelStack(draw_helper); m_yaxis.Draw(lod, draw_helper); } draw_helper.popModelTransform(); UWB_XFormInfo zrot = new UWB_XFormInfo(); zrot.UpdateRotationYByDegree(90.0f); draw_helper.pushModelTransform(); { zrot.setupModelStack(draw_helper); m_zaxis.Draw(lod, draw_helper); } draw_helper.popModelTransform(); }
public bool GetNodeBounds(ref UWB_SceneNode pSearchNode, ref UWB_BoundingBox box, ref UWB_DrawHelper helper, bool bDraw) { return(GetNodeBoundsHelper(ref pSearchNode, ref box, ref helper, 0, bDraw)); }
protected override void DrawPrimitive(eLevelofDetail lod, UWB_DrawHelper drawHelper) { eLevelofDetail oldLod = drawHelper.getLod(); drawHelper.setLod(lod); drawHelper.drawCircle(mCenter, mRadius); drawHelper.setLod(oldLod); }
protected override void SetupDrawAttributes(UWB_DrawHelper drawHelper) { base.SetupDrawAttributes(drawHelper); drawHelper.setColor1(mFlatColor); drawHelper.setColor2(mShadingColor); drawHelper.setShadeMode(mShadeMode); drawHelper.setFillMode(mFillMode); }
public void DrawWCWindow(UWB_DrawHelper drawHelper) { drawHelper.resetAttributes(); drawHelper.setShadeMode(eShadeMode.smFlat); drawHelper.setFillMode(eFillMode.fmWireframe); drawHelper.setColor1(new Color(new Vector3(1.0f, 0.0f, 0.0f))); drawHelper.drawRectangle(WCWindowMin, WCWindowMax); }
public void drawPivot(UWB_DrawHelper drawHelper, float size) { drawHelper.resetAttributes(); drawHelper.setColor1(new Color(new Vector3(1f, 1f, 1f))); drawHelper.setColor2(new Color(new Vector3(0, 0, 1f))); drawHelper.setFillMode(eFillMode.fmSolid); drawHelper.setShadeMode(eShadeMode.smGouraud); drawHelper.drawCircle(mPivot, size); }
public void Draw(eLevelofDetail lod, UWB_DrawHelper drawHelper) { if (!mVisible) return; SetupDrawAttributes(drawHelper); DrawPrimitive(lod, drawHelper); if (isDrawingBoundingVolume()) drawBoundingVolume(lod, drawHelper, Color.Red); }
public UWB_BoundingBox GetBounds(ref UWB_DrawHelper helper, bool bDraw) { UWB_BoundingBox box = new UWB_BoundingBox(); box.makeInvalid(); if (mPrimitive != null) { box.add(mPrimitive.getBoundingVolume(eLevelofDetail.lodLow)); } helper.pushModelTransform(); { mXFormInfo.setupModelStack(helper); //Draw the box for debugging if (bDraw) { box.Draw(ref helper); } Vector3 minPt = box.getMin(); Vector3 maxPt = box.getMax(); Vector3 pt1 = new Vector3(minPt.X, minPt.Y, minPt.Z); Vector3 pt2 = new Vector3(maxPt.X, minPt.Y, minPt.Z); Vector3 pt3 = new Vector3(maxPt.X, maxPt.Y, minPt.Z); Vector3 pt4 = new Vector3(minPt.X, maxPt.Y, minPt.Z); Vector3 pt5 = new Vector3(minPt.X, minPt.Y, maxPt.Z); Vector3 pt6 = new Vector3(maxPt.X, minPt.Y, maxPt.Z); Vector3 pt7 = new Vector3(maxPt.X, maxPt.Y, maxPt.Z); Vector3 pt8 = new Vector3(minPt.X, maxPt.Y, maxPt.Z); helper.transformPoint(ref pt1); helper.transformPoint(ref pt2); helper.transformPoint(ref pt3); helper.transformPoint(ref pt4); helper.transformPoint(ref pt5); helper.transformPoint(ref pt6); helper.transformPoint(ref pt7); helper.transformPoint(ref pt8); box.makeInvalid(); box.add(new UWB_BoundingBox(pt1, pt2)); box.add(new UWB_BoundingBox(pt3, pt4)); box.add(new UWB_BoundingBox(pt5, pt6)); box.add(new UWB_BoundingBox(pt7, pt8)); int count = mChildNodes.count(); for (int i = 0; i < count; i++) { box.add(mChildNodes.getItem(i).GetBounds(ref helper, bDraw)); } } helper.popModelTransform(); return(box); }
protected override void DrawPrimitive(eLevelofDetail lod, UWB_DrawHelper drawHelper) { int count = mList.count(); for (int i = 0; i < count; i++) { UWB_Primitive primitive = mList.getItem(i); if (primitive != null) { primitive.Draw(lod, drawHelper); } } }
public void drawBoundingVolume(eLevelofDetail lod, UWB_DrawHelper drawHelper, Color color) { UWB_BoundingVolume boundingVolume = getBoundingVolume(lod); if (boundingVolume != null && drawHelper != null) { drawHelper.resetAttributes(); drawHelper.setColor1(color); drawHelper.setShadeMode(eShadeMode.smFlat); drawHelper.setFillMode(eFillMode.fmWireframe); boundingVolume.Draw(ref drawHelper); } }
protected override void DrawPrimitive(eLevelofDetail lod, UWB_DrawHelper draw_helper) { UWB_XNAGraphicsDevice graphics = UWB_XNAGraphicsDevice.m_TheAPI; UWB_XNAPrimitiveMesh pCylinderMesh = new UWB_XNAPrimitiveMesh("cylinder"); UWB_XNAPrimitiveMesh pConeMesh = new UWB_XNAPrimitiveMesh("cone"); if (pCylinderMesh != null && pConeMesh != null) { pCylinderMesh.Material = Material; pConeMesh.Material = Material; draw_helper.pushModelTransform(); { // Need to add support for finding the bounding box of a mesh // the Z value is hard coded until then //UWB_BoundingBox box = (pCylinderMesh.getBoundingVolume(draw_helper.getLod()) as UWB_BoundingBox); UWB_XFormInfo cylinder_xform = new UWB_XFormInfo(); cylinder_xform.SetScale(new Vector3(0.025f, 0.025f, 0.2666666666f)); cylinder_xform.UpdateRotationYByDegree(-90.0f); cylinder_xform.SetTranslation(new Vector3(0.4f, 0.0f, 0.0f)); cylinder_xform.setupModelStack(draw_helper); try { pCylinderMesh.setMesh(graphics.mResources.Load<Model>("cylinder")); pCylinderMesh.DrawMesh(true, mFlatColor, draw_helper); } catch (Exception e) { UWBGL_XNA_Lib.UWB_Utility.echoToStatusArea((e.Message)); } //pCylinderMesh.DrawMesh(false, mFlatColor,draw_helper); } draw_helper.popModelTransform(); draw_helper.pushModelTransform(); { //const UWB_BoundingBox box = pConeMesh.getBoundingBox(); UWB_XFormInfo cone_xform = new UWB_XFormInfo(); cone_xform.SetScale(new Vector3(0.08f,0.08f, 0.1f)); cone_xform.UpdateRotationYByDegree(-90.0f); cone_xform.SetTranslation(new Vector3(0.85f,0.0f,0.0f)); cone_xform.setupModelStack(draw_helper); try { pConeMesh.setMesh(graphics.mResources.Load<Model>("cone")); pConeMesh.DrawMesh(true, mFlatColor, draw_helper); } catch (Exception e) { UWBGL_XNA_Lib.UWB_Utility.echoToStatusArea((e.Message)); } //pConeMesh.DrawMesh(false, mFlatColor, draw_helper); } draw_helper.popModelTransform(); } }
protected override void DrawPrimitive(eLevelofDetail lod, UWB_DrawHelper drawHelper) { UWB_XNAGraphicsDevice graphics = UWB_XNAGraphicsDevice.m_TheAPI; try { mesh = graphics.mResources.Load <Model>(filename); DrawMesh(true, this.mFlatColor, drawHelper); } catch (Exception e) { UWBGL_XNA_Lib.UWB_Utility.echoToStatusArea((e.Message)); } }
protected override void DrawPrimitive(eLevelofDetail lod, UWB_DrawHelper draw_helper) { UWB_XNAGraphicsDevice graphics = UWB_XNAGraphicsDevice.m_TheAPI; UWB_XNAPrimitiveMesh pCylinderMesh = new UWB_XNAPrimitiveMesh("cylinder"); UWB_XNAPrimitiveMesh pConeMesh = new UWB_XNAPrimitiveMesh("cone"); if (pCylinderMesh != null && pConeMesh != null) { pCylinderMesh.Material = Material; pConeMesh.Material = Material; draw_helper.pushModelTransform(); { // Need to add support for finding the bounding box of a mesh // the Z value is hard coded until then //UWB_BoundingBox box = (pCylinderMesh.getBoundingVolume(draw_helper.getLod()) as UWB_BoundingBox); UWB_XFormInfo cylinder_xform = new UWB_XFormInfo(); cylinder_xform.SetScale(new Vector3(0.025f, 0.025f, 0.2666666666f)); cylinder_xform.UpdateRotationYByDegree(-90.0f); cylinder_xform.SetTranslation(new Vector3(0.4f, 0.0f, 0.0f)); cylinder_xform.setupModelStack(draw_helper); try { pCylinderMesh.setMesh(graphics.mResources.Load <Model>("cylinder")); pCylinderMesh.DrawMesh(true, mFlatColor, draw_helper); } catch (Exception e) { UWBGL_XNA_Lib.UWB_Utility.echoToStatusArea((e.Message)); } //pCylinderMesh.DrawMesh(false, mFlatColor,draw_helper); } draw_helper.popModelTransform(); draw_helper.pushModelTransform(); { //const UWB_BoundingBox box = pConeMesh.getBoundingBox(); UWB_XFormInfo cone_xform = new UWB_XFormInfo(); cone_xform.SetScale(new Vector3(0.08f, 0.08f, 0.1f)); cone_xform.UpdateRotationYByDegree(-90.0f); cone_xform.SetTranslation(new Vector3(0.85f, 0.0f, 0.0f)); cone_xform.setupModelStack(draw_helper); try { pConeMesh.setMesh(graphics.mResources.Load <Model>("cone")); pConeMesh.DrawMesh(true, mFlatColor, draw_helper); } catch (Exception e) { UWBGL_XNA_Lib.UWB_Utility.echoToStatusArea((e.Message)); } //pConeMesh.DrawMesh(false, mFlatColor, draw_helper); } draw_helper.popModelTransform(); } }
protected virtual void SetupDrawAttributes(UWB_DrawHelper drawHelper) { drawHelper.resetAttributes(); drawHelper.setColor1(mFlatColor); drawHelper.SetMaterial(ref m_Material); drawHelper.EnableBlending(m_bBlendingEnabled); drawHelper.EnableLighting(m_bLightingEnabled); drawHelper.SetTextureInfo(ref m_TexFileName); if (m_TexFileName != null) { drawHelper.EnableTexture(m_bTexturingEnabled); } }
public void drawChildBoundingVolumes(eLevelofDetail lod, UWB_DrawHelper drawHelper, Color color) { if (drawHelper == null) return; int count = this.count(); for (int i = 0; i < count; i++) { UWB_Primitive primitive = mList.getItem(i); if (primitive != null) { primitive.drawBoundingVolume(lod, drawHelper, color); } } }
public override void Draw(ref UWB_DrawHelper drawHelper) { if (drawHelper != null) { Vector3 start = mMin; Vector3 end = mMin; end.X = mMax.X; drawHelper.drawLine(start, end); start = end; end.Y = mMax.Y; drawHelper.drawLine(start, end); start = end; end.X = mMin.X; drawHelper.drawLine(start, end); start = end; end.Y = mMin.Y; drawHelper.drawLine(start, end); start = mMax; end = mMax; end.X = mMin.X; drawHelper.drawLine(start, end); start = end; end.Y = mMin.Y; drawHelper.drawLine(start, end); start = end; end.X = mMax.X; drawHelper.drawLine(start, end); start = end; end.Y = mMax.Y; drawHelper.drawLine(start, end); start = mMax; end = mMax; end.Z = mMin.Z; drawHelper.drawLine(start, end); end.Y = mMin.Y; start.Y = mMin.Y; drawHelper.drawLine(start, end); end.X = mMin.X; start.X = mMin.X; drawHelper.drawLine(start, end); end.Y = mMax.Y; start.Y = mMax.Y; drawHelper.drawLine(start, end); } }
public void Draw(eLevelofDetail lod, UWB_DrawHelper drawHelper) { if (!mVisible) { return; } SetupDrawAttributes(drawHelper); DrawPrimitive(lod, drawHelper); if (isDrawingBoundingVolume()) { drawBoundingVolume(lod, drawHelper, Color.Red); } }
protected override void DrawPrimitive(eLevelofDetail lod, UWB_DrawHelper drawHelper) { Vector3 origin = new Vector3(); Vector3 xaxis = new Vector3(m_size, 0, 0); Vector3 yaxis = new Vector3(0, m_size, 0); Vector3 zaxis = new Vector3(0, 0, m_size); eLevelofDetail oldLod = drawHelper.getLod(); drawHelper.setLod(lod); drawHelper.setColor1(Color.Red); drawHelper.drawLine(origin, xaxis); drawHelper.setColor1(Color.Green); drawHelper.drawLine(origin, yaxis); drawHelper.setColor1(Color.Blue); drawHelper.drawLine(origin, zaxis); drawHelper.setLod(oldLod); }
public UWB_BoundingBox GetBounds(ref UWB_DrawHelper helper, bool bDraw) { UWB_BoundingBox box = new UWB_BoundingBox(); box.makeInvalid(); if (mPrimitive != null) box.add(mPrimitive.getBoundingVolume(eLevelofDetail.lodLow)); helper.pushModelTransform(); { mXFormInfo.setupModelStack(helper); //Draw the box for debugging if (bDraw) box.Draw(ref helper); Vector3 minPt = box.getMin(); Vector3 maxPt = box.getMax(); Vector3 pt1 = new Vector3(minPt.X, minPt.Y, minPt.Z); Vector3 pt2 = new Vector3(maxPt.X, minPt.Y, minPt.Z); Vector3 pt3 = new Vector3(maxPt.X, maxPt.Y, minPt.Z); Vector3 pt4 = new Vector3(minPt.X, maxPt.Y, minPt.Z); Vector3 pt5 = new Vector3(minPt.X, minPt.Y, maxPt.Z); Vector3 pt6 = new Vector3(maxPt.X, minPt.Y, maxPt.Z); Vector3 pt7 = new Vector3(maxPt.X, maxPt.Y, maxPt.Z); Vector3 pt8 = new Vector3(minPt.X, maxPt.Y, maxPt.Z); helper.transformPoint(ref pt1); helper.transformPoint(ref pt2); helper.transformPoint(ref pt3); helper.transformPoint(ref pt4); helper.transformPoint(ref pt5); helper.transformPoint(ref pt6); helper.transformPoint(ref pt7); helper.transformPoint(ref pt8); box.makeInvalid(); box.add(new UWB_BoundingBox(pt1, pt2)); box.add(new UWB_BoundingBox(pt3, pt4)); box.add(new UWB_BoundingBox(pt5, pt6)); box.add(new UWB_BoundingBox(pt7, pt8)); int count = mChildNodes.count(); for (int i = 0; i < count; i++) box.add(mChildNodes.getItem(i).GetBounds(ref helper, bDraw)); } helper.popModelTransform(); return box; }
public void drawChildBoundingVolumes(eLevelofDetail lod, UWB_DrawHelper drawHelper, Color color) { if (drawHelper == null) { return; } int count = this.count(); for (int i = 0; i < count; i++) { UWB_Primitive primitive = mList.getItem(i); if (primitive != null) { primitive.drawBoundingVolume(lod, drawHelper, color); } } }
protected bool GetNodeBoundsHelper(ref UWB_SceneNode pSearchNode, ref UWB_BoundingBox box, ref UWB_DrawHelper helper, int level, bool bDraw) { bool found = false; if (Object.ReferenceEquals(this, pSearchNode)) { box = this.GetBounds(ref helper, bDraw); found = true; } else { helper.pushModelTransform(); { level++; this.getXFormInfo().setupModelStack(helper); int count = this.numChildren(); for (int i = 0; i < count; i++) { UWB_SceneNode pChildNode = this.getChildNode(i); if (pChildNode.GetNodeBoundsHelper(ref pSearchNode, ref box, ref helper, level, bDraw)) { found = true; break; } } level--; } helper.popModelTransform(); } if (0 == level && found && bDraw) { helper.resetAttributes(); helper.setColor1(new Color(0, 0, 255)); helper.setShadeMode(eShadeMode.smFlat); helper.setFillMode(eFillMode.fmWireframe); box.Draw(ref helper); } return(found); }
public void Draw(eLevelofDetail lod, UWB_DrawHelper drawHelper) { drawHelper.pushModelTransform(); mXFormInfo.setupModelStack(drawHelper); if (mPrimitive != null) { mPrimitive.Draw(lod, drawHelper); } int count = mChildNodes.count(); for (int i = 0; i < count; i++) { mChildNodes.getItem(i).Draw(lod, drawHelper); } if (mPivotVisible) { mXFormInfo.drawPivot(drawHelper, .2f); } drawHelper.popModelTransform(); }
protected override void SetupDrawAttributes(UWB_DrawHelper drawHelper) { //nothing to do here }
protected override void DrawPrimitive(eLevelofDetail lod, UWB_DrawHelper drawHelper) { drawHelper.drawTriangle(mV1, mV2, mV3); }
public virtual void Draw(ref UWB_DrawHelper drawHelper) { }
protected override void DrawPrimitive(eLevelofDetail lod, UWB_DrawHelper drawHelper) { drawHelper.drawRectangle(m_bounds.getMin(), m_bounds.getMax()); }
protected override void DrawPrimitive(eLevelofDetail lod, UWB_DrawHelper drawHelper) { drawHelper.drawPoint(mPoint); }
protected override void SetupDrawAttributes(UWB_DrawHelper drawHelper) { base.SetupDrawAttributes(drawHelper); drawHelper.setShadeMode(eShadeMode.smFlat); }
public void setupModelStack(UWB_DrawHelper drawHelper) { drawHelper.accumulateModelTransform(mTranslation, mScale, GetRotation(), mPivot); }
protected bool GetNodeBoundsHelper(ref UWB_SceneNode pSearchNode, ref UWB_BoundingBox box, ref UWB_DrawHelper helper, int level, bool bDraw) { bool found = false; if( Object.ReferenceEquals(this, pSearchNode)) { box = this.GetBounds( ref helper, bDraw ); found = true; } else { helper.pushModelTransform(); { level++; this.getXFormInfo().setupModelStack(helper); int count = this.numChildren(); for(int i=0; i<count; i++) { UWB_SceneNode pChildNode = this.getChildNode( i ); if( pChildNode.GetNodeBoundsHelper( ref pSearchNode, ref box, ref helper, level, bDraw ) ) { found = true; break; } } level--; } helper.popModelTransform(); } if (0 == level && found && bDraw) { helper.resetAttributes(); helper.setColor1(new Color(0,0,255)); helper.setShadeMode(eShadeMode.smFlat); helper.setFillMode(eFillMode.fmWireframe); box.Draw(ref helper); } return found; }
// Pure virtual function that must be override!! public virtual void DrawLightGeometry(UWB_DrawHelper draw_helper) { }
protected virtual void DrawPrimitive(eLevelofDetail lod, UWB_DrawHelper drawHelper) { }
protected override void SetupDrawAttributes(UWB_DrawHelper drawHelper) { base.SetupDrawAttributes(drawHelper); drawHelper.setColor1(mFlatColor); drawHelper.setPointSize(mPointSize); }
protected override void DrawPrimitive(eLevelofDetail lod, UWB_DrawHelper drawHelper) { drawHelper.drawRectangleXZ(m_bounds.getMin(), m_bounds.getMax()); }
public bool GetNodeBounds( ref UWB_SceneNode pSearchNode, ref UWB_BoundingBox box, ref UWB_DrawHelper helper, bool bDraw) { return GetNodeBoundsHelper(ref pSearchNode, ref box, ref helper, 0, bDraw ); }
protected override void DrawPrimitive(eLevelofDetail lod, UWB_DrawHelper drawHelper) { drawHelper.drawLine(mStart, mEnd); }
protected override void DrawPrimitive(eLevelofDetail lod, UWB_DrawHelper drawHelper) { UWB_XNAGraphicsDevice graphics = UWB_XNAGraphicsDevice.m_TheAPI; try { mesh = graphics.mResources.Load<Model>(filename); DrawMesh(true, this.mFlatColor, drawHelper); } catch (Exception e) { UWBGL_XNA_Lib.UWB_Utility.echoToStatusArea((e.Message)); } }
public virtual void DrawMesh(bool bShowflatColor, Color MaterialColor, UWB_DrawHelper drawHelper) { UWB_XNAGraphicsDevice graphics = UWB_XNAGraphicsDevice.m_TheAPI; GraphicsDevice device = UWB_XNAGraphicsDevice.m_TheAPI.GraphicsDevice; UWB_XNAEffect effect = UWB_XNAGraphicsDevice.m_TheAPI.LightingEffect; SetupDrawAttributes(drawHelper); UWB_Material material = this.m_Material; //if (bShowflatColor && !m_bTexturingEnabled) //{ // material = new UWB_Material(Color.Gray.ToVector4(), // Color.Gray.ToVector4(), // Color.Gray.ToVector4(), // Color.White.ToVector4(), 1f); // material.Emissive = MaterialColor.ToVector4(); //} /* If texturing is enabled, there are two option... one is that * there has been a texture set for the mesh, and another is that * the mesh has a texture defined inside the mesh file. In the * second case, this only checks the FIRST mesh part and uses the * FIRST texture. */ Texture2D texture = null; if (this.m_bTexturingEnabled) { texture = UWB_XNAGraphicsDevice.m_TheAPI.RetrieveTexture(m_TexFileName); BasicEffect meshEffect = (mesh.Meshes[0].MeshParts[0].Effect as BasicEffect); Texture2D partTexture = meshEffect.Texture; // If there is no supplied texture then use the texture and material of the first mesh part if (texture == null && partTexture != null) { texture = partTexture; material.Ambient = new Vector4(meshEffect.AmbientLightColor, meshEffect.Alpha); material.Diffuse = new Vector4(meshEffect.DiffuseColor, meshEffect.Alpha); material.Emissive = new Vector4(meshEffect.EmissiveColor, meshEffect.Alpha); material.Specular = new Vector4(meshEffect.SpecularColor, meshEffect.Alpha); material.Power = meshEffect.SpecularPower; } } effect.Material = material; if (texture != null) { effect.Texture = texture; effect.TextureEnabled = true; } else { effect.Texture = texture; effect.TextureEnabled = false; } for (int m = 0; m < mesh.Meshes.Count; m++) { for (int part = 0; part < mesh.Meshes[m].MeshParts.Count; part++) { ModelMeshPart mp = mesh.Meshes[m].MeshParts[part]; device.Indices = mp.IndexBuffer; device.SetVertexBuffer(mp.VertexBuffer); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); device.DrawIndexedPrimitives(PrimitiveType.TriangleList, mp.VertexOffset, 0, mp.NumVertices, mp.StartIndex, mp.PrimitiveCount); } } } }
public virtual void DrawMesh(bool bShowflatColor, Color MaterialColor, UWB_DrawHelper drawHelper) { UWB_XNAGraphicsDevice graphics = UWB_XNAGraphicsDevice.m_TheAPI; GraphicsDevice device = UWB_XNAGraphicsDevice.m_TheAPI.GraphicsDevice; UWB_XNAEffect effect = UWB_XNAGraphicsDevice.m_TheAPI.LightingEffect; SetupDrawAttributes(drawHelper); UWB_Material material = this.m_Material; //if (bShowflatColor && !m_bTexturingEnabled) //{ // material = new UWB_Material(Color.Gray.ToVector4(), // Color.Gray.ToVector4(), // Color.Gray.ToVector4(), // Color.White.ToVector4(), 1f); // material.Emissive = MaterialColor.ToVector4(); //} /* If texturing is enabled, there are two option... one is that there has been a texture set for the mesh, and another is that the mesh has a texture defined inside the mesh file. In the second case, this only checks the FIRST mesh part and uses the FIRST texture. */ Texture2D texture = null; if (this.m_bTexturingEnabled) { texture = UWB_XNAGraphicsDevice.m_TheAPI.RetrieveTexture(m_TexFileName); BasicEffect meshEffect = (mesh.Meshes[0].MeshParts[0].Effect as BasicEffect); Texture2D partTexture = meshEffect.Texture; // If there is no supplied texture then use the texture and material of the first mesh part if (texture == null && partTexture != null) { texture = partTexture; material.Ambient = new Vector4(meshEffect.AmbientLightColor, meshEffect.Alpha); material.Diffuse = new Vector4(meshEffect.DiffuseColor, meshEffect.Alpha); material.Emissive = new Vector4(meshEffect.EmissiveColor, meshEffect.Alpha); material.Specular = new Vector4(meshEffect.SpecularColor, meshEffect.Alpha); material.Power = meshEffect.SpecularPower; } } effect.Material = material; if (texture != null) { effect.Texture = texture; effect.TextureEnabled = true; } else { effect.Texture = texture; effect.TextureEnabled = false; } for (int m = 0; m < mesh.Meshes.Count; m++) { for (int part = 0; part < mesh.Meshes[m].MeshParts.Count; part++) { ModelMeshPart mp = mesh.Meshes[m].MeshParts[part]; device.Indices = mp.IndexBuffer; device.SetVertexBuffer(mp.VertexBuffer); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); device.DrawIndexedPrimitives(PrimitiveType.TriangleList, mp.VertexOffset, 0, mp.NumVertices, mp.StartIndex, mp.PrimitiveCount); } } } }
protected virtual void SetupDrawAttributes(UWB_DrawHelper drawHelper) { drawHelper.resetAttributes(); drawHelper.setColor1(mFlatColor); drawHelper.SetMaterial(ref m_Material); drawHelper.EnableBlending(m_bBlendingEnabled); drawHelper.EnableLighting(m_bLightingEnabled); drawHelper.SetTextureInfo(ref m_TexFileName); if (m_TexFileName != null) drawHelper.EnableTexture(m_bTexturingEnabled); }