public override void Process(SceneReaderContext context) { context.VerifyWorld("Texture"); var textureParams = new TextureParams(Parameters, Parameters, context.GraphicsState.FloatTextures, context.GraphicsState.SpectrumTextures); switch (TextureType) { case "float": { context.GraphicsState.FloatTextures[Name] = Factories.MakeFloatTexture( TextureClass, context.CurrentTransform[0], textureParams);; break; } case "color": case "spectrum": { context.GraphicsState.SpectrumTextures[Name] = Factories.MakeSpectrumTexture( TextureClass, context.CurrentTransform[0], textureParams);; break; } default: throw new InvalidOperationException("Texture type '" + TextureType + " ' unknown."); } }
public override void Process(SceneReaderContext context) { context.VerifyWorld("ObjectInstance"); if (context.RenderOptions.CurrentInstance != null) throw new InvalidOperationException("ObjectInstance can't be called inside instance definition."); if (!context.RenderOptions.Instances.ContainsKey(Name)) throw new InvalidOperationException("Unable to find instance named '" + Name + "'."); var instances = context.RenderOptions.Instances[Name]; if (instances.Count == 0) return; if (instances.Count > 1 || !instances[0].CanIntersect) { // Refine instance primitives and create aggregate. var accelerator = Factories.MakeAccelerator( context.RenderOptions.AcceleratorName, context.RenderOptions.AcceleratorParams, instances); instances.Clear(); instances.Add(accelerator); } var worldToInstance0 = Transform.Invert(context.CurrentTransform[0]); var worldToInstance1 = Transform.Invert(context.CurrentTransform[1]); var animatedWorldToInstance = new AnimatedTransform( worldToInstance0, context.RenderOptions.TransformStartTime, worldToInstance1, context.RenderOptions.TransformEndTime); context.RenderOptions.Primitives.Add(new TransformedPrimitive( instances[0], animatedWorldToInstance)); }
public override void Process(SceneReaderContext context) { context.VerifyWorld("Texture"); var textureParams = new TextureParams(Parameters, Parameters, context.GraphicsState.FloatTextures, context.GraphicsState.SpectrumTextures); switch (TextureType) { case "float" : { context.GraphicsState.FloatTextures[Name] = Factories.MakeFloatTexture( TextureClass, context.CurrentTransform[0], textureParams); ; break; } case "color" : case "spectrum" : { context.GraphicsState.SpectrumTextures[Name] = Factories.MakeSpectrumTexture( TextureClass, context.CurrentTransform[0], textureParams); ; break; } default : throw new InvalidOperationException("Texture type '" + TextureType +" ' unknown."); } }
public override void Process(SceneReaderContext context) { if (context.NamedCoordinateSystems.ContainsKey(Name)) context.CurrentTransform = context.NamedCoordinateSystems[Name]; else throw new InvalidOperationException("Could not find named coordinate system '" + Name + "'."); }
public override void Process(SceneReaderContext context) { context.VerifyWorld("AttributeBegin"); context.GraphicsStateStack.Push(context.GraphicsState.Clone()); context.TransformStack.Push(context.CurrentTransform.Clone()); context.ActiveTransformBitsStack.Push(context.ActiveTransformBits); }
public override void Process(SceneReaderContext context) { context.VerifyOptions("WorldBegin"); context.CurrentState = SceneReaderState.WorldBlock; for (var i = 0; i < TransformSet.MaxTransforms; i++) context.CurrentTransform[i] = new Transform(); context.ActiveTransformBits = TransformSet.AllTransformsBits; context.NamedCoordinateSystems["world"] = context.CurrentTransform; }
public override void Process(SceneReaderContext context) { context.VerifyWorld("MakeNamedMaterial"); var textureParams = new TextureParams(Parameters, context.GraphicsState.MaterialParams, context.GraphicsState.FloatTextures, context.GraphicsState.SpectrumTextures); context.GraphicsState.NamedMaterials[MaterialName] = Factories.MakeMaterial( MaterialType, context.CurrentTransform[0], textureParams); }
public override void Process(SceneReaderContext context) { context.VerifyWorld("WorldEnd"); if (context.GraphicsStateStack.Count > 0) throw new InvalidOperationException("Missing end to AttributeBegin"); if (context.TransformStack.Count > 0) throw new InvalidOperationException("Missing end to TransformBegin"); }
public override void Process(SceneReaderContext context) { context.VerifyWorld("ObjectEnd"); if (context.RenderOptions.CurrentInstance == null) throw new InvalidOperationException("ObjectEnd called outside of instance definition."); context.RenderOptions.CurrentInstance = null; new AttributeEndDirective().Process(context); }
public override void Process(SceneReaderContext context) { context.VerifyWorld("ObjectBegin"); new AttributeBeginDirective().Process(context); if (context.RenderOptions.CurrentInstance != null) throw new InvalidOperationException("ObjectBegin called inside of instance definition."); context.RenderOptions.Instances[Name] = new List<Primitive>(); context.RenderOptions.CurrentInstance = context.RenderOptions.Instances[Name]; }
public override void Process(SceneReaderContext context) { context.VerifyWorld("TransformEnd"); if (context.TransformStack.Count == 0) throw new InvalidOperationException("Unmatched TransformEnd encountered."); context.CurrentTransform = context.TransformStack.Pop(); context.ActiveTransformBits = context.ActiveTransformBitsStack.Pop(); }
public override void Process(SceneReaderContext context) { context.VerifyOptions("WorldBegin"); context.CurrentState = SceneReaderState.WorldBlock; for (var i = 0; i < TransformSet.MaxTransforms; i++) { context.CurrentTransform[i] = new Transform(); } context.ActiveTransformBits = TransformSet.AllTransformsBits; context.NamedCoordinateSystems["world"] = context.CurrentTransform; }
public override void Process(SceneReaderContext context) { context.VerifyWorld("ObjectEnd"); if (context.RenderOptions.CurrentInstance == null) { throw new InvalidOperationException("ObjectEnd called outside of instance definition."); } context.RenderOptions.CurrentInstance = null; new AttributeEndDirective().Process(context); }
public override void Process(SceneReaderContext context) { if (context.NamedCoordinateSystems.ContainsKey(Name)) { context.CurrentTransform = context.NamedCoordinateSystems[Name]; } else { throw new InvalidOperationException("Could not find named coordinate system '" + Name + "'."); } }
public override void Process(SceneReaderContext context) { context.VerifyWorld("TransformEnd"); if (context.TransformStack.Count == 0) { throw new InvalidOperationException("Unmatched TransformEnd encountered."); } context.CurrentTransform = context.TransformStack.Pop(); context.ActiveTransformBits = context.ActiveTransformBitsStack.Pop(); }
public override void Process(SceneReaderContext context) { context.VerifyWorld("ObjectBegin"); new AttributeBeginDirective().Process(context); if (context.RenderOptions.CurrentInstance != null) { throw new InvalidOperationException("ObjectBegin called inside of instance definition."); } context.RenderOptions.Instances[Name] = new List <Primitive>(); context.RenderOptions.CurrentInstance = context.RenderOptions.Instances[Name]; }
public override void Process(SceneReaderContext context) { context.VerifyWorld("WorldEnd"); if (context.GraphicsStateStack.Count > 0) { throw new InvalidOperationException("Missing end to AttributeBegin"); } if (context.TransformStack.Count > 0) { throw new InvalidOperationException("Missing end to TransformBegin"); } }
public override void Process(SceneReaderContext context) { switch (Type) { case ActiveTransformType.All: context.ActiveTransformBits = TransformSet.AllTransformsBits; break; case ActiveTransformType.Start: context.ActiveTransformBits = TransformSet.StartTransformBits; break; case ActiveTransformType.End: context.ActiveTransformBits = TransformSet.EndTransformBits; break; default: throw new ArgumentOutOfRangeException(); } }
public override void Process(SceneReaderContext context) { context.VerifyWorld("ObjectInstance"); if (context.RenderOptions.CurrentInstance != null) { throw new InvalidOperationException("ObjectInstance can't be called inside instance definition."); } if (!context.RenderOptions.Instances.ContainsKey(Name)) { throw new InvalidOperationException("Unable to find instance named '" + Name + "'."); } var instances = context.RenderOptions.Instances[Name]; if (instances.Count == 0) { return; } if (instances.Count > 1 || !instances[0].CanIntersect) { // Refine instance primitives and create aggregate. var accelerator = Factories.MakeAccelerator( context.RenderOptions.AcceleratorName, context.RenderOptions.AcceleratorParams, instances); instances.Clear(); instances.Add(accelerator); } var worldToInstance0 = Transform.Invert(context.CurrentTransform[0]); var worldToInstance1 = Transform.Invert(context.CurrentTransform[1]); var animatedWorldToInstance = new AnimatedTransform( worldToInstance0, context.RenderOptions.TransformStartTime, worldToInstance1, context.RenderOptions.TransformEndTime); context.RenderOptions.Primitives.Add(new TransformedPrimitive( instances[0], animatedWorldToInstance)); }
public override void Process(SceneReaderContext context) { context.ForActiveTransforms(t => t * Transform.LookAt(Eye, LookAt, Up)); }
public override void Process(SceneReaderContext context) { context.NamedCoordinateSystems[Name] = context.CurrentTransform; }
public override void Process(SceneReaderContext context) { context.VerifyWorld("NamedMaterial"); context.GraphicsState.CurrentNamedMaterial = MaterialName; }
public override void Process(SceneReaderContext context) { context.ForActiveTransforms(t => t * Transform.Translate(Translation)); }
public override void Process(SceneReaderContext context) { context.VerifyWorld("ReverseOrientation"); context.GraphicsState.ReverseOrientation = !context.GraphicsState.ReverseOrientation; }
private void ProcessShape(SceneReaderContext context) { Primitive prim = null; AreaLight area = null; if (!context.CurrentTransform.IsAnimated) { // Create primitive for static shape. var shape = Factories.MakeShape(ImplementationType, context.CurrentTransform[0], context.GraphicsState.ReverseOrientation, Parameters); var material = context.GraphicsState.CreateMaterial( Parameters, context.CurrentTransform[0]); // Possibly create area light for shape. if (!string.IsNullOrEmpty(context.GraphicsState.AreaLight)) { area = Factories.MakeAreaLight( context.GraphicsState.AreaLight, context.CurrentTransform[0], context.GraphicsState.AreaLightParams, shape); } prim = new GeometricPrimitive(shape, material, area); } else { // Create primitive for animated shape. var shape = Factories.MakeShape(ImplementationType, new Transform(), context.GraphicsState.ReverseOrientation, Parameters); var material = context.GraphicsState.CreateMaterial( Parameters, context.CurrentTransform[0]); // Get animatedWorldToObject transform for shape. var worldToObj0 = Transform.Invert(context.CurrentTransform[0]); var worldToObj1 = Transform.Invert(context.CurrentTransform[1]); var animatedWorldToObject = new AnimatedTransform( worldToObj0, context.RenderOptions.TransformStartTime, worldToObj1, context.RenderOptions.TransformEndTime); Primitive basePrim = new GeometricPrimitive(shape, material, null); if (!basePrim.CanIntersect) { // Refine animated shape and create BVH if more than one shape created. var refinedPrimitives = basePrim.FullyRefine(); if (refinedPrimitives.Count == 0) { return; } basePrim = (refinedPrimitives.Count > 1) ? new BoundingVolumeHierarchyAccelerator(refinedPrimitives) : refinedPrimitives[0]; } prim = new TransformedPrimitive(basePrim, animatedWorldToObject); } // Add primitive to scene or current instance. if (context.RenderOptions.CurrentInstance != null) { context.RenderOptions.CurrentInstance.Add(prim); } else { context.RenderOptions.Primitives.Add(prim); if (area != null) { context.RenderOptions.Lights.Add(area); } } }
private void ProcessShape(SceneReaderContext context) { Primitive prim = null; AreaLight area = null; if (!context.CurrentTransform.IsAnimated) { // Create primitive for static shape. var shape = Factories.MakeShape(ImplementationType, context.CurrentTransform[0], context.GraphicsState.ReverseOrientation, Parameters); var material = context.GraphicsState.CreateMaterial( Parameters, context.CurrentTransform[0]); // Possibly create area light for shape. if (!string.IsNullOrEmpty(context.GraphicsState.AreaLight)) area = Factories.MakeAreaLight( context.GraphicsState.AreaLight, context.CurrentTransform[0], context.GraphicsState.AreaLightParams, shape); prim = new GeometricPrimitive(shape, material, area); } else { // Create primitive for animated shape. var shape = Factories.MakeShape(ImplementationType, new Transform(), context.GraphicsState.ReverseOrientation, Parameters); var material = context.GraphicsState.CreateMaterial( Parameters, context.CurrentTransform[0]); // Get animatedWorldToObject transform for shape. var worldToObj0 = Transform.Invert(context.CurrentTransform[0]); var worldToObj1 = Transform.Invert(context.CurrentTransform[1]); var animatedWorldToObject = new AnimatedTransform( worldToObj0, context.RenderOptions.TransformStartTime, worldToObj1, context.RenderOptions.TransformEndTime); Primitive basePrim = new GeometricPrimitive(shape, material, null); if (!basePrim.CanIntersect) { // Refine animated shape and create BVH if more than one shape created. var refinedPrimitives = basePrim.FullyRefine(); if (refinedPrimitives.Count == 0) return; basePrim = (refinedPrimitives.Count > 1) ? new BoundingVolumeHierarchyAccelerator(refinedPrimitives) : refinedPrimitives[0]; } prim = new TransformedPrimitive(basePrim, animatedWorldToObject); } // Add primitive to scene or current instance. if (context.RenderOptions.CurrentInstance != null) { context.RenderOptions.CurrentInstance.Add(prim); } else { context.RenderOptions.Primitives.Add(prim); if (area != null) context.RenderOptions.Lights.Add(area); } }
public abstract void Process(SceneReaderContext context);
public override void Process(SceneReaderContext context) { context.ForActiveTransforms(t => t * Transform.Rotate(Angle, Axis)); }
public override void Process(SceneReaderContext context) { context.ForActiveTransforms(t => t * Transform.Scale(Scale.X, Scale.Y, Scale.Z)); }
public override void Process(SceneReaderContext context) { switch (DirectiveType) { case StandardDirectiveType.Accelerator: context.VerifyOptions("Accelerator"); context.RenderOptions.AcceleratorName = ImplementationType; context.RenderOptions.AcceleratorParams = Parameters; break; case StandardDirectiveType.AreaLightSource: context.VerifyWorld("AreaLightSource"); context.GraphicsState.AreaLight = ImplementationType; context.GraphicsState.AreaLightParams = Parameters; break; case StandardDirectiveType.Camera: context.VerifyOptions("Camera"); context.RenderOptions.CameraName = ImplementationType; context.RenderOptions.CameraParams = Parameters; context.RenderOptions.CameraToWorld = TransformSet.Invert(context.CurrentTransform); context.NamedCoordinateSystems["camera"] = context.RenderOptions.CameraToWorld; break; case StandardDirectiveType.Film: context.VerifyOptions("Film"); context.RenderOptions.FilmName = ImplementationType; context.RenderOptions.FilmParams = Parameters; break; case StandardDirectiveType.LightSource: context.VerifyWorld("LightSource"); context.RenderOptions.Lights.Add(Factories.MakeLight( ImplementationType, context.CurrentTransform[0], Parameters)); break; case StandardDirectiveType.Material: context.VerifyWorld("Material"); context.GraphicsState.Material = ImplementationType; context.GraphicsState.MaterialParams = Parameters; context.GraphicsState.CurrentNamedMaterial = ""; break; case StandardDirectiveType.PixelFilter: context.VerifyOptions("PixelFilter"); context.RenderOptions.FilterName = ImplementationType; context.RenderOptions.FilterParams = Parameters; break; case StandardDirectiveType.Renderer: context.VerifyOptions("Renderer"); context.RenderOptions.RendererName = ImplementationType; context.RenderOptions.RendererParams = Parameters; break; case StandardDirectiveType.Sampler: context.VerifyOptions("Sampler"); context.RenderOptions.SamplerName = ImplementationType; context.RenderOptions.SamplerParams = Parameters; break; case StandardDirectiveType.Shape: context.VerifyWorld("Shape"); ProcessShape(context); break; case StandardDirectiveType.SurfaceIntegrator: context.VerifyOptions("SurfaceIntegrator"); context.RenderOptions.SurfaceIntegratorName = ImplementationType; context.RenderOptions.SurfaceIntegratorParams = Parameters; break; case StandardDirectiveType.Volume: context.VerifyWorld("Volume"); context.RenderOptions.VolumeRegions.Add(Factories.MakeVolumeRegion( ImplementationType, context.CurrentTransform[0], Parameters)); break; case StandardDirectiveType.VolumeIntegrator: context.VerifyOptions("VolumeIntegrator"); context.RenderOptions.VolumeIntegratorName = ImplementationType; context.RenderOptions.VolumeIntegratorParams = Parameters; break; default: throw new ArgumentOutOfRangeException(); } }
public override void Process(SceneReaderContext context) { context.VerifyOptions("TransformTimes"); context.RenderOptions.TransformStartTime = Start; context.RenderOptions.TransformEndTime = End; }
public override void Process(SceneReaderContext context) { context.ForActiveTransforms(t => new Transform(Transform)); }