public World(Camera camera, Viewport viewport) { this.camera = camera; this.viewport = viewport; this.lights = new List<Light>(); this.sceneObjects = new List<SceneObject>(); }
public Ray ShootRay(Viewport viewport, int x, int y) { Vector3D origin = new Vector3D( viewport.Scaling * ((float)x + 0.5f - (float)viewport.Width / 2f), viewport.Scaling * ((float)y + 0.5f - (float)viewport.Height / 2f), 0f); Vector4D P = new Vector4D(origin); Matrix RX = Matrix.CreateRotationMatrix(Axis.X, alpha); Matrix RY = Matrix.CreateRotationMatrix(Axis.Y, beta); Matrix R = RX * RY; Matrix T = Matrix.CreateTranslationMatrix(position); Vector4D realOrigin = (T * R) * P; return new Ray(realOrigin.Vect3D, forward); }