Beispiel #1
0
        protected override void UpdateResourceCore(DUCE.Channel channel)
        {
            Debug.Assert(_duceResource.IsOnChannel(channel));
            DependencyObject dobj = ((DependencyObject)_dependencyObject.Target);

            // The dependency object was GCed, nothing to do here
            if (dobj == null)
            {
                return;
            }

            Vector3D tempValue = (Vector3D)dobj.GetValue(_dependencyProperty);

            DUCE.MILCMD_VECTOR3DRESOURCE data;
            data.Type   = MILCMD.MilCmdVector3DResource;
            data.Handle = _duceResource.GetHandle(channel);
            data.Value  = CompositionResourceManager.Vector3DToMilPoint3F(tempValue);

            unsafe
            {
                channel.SendCommand(
                    (byte *)&data,
                    sizeof(DUCE.MILCMD_VECTOR3DRESOURCE));
            }
        }
Beispiel #2
0
        internal override void UpdateResource(DUCE.Channel channel, bool skipOnChannelCheck)
        {
            // If we're told we can skip the channel check, then we must be on channel
            Debug.Assert(!skipOnChannelCheck || _duceResource.IsOnChannel(channel));

            if (skipOnChannelCheck || _duceResource.IsOnChannel(channel))
            {
                base.UpdateResource(channel, skipOnChannelCheck);

                // Read values of properties into local variables
                Transform3D vTransform = Transform;

                // Obtain handles for properties that implement DUCE.IResource
                DUCE.ResourceHandle hTransform;
                if (vTransform == null ||
                    Object.ReferenceEquals(vTransform, Transform3D.Identity)
                    )
                {
                    hTransform = DUCE.ResourceHandle.Null;
                }
                else
                {
                    hTransform = ((DUCE.IResource)vTransform).GetHandle(channel);
                }

                // Obtain handles for animated properties
                DUCE.ResourceHandle hColorAnimations     = GetAnimationResourceHandle(ColorProperty, channel);
                DUCE.ResourceHandle hDirectionAnimations = GetAnimationResourceHandle(DirectionProperty, channel);

                // Pack & send command packet
                DUCE.MILCMD_DIRECTIONALLIGHT data;
                unsafe
                {
                    data.Type       = MILCMD.MilCmdDirectionalLight;
                    data.Handle     = _duceResource.GetHandle(channel);
                    data.htransform = hTransform;
                    if (hColorAnimations.IsNull)
                    {
                        data.color = CompositionResourceManager.ColorToMilColorF(Color);
                    }
                    data.hColorAnimations = hColorAnimations;
                    if (hDirectionAnimations.IsNull)
                    {
                        data.direction = CompositionResourceManager.Vector3DToMilPoint3F(Direction);
                    }
                    data.hDirectionAnimations = hDirectionAnimations;

                    // Send packed command structure
                    channel.SendCommand(
                        (byte *)&data,
                        sizeof(DUCE.MILCMD_DIRECTIONALLIGHT));
                }
            }
        }
Beispiel #3
0
        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal Methods

        internal override void UpdateResource(DUCE.Channel channel, bool skipOnChannelCheck)
        {
            // If we're told we can skip the channel check, then we must be on channel
            Debug.Assert(!skipOnChannelCheck || _duceResource.IsOnChannel(channel));

            if (skipOnChannelCheck || _duceResource.IsOnChannel(channel))
            {
                base.UpdateResource(channel, skipOnChannelCheck);

                // Obtain handles for animated properties
                DUCE.ResourceHandle hAxisAnimations  = GetAnimationResourceHandle(AxisProperty, channel);
                DUCE.ResourceHandle hAngleAnimations = GetAnimationResourceHandle(AngleProperty, channel);

                // Pack & send command packet
                DUCE.MILCMD_AXISANGLEROTATION3D data;
                unsafe
                {
                    data.Type   = MILCMD.MilCmdAxisAngleRotation3D;
                    data.Handle = _duceResource.GetHandle(channel);
                    if (hAxisAnimations.IsNull)
                    {
                        data.axis = CompositionResourceManager.Vector3DToMilPoint3F(Axis);
                    }
                    data.hAxisAnimations = hAxisAnimations;
                    if (hAngleAnimations.IsNull)
                    {
                        data.angle = Angle;
                    }
                    data.hAngleAnimations = hAngleAnimations;

                    // Send packed command structure
                    channel.SendCommand(
                        (byte *)&data,
                        sizeof(DUCE.MILCMD_AXISANGLEROTATION3D));
                }
            }
        }
        internal override void UpdateResource(DUCE.Channel channel, bool skipOnChannelCheck)
        {
            // If we're told we can skip the channel check, then we must be on channel
            Debug.Assert(!skipOnChannelCheck || _duceResource.IsOnChannel(channel));

            if (skipOnChannelCheck || _duceResource.IsOnChannel(channel))
            {
                base.UpdateResource(channel, skipOnChannelCheck);

                // Read values of properties into local variables
                Transform3D vTransform = Transform;

                // Obtain handles for properties that implement DUCE.IResource
                DUCE.ResourceHandle hTransform;
                if (vTransform == null ||
                    Object.ReferenceEquals(vTransform, Transform3D.Identity)
                    )
                {
                    hTransform = DUCE.ResourceHandle.Null;
                }
                else
                {
                    hTransform = ((DUCE.IResource)vTransform).GetHandle(channel);
                }

                // Obtain handles for animated properties
                DUCE.ResourceHandle hNearPlaneDistanceAnimations = GetAnimationResourceHandle(NearPlaneDistanceProperty, channel);
                DUCE.ResourceHandle hFarPlaneDistanceAnimations  = GetAnimationResourceHandle(FarPlaneDistanceProperty, channel);
                DUCE.ResourceHandle hPositionAnimations          = GetAnimationResourceHandle(PositionProperty, channel);
                DUCE.ResourceHandle hLookDirectionAnimations     = GetAnimationResourceHandle(LookDirectionProperty, channel);
                DUCE.ResourceHandle hUpDirectionAnimations       = GetAnimationResourceHandle(UpDirectionProperty, channel);
                DUCE.ResourceHandle hFieldOfViewAnimations       = GetAnimationResourceHandle(FieldOfViewProperty, channel);

                // Pack & send command packet
                DUCE.MILCMD_PERSPECTIVECAMERA data;
                unsafe
                {
                    data.Type       = MILCMD.MilCmdPerspectiveCamera;
                    data.Handle     = _duceResource.GetHandle(channel);
                    data.htransform = hTransform;
                    if (hNearPlaneDistanceAnimations.IsNull)
                    {
                        data.nearPlaneDistance = NearPlaneDistance;
                    }
                    data.hNearPlaneDistanceAnimations = hNearPlaneDistanceAnimations;
                    if (hFarPlaneDistanceAnimations.IsNull)
                    {
                        data.farPlaneDistance = FarPlaneDistance;
                    }
                    data.hFarPlaneDistanceAnimations = hFarPlaneDistanceAnimations;
                    if (hPositionAnimations.IsNull)
                    {
                        data.position = CompositionResourceManager.Point3DToMilPoint3F(Position);
                    }
                    data.hPositionAnimations = hPositionAnimations;
                    if (hLookDirectionAnimations.IsNull)
                    {
                        data.lookDirection = CompositionResourceManager.Vector3DToMilPoint3F(LookDirection);
                    }
                    data.hLookDirectionAnimations = hLookDirectionAnimations;
                    if (hUpDirectionAnimations.IsNull)
                    {
                        data.upDirection = CompositionResourceManager.Vector3DToMilPoint3F(UpDirection);
                    }
                    data.hUpDirectionAnimations = hUpDirectionAnimations;
                    if (hFieldOfViewAnimations.IsNull)
                    {
                        data.fieldOfView = FieldOfView;
                    }
                    data.hFieldOfViewAnimations = hFieldOfViewAnimations;

                    // Send packed command structure
                    channel.SendCommand(
                        (byte *)&data,
                        sizeof(DUCE.MILCMD_PERSPECTIVECAMERA));
                }
            }
        }
Beispiel #5
0
        internal override void UpdateResource(DUCE.Channel channel, bool skipOnChannelCheck)
        {
            // If we're told we can skip the channel check, then we must be on channel
            Debug.Assert(!skipOnChannelCheck || _duceResource.IsOnChannel(channel));

            if (skipOnChannelCheck || _duceResource.IsOnChannel(channel))
            {
                base.UpdateResource(channel, skipOnChannelCheck);

                // Read values of properties into local variables
                Transform3D vTransform = Transform;

                // Obtain handles for properties that implement DUCE.IResource
                DUCE.ResourceHandle hTransform;
                if (vTransform == null ||
                    Object.ReferenceEquals(vTransform, Transform3D.Identity)
                    )
                {
                    hTransform = DUCE.ResourceHandle.Null;
                }
                else
                {
                    hTransform = ((DUCE.IResource)vTransform).GetHandle(channel);
                }

                // Obtain handles for animated properties
                DUCE.ResourceHandle hColorAnimations                = GetAnimationResourceHandle(ColorProperty, channel);
                DUCE.ResourceHandle hPositionAnimations             = GetAnimationResourceHandle(PositionProperty, channel);
                DUCE.ResourceHandle hRangeAnimations                = GetAnimationResourceHandle(RangeProperty, channel);
                DUCE.ResourceHandle hConstantAttenuationAnimations  = GetAnimationResourceHandle(ConstantAttenuationProperty, channel);
                DUCE.ResourceHandle hLinearAttenuationAnimations    = GetAnimationResourceHandle(LinearAttenuationProperty, channel);
                DUCE.ResourceHandle hQuadraticAttenuationAnimations = GetAnimationResourceHandle(QuadraticAttenuationProperty, channel);
                DUCE.ResourceHandle hDirectionAnimations            = GetAnimationResourceHandle(DirectionProperty, channel);
                DUCE.ResourceHandle hOuterConeAngleAnimations       = GetAnimationResourceHandle(OuterConeAngleProperty, channel);
                DUCE.ResourceHandle hInnerConeAngleAnimations       = GetAnimationResourceHandle(InnerConeAngleProperty, channel);

                // Pack & send command packet
                DUCE.MILCMD_SPOTLIGHT data;
                unsafe
                {
                    data.Type       = MILCMD.MilCmdSpotLight;
                    data.Handle     = _duceResource.GetHandle(channel);
                    data.htransform = hTransform;
                    if (hColorAnimations.IsNull)
                    {
                        data.color = CompositionResourceManager.ColorToMilColorF(Color);
                    }
                    data.hColorAnimations = hColorAnimations;
                    if (hPositionAnimations.IsNull)
                    {
                        data.position = CompositionResourceManager.Point3DToMilPoint3F(Position);
                    }
                    data.hPositionAnimations = hPositionAnimations;
                    if (hRangeAnimations.IsNull)
                    {
                        data.range = Range;
                    }
                    data.hRangeAnimations = hRangeAnimations;
                    if (hConstantAttenuationAnimations.IsNull)
                    {
                        data.constantAttenuation = ConstantAttenuation;
                    }
                    data.hConstantAttenuationAnimations = hConstantAttenuationAnimations;
                    if (hLinearAttenuationAnimations.IsNull)
                    {
                        data.linearAttenuation = LinearAttenuation;
                    }
                    data.hLinearAttenuationAnimations = hLinearAttenuationAnimations;
                    if (hQuadraticAttenuationAnimations.IsNull)
                    {
                        data.quadraticAttenuation = QuadraticAttenuation;
                    }
                    data.hQuadraticAttenuationAnimations = hQuadraticAttenuationAnimations;
                    if (hDirectionAnimations.IsNull)
                    {
                        data.direction = CompositionResourceManager.Vector3DToMilPoint3F(Direction);
                    }
                    data.hDirectionAnimations = hDirectionAnimations;
                    if (hOuterConeAngleAnimations.IsNull)
                    {
                        data.outerConeAngle = OuterConeAngle;
                    }
                    data.hOuterConeAngleAnimations = hOuterConeAngleAnimations;
                    if (hInnerConeAngleAnimations.IsNull)
                    {
                        data.innerConeAngle = InnerConeAngle;
                    }
                    data.hInnerConeAngleAnimations = hInnerConeAngleAnimations;

                    // Send packed command structure
                    channel.SendCommand(
                        (byte *)&data,
                        sizeof(DUCE.MILCMD_SPOTLIGHT));
                }
            }
        }
Beispiel #6
0
        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal Methods

        internal override void UpdateResource(DUCE.Channel channel, bool skipOnChannelCheck)
        {
            // If we're told we can skip the channel check, then we must be on channel
            Debug.Assert(!skipOnChannelCheck || _duceResource.IsOnChannel(channel));

            if (skipOnChannelCheck || _duceResource.IsOnChannel(channel))
            {
                base.UpdateResource(channel, skipOnChannelCheck);

                // Read values of properties into local variables
                Point3DCollection  vPositions          = Positions;
                Vector3DCollection vNormals            = Normals;
                PointCollection    vTextureCoordinates = TextureCoordinates;
                Int32Collection    vTriangleIndices    = TriangleIndices;

                // Store the count of this resource's contained collections in local variables.
                int PositionsCount          = (vPositions == null) ? 0 : vPositions.Count;
                int NormalsCount            = (vNormals == null) ? 0 : vNormals.Count;
                int TextureCoordinatesCount = (vTextureCoordinates == null) ? 0 : vTextureCoordinates.Count;
                int TriangleIndicesCount    = (vTriangleIndices == null) ? 0 : vTriangleIndices.Count;

                // Pack & send command packet
                DUCE.MILCMD_MESHGEOMETRY3D data;
                unsafe
                {
                    data.Type                   = MILCMD.MilCmdMeshGeometry3D;
                    data.Handle                 = _duceResource.GetHandle(channel);
                    data.PositionsSize          = (uint)(sizeof(MilPoint3F) * PositionsCount);
                    data.NormalsSize            = (uint)(sizeof(MilPoint3F) * NormalsCount);
                    data.TextureCoordinatesSize = (uint)(sizeof(Point) * TextureCoordinatesCount);
                    data.TriangleIndicesSize    = (uint)(sizeof(Int32) * TriangleIndicesCount);

                    channel.BeginCommand(
                        (byte *)&data,
                        sizeof(DUCE.MILCMD_MESHGEOMETRY3D),
                        (int)(data.PositionsSize +
                              data.NormalsSize +
                              data.TextureCoordinatesSize +
                              data.TriangleIndicesSize)
                        );


                    // Copy this collection's elements (or their handles) to reserved data
                    for (int i = 0; i < PositionsCount; i++)
                    {
                        MilPoint3F resource = CompositionResourceManager.Point3DToMilPoint3F(vPositions.Internal_GetItem(i));
                        channel.AppendCommandData(
                            (byte *)&resource,
                            sizeof(MilPoint3F)
                            );
                    }

                    // Copy this collection's elements (or their handles) to reserved data
                    for (int i = 0; i < NormalsCount; i++)
                    {
                        MilPoint3F resource = CompositionResourceManager.Vector3DToMilPoint3F(vNormals.Internal_GetItem(i));
                        channel.AppendCommandData(
                            (byte *)&resource,
                            sizeof(MilPoint3F)
                            );
                    }

                    // Copy this collection's elements (or their handles) to reserved data
                    for (int i = 0; i < TextureCoordinatesCount; i++)
                    {
                        Point resource = vTextureCoordinates.Internal_GetItem(i);
                        channel.AppendCommandData(
                            (byte *)&resource,
                            sizeof(Point)
                            );
                    }

                    // Copy this collection's elements (or their handles) to reserved data
                    for (int i = 0; i < TriangleIndicesCount; i++)
                    {
                        Int32 resource = vTriangleIndices.Internal_GetItem(i);
                        channel.AppendCommandData(
                            (byte *)&resource,
                            sizeof(Int32)
                            );
                    }

                    channel.EndCommand();
                }
            }
        }