Eyeshot 11 WinForms API Reference
WinForms Assembly / devDept.Eyeshot.Entities Namespace / BlockReference Class / MoveTo Method
Example

In This Topic
    MoveTo Method
    In This Topic
    Allow the entity to be moved/rotated on the GPU using OpenGL calls during animation.
    Syntax
    'Declaration
     
    Public Overridable Sub MoveTo( _
       ByVal data As DrawParams _
    ) 
    public virtual void MoveTo( 
       DrawParams data
    )

    Parameters

    data
    Remarks

    There is no need to encapsulate the transformations into the gl.PushMatrix() / gl.PopMatrix() calls

    It is always recommended to call base class implementation from overriders.

    It's important when applying an on-the-fly transformation in this method to override the BlockReference.IsInFrustum()and call the base method with the "center" parameter transformed in the same way, in order to avoid undesired clipping.
    Example
    The following code demonstrates how to animate a subclassed BlockReference entity.
    class Oscillating : BlockReference
    {
     
    double alpha;
     double beta;
     double xPos;
     
    public Oscillating(string blockName)
     : base(0, 0, 0, blockName, 1, 1, 1, 0)
     {
     }
     
    protected override void Animate(int frameNumber)
     {
     
    alpha += 1;
     
    if (alpha > 359)
     
    alpha = 0;
     
    // cranckshaft radius
     double r = 50;
     // connecting rod length
     double l = 120;
     
    beta = Math.Asin(r * Math.Sin(Utility.DegToRad(alpha)) / l);
     
    xPos = r * Math.Cos(Utility.DegToRad(alpha)) - l * Math.Cos(beta);
     
    }
     
    public override void MoveTo()
     {
     
    base.MoveTo();
     
    gl.Translated(xPos, 0, 0); 
    gl.Rotated(Utility.RadToDeg(beta), 0, 1, 0);
     
    }
     
    }
    Class Oscillating
     Inherits BlockReference
     
    Private alpha As Double
     Private beta As Double
     Private xPos As Double
     
    Public Sub New(ByVal blockName As String)
     MyBase.New(0, 0, 0, blockName, 1, 1, _ 
    1, 0)
     End Sub
     
    Protected Overloads Overrides Sub Animate(ByVal frameNumber As Integer)
     
    alpha += 1
     
    If alpha > 359 Then
     
    alpha = 0
     
    End If
     
    ' cranckshaft radius
     Dim r As Double = 50
     ' connecting rod length
     Dim l As Double = 120
     
    beta = Math.Asin(r * Math.Sin(Utility.DegToRad(alpha)) / l)
     
    xPos = r * Math.Cos(Utility.DegToRad(alpha)) - l * Math.Cos(beta)
     
    End Sub
     
    Public Overloads Overrides Sub MoveTo()
     
    MyBase.MoveTo()
     
    gl.Translated(xPos, 0, 0)
     
    gl.Rotated(Utility.RadToDeg(beta), 0, 1, 0)
     
    End Sub
     
    End Class
    See Also