Table of Contents

Class DemoSatellite

Namespace
Sample.Disp
Assembly
Hi.Sample.Wpf.dll

Demonstrates a simple solar system animation using IDisplayee interface. Shows how to create a hierarchical transform structure with sun, earth and moon using Mat4d matrices and model matrix stack transformations.

public class DemoSatellite : IDisplayee, IExpandToBox3d
Inheritance
DemoSatellite
Implements
Inherited Members

Remarks

Source Code

using Hi.Geom;
using Hi.Disp;

namespace Sample.Disp
{
    /// <summary>
    /// Demonstrates a simple solar system animation using <see cref="IDisplayee"/> interface.
    /// Shows how to create a hierarchical transform structure with sun, earth and moon using
    /// <see cref="Mat4d"/> matrices and model matrix stack transformations.
    /// </summary>
    /// <remarks>
    /// ### Source Code
    /// [!code-csharp[SampleCode](~/../Hi.Sample.Wpf/Disp/DemoSatellite.cs)]
    /// </remarks>
    public class DemoSatellite : IDisplayee
    {
        Drawing sun;
        Drawing earth;
        Drawing moon;
        double angle_earth;
        double angle_moon;
        DemoSatellite()
        {
            sun = Box3d.CenterUnitBox.ScaleFromCenter(4).ToDraw_Face();
            earth = Box3d.CenterUnitBox.ScaleFromCenter(2).ToDraw_Face();
            moon = Box3d.CenterUnitBox.ToDraw_Face();
        }
        /// <inheritdoc/>
        public void Display(Bind bind)
        {
            sun.Display(bind);
            bind.ModelMatStack.Push();
            bind.ModelMatStack.Mul(new Mat4d(new AxisAngle4d(new Vec3d(0, 0, 1), angle_earth += 0.03)));
            bind.ModelMatStack.Mul(new Mat4d(new Vec3d(12, 0, 0)));
            earth.Display(bind);
            bind.ModelMatStack.Push();
            bind.ModelMatStack.Mul(new Mat4d(new AxisAngle4d(new Vec3d(0, 0, 1), angle_moon += 0.02)));
            bind.ModelMatStack.Mul(new Mat4d(new Vec3d(4, 0, 0)));
            moon.Display(bind);
            bind.ModelMatStack.Pop();
            bind.ModelMatStack.Pop();
        }
        /// <inheritdoc/>
        public void ExpandToBox3d(Box3d dst)
        {
            dst.Expand(new Vec3d(-14, -14, -2));
            dst.Expand(new Vec3d(14, 14, 2));
        }

        static void Main()
        {
            DemoUtil.RunApplication("DemoSatellite", new DemoSatellite());
        }
    }
}

Methods

Display(Bind)

Display function called in DispEngine rendering loop.

public void Display(Bind bind)

Parameters

bind Bind

Bind with DispEngine. See Bind.

ExpandToBox3d(Box3d)

Expands the destination box. This function is usually used to compute the bounding box of elements.

public void ExpandToBox3d(Box3d dst)

Parameters

dst Box3d

Destination box