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 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(); } }
private UWB_Primitive CreateSphereMesh() { UWB_XNAPrimitiveMesh m = new UWB_XNAPrimitiveMesh("sphere"); m.EnableTexturing(false); m.EnableLighting(true); return m; }
private UWB_Primitive CreateRectangle(RTRectangle r) { UWB_XNAPrimitiveMesh m = new UWB_XNAPrimitiveMesh("HiResFloor"); m.EnableTexturing(false); m.EnableLighting(true); return m; }
private void AddCamera(RayTracer_552.RTCamera c) { // Look at position UWB_SceneNode atN = new UWB_SceneNode(); UWB_XNAPrimitiveMesh at = new UWB_XNAPrimitiveMesh("sphere"); at.Material.Diffuse = new Vector4(0.8f, 0.1f, 0.1f, 1.0f); atN.setPrimitive(at); UWB_XFormInfo atxf = atN.getXFormInfo(); atxf.SetTranslation(c.AtPosition); atxf.SetScale(new Vector3(0.3f, 0.3f, 0.3f)); atN.setXFormInfo(atxf); // Eye position UWB_SceneNode eyeN = new UWB_SceneNode(); UWB_XNAPrimitiveMesh eye = new UWB_XNAPrimitiveMesh("cone"); eyeN.setPrimitive(eye); UWB_XFormInfo eyexf = eyeN.getXFormInfo(); eyexf.SetTranslation(c.EyePosition); mCameraPosition = c.EyePosition; Vector3 init = new Vector3(0, 0, 1); // initial cone orientation Vector3 final = c.AtPosition - c.EyePosition; final = Vector3.Normalize(final); float dot = Vector3.Dot(init, final); if (Math.Abs(dot) < 0.9999) { float angle = (float)Math.Acos(dot); Vector3 axis = Vector3.Cross(init, final); axis = Vector3.Normalize(axis); Quaternion q = Quaternion.CreateFromAxisAngle(axis, angle); eyexf.SetRotationQuat(q); } eyeN.setXFormInfo(eyexf); // Lines ... UWB_SceneNode lineN = new UWB_SceneNode(); mCameraPrimitives = new UWB_PrimitiveList(); lineN.setPrimitive(mCameraPrimitives); UWB_PrimitiveLine l = new UWB_PrimitiveLine(); l.setStartPoint(c.EyePosition.X, c.EyePosition.Y, c.EyePosition.Z); l.setEndPoint(c.AtPosition.X, c.AtPosition.Y, c.AtPosition.Z); mCameraPrimitives.append(l); mCamera.insertChildNode(lineN); mCamera.insertChildNode(atN); mCamera.insertChildNode(eyeN); }