Ejemplo n.º 1
0
        public LEDTerrainModule(ModuleConfiguration moduleConfiguration) : base(moduleConfiguration, 2.5f)
        {
            perlin  = new Perlin(-1);
            matProj = Mat4x4.MakeProjection(45.0f, 1.5f, 0.1f, 1000.0f);

            // Set up "World Tranmsform" though not updating theta
            // makes this a bit redundant
            Mat4x4 matRotZ, matRotX;

            matRotZ = Mat4x4.MakeRotationZ(0f);
            matRotX = Mat4x4.MakeRotationX(1.1f);

            Mat4x4 matTrans = Mat4x4.MakeTranslation(0.0f, 0.0f, 5.0f);

            matWorld = Mat4x4.MakeIdentity(); // Form World Matrix
            matWorld = matRotZ * matRotX;     // Transform by rotation
            matWorld = matWorld * matTrans;   // Transform by translation

            // Create "Point At" Matrix for camera
            Vector3D vUp          = new Vector3D(0, 2, 0);
            Vector3D vTarget      = new Vector3D(0, 0, 1);
            Mat4x4   matCameraRot = Mat4x4.MakeRotationY(fYaw);

            vLookDir = matCameraRot * vTarget;
            vTarget  = vCamera + vLookDir;
            Mat4x4 matCamera = Mat4x4.PointAt(vCamera, vTarget, vUp);

            // Make view matrix from camera
            matView = matCamera.QuickInverse();
        }
Ejemplo n.º 2
0
        protected override Image <Rgba32> Run()
        {
            fElapsedTime = stopwatch.ElapsedMilliseconds / 1000f;
            stopwatch.Restart();
            image           = new Image <Rgba32>(renderWidth, renderHeight);
            engine3D.Canvas = image;

            // Set up "World Tranmsform" though not updating theta
            // makes this a bit redundant
            Mat4x4 matRotZ, matRotX;

            fTheta += 1.0f * fElapsedTime;             // Uncomment to spin me right round baby right round
            matRotZ = Mat4x4.MakeRotationZ(fTheta * 0.5f);
            matRotX = Mat4x4.MakeRotationX(fTheta);

            Mat4x4 matTrans = Mat4x4.MakeTranslation(0.0f, 0.0f, 5.0f);

            Mat4x4 matWorld = Mat4x4.MakeIdentity();  // Form World Matrix

            matWorld = matRotZ * matRotX;             // Transform by rotation
            matWorld = matWorld * matTrans;           // Transform by translation

            // Create "Point At" Matrix for camera
            Vector3D vUp          = new Vector3D(0, 1, 0);
            Vector3D vTarget      = new Vector3D(0, 0, 1);
            Mat4x4   matCameraRot = Mat4x4.MakeRotationY(fYaw);

            vLookDir = matCameraRot * vTarget;
            vTarget  = vCamera + vLookDir;
            Mat4x4 matCamera = Mat4x4.PointAt(vCamera, vTarget, vUp);

            // Make view matrix from camera
            Mat4x4 matView = matCamera.QuickInverse();

            // Store triagles for rastering later
            // Store triagles for rastering later
            drawTriangles(meshCube, matWorld, matView, matProj, vCamera, light_direction, false);

            image.Mutate(c => c.Resize(LEDWidth, LEDHeight));
            return(image);
        }