The default implementation of ITransform.
Inheritance: ITransform
Example #1
0
        public ITransform CreateLocalPosition(Vector3 localPosition)
        {
            var transform = new DefaultTransform();

            transform.LocalPosition = localPosition;
            return(transform);
        }
Example #2
0
        public ITransform CreateFromCustomMatrix(Matrix localMatrix)
        {
            var transform = new DefaultTransform();

            transform.SetFromCustomMatrix(localMatrix);
            return(transform);
        }
Example #3
0
        public ITransform CreateLocalPosition(float x, float y, float z)
        {
            var transform = new DefaultTransform();

            transform.LocalPosition = new Vector3(x, y, z);
            return(transform);
        }
Example #4
0
        public ITransform DeserializeFromNetwork()
        {
            var transform = new DefaultTransform();

            DeserializeFromNetwork(transform);
            return(transform);
        }
 public ITransform CreateFromModifiedSRTFinalTransform(IFinalTransform existingFinalTransform, Vector3 scaleFactor, Quaternion appliedRotation, Vector3 addedPosition)
 {
     var transform = new DefaultTransform();
     //transform.LocalPosition = existingFinalTransform.AbsolutePosition + addedPosition;
     //transform.LocalRotation = existingFinalTransform.AbsoluteRotation * appliedRotation;
     //transform.LocalScale = existingFinalTransform.AbsoluteScale * scaleFactor;            
     return transform;
 }
 public ITransform CreateFromSRTMatrix(Vector3 localScale, Quaternion localRotation, Vector3 localPosition)
 {
     var transform = new DefaultTransform();
     transform.LocalPosition = localPosition;
     transform.LocalRotation = localRotation;
     transform.LocalScale = localScale;
     return transform;
 }
        public Render3DCubeComponent(INode node, I3DRenderUtilities renderUtilities, IAssetManagerProvider assetManagerProvider)
        {
            _node = node;
            _renderUtilities = renderUtilities;

            Enabled = true;
            Effect = assetManagerProvider.GetAssetManager().Get<UberEffectAsset>("effect.BuiltinSurface").Effects?["Color"];
            Transform = new DefaultTransform();
        }
Example #8
0
        public Render3DCubeComponent(INode node, I3DRenderUtilities renderUtilities, IAssetManager assetManager)
        {
            _node                 = node;
            _renderUtilities      = renderUtilities;
            _defaultSurfaceEffect = assetManager.Get <UberEffectAsset>("effect.BuiltinSurface");

            Enabled   = true;
            Transform = new DefaultTransform();
        }
Example #9
0
        public ITransform CreateFromModifiedSRTFinalTransform(IFinalTransform existingFinalTransform, Vector3 scaleFactor, Quaternion appliedRotation, Vector3 addedPosition)
        {
            var transform = new DefaultTransform();

            //transform.LocalPosition = existingFinalTransform.AbsolutePosition + addedPosition;
            //transform.LocalRotation = existingFinalTransform.AbsoluteRotation * appliedRotation;
            //transform.LocalScale = existingFinalTransform.AbsoluteScale * scaleFactor;
            return(transform);
        }
Example #10
0
        public ITransform CreateFromSRTMatrix(Vector3 localScale, Quaternion localRotation, Vector3 localPosition)
        {
            var transform = new DefaultTransform();

            transform.LocalPosition = localPosition;
            transform.LocalRotation = localRotation;
            transform.LocalScale    = localScale;
            return(transform);
        }
Example #11
0
        protected PhysicalBaseRigidBodyComponent(INode node, IPhysicsEngine physicsEngine)
        {
            _node           = node;
            _physicsEngine  = physicsEngine;
            _addedRigidBody = false;

            Enabled   = true;
            Transform = new DefaultTransform();
        }
        public Render3DCubeComponent(INode node, I3DRenderUtilities renderUtilities, IAssetManagerProvider assetManagerProvider)
        {
            _node            = node;
            _renderUtilities = renderUtilities;

            Enabled   = true;
            Effect    = assetManagerProvider.GetAssetManager().Get <UberEffectAsset>("effect.BuiltinSurface").Effects?["Color"];
            Transform = new DefaultTransform();
        }
Example #13
0
 public Wall(I2DRenderUtilities twoDRenderUtilities, Vector2 start, Vector2 end)
 {
     this.Start                      = start;
     this.End                        = end;
     this.DebugRender                = false;
     this.m_2DRenderUtilities        = twoDRenderUtilities;
     this.DebugRenderWallColor       = Color.Black;
     this.DebugRenderWallNormalColor = Color.DarkGray;
     Transform                       = new DefaultTransform();
 }
Example #14
0
 public Wall(I2DRenderUtilities twoDRenderUtilities, Vector2 start, Vector2 end)
 {
     this.Start = start;
     this.End = end;
     this.DebugRender = false;
     this.m_2DRenderUtilities = twoDRenderUtilities;
     this.DebugRenderWallColor = Color.Black;
     this.DebugRenderWallNormalColor = Color.DarkGray;
     Transform = new DefaultTransform();
 }
Example #15
0
        /// <summary>
        /// Initializes a new <see cref="ComponentizedEntity"/>.
        /// <para>
        /// Componentized entities are entities which automatically support the attachment
        /// of updatable and renderable components (<see cref="IUpdatableComponent"/> and
        /// <see cref="IRenderableComponent"/> respectively).
        /// </para>
        /// </summary>
        protected ComponentizedEntity()
        {
            Transform = new DefaultTransform();

            _handleEvent = RegisterCallable <IEventfulComponent, IGameContext, IEventEngine <IGameContext>, Event, EventState>(EventCallback);
            _handleMessageRecievedClient = RegisterCallable <INetworkedComponent, IGameContext, IUpdateContext, MxDispatcher, MxClient, byte[], uint, EventState>(ClientMessageCallback);
            _handleMessageRecievedServer = RegisterCallable <INetworkedComponent, IServerContext, IUpdateContext, MxDispatcher, MxClient, byte[], uint, EventState>(ServerMessageCallback);
            _networkIdentifiableClient   = RegisterCallable <INetworkIdentifiable, IGameContext, IUpdateContext, int, int>((c, g, u, i, ft) => c.ReceiveNetworkIDFromServer(g, u, i, ft));
            _networkIdentifiableServer   = RegisterCallable <INetworkIdentifiable, IServerContext, IUpdateContext, MxClient, int>((c, s, u, mc, i) => c.ReceivePredictedNetworkIDFromClient(s, u, mc, i));
            _getLights = RegisterCallable <ILightableComponent, List <ILight> >(GetLightCallback);

            OnComponentsChanged();
        }
        public Render3DModelComponent(
            INode node,
            I3DRenderUtilities renderUtilities,
            IAssetManagerProvider assetManagerProvider,
            ITextureFromHintPath textureFromHintPath,
            IRenderBatcher renderBatcher)
        {
            _node                = node;
            _renderUtilities     = renderUtilities;
            _textureFromHintPath = textureFromHintPath;
            _renderBatcher       = renderBatcher;
            _assetManager        = assetManagerProvider.GetAssetManager();
            _animationTracker    = new Stopwatch();

            Enabled   = true;
            Transform = new DefaultTransform();
        }
Example #17
0
        public EntityGroup(INode node, IEditorQuery <EntityGroup> editorQuery)
        {
            _node     = node;
            Transform = new DefaultTransform();

            // EditorGroup is used to represent game groups in the editor
            // and we need to map the transform to this object.
            if (editorQuery.Mode == EditorQueryMode.LoadingConfiguration)
            {
                editorQuery.MapTransform(this, x => this.Transform.Assign(x));

                _node.ChildrenChanged    += ChildrenChanged;
                _node.DescendantsChanged += DescendantsChanged;
                ChildrenChanged(null, null);
                DescendantsChanged(null, null);
            }
        }
 public ITransform CreateFromCustomMatrix(Matrix localMatrix)
 {
     var transform = new DefaultTransform();
     transform.SetFromCustomMatrix(localMatrix);
     return transform;
 }
 public ITransform CreateLocalPosition(float x, float y, float z)
 {
     var transform = new DefaultTransform();
     transform.LocalPosition = new Vector3(x, y, z);
     return transform;
 }
 public ITransform CreateLocalPosition(Vector3 localPosition)
 {
     var transform = new DefaultTransform();
     transform.LocalPosition = localPosition;
     return transform;
 }
        public Render3DModelComponent(
            INode node,
            I3DRenderUtilities renderUtilities,
            IAssetManagerProvider assetManagerProvider,
            ITextureFromHintPath textureFromHintPath,
            IRenderBatcher renderBatcher)
        {
            _node = node;
            _renderUtilities = renderUtilities;
            _textureFromHintPath = textureFromHintPath;
            _renderBatcher = renderBatcher;
            _assetManager = assetManagerProvider.GetAssetManager();
            _animationTracker = new Stopwatch();

            Enabled = true;
            Transform = new DefaultTransform();
        }
 public ITransform DeserializeFromNetwork()
 {
     var transform = new DefaultTransform();
     DeserializeFromNetwork(transform);
     return transform;
 }
Example #23
0
        public AbsoluteMatrixComponent(INode node)
        {
            _finalTransform = new DefaultFinalTransform(this, node);

            Transform = new DefaultTransform();
        }
Example #24
0
 /// <summary>
 /// Initializes a new entity.
 /// </summary>
 public Entity()
 {
     Transform = new DefaultTransform();
 }
Example #25
0
 /// <summary>
 /// Initializes a new entity.
 /// </summary>
 public Entity()
 {
     _finalTransform = new DefaultFinalTransform(this, null);
     Transform       = new DefaultTransform();
 }
Example #26
0
        public sealed override ITransform Get(int tick)
        {
            int previousTick, nextTick;

            this.FindSurroundingTickValues(
                this.KnownKeys,
                tick,
                out previousTick,
                out nextTick);

            if (previousTick != -1)
            {
                previousTick = this.KnownKeys[previousTick];
            }

            if (nextTick != -1)
            {
                nextTick = this.KnownKeys[nextTick];
            }

            if (previousTick != -1 && nextTick != -1)
            {
                // If they are the same, skip and return the value.
                if (previousTick == nextTick)
                {
                    return(this.KnownValues[previousTick]);
                }

                // Construct a new transform based on linearly interpolating
                // the values within the transform.
                var previousValue = this.KnownValues[previousTick];
                var nextValue     = this.KnownValues[nextTick];

                if (previousValue.IsSRTMatrix != nextValue.IsSRTMatrix)
                {
                    // We can't interpolate this.
                    return(this.KnownValues[previousTick]);
                }

                var ratio = (tick - previousTick) / (nextTick - (float)previousTick);

                if (previousValue.IsSRTMatrix && nextValue.IsSRTMatrix)
                {
                    // Interpolate based on local position, rotation and scale.
                    return(new DefaultTransform
                    {
                        LocalPosition = Vector3.Lerp(previousValue.LocalPosition, nextValue.LocalPosition, ratio),
                        LocalRotation = Quaternion.Lerp(previousValue.LocalRotation, nextValue.LocalRotation, ratio),
                        LocalScale = Vector3.Lerp(previousValue.LocalScale, nextValue.LocalScale, ratio),
                    });
                }

                if (!previousValue.IsSRTMatrix && !nextValue.IsSRTMatrix)
                {
                    // Interpolate using the custom matrix.  This will probably give a nonsensical
                    // result in most cases?
                    var transform = new DefaultTransform();
                    transform.SetFromCustomMatrix(Matrix.Lerp(previousValue.LocalMatrix, nextValue.LocalMatrix, ratio));
                    return(transform);
                }
            }

            if (previousTick != -1 && nextTick == -1)
            {
                // Return the previous value and don't attempt to predict the future.
                return(this.KnownValues[previousTick]);
            }

            if (nextTick == -1 && previousTick != -1)
            {
                // TODO: Extrapolation
                return(this.KnownValues[previousTick]);
            }

            return(new DefaultTransform());
        }