Пример #1
0
 /// <summary>
 /// 視線と逆を向く回転行列作成
 /// </summary>
 /// <param name="camera"></param>
 /// <returns></returns>
 Matrix CalcBillboardRotateMatrix(CameraBase camera)
 {
     var rotatMatrix = Matrix.CreateLookAt(
         Vector3.Zero,
         camera.At - camera.Eye,
         camera.Up);
     return Matrix.Invert(rotatMatrix);
 }
Пример #2
0
        Matrix CalcWorldMatrix(AffineTransform transform, CameraBase camera)
        {
            var scale = Matrix.CreateScale(transform.Scale);
            var rotat =
                Matrix.CreateRotationZ(transform.Rotation.Z) *
                Matrix.CreateRotationY(transform.Rotation.Y) *
                Matrix.CreateRotationX(transform.Rotation.X) *
                CalcBillboardRotateMatrix(camera);
            var trans = Matrix.CreateTranslation(transform.Translation);

            return scale * rotat * trans;
        }
Пример #3
0
 public Deco_Shock(AffineTransform transform, CameraBase camera)
 {
     for (var i = 0; i < 3; ++i)
     {
         Particles.Add(new ccm.Particle.Particle_Twister(
             transform,
             camera,
             2000.0f,
             120.0f * i,
             360.0f,
             0.0f,
             "Texture/particle001",
             true));
     }
 }
Пример #4
0
 public Deco_Twister(AffineTransform transform, CameraBase camera, HimaLib.Math.IRand rand)
 {
     for (var i = 0; i < 16; ++i)
     {
         Particles.Add(new ccm.Particle.Particle_Twister(
             transform,
             camera,
             rand.NextFloat() * 100.0f + 900.0f,
             rand.NextFloat() * 360.0f,
             rand.NextFloat() * 180.0f + 300.0f,
             rand.NextFloat() * 10.0f + 5.0f,
             "Texture/particle000",
             false));
     }
 }
Пример #5
0
        public void UpdateFrustum(CameraBase camera)
        {
            var invViewProj = Matrix.Invert(camera.View * camera.Projection);

            var projCorners = new Vector3[8]
            {
                new Vector3(-1, 1, 0),  // 0 near_tl
                new Vector3(1, 1, 0),   // 1 near_tr
                new Vector3(-1, -1, 0), // 2 near_bl
                new Vector3(1, -1, 0),  // 3 near_br
                new Vector3(-1, 1, 1),  // 4 far_tl
                new Vector3(1, 1, 1),   // 5 far_tr
                new Vector3(-1, -1, 1), // 6 far_bl
                new Vector3(1, -1, 1),  // 7 far_br
            };

            var worldCorners = projCorners.Select(c =>
            {
                return Vector3.TransformCoord(c, invViewProj);
            }).ToArray();

            // 法線が視錐台の外側を向くように面を作る(右手系)
            Planes[0] = new Plane(worldCorners[0], worldCorners[2], worldCorners[1]);   // Near
            Planes[1] = new Plane(worldCorners[5], worldCorners[7], worldCorners[4]);   // Far
            Planes[2] = new Plane(worldCorners[0], worldCorners[1], worldCorners[4]);   // Top
            Planes[3] = new Plane(worldCorners[2], worldCorners[6], worldCorners[3]);   // Bottom
            Planes[4] = new Plane(worldCorners[0], worldCorners[4], worldCorners[2]);   // Left
            Planes[5] = new Plane(worldCorners[1], worldCorners[3], worldCorners[5]);   // Right

            // 簡易版は視錐台に外接するAABBでカリングする
            MinFrustumAABB = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
            MaxFrustumAABB = new Vector3(float.MinValue, float.MinValue, float.MinValue);

            foreach (var frustumCorner in worldCorners)
            {
                MinFrustumAABB.X = MathUtil.Min(MinFrustumAABB.X, frustumCorner.X);
                MinFrustumAABB.Y = MathUtil.Min(MinFrustumAABB.Y, frustumCorner.Y);
                MinFrustumAABB.Z = MathUtil.Min(MinFrustumAABB.Z, frustumCorner.Z);

                MaxFrustumAABB.X = MathUtil.Max(MaxFrustumAABB.X, frustumCorner.X);
                MaxFrustumAABB.Y = MathUtil.Max(MaxFrustumAABB.Y, frustumCorner.Y);
                MaxFrustumAABB.Z = MathUtil.Max(MaxFrustumAABB.Z, frustumCorner.Z);
            }
        }
Пример #6
0
        public ViewerCameraUpdater(CameraBase camera, IController controller)
        {
            this.camera = camera;
            this.controller = controller;

            InitEyeZ = 30.0f;
            MaxEyeZ = 110.0f;
            MinEyeZ = 10.0f;
            EyeZInterval = 0.1f;

            RotInterval = 0.04f;
            PanInterval = 0.2f;

            MaxRotX = MathUtil.PiOver2 * 0.99f;
            MinRotX = -MathUtil.PiOver2 * 0.99f;

            EnableCameraKey = false;
            EnablePan = false;
            RotWithoutKey = false;

            Reset();
        }
Пример #7
0
        public Particle_Twister(
            HimaLib.Math.AffineTransform transform, 
            CameraBase camera,
            float finishMilliSeconds,
            float startDegree,
            float degreeDelta,
            float endHeightDelta,
            string textureName,
            bool loop)
        {
            InitialPosition = new Vector3(transform.Translation);
            Transform = new AffineTransform(transform);

            SimpleBillboardRenderParameter.IsShadowCaster = false;
            SimpleBillboardRenderParameter.IsShadowReceiver = false;
            SimpleBillboardRenderParameter.IsTranslucent = true;
            SimpleBillboardRenderParameter.GBufferEnabled = false;

            SimpleBillboardRenderParameter.Camera = camera;
            SimpleBillboardRenderParameter.Alpha = 0.8f;

            SimpleBillboardRenderParameter.AffineTransform = Transform;
            SimpleBillboardRenderParameter.AffineTransform.Scale = Vector3.One * 0.04f;
            SimpleBillboardRenderParameter.AffineTransform.Rotation = Vector3.Zero;

            SimpleBillboardRenderParameter.Texture = TextureFactory.Instance.CreateFromImage(textureName);

            if (loop)
            {
                CreateUpdater(finishMilliSeconds, startDegree, degreeDelta, endHeightDelta);
            }
            else
            {
                CreateUpdater(finishMilliSeconds, startDegree, degreeDelta, endHeightDelta, () => { Alive = false; });
            }
        }