public void Interpolate(float time, out Transform t) { // Handle boundary conditions for matrix interpolation if (!_actuallyAnimated || time <= _startTime) { t = _startTransform; return; } if (time >= _endTime) { t = _endTransform; return; } float dt = (time - _startTime) / (_endTime - _startTime); // Interpolate translation at _dt_ Vector trans = (1.0f - dt) * _t[0] + dt * _t[1]; // Interpolate rotation at _dt_ Quaternion rotate = Quaternion.Slerp(dt, _r[0], _r[1]); // Interpolate scale at _dt_ var scale = new Matrix4x4(); for (int i = 0; i < 3; ++i) for (int j = 0; j < 3; ++j) scale.M[i, j] = MathUtility.Lerp(dt, _s[0].M[i, j], _s[1].M[i, j]); // Compute interpolated matrix as product of interpolated components t = Transform.Translate(trans) * rotate.ToTransform() * new Transform(scale); }
protected Shape(Transform objectToWorld, bool reverseOrientation) { ObjectToWorld = objectToWorld; WorldToObject = Transform.Invert(objectToWorld); ReverseOrientation = reverseOrientation; TransformSwapsHandedness = objectToWorld.SwapsHandedness(); }
public Material CreateMaterial(ParamSet parameters, Transform transform) { var textureParams = new TextureParams(parameters, MaterialParams, FloatTextures, SpectrumTextures); if (!string.IsNullOrEmpty(CurrentNamedMaterial) && NamedMaterials.ContainsKey(CurrentNamedMaterial)) return NamedMaterials[CurrentNamedMaterial]; return Factories.MakeMaterial(Material, transform, textureParams); }
public Disk(Transform objectToWorld, bool reverseOrientation, float height, float radius, float innerRadius, float phiMax) : base(objectToWorld, reverseOrientation) { _height = height; _radius = radius; _innerRadius = innerRadius; _phiMax = MathUtility.ToRadians(MathUtility.Clamp(phiMax, 0.0f, 360.0f)); }
public Cylinder(Transform objectToWorld, bool reverseOrientation, float radius, float zMin, float zMax, float phiMax) : base(objectToWorld, reverseOrientation) { _radius = radius; _zMin = Math.Min(zMin, zMax); _zMax = Math.Max(zMin, zMax); _phiMax = MathUtility.ToRadians(MathUtility.Clamp(phiMax, 0.0f, 360.0f)); }
public Intersection(DifferentialGeometry dg, Primitive primitive, Transform objectToWorld, Transform worldToObject, float rayEpsilon) { _dg = dg; _primitive = primitive; WorldToObject = worldToObject; ObjectToWorld = objectToWorld; _rayEpsilon = rayEpsilon; }
public Sphere(Transform objectToWorld, bool reverseOrientation, float radius, float z0, float z1, float phiMax) : base(objectToWorld, reverseOrientation) { _radius = radius; _zMin = MathUtility.Clamp(Math.Min(z0, z1), -radius, radius); _zMax = MathUtility.Clamp(Math.Max(z0, z1), -radius, radius); _thetaMin = MathUtility.Acos(MathUtility.Clamp(_zMin / radius, -1.0f, 1.0f)); _thetaMax = MathUtility.Acos(MathUtility.Clamp(_zMax / radius, -1.0f, 1.0f)); _phiMax = MathUtility.ToRadians(MathUtility.Clamp(phiMax, 0.0f, 360.0f)); }
protected ProjectiveCamera(AnimatedTransform cameraToWorld, Transform cameraToScreen, float[] screenWindow, float shutterOpen, float shutterClose, float lensRadius, float focalDistance, Film film) : base(cameraToWorld, shutterOpen, shutterClose, film) { _cameraToScreen = cameraToScreen; _lensRadius = lensRadius; _focalDistance = focalDistance; // Compute projective camera screen transformations _screenToRaster = Transform.Scale(film.XResolution, film.YResolution, 1.0f) * Transform.Scale(1.0f / (screenWindow[1] - screenWindow[0]), 1.0f / (screenWindow[2] - screenWindow[3]), 1.0f) * Transform.Translate(new Vector(-screenWindow[0], -screenWindow[3], 0.0f)); _rasterToScreen = Transform.Invert(_screenToRaster); _rasterToCamera = Transform.Invert(_cameraToScreen) * _rasterToScreen; }
public AnimatedTransform( Transform startTransform, float startTime, Transform endTransform, float endTime) { _startTransform = startTransform; _startTime = startTime; _endTransform = endTransform; _endTime = endTime; _actuallyAnimated = !startTransform.Equals(endTransform); _t = new Vector[2]; _r = new Quaternion[2]; _s = new Matrix4x4[2]; Decompose(startTransform.Matrix, out _t[0], out _r[0], out _s[0]); Decompose(endTransform.Matrix, out _t[1], out _r[1], out _s[1]); }
public static AreaLight MakeAreaLight(string name, Transform lightToWorld, ParamSet parameters, Shape shape) { switch (name) { case "area": case "diffuse": { var l = parameters.FindSpectrum("L", new Spectrum(1.0f)); var scale = parameters.FindSpectrum("scale", new Spectrum(1.0f)); var numSamples = parameters.FindInt32("nsamples", 1); return new DiffuseAreaLight(lightToWorld, l * scale, numSamples, shape); } default: throw new ArgumentException("Unknown area light: " + name); } }
public static Material MakeMaterial(string name, Transform materialToWorld, TextureParams parameters) { switch (name) { case "matte" : { var kd = parameters.GetSpectrumTexture("Kd", new Spectrum(0.5f)); var sigma = parameters.GetFloatTexture("sigma", 0.0f); var bumpMap = parameters.GetOptionalFloatTexture("bumpmap"); return new MatteMaterial(kd, sigma, bumpMap); } default: throw new ArgumentException("Unknown material: " + name); } }
public static Shape MakeShape(string name, Transform objectToWorld, bool reverseOrientation, ParamSet parameters) { switch (name) { case "cylinder": { var radius = parameters.FindSingle("radius", 1.0f); var zMin = parameters.FindSingle("zmin", -1); var zMax = parameters.FindSingle("zmax", 1); var phiMax = parameters.FindSingle("phimax", 360.0f); return new Cylinder(objectToWorld, reverseOrientation, radius, zMin, zMax, phiMax); } case "disk" : { var height = parameters.FindSingle("height", 0.0f); var radius = parameters.FindSingle("radius", 1.0f); var innerRadius = parameters.FindSingle("innerradius", 0.0f); var phiMax = parameters.FindSingle("phimax", 360.0f); return new Disk(objectToWorld, reverseOrientation, height, radius, innerRadius, phiMax); } case "sphere": { var radius = parameters.FindSingle("radius", 1.0f); var zMin = parameters.FindSingle("zmin", -radius); var zMax = parameters.FindSingle("zmax", radius); var phiMax = parameters.FindSingle("phimax", 360.0f); return new Sphere(objectToWorld, reverseOrientation, radius, zMin, zMax, phiMax); } default: throw new ArgumentException("Unknown shape: " + name); } }
public static Transform Invert(Transform t) { return new Transform(t._mInv, t._m); }
public static Light MakeLight(string name, Transform lightToWorld, ParamSet parameters) { switch (name) { case "distant" : { var l = parameters.FindSpectrum("L", new Spectrum(1.0f)); var scale = parameters.FindSpectrum("scale", new Spectrum(1.0f)); var from = parameters.FindPoint("from", Point.Zero); var to = parameters.FindPoint("to", new Point(0, 0, 1)); var dir = from - to; return new DistantLight(lightToWorld, l * scale, dir); } case "point": { var i = parameters.FindSpectrum("I", new Spectrum(1.0f)); var scale = parameters.FindSpectrum("scale", new Spectrum(1.0f)); var from = parameters.FindPoint("from", Point.Zero); var l2w = Transform.Translate((Vector) from) * lightToWorld; return new PointLight(l2w, i * scale); } default: throw new ArgumentException("Unknown light: " + name); } }
protected Light(Transform lightToWorld, int numSamples = 1) { _lightToWorld = lightToWorld; _worldToLight = Transform.Invert(lightToWorld); _numSamples = Math.Max(numSamples, 1); }
public static Transform Transpose(Transform t) { return new Transform( Matrix4x4.Transpose(t._m), Matrix4x4.Transpose(t._mInv)); }
public virtual DifferentialGeometry GetShadingGeometry( Transform objectToWorld, DifferentialGeometry dg) { return dg; }
public static Texture<Spectrum> MakeSpectrumTexture(string name, Transform textureToWorld, TextureParams textureParams) { switch (name) { case "constant": { return new ConstantTexture<Spectrum>(textureParams.FindSpectrum("value", new Spectrum(1.0f))); } default: throw new ArgumentException("Unknown spectrum texture: " + name); } }
public abstract Bssrdf GetBssrdf(DifferentialGeometry dg, Transform objectToWorld);
public override Bssrdf GetBssrdf(DifferentialGeometry dg, Transform objectToWorld) { var dgs = _shape.GetShadingGeometry(objectToWorld, dg); return _material.GetBssrdf(dg, dgs); }
public PointLight(Transform lightToWorld, Spectrum intensity) : base(lightToWorld) { _intensity = intensity; _lightPosition = lightToWorld.TransformPoint(Point.Zero); }
protected AreaLight(Transform lightToWorld, int numSamples) : base(lightToWorld, numSamples) { }
public DistantLight(Transform lightToWorld, Spectrum radiance, Vector direction) : base(lightToWorld) { _radiance = radiance; _direction = Vector.Normalize(lightToWorld.TransformVector(ref direction)); }
public static VolumeRegion MakeVolumeRegion(string name, Transform volumeToWorld, ParamSet parameters) { switch (name) { default: throw new ArgumentException("Unknown volume region: " + name); } }
public override Bssrdf GetBssrdf(DifferentialGeometry dg, Transform objectToWorld) { return null; }
public static Texture<float> MakeFloatTexture(string name, Transform textureToWorld, TextureParams textureParams) { switch (name) { case "constant": { return new ConstantTexture<float>(textureParams.FindSingle("value", 1.0f)); } default: throw new ArgumentException("Unknown float texture: " + name); } }
public DiffuseAreaLight(Transform lightToWorld, Spectrum lemit, int numSamples, Shape shape) : base(lightToWorld, numSamples) { }
public TransformSet() { _transforms = new Transform[MaxTransforms]; for (var i = 0; i < MaxTransforms; i++) _transforms[i] = new Transform(); }
public override Bssrdf GetBssrdf(DifferentialGeometry dg, Transform objectToWorld) { throw new InvalidOperationException("Aggregate.GetBssrdf() method called; should have gone to GeometricPrimitive."); }