/// <summary/> public static Visual3D[] MakeScene(Variation v) { v.AssertExistenceOf("Scene"); string scene = v["Scene"]; if (scene == "Explicit") { v.AssertExistenceOf("Visual0"); return(MakeVisuals(v, "Visual")); } else if (scene == "VisualPerModel") { v.AssertExistenceOf("Visual0"); Visual3D[] visuals = MakeVisuals(v, "Visual"); ExpandModelGroups(visuals); return(visuals); } else { ModelVisual3D visual = new ModelVisual3D(); visual.Content = SceneFactory.MakeScene(scene); return(new Visual3D[] { visual }); } }
/// <summary> /// This summary has not been prepared yet. NOSUMMARY - pantal07 /// </summary> public override void Init(Variation v) { base.Init(v); v.AssertExistenceOf("ClassName", "Property", "From", "To", "DefaultValue", "TestType"); testType = (TestType)Enum.Parse(typeof(TestType), v["TestType"]); }
/// <summary/> public static Light MakeLight(Variation v) { Light light = null; if (v["Light"] != null) { v.AssertAbsenceOf("LightType", "LightColor", "LightPosition", "LightDirection", "LightRange", "LightConstantAttenuation", "LightLinearAttenuation", "LightQuadraticAttenuation", "LightInnerConeAngle", "LightOuterConeAngle"); light = LightFactory.MakeLight(v["Light"]); } else { v.AssertExistenceOf("LightType", "LightColor"); switch (v["LightType"]) { case "Ambient": light = new AmbientLight(); break; case "Directional": v.AssertExistenceOf("LightDirection"); light = new DirectionalLight(); ((DirectionalLight)light).Direction = StringConverter.ToVector3D(v["LightDirection"]); break; case "Point": v.AssertExistenceOf("LightPosition", "LightRange", "LightConstantAttenuation", "LightLinearAttenuation", "LightQuadraticAttenuation"); light = new PointLight(); SetLocalLightParameters((PointLight)light, v); break; case "Spot": v.AssertExistenceOf("LightPosition", "LightDirection", "LightRange", "LightConstantAttenuation", "LightLinearAttenuation", "LightQuadraticAttenuation", "LightInnerConeAngle", "LightOuterConeAngle"); light = new SpotLight(); SetLocalLightParameters((SpotLight)light, v); ((SpotLight)light).Direction = StringConverter.ToVector3D(v["LightDirection"]); ((SpotLight)light).InnerConeAngle = StringConverter.ToDouble(v["LightInnerConeAngle"]); ((SpotLight)light).OuterConeAngle = StringConverter.ToDouble(v["LightOuterConeAngle"]); break; default: throw new ApplicationException("Invalid light type: " + v["LightType"]); } light.Color = StringConverter.ToColor(v["LightColor"]); } return(light); }
/// <summary/> public override void Init(Variation v) { base.Init(v); v.AssertExistenceOf("ExpectedException", "Visual"); exceptionType = Type.GetType(v["ExpectedException"]); visual = VisualFactory.MakeVisual(v["Visual"]); }
/// <summary/> public override void Init(Variation v) { base.Init(v); v.AssertExistenceOf("RenderingMode", "Visual", "ReferenceWindowPosition"); renderingMode = v["RenderingMode"]; // Create two copies so that we don't have aliasing problems firstVisual = VisualFactory.MakeVisual(v["Visual"]); secondVisual = VisualFactory.MakeVisual(v["Visual"]); firstPass = true; referenceWindowPosition = StringConverter.ToPoint(v["ReferenceWindowPosition"]); }
/// <summary> /// This summary has not been prepared yet. NOSUMMARY - pantal07 /// </summary> public AnimationTimeline MakeAnimation(Variation v, Type baseType) { v.AssertExistenceOf("From", "To", "DurationSeconds"); Type animationType = GetAnimationType(baseType); object[] args = GetAnimationConstructorArgs(v, baseType); AnimationTimeline timeline = (AnimationTimeline)TrustedActivator.CreateInstance(animationType, args); timeline.RepeatBehavior = RepeatBehavior.Forever; return(timeline); }
/// <summary/> public static Camera MakeCamera(Variation v) { Camera camera = null; if (v["Camera"] != null) { v.AssertAbsenceOf("CameraType", "CameraPosition", "CameraLookDirection", "CameraUp", "CameraNearPlaneDistance", "CameraFarPlaneDistance", "CameraWidth", "CameraFieldOfView", "CameraViewMatrix", "CameraProjectionMatrix"); camera = CameraFactory.MakeCamera(v["Camera"]); } else { v.AssertExistenceOf("CameraType"); switch (v["CameraType"]) { case "Orthographic": v.AssertExistenceOf("CameraPosition", "CameraLookDirection", "CameraUp", "CameraNearPlaneDistance", "CameraFarPlaneDistance", "CameraWidth"); camera = new OrthographicCamera(); SetProjectionCameraParameters(camera, v); ((OrthographicCamera)camera).Width = StringConverter.ToDouble(v["CameraWidth"]); break; case "Perspective": v.AssertExistenceOf("CameraPosition", "CameraLookDirection", "CameraUp", "CameraNearPlaneDistance", "CameraFarPlaneDistance", "CameraFieldOfView"); camera = new PerspectiveCamera(); SetProjectionCameraParameters(camera, v); ((PerspectiveCamera)camera).FieldOfView = StringConverter.ToDouble(v["CameraFieldOfView"]); break; case "Matrix": v.AssertExistenceOf("CameraViewMatrix", "CameraProjectionMatrix"); camera = new MatrixCamera(); ((MatrixCamera)camera).ViewMatrix = StringConverter.ToMatrix3D(v["CameraViewMatrix"]); ((MatrixCamera)camera).ProjectionMatrix = StringConverter.ToMatrix3D(v["CameraProjectionMatrix"]); break; case "MatrixOrtho": v.AssertExistenceOf("CameraPosition", "CameraLookDirection", "CameraUp", "CameraNearPlaneDistance", "CameraFarPlaneDistance", "CameraWidth", "CameraHeight"); camera = new MatrixCamera(); ((MatrixCamera)camera).ViewMatrix = MakeViewMatrix(v); ((MatrixCamera)camera).ProjectionMatrix = MakeOrthoMatrix(v); break; case "MatrixPersp": v.AssertExistenceOf("CameraPosition", "CameraLookDirection", "CameraUp", "CameraNearPlaneDistance", "CameraFarPlaneDistance", "CameraFieldOfViewX", "CameraFieldOfViewY"); camera = new MatrixCamera(); ((MatrixCamera)camera).ViewMatrix = MakeViewMatrix(v); ((MatrixCamera)camera).ProjectionMatrix = MakePerspMatrix(v); break; default: throw new ApplicationException("Invalid camera type: " + v["CameraType"]); } } return(camera); }
/// <summary/> public override void Init(Variation v) { base.Init(v); v.AssertExistenceOf("ClassName", "Namespace", "CanInherit", "Assembly"); this.className = v["ClassName"]; this.nameSpace = v["Namespace"]; string inherit = v["CanInherit"]; string asm = v["Assembly"]; dotnetPath = v["DotnetPath"]; // We define this for local testing if we don't use avalon.msi if (dotnetPath == null) { try { dotnetPath = EnvironmentWrapper.GetEnvironmentVariable("LAPI"); } catch (System.Security.SecurityException ex) { AddFailure("Could not access the Environment variable: LAPI"); Log("Exception: " + ex); } if (dotnetPath == null) { throw new ApplicationException("LAPI is not defined. I can't find my binaries."); } } Log("DotnetPath = " + dotnetPath); TrustedAssembly assembly = TrustedAssembly.LoadFile(TrustedPath.Combine(dotnetPath, asm)); this.type = assembly.GetType(nameSpace + "." + className); if (type == null) { throw new ApplicationException(nameSpace + "." + className + " was not found in " + asm); } this.classGenerator = new ClassGenerator(type); this.canInherit = StringConverter.ToBool(inherit); }
/// <summary/> public static Transform3D MakeTransform3D(Variation v) { Transform3D tx; if (v["TransformType"] == null) { v.AssertAbsenceOf("TranslateOffset", "RotateAngle", "RotateAxis", "RotateQuaternion", "RotateCenter", "ScaleVector", "ScaleCenter", "MatrixValue"); tx = Transform3D.Identity; } else { switch (v["TransformType"]) { case "Translate": v.AssertExistenceOf("TranslateOffset"); tx = new TranslateTransform3D(StringConverter.ToVector3D(v["TranslateOffset"])); break; case "RotateAxisAngle": v.AssertExistenceOf("RotateAngle", "RotateAxis"); tx = new RotateTransform3D(new AxisAngleRotation3D(StringConverter.ToVector3D(v["RotateAxis"]), StringConverter.ToDouble(v["RotateAngle"]))); break; case "RotateAxisAngleCenter": v.AssertExistenceOf("RotateAngle", "RotateAxis", "RotateCenter"); tx = new RotateTransform3D(new AxisAngleRotation3D(StringConverter.ToVector3D(v["RotateAxis"]), StringConverter.ToDouble(v["RotateAngle"])), StringConverter.ToPoint3D(v["RotateCenter"])); break; case "RotateQuaternion": v.AssertExistenceOf("RotateQuaternion"); tx = new RotateTransform3D(new QuaternionRotation3D(StringConverter.ToQuaternion(v["RotateQuaternion"]))); break; case "RotateQuaternionCenter": v.AssertExistenceOf("RotateQuaternion", "RotateCenter"); tx = new RotateTransform3D(new QuaternionRotation3D(StringConverter.ToQuaternion(v["RotateQuaternion"])), StringConverter.ToPoint3D(v["RotateCenter"])); break; case "RotateNullRotation": tx = new RotateTransform3D(); ((RotateTransform3D)tx).Rotation = null; break; case "Scale": v.AssertExistenceOf("ScaleVector"); tx = new ScaleTransform3D(StringConverter.ToVector3D(v["ScaleVector"])); break; case "ScaleCenter": v.AssertExistenceOf("ScaleVector", "ScaleCenter"); tx = new ScaleTransform3D(StringConverter.ToVector3D(v["ScaleVector"]), StringConverter.ToPoint3D(v["ScaleCenter"])); break; case "Matrix": v.AssertExistenceOf("MatrixValue"); tx = new MatrixTransform3D(StringConverter.ToMatrix3D(v["MatrixValue"])); break; case "Group": tx = new Transform3DGroup(); break; case "GroupNullChildren": tx = new Transform3DGroup(); ((Transform3DGroup)tx).Children = null; break; case "Null": tx = null; break; default: throw new ApplicationException("Invalid TransformType specified: " + v["TransformType"]); } } return(tx); }
private static Material MakeMaterial(Variation v, string namePrefix) { Material material = null; string type = namePrefix + "Type"; string specularPower = namePrefix + "SpecularPower"; string ambientColor = namePrefix + "AmbientColor"; string color = namePrefix + "Color"; // Material CAN be null if (v[namePrefix] == "Group") { v.AssertAbsenceOf(ambientColor, color, specularPower); if (v[type] != null && v[type] != "Group") { throw new ArgumentException("Can't have " + namePrefix + "=Group and type=" + v[type]); } material = MakeMaterialGroup(v, namePrefix); } else if (v[namePrefix] != null) { if (v[type] != null) { switch (v[type]) { case "Group": throw new ArgumentException("Can't have 'Group' type without " + namePrefix + "='Group'"); case "Specular": v.AssertExistenceOf(specularPower); material = MaterialFactory.MakeMaterial( v[namePrefix], v[type], StringConverter.ToDouble(v[specularPower])); break; default: v.AssertAbsenceOf(specularPower); material = MaterialFactory.MakeMaterial(v[namePrefix], v[type]); break; } } else { v.AssertAbsenceOf(specularPower); material = MaterialFactory.MakeMaterial(v[namePrefix]); } // Parse Color Knobs if (v[ambientColor] != null) { if (material is DiffuseMaterial) { ((DiffuseMaterial)material).AmbientColor = StringConverter.ToColor(v[ambientColor]); } else { throw new ArgumentException("Can't set " + namePrefix + "AmbientColor on non-DiffuseMaterial"); } } if (v[color] != null) { if (material is DiffuseMaterial) { ((DiffuseMaterial)material).Color = StringConverter.ToColor(v[color]); } else if (material is EmissiveMaterial) { ((EmissiveMaterial)material).Color = StringConverter.ToColor(v[color]); } else if (material is SpecularMaterial) { ((SpecularMaterial)material).Color = StringConverter.ToColor(v[color]); } else { throw new ArgumentException("Can't set " + namePrefix + "Color on MaterialGroup"); } } } return(material); }
public static ScreenSpaceLines3D MakeScreenSpaceLines(Variation v) { v.AssertExistenceOf("Lines"); return(ScreenSpaceLinesFactory.MakeLines(v["Lines"])); }
/// <summary/> public static MeshGeometry3D MakeMesh(Variation v) { v.AssertExistenceOf("Mesh"); return(MeshFactory.MakeMesh(v["Mesh"])); }
/// <summary/> public XamlTestObjects(Variation v) : base(v) { v.AssertExistenceOf("Filename"); filename = v["Filename"]; }