public void Draw(Graphics.ISceneContext sc) { using (var scope = sc.Push()) { scope.DepthTest = false; scope.BackFaceCulling = true; DrawBox(sc, this.BoundingBox); scope.Color = Color.Red; scope.Lighting = true; Geom.Point3d p = sc.Camera.ScreenToCamera(_pos); double len = _length * sc.Camera.LengthPerPixel; scope.MultMatrix(new Geom.HmMatrix3d( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, p.x / len, p.y / len, 0, 1 / len )); scope.MultMatrix(sc.Camera.ViewingPos.r.ToMatrix()); // デプスでソートし、奥から手前に向かって順に描画するようにする foreach (var scene in _components.OrderBy(s => s.GetDepth(sc))) { scene.Draw(sc); } } }
public void Draw(Graphics.ISceneContext sc) { if (this.Direction == ClipDirections.None) { return; } using (var scope = sc.Push()) { var epsilon = 1.0e-3 * _docviews.WorldDocumentScene.BoundingSphere.Radius; var codsys = _clip.CodSys; codsys.o -= epsilon * codsys.n; scope.MultMatrix(codsys); scope.Color = Color.FromArgb(16, Color.Lime); scope.DepthMask = false; scope.Lighting = false; var radius = _docviews.WorldDocumentScene.BoundingSphere.Radius; sc.DrawQuads(gl => { gl.Vertex(radius, radius); gl.Vertex(-radius, radius); gl.Vertex(-radius, -radius); gl.Vertex(radius, -radius); }); scope.Color = (_highlightIndex == -1) ? Color.Lime : Color.Orange; sc.DrawLineLoop(gl => { gl.Vertex(radius, radius); gl.Vertex(-radius, radius); gl.Vertex(-radius, -radius); gl.Vertex(radius, -radius); }); } }
static void DrawBox(Graphics.ISceneContext sc, Geom.Box2i box) { const int SHADOW = 4; GL.glColor4f(0.5f, 0.5f, 0.5f, 0.5f); GL.glBegin(GL.GL_QUADS); foreach (var p in new Geom.Point2i[] { // 右側の影 new Geom.Point2i(box.Upper.x, box.Lower.y + SHADOW), new Geom.Point2i(box.Upper.x, box.Upper.y), new Geom.Point2i(box.Upper.x + SHADOW, box.Upper.y), new Geom.Point2i(box.Upper.x + SHADOW, box.Lower.y + SHADOW), // 下側の影 new Geom.Point2i(box.Lower.x + SHADOW, box.Upper.y), new Geom.Point2i(box.Lower.x + SHADOW, box.Upper.y + SHADOW), new Geom.Point2i(box.Upper.x, box.Upper.y + SHADOW), new Geom.Point2i(box.Upper.x, box.Upper.y), // 右下の影 new Geom.Point2i(box.Upper.x, box.Upper.y), new Geom.Point2i(box.Upper.x, box.Upper.y + SHADOW), new Geom.Point2i(box.Upper.x + SHADOW, box.Upper.y + SHADOW), new Geom.Point2i(box.Upper.x + SHADOW, box.Upper.y) }.Select(pt => sc.Camera.ScreenToCamera(pt))) { GL.glVertex3dv(p); } GL.glEnd(); GL.glColor4f(1, 1, 1, 0.5f); GL.glBegin(GL.GL_QUADS); foreach (var p in new Geom.Point2i[] { new Geom.Point2i(box.Lower.x, box.Lower.y), new Geom.Point2i(box.Lower.x, box.Upper.y), new Geom.Point2i(box.Upper.x, box.Upper.y), new Geom.Point2i(box.Upper.x, box.Lower.y) }.Select(pt => sc.Camera.ScreenToCamera(pt))) { GL.glVertex3dv(p); } GL.glEnd(); }
public void Draw(Graphics.ISceneContext sc) { using (var scope = sc.Push()) { scope.Color = this.Color; _obj.Render(); } }
public double GetDepth(Graphics.ISceneContext sc) { return(sc.Camera.WorldToCamera(_pos).z); }
void Graphics.IScene.Draw(Graphics.ISceneContext con) { }
static void DrawNumber(Graphics.ISceneContext sc, int x, int y, double num) { sc.DrawStrokeRoman(num.ToString(), x, y, 0.1); }