Esempio n. 1
0
        public static void update()
        {
            bool modified = false;

              int camera_count = camera_transform_stack_count;
              if (camera_transform_stack_modified)
              {
            modified = true;
            camera_transform_stack_modified = false;

            if (camera_count > 0)
            {
              int mpos = 0;
              camera_transform = camera_transform_stack[0];

              while (--camera_count > 0)
              {
            camera_transform = camera_transform.times(camera_transform_stack[++mpos]);
              }
            }
            else
            {
              camera_transform = new Matrix2x3(1,0,0,0,1,0);
            }
              }

              int  object_count = object_transform_stack_count;
              if (object_transform_stack_modified)
              {
            modified = true;
            object_transform_stack_modified = false;

            if (object_count > 0)
            {
              int mpos = object_count;
              object_transform = object_transform_stack[--mpos];

              while (--object_count > 0)
              {
            object_transform = object_transform.times( object_transform_stack[--mpos] );
              }
            }
            else
            {
              object_transform = new Matrix2x3(1,0,0,0,1,0);
            }
              }

              if (modified) transform = camera_transform.times( object_transform );
        }
Esempio n. 2
0
        public static CompoundTransform create_from( ClassTransformManager obj,
            CompoundVector2 size, CompoundVector2 handle,
            CompoundRadians angle, CompoundVector2 scale,
            CompoundVector2 position,
            bool hflip, bool vflip)
        {
            double handle_x = handle.property_x;
              double handle_y = handle.property_y;
              double size_x = size.property_x;
              double size_y = size.property_y;
              double scale_x = scale.property_x;
              double scale_y = scale.property_y;

              if (hflip || vflip)
              {
            handle_x -= size_x / 2.0;
            handle_y -= size_y / 2.0;
              }

              double cost = Math.Cos(angle.property_value);
              double sint = Math.Sin(angle.property_value);

              double r1c1 = cost*scale_x;
              double r1c2 = -sint*scale_y;
              double r1c3 = position.property_x - scale_x*handle_x*cost + sint*scale_y*handle_y;

              double r2c1 = sint*scale_x;
              double r2c2 = cost*scale_y;
              double r2c3 = position.property_y - scale_x*handle_x*sint - cost*scale_y*handle_y;

              Matrix2x3 m = new Matrix2x3(r1c1,r1c2,r1c3,r2c1,r2c2,r2c3);
              if (hflip || vflip)
              {
            if (hflip)
            {
              if (vflip)
              {
            m = m.times( new Matrix2x3(-1,0,0,0,-1,0) );
              }
              else
              {
            m = m.times( new Matrix2x3(-1,0,0,0,1,0) );
              }
            }
            else
            {
              m = m.times( new Matrix2x3(1,0,0,0,-1,0) );
            }

            // translate by -size/2
            m = m.times( new Matrix2x3(1,0,-size_x/2.0,0,1,-size_y/2.0) );
              }

              return new CompoundTransform(
            new CompoundTransformRow(m.r1c1,m.r1c2,m.r1c3),
            new CompoundTransformRow(m.r2c1,m.r2c2,m.r2c3)
              );
        }