コード例 #1
0
        public static void AddTestComponent( Entity entity, GeometricPrimitiveType primitiveType, float size )
        {
            Transform transform = new Transform();
            entity.AddAttribute( Attributes.TRANSFORM, transform );

            PrimitiveRenderComponent renderComponent = new PrimitiveRenderComponent( entity );
            renderComponent.GeometricPrimitiveType = primitiveType;
            renderComponent.Color = Color.LimeGreen;
            renderComponent.Wireframe = false;
            renderComponent.m_size = size;
            entity.AddComponent( renderComponent );
        }
コード例 #2
0
        public static void AddShipTestComponent(Entity entity)
        {
            ModelRenderComponent component = new ModelRenderComponent( entity );

            ModelRenderData componentData = new ModelRenderData();
            componentData.Model = "Models/Ship";
            Transform modelTransform = new Transform();
            modelTransform.Scale = new Vector3( 0.001f );
            componentData.Transform = modelTransform;

            component.LoadData( componentData );
            entity.AddComponent( component );
        }
コード例 #3
0
ファイル: ScenegraphNode.cs プロジェクト: tgorkin/XEngine
 public ScenegraphNode FindByTransform(Transform searchTransform)
 {
     ScenegraphNode result = null;
     if ( m_transform == searchTransform ) {
         result = this;
     } else {
         foreach ( ScenegraphNode childNode in Children ) {
             result = childNode.FindByTransform( searchTransform );
             if ( result != null ) {
                 break;
             }
         }
     }
     return result;
 }
コード例 #4
0
 public override void Initialize()
 {
     m_primitive = GeometricPrimitive.Factory( this.m_primitiveType, m_size );
     m_transform = this.Entity.GetAttribute<Transform>( Attributes.TRANSFORM );
     m_primitive.Color = m_color;
     m_primitive.Wireframe = m_wireframe;
     m_primitive.Initialize();
 }
コード例 #5
0
ファイル: Transform.cs プロジェクト: tgorkin/XEngine
 public void UpdateWorld(Transform parent)
 {
     if ( parent != null ) {
         m_world = Local * parent.World;
     } else {
         m_world = Local;
     }
     m_isDirty = false;
 }
コード例 #6
0
ファイル: Transform.cs プロジェクト: tgorkin/XEngine
        public static Transform CreateFromType( TransformType type, float value )
        {
            Transform result = new Transform();
            switch ( type ) {
                case TransformType.RotationX:
                    result.Rotation = Matrix.CreateRotationX( value );
                    break;
                case TransformType.RotationY:
                    result.Rotation = Matrix.CreateRotationY( value );
                    break;
                case TransformType.RotationZ:
                    result.Rotation = Matrix.CreateRotationZ( value );
                    break;
                case TransformType.TranslationX:
                    result.Position = new Vector3(value, 0, 0);
                    break;
                case TransformType.TranslationY:
                    result.Position = new Vector3(0, value, 0);
                    break;
                case TransformType.TranslationZ:
                    result.Position = new Vector3(0, 0, value);
                    break;
                case TransformType.ScaleX:
                    result.Scale = new Vector3( value, 1, 1 );
                    break;
                case TransformType.ScaleY:
                    result.Scale = new Vector3( 1, value, 1 );
                    break;
                case TransformType.ScaleZ:
                    result.Scale = new Vector3( 1, 1, value );
                    break;

            }
            return result;
        }
コード例 #7
0
ファイル: MoveComponent.cs プロジェクト: tgorkin/XEngine
 public override void Initialize()
 {
     m_transform = this.Entity.GetAttribute<Transform>( Attributes.TRANSFORM );
     m_velocity = this.Entity.GetAttribute<Vector3>( Attributes.VELOCITY );
 }
コード例 #8
0
ファイル: ScenegraphNode.cs プロジェクト: tgorkin/XEngine
 public ScenegraphNode(Transform transform)
 {
     m_transform = transform;
     Children = new List<ScenegraphNode>();
 }
コード例 #9
0
 public ModelRenderComponent( Entity entity )
     : base(entity)
 {
     m_localTransform = new Transform();
 }
コード例 #10
0
 public override void LoadData( ComponentData componentData )
 {
     ModelRenderData data = componentData as ModelRenderData;
     if ( data != null ) {
         m_modelName = data.Model;
         m_localTransform = data.Transform;
     }
 }
コード例 #11
0
        public override void Initialize()
        {
            m_model = new XEngineModel( m_modelName );
            m_model.Initialize();
            m_entityTransform = this.Entity.GetAttribute<Transform>( Attributes.TRANSFORM );

            //BoundingSphere boundingSphere = ModelUtils.GetGlobalBoundingSphere( m_model );
            //BoundingSphere boundingSphere = m_model.Meshes[1].BoundingSphere;
            //boundingSphere = boundingSphere.Transform( m_localTransform.Local );
            //this.Entity.AddAttribute( Attributes.BOUNDING_SPHERE, boundingSphere );
        }
コード例 #12
0
ファイル: OrbitComponent.cs プロジェクト: tgorkin/XEngine
 public override void Initialize()
 {
     m_transform = this.Entity.GetAttribute<Transform>( Attributes.TRANSFORM );
 }