/// <summary> /// Default constructor. /// </summary> public Camera(Scene scene) { _scene = scene; // set default positioning _position = new Vector(0.0, 0.0, 9.0); _upVec = new Vector(0.0, 1.0, 0.0); _center = new Vector(); // set default field of view fov = new Angle(); fov["deg"] = 28.0; // set default interaction factors dollyFactor = 0.15; panFactor = 0.05; lastDirection = ViewDirection.Front; Frustum = new FrustumDef(); DefaultAnimationOptions.Duration = 4.0; DefaultAnimationOptions.EaseType = EaseType.Quadratic; UseInertia = true; InertiaAnimationOptions = new AnimationOptions() { Duration = 6.0, EaseType = EaseType.Linear }; InertiaType = InteractionType.None; }
/// <summary> /// Render the reference item. /// </summary> /// <param name="scene"> A <see cref="Scene"/> to render to. </param> public override void RenderOpaque(Scene scene) { scene.RenderManager.EnableAntialiasing(); scene.Lighting.Disable(); base.RenderOpaque(scene); Color fill = ModelingOptions.Global.GetColor("ref-fill", HitState); if (fill.IsOpaque) { fill.Setup(); RenderFill(scene); } Color edge = ModelingOptions.Global.GetColor("ref-edge", HitState); if (edge.IsOpaque) { edge.Setup(); if (HitState == HitState.None) gl.glLineWidth(1f); else gl.glLineWidth(2f); RenderEdge(scene); } scene.RenderManager.DisableAntialiasing(); }
public override void RenderOverlay(Scene scene) { // compute the current frame rate if (_stopwatch.IsRunning) { var fps = 1.0 / _stopwatch.Elapsed.TotalSeconds; _stopwatch.Reset(); _fpsAverager.Add(fps); } else { _stopwatch.Start(); } // get the last mouse position Coord pos; if (_lastMouseEvent != null) pos = _lastMouseEvent.Pos; else pos = new Coord(); _label.Body = String.Format("{0:###.#} fps -- {1} ({2} x {3})", _fpsAverager.Compute(), pos, Scene.Width, Scene.Height); OnSceneResized(Scene); base.RenderOverlay(scene); }
public static DecoratorBase Get(Scene scene) { DecoratorBase decorator; if (_decorators.TryGetValue(scene, out decorator)) return decorator; return Default; }
/// <summary> /// Adds a scene to the collection. /// </summary> public virtual void Add(Scene scene) { _scenes.Add(scene); scene.Parent = this; if (NumScenes == 1) Current = scene; OnChildrenChanged(); }
/// <summary> /// Default constructor. /// </summary> /// <param name="scene">The scene to animate on.</param> public Animator(Scene scene) { this.scene = scene; interval = 0.1; timer = new Timer(1/interval); timer.Elapsed += OnTick; }
/// <summary> /// Inserts a scene to the collection at the given index. /// </summary> public virtual void Insert(int index, Scene scene) { _scenes.Insert(index, scene); scene.Parent = this; if (NumScenes == 1) Current = scene; OnChildrenChanged(); }
/// <summary> /// Highlights the given point. /// </summary> protected void HighlightPoint(Scene scene, Point point, Color color, float size) { scene.Lighting.Disable(); gl.glPointSize(size); color.Setup(); gl.glBegin(gl.GL_POINTS); point.glVertex(); gl.glEnd(); }
public override void RenderOverlay(Scene scene) { // if we're dirty, we need to update the position, but this can't be done // in ComputeGeometry() since we don't know the scene if (IsDirty) UpdatePosition(scene); base.RenderOverlay(scene); }
public SceneInfoOverlay(Scene scene) : base(AnchorLocation.SE) { Scene = scene; _label = new Label(); Control = _label; _fpsAverager = new RunningAverager(20); _stopwatch = new Stopwatch(); }
public override void RenderOpaque(Scene scene) { base.RenderOpaque(scene); switch (scene.RenderManager.ColorMode) { case ColorMode.Cartoon: CartoonColor.Setup(); break; case ColorMode.Realistic: Material.Setup(); break; } }
public override void RenderOpaque(Scene scene) { base.RenderOpaque(scene); if (!IsVisible) return; if (axes[0] == null && corner == null) return; gl.glLineWidth(1f); gl.glBegin(gl.GL_LINES); for (int n = 0; n < 2; n++) // axes number { int nOther = 1 - n; // number of the other axes int dim = axes[n].Dimension; // dimension of this axis int dimOther = axes[nOther].Dimension; // dimension of the other axis double firstTickStep = axes[n].FirstWorldTickStep; // first tick step in world coords double tickStep = axes[n].WorldTickStep; // all other tick steps in world coords // figure out the corner to actually start in Vector corner_ = Corner.Copy(); if (corner_[dim] == axes[n].Stop[dim]) corner_[dim] = axes[n].Start[dim]; // get the two points that transverse the axis Vector currentPoint1 = corner_; // one of the points moving along the axis Vector currentPoint2 = corner_.Copy(); // one of the points moving along the axis if (corner_[dimOther] == axes[nOther].Start[dimOther]) currentPoint2[dimOther] = axes[nOther].Stop[dimOther]; else currentPoint2[dimOther] = axes[nOther].Start[dimOther]; // initialize the points to the first tick currentPoint1[dim] += firstTickStep; currentPoint2[dim] += firstTickStep; // cycle through tick marks for this dimension for (int t = 0; t < axes[n].TickVals.Length; t++) { currentPoint1.glVertex(); currentPoint1[dim] += tickStep; currentPoint2.glVertex(); currentPoint2[dim] += tickStep; } } gl.glEnd(); }
internal DockButton(Scene scene) { Scene = scene; _label = new Label(scene.Name); AddChild(_label); var closeIcon = new Image(ResourceHelper.GetStream("close.png")); CloseButton = new Button(closeIcon) { Padding = 3, IsHoverable = true }; CloseButton.Clicked += Scene.AttemptClosing; AddChild(CloseButton); IsHoverable = true; }
/// <summary> /// Renders the rubber band to the viewport. /// </summary> public virtual void Render(Scene scene) { if (Enabled) // only render if it's enabled { gl.glBegin(gl.GL_LINE_STRIP); gl.glColor3f(0f, 0.5f, 0.8f); gl.glLineWidth(1.5f); gl.glVertex3d(Start.X, Start.Y, 0); gl.glVertex3d(Start.X, Stop.Y, 0); gl.glVertex3d(Stop.X, Stop.Y, 0); gl.glVertex3d(Stop.X, Start.Y, 0); gl.glVertex3d(Start.X, Start.Y, 0); gl.glEnd(); } }
public override void RenderOverlay(Scene scene) { if (GrayScene) { // shade out the background scene.Lighting.Disable(); gl.glColor4d(0.85, 0.85, 0.85, 0.75); gl.glBegin(gl.GL_POLYGON); gl.glVertex2i(0, 0); gl.glVertex2d(scene.Width, 0); gl.glVertex2d(scene.Width, scene.Height); gl.glVertex2d(0, scene.Height); gl.glEnd(); } base.RenderOverlay(scene); }
/// <summary> /// Removes a scene to the collection. /// </summary> public virtual void Remove(Scene scene) { var index = _scenes.IndexOf(scene); _scenes.Remove(scene); scene.Parent = null; if (Current == scene) { if (NumScenes > 0) { if (index > 0) Current = _scenes[index - 1]; else Current = _scenes[0]; } else Current = null; } OnChildrenChanged(); }
public override void RenderOverlay(Scene scene) { base.RenderOverlay(scene); scene.Lighting.Disable(); gl.glLineWidth(3f); gl.glBegin(gl.GL_LINE_LOOP); gl.glColor3f(1.0f, 0f, 0f); gl.glVertex2d(Origin.X, Origin.Y); gl.glVertex2d(Origin.X + Size.X, Origin.Y); gl.glVertex2d(Origin.X + Size.X, Origin.Y + Size.Y); gl.glVertex2d(Origin.X, Origin.Y + Size.Y); gl.glEnd(); gl.glBegin(gl.GL_QUADS); gl.glColor4f(1.0f, 0f, 0f, 0.5f); gl.glVertex2d(Origin.X, Origin.Y); gl.glVertex2d(Origin.X + Size.X, Origin.Y); gl.glVertex2d(Origin.X + Size.X, Origin.Y + Size.Y); gl.glVertex2d(Origin.X, Origin.Y + Size.Y); gl.glEnd(); }
public override void RenderOverlay(Scene scene) { base.RenderOverlay(scene); if (!IsVisible) return; // get the screen coordinates of the axis Coord startCoord = scene.Camera.WorldToScreen(Start); Coord stopCoord = scene.Camera.WorldToScreen(Stop); // flip the coordinates around if they aren't in x order (this helps with drawing ticks) if (startCoord.X > stopCoord.X) { Coord dummy = stopCoord; stopCoord = startCoord; startCoord = dummy; } // the main axis line // RIGHT NOW, THIS IS COLLIDING WITH THE GRID AND LOOKS FUNNY gl.glBegin(gl.GL_LINES); gl.glVertex2d(startCoord.X, startCoord.Y); gl.glVertex2d(stopCoord.X, stopCoord.Y); gl.glEnd(); // get the angle of the main axis line bool isVertical = false, ishorizontal = false; Angle tickAngle = new Angle(); if (startCoord.X == stopCoord.X) // the axis is vertical { isVertical = true; if (startCoord.X < scene.Width / 2) // it's on the left side tickAngle = Angle.Pi(); else tickAngle = new Angle(); } if (startCoord.Y == stopCoord.Y) // the axis is horizontal { ishorizontal = true; if (startCoord.Y < scene.Height / 2) // it's on the bottom side tickAngle = Angle.Pi() * 1.5; else tickAngle = Angle.Pi() * 0.5; } if (ishorizontal && isVertical) // the axis is singular, don't render it return; if (!ishorizontal && !isVertical) // the axis is sloped { tickAngle = Angle.ArcTan(stopCoord.Y - startCoord.Y, stopCoord.X - startCoord.X); // determine which direction to flip it Angle angleToCenter = (stopCoord - startCoord).AngleTo(AxesCenter-startCoord); if (angleToCenter.Value >= 0) tickAngle.DecByHalfPi(); else tickAngle.IncByHalfPi(); } // compute tick position ComputeTickPositions(); // render the axis label double labelOffset = 70; Coord labelPos = (startCoord + stopCoord) / 2; _labelPane.Origin = labelPos + tickAngle.ToCoord() * labelOffset; //if (_labelPane.Label.Body.Length > 5 && tickAngle.ToCoord().Orientation == Orientation.Horizontal) // _labelPane.Angle = Angle.Pi() / 2; //else // _labelPane.Angle = new Angle(); _labelPane.RenderOverlay(scene); // render the ticks gl.glBegin(gl.GL_LINES); for (int i = 0; i < _tickPositions.Length; i++) { startCoord = scene.Camera.WorldToScreen(_tickPositions[i]); gl.glVertex2d(startCoord.X, startCoord.Y); // the point where the tick intersects the axis gl.glVertex2d(startCoord.X + _tickLength * tickAngle.Cos(), startCoord.Y + _tickLength * tickAngle.Sin()); //the other point // store the label position double labelFactor = 3; if (tickAngle.ToCoord().Orientation == Orientation.Horizontal) labelFactor = 4; _tickLabels[i].Origin = startCoord + tickAngle.ToCoord() * labelFactor * _tickLength; } gl.glEnd(); // render the tick labels for (int i = 0; i < _tickPositions.Length; i++) { _tickLabels[i].RenderOverlay(scene); } }
/// <summary> /// Makes the child the current one. /// </summary> /// <remarks>Recursively propogates through the hierarchy.</remarks> protected virtual void MakeChildCurrent(Scene child) { MakeCurrent(); }
public SceneClosingEvent(Scene scene) : base(scene) { }
public SceneRenderEvent(Scene scene) : base(scene) { }
public override void OnSceneResized(Scene scene) { base.OnSceneResized(scene); UpdatePosition(scene); }
public override void RenderOverlay (Scene scene) { base.RenderOverlay (scene); foreach (var anchor in anchors.Values) { anchor.RenderOverlay(scene); } }
/// <summary> /// Updates the position of the anchor based on the scene. /// </summary> private void UpdatePosition(Scene scene) { if (Control != null) { ComputeGeometry(); Control.ComputeGeometry(); switch (location) { case AnchorLocation.N: Origin = new Coord((scene.Width - RenderWidth) / 2.0, scene.Height - RenderHeight); break; case AnchorLocation.NE: Origin = new Coord(scene.Width - RenderWidth - 2, scene.Height - RenderHeight - 2); break; case AnchorLocation.E: Origin = new Coord(scene.Width - RenderWidth, (scene.Height - RenderHeight) / 2.0); break; case AnchorLocation.SE: Origin = new Coord(scene.Width - RenderWidth, 0); break; case AnchorLocation.S: Origin = new Coord((scene.Width - RenderWidth) / 2.0, 0); break; case AnchorLocation.SW: Origin = new Coord(0, 0); break; case AnchorLocation.W: Origin = new Coord(0, (scene.Height - RenderHeight) / 2.0); break; case AnchorLocation.NW: Origin = new Coord(0, scene.Height - RenderHeight); break; } } }
public Viewport(IViewportAdapter adapter) { Lighting = new Lighting(); this.adapter = adapter; RootScene = new Scene(this); }
/// <summary> /// Gets called by the scene when the modal overlay is shown in it. /// </summary> public virtual void OnShown(Scene scene) { }
public override void OnSceneResized(Scene scene) { base.OnSceneResized(scene); foreach (AnchorPane anchor in anchors.Values) anchor.OnSceneResized(scene); }
/// <summary> /// Renders the opaque portion of the renderable. /// </summary> /// <param name="scene"> A <see cref="Scene"/> to render to. </param> public virtual void RenderOpaque(Scene scene) { if (IsDirty) ComputeGeometry(); }
/// <summary> /// Renders the transparent portion of the renderable, /// </summary> /// <param name="scene"> A <see cref="Scene"/> to render to. </param> public virtual void RenderTransparent(Scene scene) { if (IsDirty) ComputeGeometry(); }
/// <summary> /// Default constructor. /// </summary> public KeyEvent(Scene scene, int keyVal, InteractionModifier modifier) : base(scene) { Value = keyVal; Modifier = modifier; }