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.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) { 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("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("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("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("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) { 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("ReverseOrientation"); context.GraphicsState.ReverseOrientation = !context.GraphicsState.ReverseOrientation; }
public override void Process(SceneReaderContext context) { context.VerifyWorld("NamedMaterial"); context.GraphicsState.CurrentNamedMaterial = MaterialName; }
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(); } }