// Use this for initialization void Start() { // get Interface Script gui_script = GameObject.Find("GUI").gameObject.GetComponent <InterfaceScript>(); osc = GameObject.Find("osc_script").gameObject.GetComponent <OSCReceiver1> (); spheres = GameObject.Find("spheres_script").gameObject.GetComponent <Spheres> (); }
public override void ReadData(BinaryReader stream, IDictionary <object, object> userdata, int totalSize) { Name = stream.ReadSizedString(); int length = stream.ReadInt32(); Capsules.Capacity = length; for (int i = 0; i < length; i++) { Capsules.Add(new ShapeCapsule(stream)); } length = stream.ReadInt32(); Spheres.Capacity = length; for (int i = 0; i < length; i++) { Spheres.Add(new ShapeSphere(stream)); } length = stream.ReadInt32(); Manifolds.Capacity = length; for (int i = 0; i < length; i++) { Manifolds.Add(new ShapeManifold(stream)); } }
protected override ModuleBase CreateAndReadyModule() { Spheres spheres = new Spheres(); spheres.Frequency = frequency; return(spheres); }
void ShowScore() { if (score > finalScore) { finalScore = score; } if (finalScore > PlayerPrefs.GetFloat("MemoryScore")) { PlayerPrefs.SetFloat("MemoryScore", finalScore); } else { finalScore = PlayerPrefs.GetFloat("MemoryScore"); } lives = 5; UI.SetActive(false); Capsules.SetActive(false); Spheres.GetComponent <Randomsphere>().Getclonei().SetActive(false); Spheres.GetComponent <Randomsphere>().Getclonej().SetActive(false); Spheres.GetComponent <Randomsphere>().Getclonek().SetActive(false); scoreBoard.SetActive(true); scoreBoard.transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z + 35); Username.GetComponent <TMPro.TextMeshPro>().text = FacebookManager.Instance.ProfileName + ": " + score.ToString(); if (FacebookManager.Instance.ProfilePic != null) { ProfilePic.GetComponent <Image>().sprite = FacebookManager.Instance.ProfilePic; } }
/// <summary> /// Создаем одну сферу /// </summary> private void GenerateSphere() { GameObject go = GameObject.CreatePrimitive(PrimitiveType.Sphere); go.AddComponent <BallScript>(); Spheres.Add(go); lastGenTime = GameTime; }
public void DestroySphere(Sphere sphere, bool shouldRemoveFromList = true) { if (shouldRemoveFromList) { Spheres.Remove(sphere); uiTextRefresher.Refresh($"{Spheres.Count:D3}"); } sphere.gameObject.SetActive(false); }
public CanFlyTo(Vector3D destination, Sandbox.ModAPI.IMyCubeGrid gridDest, GridDimensions gridDims, bool isAlternate, bool ignoreAsteroids) { this.myGrid = gridDims.myGrid; this.gridDest = gridDest; this.myAttached = AttachedGrids.getFor(gridDims.myGrid); this.ignoreAsteroids = ignoreAsteroids; myLogger = new Logger(gridDims.myGrid.DisplayName, "CanFlyTo"); collisionSpheres = new Spheres(destination, gridDims, isAlternate); log(myLogger, "got grid dest: " + this.gridDest, ".ctor()", Logger.severity.TRACE); }
public void ReflectanceIsSignificantAtSmallViewAngles() { var s = Spheres.GlassSphere(); var r = new Ray(new Point(0, 0.99f, -2f), new Vector(0, 0, 1)); var xs = Intersections.Create(new Intersection(1.8589f, s)); var comps = new IntersectionInfo(xs[0], r, xs); var reflectance = PhongShading.Schlick(comps); reflectance.Should().BeApproximately(0.48873f, 0.0001f); }
public void SchlickApproximationForTotalInternalReflectionIsOne() { var s = Spheres.GlassSphere(); var r = new Ray(new Point(0, 0, MathF.Sqrt(2f) / 2f), new Vector(0, 1, 0)); var xs = Intersections.Create(new Intersection(-MathF.Sqrt(2f) / 2f, s), new Intersection(MathF.Sqrt(2f) / 2f, s)); var comps = new IntersectionInfo(xs[1], r, xs); var reflectance = PhongShading.Schlick(comps); reflectance.Should().Be(1f); }
public void ReflectanceIsSmallAtPerpendicularViewAngles() { var s = Spheres.GlassSphere(); var r = new Ray(new Point(0, 0, 0), new Vector(0, 1, 0)); var xs = Intersections.Create(new Intersection(-1f, s), new Intersection(1f, s)); var comps = new IntersectionInfo(xs[1], r, xs); var reflectance = PhongShading.Schlick(comps); reflectance.Should().BeApproximately(0.04f, 0.0001f); }
// Use this for initialization void Start() { sphereScript = sphereController.GetComponent <Spheres>(); // up trans upTrans = Quaternion.LookRotation(Vector3.up); // look up // make sure target is zeroed target.localPosition = Vector3.zero; savedOrientation = Quaternion.identity; // init target.localRotation = upTrans * savedOrientation; }
public void RestartGame() { finnished = false; UI.SetActive(true); scoreBoard.SetActive(false); lives = 5; score = 0; Level = 1; theLives.GetComponent <TMPro.TextMeshPro>().text = "LIVES: " + lives; Spheres.GetComponent <Randomsphere>().Reset(); startTime = 60.0f; timeRemaining = 60.0f; }
private void Awake() { Sphere[] spheresInScene = FindObjectsOfType <Sphere>(); if (spheresInScene.Length > 0) { Spheres.AddRange(spheresInScene); } else if (spawnSpheresIfSceneIsEmpty) { SpawnSpheres(); } }
private ModuleBase chooseModuleBase(NoiseType moduleType) { ModuleBase moduleBase; switch (moduleType) { case NoiseType.Billow: moduleBase = new Billow(); break; case NoiseType.RiggedMultifractal: moduleBase = new RiggedMultifractal(); break; case NoiseType.Voronoi: moduleBase = new Voronoi(); break; case NoiseType.Checker: moduleBase = new Checker(); break; case NoiseType.Cylinders: moduleBase = new Cylinders(); break; case NoiseType.Spheres: moduleBase = new Spheres(); break; case NoiseType.Mix: Perlin perlin = new Perlin(); RiggedMultifractal rigged = new RiggedMultifractal(); moduleBase = new Add(perlin, rigged); break; case NoiseType.RiggedMChecker: Checker checker = new Checker(); RiggedMultifractal rigged2 = new RiggedMultifractal(); moduleBase = new Add(checker, rigged2); break; default: moduleBase = new Perlin(); break; } return(moduleBase); }
private void Awake() { device = new BluetoothDevice(); tryConnect(); sphereScript = sphereController.GetComponent <Spheres>(); // up trans upTrans = Quaternion.LookRotation(Vector3.up); // look up // make sure target is zeroed target.localPosition = Vector3.zero; savedOrientation = Quaternion.identity; target.localRotation = upTrans * firstRec * savedOrientation; }
private IEnumerator SphereRoutine() { while (Spheres.Count < SphereLimit) { var newSphere = SphereSpawner.Spawn().GetComponent <Sphere>(); Spheres.Add(newSphere); uiTextRefresher.Refresh($"{Spheres.Count:D3}"); yield return(QuarterSecond); } foreach (var sphere in Spheres) { sphere.ReversePullForce = true; } }
public void DeterminesN1AndN2() { var a = Spheres.GlassSphere(); a.SetTransform(Transform.Scale(2f)); a.Material.RefractiveIndex = 1.5f; var b = Spheres.GlassSphere(); b.SetTransform(Transform.TranslateZ(-0.25f)); b.Material.RefractiveIndex = 2.0f; var c = Spheres.GlassSphere(); c.SetTransform(Transform.TranslateZ(0.25f)); c.Material.RefractiveIndex = 2.5f; var r = new Ray(new Point(0, 0, -4), new Vector(0, 0, 1)); var xs = Intersections.Create( new Intersection(2.00f, a), new Intersection(2.75f, b), new Intersection(3.25f, c), new Intersection(4.75f, b), new Intersection(5.25f, c), new Intersection(6.00f, a) ); var comps = new List <IntersectionInfo>(); for (var i = 0; i < xs.Count; i++) { comps.Add(new IntersectionInfo(xs[i], r, xs)); } comps[0].N1.Should().Be(1.0f); comps[0].N2.Should().Be(1.5f); comps[1].N1.Should().Be(1.5f); comps[1].N2.Should().Be(2.0f); comps[2].N1.Should().Be(2.0f); comps[2].N2.Should().Be(2.5f); comps[3].N1.Should().Be(2.5f); comps[3].N2.Should().Be(2.5f); comps[4].N1.Should().Be(2.5f); comps[4].N2.Should().Be(1.5f); comps[5].N1.Should().Be(1.5f); comps[5].N2.Should().Be(1.0f); }
void Start() { mTrackableBehaviour = GetComponent <TrackableBehaviour>(); if (mTrackableBehaviour) { mTrackableBehaviour.RegisterTrackableEventHandler(this); } //set up osc script, do it here and use a 'ready' boolean to avoid runtime errors osc = GameObject.Find("osc_script").gameObject.GetComponent <OSCReceiver1> (); spheres = GameObject.Find("spheres_script").gameObject.GetComponent <Spheres> (); osc_ready = true; //set up connection with computation script compute = GameObject.Find("computation_script").gameObject.GetComponent <Computation> (); Debug.Log("let's see if the communication is possible"); //Debug.Log(osc.TestCommunication()); }
/// <summary> /// Восстанавливаем условия по умолчанию /// </summary> public void Reset() { foreach (GameObject sphere in Spheres) { Destroy(sphere); } Spheres.Clear(); audio.clip = LoadingManager.MarioTheme; audio.Stop(); GradientGenerator.GenereteTextures(); lastGenTime = 0f; GameTime = 0f; Points = 0; SpeedMultiplier = 1f; spheresMaxCount = 5; }
public override string ToString() { var sb = new StringBuilder(); if (Coins > 0u) { sb.Append($"$emotecoins {Coins.ToString()} "); } if (Tokens > 0u) { sb.Append($"$emotetokens {Tokens.ToString()} "); } if (Chests > 0u) { sb.Append($"$emotechest {Chests.ToString()} "); } if (Spheres > 0u) { sb.Append($"$emotesphere {Spheres.ToString()} "); } if (Capsules > 0u) { sb.Append($"$emotecapsule {Capsules.ToString()} "); } if (Tickets > 0u) { sb.Append($"$emoteticket {Tickets.ToString()} "); } if (BonusDoubleExp > 0u) { sb.Append($"$emote2exp {BonusDoubleExp.ToString()} "); } if (BonusBotRespect > 0u) { sb.Append($"$emoterespect {BonusBotRespect.ToString()} "); } if (BonusRewind > 0u) { sb.Append($"$emoterewind {BonusRewind.ToString()} "); } return(sb.ToString().TrimEnd()); }
void Start() { _spheres = new List <EchoSphere>(); for (int i = 0; i < SphereCount; i++) { EchoSphere es = new EchoSphere { EchoMaterial = GetComponent <Renderer>().material, EchoColor = Color.white, SphereMaxRadius = SphereMaxRadius, FadeDelay = FadeDelay, FadeRate = FadeRate, EchoSpeed = EchoSpeed, SphereIndex = i }; Spheres.Add(es); } _currentSphere = 0; }
private void ComputeBlock(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) { var spheres = Spheres.ToArray(); for (var z = minZ; z < maxZ; z++) { var zres = z * _resolution * _resolution; for (var y = minY; y < maxY; y++) { var yres = y * _resolution; for (var x = minX; x < maxX; x++) { var index = x + yres + zres; var(vx, vy, vz) = _vertices[index]; var isoValue = 0f; var normal = Vector3.Zero; foreach (var sphere in spheres) { var(bx, by, bz) = sphere.Position; var cx = vx - bx; var cy = vy - by; var cz = vz - bz; var dist = cx * cx + cy * cy + cz * cz; if (dist <= 0) { continue; } var d = sphere.Radius / (dist * dist); isoValue += d * dist; normal.X += d * cx; normal.Y += d * cy; normal.Z += d * cz; } _isoValues[index] += isoValue; _normals[index] += normal; } } } }
public IModule3D CreateModule(int globalSeed) { PrimitiveModule primitiveModule = null; switch (primative) { case NoisePrimitive.Constant: primitiveModule = new Constant(offset); break; case NoisePrimitive.Cylinders: primitiveModule = new Cylinders(offset); break; case NoisePrimitive.Spheres: primitiveModule = new Spheres(offset); break; case NoisePrimitive.BevinsGradient: primitiveModule = new BevinsGradient(); break; case NoisePrimitive.BevinsValue: primitiveModule = new BevinsValue(); break; case NoisePrimitive.ImprovedPerlin: primitiveModule = new ImprovedPerlin(); break; case NoisePrimitive.SimplexPerlin: primitiveModule = new SimplexPerlin(); break; } primitiveModule.Quality = quality; primitiveModule.Seed = globalSeed + seed; return((IModule3D)primitiveModule); }
/// <summary> /// Implementation of the ITrackableEventHandler function called when the /// tracking state changes. /// </summary> public void OnTrackableStateChanged( TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus) { if (newStatus == TrackableBehaviour.Status.DETECTED || newStatus == TrackableBehaviour.Status.TRACKED || newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED) { spheres = GameObject.Find("spheres_script").gameObject.GetComponent <Spheres> (); TrackableStatus = true; OnTrackingFound(); //send message to osc script // if(osc_ready){ // osc.TargetTracking (true); // } // relay tracking data to computation script // if(computation_script_ready){ // compute.TargetTrackingState (true); // } } else { spheres = GameObject.Find("spheres_script").gameObject.GetComponent <Spheres> (); TrackableStatus = false; OnTrackingLost(); //send message to osc script // if(osc_ready){ // osc.TargetTracking (false); // } // relay tracking data to computation script // if(computation_script_ready){ // compute.TargetTrackingState (true); // } } }
ModuleBase CreateNoiseModule() { ModuleBase noiseModule = null; switch (_noiseType) { case NoiseType.Perlin: noiseModule = new Perlin(_frequency, _lancuraity, _persistence, _octaves, 2, QualityMode.Low); break; case NoiseType.Voronoi: noiseModule = new Voronoi(_frequency, _displacement, 0, false); break; case NoiseType.RidgedMultifractal: noiseModule = new RidgedMultifractal(_frequency, _lancuraity, _octaves, 0, QualityMode.Low); break; case NoiseType.Billow: noiseModule = new Billow(_frequency, _lancuraity, _persistence, _octaves, 0, QualityMode.Low); break; case NoiseType.Spheres: noiseModule = new Spheres(_frequency); break; case NoiseType.Checker: noiseModule = new Checker(); break; case NoiseType.Cylinders: noiseModule = new Cylinders(_frequency); break; } return(noiseModule); }
protected override ModuleBase CreateAndReadyModule() { Spheres spheres = new Spheres(); spheres.Frequency = frequency; return spheres; }
public HistoricalFigure(List <Property> properties, World world) : base(properties, world) { Initialize(); foreach (Property property in properties) { switch (property.Name) { case "appeared": Appeared = Convert.ToInt32(property.Value); break; case "birth_year": BirthYear = Convert.ToInt32(property.Value); break; case "birth_seconds72": BirthSeconds72 = Convert.ToInt32(property.Value); break; case "death_year": DeathYear = Convert.ToInt32(property.Value); break; case "death_seconds72": DeathSeconds72 = Convert.ToInt32(property.Value); break; case "name": Name = Formatting.InitCaps(property.Value.Replace("'", "`")); break; case "race": Race = string.Intern(Formatting.FormatRace(property.Value)); break; case "caste": Caste = string.Intern(Formatting.InitCaps(property.Value.ToLower().Replace('_', ' '))); break; case "associated_type": AssociatedType = string.Intern(Formatting.InitCaps(property.Value.ToLower().Replace('_', ' '))); break; case "deity": Deity = true; property.Known = true; break; case "skeleton": Skeleton = true; property.Known = true; break; case "force": Force = true; property.Known = true; Race = "Force"; break; case "zombie": Zombie = true; property.Known = true; break; case "ghost": Ghost = true; property.Known = true; break; case "hf_link": //Will be processed after all HFs have been loaded world.AddHFtoHfLink(this, property); property.Known = true; List <string> knownSubProperties = new List <string> { "hfid", "link_strength", "link_type" }; if (property.SubProperties != null) { foreach (string subPropertyName in knownSubProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } } break; case "entity_link": case "entity_former_position_link": case "entity_position_link": world.AddHFtoEntityLink(this, property); property.Known = true; if (property.SubProperties != null) { foreach (string subPropertyName in KnownEntitySubProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } } break; case "entity_reputation": world.AddReputation(this, property); property.Known = true; if (property.SubProperties != null) { foreach (string subPropertyName in Reputation.KnownReputationSubProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } } break; case "entity_squad_link": case "entity_former_squad_link": property.Known = true; if (property.SubProperties != null) { foreach (string subPropertyName in KnownEntitySquadLinkProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } } break; case "relationship_profile_hf": case "relationship_profile_hf_visual": property.Known = true; if (property.SubProperties != null) { RelationshipProfiles.Add(new RelationshipProfileHf(property.SubProperties)); } break; case "site_link": world.AddHFtoSiteLink(this, property); property.Known = true; if (property.SubProperties != null) { foreach (string subPropertyName in KnownSiteLinkSubProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } } break; case "hf_skill": property.Known = true; if (property.SubProperties != null) { Skills.Add(new Skill(property.SubProperties)); } break; case "active_interaction": ActiveInteractions.Add(string.Intern(property.Value)); break; case "interaction_knowledge": InteractionKnowledge.Add(string.Intern(property.Value)); break; case "animated": Animated = true; property.Known = true; break; case "animated_string": if (AnimatedType != "") { throw new Exception("Animated Type already exists."); } AnimatedType = Formatting.InitCaps(property.Value); break; case "journey_pet": JourneyPets.Add(Formatting.FormatRace(property.Value)); break; case "goal": Goal = Formatting.InitCaps(property.Value); break; case "sphere": Spheres.Add(property.Value); break; case "current_identity_id": CurrentIdentityId = Convert.ToInt32(property.Value); break; case "used_identity_id": UsedIdentityIds.Add(Convert.ToInt32(property.Value)); break; case "ent_pop_id": EntityPopulationId = Convert.ToInt32(property.Value); break; case "holds_artifact": HoldingArtifacts.Add(world.GetArtifact(Convert.ToInt32(property.Value))); break; case "adventurer": Adventurer = true; property.Known = true; break; case "breed_id": BreedId = property.Value; if (!string.IsNullOrWhiteSpace(BreedId)) { if (world.Breeds.ContainsKey(BreedId)) { world.Breeds[BreedId].Add(this); } else { world.Breeds.Add(BreedId, new List <HistoricalFigure> { this }); } } break; case "sex": property.Known = true; break; } } if (string.IsNullOrWhiteSpace(Name)) { Name = !string.IsNullOrWhiteSpace(AnimatedType) ? Formatting.InitCaps(AnimatedType) : "(Unnamed)"; } if (Adventurer) { world.AddPlayerRelatedDwarfObjects(this); } }
public HistoricalFigure(List <Property> properties, World world) : base(properties, world) { Initialize(); List <string> knownEntitySubProperties = new List <string>() { "entity_id", "link_strength", "link_type", "position_profile_id", "start_year", "end_year" }; List <string> knownReputationSubProperties = new List <string>() { "entity_id", "unsolved_murders", "first_ageless_year", "first_ageless_season_count", "rep_enemy_fighter" }; List <string> knownSiteLinkSubProperties = new List <string>() { "link_type", "site_id", "sub_id", "entity_id" }; List <string> knownEntitySquadLinkProperties = new List <string>() { "squad_id", "squad_position", "entity_id", "start_year", "end_year" }; List <string> knownRelationshipProfileProperties = new List <string>() { "hf_id", "meet_count", "last_meet_year", "last_meet_seconds72", "rep_friendly", "rep_buddy", "rep_grudge" }; foreach (Property property in properties) { switch (property.Name) { case "appeared": Appeared = Convert.ToInt32(property.Value); break; case "birth_year": BirthYear = Convert.ToInt32(property.Value); break; case "birth_seconds72": BirthSeconds72 = Convert.ToInt32(property.Value); break; case "death_year": DeathYear = Convert.ToInt32(property.Value); break; case "death_seconds72": DeathSeconds72 = Convert.ToInt32(property.Value); break; case "name": Name = String.Intern(Formatting.InitCaps(property.Value)); break; case "race": Race = String.Intern(Formatting.FormatRace(property.Value)); break; case "caste": Caste = Formatting.InitCaps(property.Value.ToLower().Replace('_', ' ')); break; case "associated_type": AssociatedType = Formatting.InitCaps(property.Value.ToLower().Replace('_', ' ')); break; case "deity": Deity = true; property.Known = true; break; case "skeleton": Skeleton = true; property.Known = true; break; case "force": Force = true; property.Known = true; break; case "zombie": Zombie = true; property.Known = true; break; case "ghost": Ghost = true; property.Known = true; break; case "hf_link": //Will be processed after all HFs have been loaded world.AddHFtoHFLink(this, property); property.Known = true; List <string> knownSubProperties = new List <string>() { "hfid", "link_strength", "link_type" }; foreach (string subPropertyName in knownSubProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } break; case "entity_link": case "entity_former_position_link": case "entity_position_link": world.AddHFtoEntityLink(this, property); foreach (string subPropertyName in knownEntitySubProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } break; case "entity_reputation": world.AddReputation(this, property); foreach (string subPropertyName in knownReputationSubProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } break; case "entity_squad_link": case "entity_former_squad_link": property.Known = true; foreach (string subPropertyName in knownEntitySquadLinkProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } break; case "relationship_profile_hf": property.Known = true; foreach (string subPropertyName in knownRelationshipProfileProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } break; case "site_link": world.AddHFtoSiteLink(this, property); foreach (string subPropertyName in knownSiteLinkSubProperties) { Property subProperty = property.SubProperties.FirstOrDefault(property1 => property1.Name == subPropertyName); if (subProperty != null) { subProperty.Known = true; } } break; case "hf_skill": Skills.Add(new Skill(property.SubProperties)); break; case "active_interaction": ActiveInteractions.Add(property.Value); break; case "interaction_knowledge": InteractionKnowledge.Add(property.Value); break; case "animated": Animated = true; property.Known = true; break; case "animated_string": if (AnimatedType != "") { throw new Exception("Animated Type already exists."); } AnimatedType = Formatting.InitCaps(property.Value); break; case "journey_pet": JourneyPets.Add(Formatting.FormatRace(property.Value)); break; case "goal": Goal = Formatting.InitCaps(property.Value); break; case "sphere": Spheres.Add(property.Value); break; case "current_identity_id": world.AddHFCurrentIdentity(this, Convert.ToInt32(property.Value)); break; case "used_identity_id": world.AddHFUsedIdentity(this, Convert.ToInt32(property.Value)); break; case "ent_pop_id": EntityPopulation = world.GetEntityPopulation(Convert.ToInt32(property.Value)); break; case "holds_artifact": HoldingArtifacts.Add(world.GetArtifact(Convert.ToInt32(property.Value))); break; case "adventurer": Adventurer = true; property.Known = true; break; } } if (Name == "") { Name = "(Unnamed)"; } }
public void ReadFile(string path) { var transformStack = new Stack <Matrix4x4>(); transformStack.Push(Matrix4x4.Identity); var contents = File.ReadLines(path); var vertCount = 0; foreach (var line in contents) { string[] splitLine; ObjectProperties objProps; Vector4 lightPos; Vector3 lightCol; if (line.StartsWith("#") || line == string.Empty) { continue; } else { splitLine = line.Split(new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries); } var cmd = splitLine[0]; switch (cmd) { case "size": ImageWidth = int.Parse(splitLine[1]); ImageHeight = int.Parse(splitLine[2]); SetAspectRatio(); break; case "maxdepth": RecursionMaxDepth = int.Parse(splitLine[1]); break; case "maxverts": Vertices = new Vector3[int.Parse(splitLine[1])]; break; case "vertex": GetFloatCmdValues(splitLine); Vertices[vertCount++] = Get3dVectorFromFirstValues(); break; case "tri": GetFloatCmdValues(splitLine); var vert1 = Vertices[(int)CmdValues[0]]; var vert2 = Vertices[(int)CmdValues[1]]; var vert3 = Vertices[(int)CmdValues[2]]; objProps = CreateObjectProperties(); Triangles.Add(new Triangle(vert1, vert2, vert3, objProps, transformStack.Peek())); break; case "sphere": GetFloatCmdValues(splitLine); objProps = CreateObjectProperties(); var spherePos = new Vector3(CmdValues[0], CmdValues[1], CmdValues[2]); Spheres.Add(new Sphere(spherePos, CmdValues[3], objProps, transformStack.Peek())); break; case "output": OutputFilename = splitLine[1]; break; case "camera": GetFloatCmdValues(splitLine); EyeInit = new Vector3(CmdValues[0], CmdValues[1], CmdValues[2]); LookAtPoint = new Vector3(CmdValues[3], CmdValues[4], CmdValues[5]); UpInit = new Vector3(CmdValues[6], CmdValues[7], CmdValues[8]); FovYRad = Transform.ToRadians(CmdValues[9]); SetFovX(); ModelView = SetLookAtMatrix(); break; case "attenuation": GetFloatCmdValues(splitLine); Attenuation = new[] { CmdValues[0], CmdValues[1], CmdValues[2] }; break; case "ambient": GetFloatCmdValues(splitLine); Ambient = Get3dVectorFromFirstValues(); break; case "diffuse": GetFloatCmdValues(splitLine); Diffuse = Get3dVectorFromFirstValues(); break; case "specular": GetFloatCmdValues(splitLine); Specular = Get3dVectorFromFirstValues(); break; case "emission": GetFloatCmdValues(splitLine); Emission = Get3dVectorFromFirstValues(); break; case "shininess": Shininess = float.Parse(splitLine[1]); break; case "directional": GetFloatCmdValues(splitLine); lightPos = new Vector4(CmdValues[0], CmdValues[1], CmdValues[2], 0); lightCol = new Vector3(CmdValues[3], CmdValues[4], CmdValues[5]); Lights.Add(new Light(lightPos, lightCol, new float[] { 1, 0, 0 })); break; case "point": GetFloatCmdValues(splitLine); lightPos = new Vector4(CmdValues[0], CmdValues[1], CmdValues[2], 1); lightCol = new Vector3(CmdValues[3], CmdValues[4], CmdValues[5]); Lights.Add(new Light(lightPos, lightCol, Attenuation)); break; case "translate": GetFloatCmdValues(splitLine); var translateMat = GetTranslationMatrix(Get3dVectorFromFirstValues()); RightMultiplyTopStack(translateMat, transformStack); break; case "rotate": GetFloatCmdValues(splitLine); var angle = CmdValues[3]; var rotMat = GetRotationMatrix(Get3dVectorFromFirstValues(), angle); RightMultiplyTopStack(rotMat, transformStack); break; case "scale": GetFloatCmdValues(splitLine); var scaleMat = GetScaleMatrix(Get3dVectorFromFirstValues()); RightMultiplyTopStack(scaleMat, transformStack); break; case "pushTransform": transformStack.Push(transformStack.Peek()); break; case "popTransform": transformStack.Pop(); break; default: if (cmd == "maxvertnorms" || cmd == "vertexnormal" || cmd == "trinormal") { break; } throw new InvalidEnumArgumentException($"There is no such command as {cmd}"); } } }
public override void Unpack(BinaryReader reader) { Id = reader.ReadUInt32(); Bitfield = reader.ReadUInt32(); AllowFreeHeading = (Bitfield & 4) != 0; HasPhysicsBSP = (Bitfield & 8) != 0; // Get all the GraphicsObjects in this SetupModel. These are all the 01-types. uint numParts = reader.ReadUInt32(); for (int i = 0; i < numParts; i++) { Parts.Add(reader.ReadUInt32()); } if ((Bitfield & 1) != 0) { for (int i = 0; i < numParts; i++) { ParentIndex.Add(reader.ReadUInt32()); } } if ((Bitfield & 2) != 0) { for (int i = 0; i < numParts; i++) { DefaultScale.Add(reader.ReadVector3()); } } HoldingLocations.Unpack(reader); ConnectionPoints.Unpack(reader); int placementsCount = reader.ReadInt32(); for (int i = 0; i < placementsCount; i++) { int key = reader.ReadInt32(); // there is a frame for each Part var placementType = new PlacementType(); placementType.Unpack(reader, (uint)Parts.Count); PlacementFrames.Add(key, placementType); } CylSpheres.Unpack(reader); Spheres.Unpack(reader); Height = reader.ReadSingle(); Radius = reader.ReadSingle(); StepDownHeight = reader.ReadSingle(); StepUpHeight = reader.ReadSingle(); SortingSphere.Unpack(reader); SelectionSphere.Unpack(reader); Lights.Unpack(reader); DefaultAnimation = reader.ReadUInt32(); DefaultScript = reader.ReadUInt32(); DefaultMotionTable = reader.ReadUInt32(); DefaultSoundTable = reader.ReadUInt32(); DefaultScriptTable = reader.ReadUInt32(); }
/// <summary> /// /// </summary> protected void GenerateNoise() { EnabledInterface(false); // Parse input ------------------------------------------------------------------------------------ int seed = ParseInt(_tbxSeed.Text, PrimitiveModule.DefaultSeed); double frequency = ParseDouble(_tbxFrequency.Text, FilterModule.DEFAULT_FREQUENCY); double lacunarity = ParseDouble(_tbxLacunarity.Text, FilterModule.DEFAULT_LACUNARITY); double gain = ParseDouble(_tbxGain.Text, FilterModule.DEFAULT_GAIN); double offset = ParseDouble(_tbxOffset.Text, FilterModule.DEFAULT_OFFSET); double exponent = ParseDouble(_tbxExponent.Text, FilterModule.DEFAULT_SPECTRAL_EXPONENT); var octaveCount = (int)_nstpOctave.Value; bool seamless = _chkbx.Checked; GradientColor gradient = GradientColors.Grayscale; NoiseQuality quality = PrimitiveModule.DefaultQuality; var primitive = NoisePrimitive.ImprovedPerlin; var filter = NoiseFilter.SumFractal; try { quality = (NoiseQuality)Enum.Parse(typeof(NoiseQuality), _cbxQuality.Text); } catch { MessageBox.Show( String.Format("Unknown quality '{0}'", _cbxQuality.Text), "Libnoise Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); EnabledInterface(true); return; } try { primitive = (NoisePrimitive)Enum.Parse(typeof(NoisePrimitive), _cbxPrimitive.Text); } catch { MessageBox.Show( String.Format("Unknown primitive '{0}'", _cbxPrimitive.Text), "Libnoise Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); EnabledInterface(true); return; } try { filter = (NoiseFilter)Enum.Parse(typeof(NoiseFilter), _cbxFilter.Text); } catch { MessageBox.Show( String.Format("Unknown filter '{0}'", _cbxFilter.Text), "Libnoise Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); EnabledInterface(true); return; } switch (_cbxGradient.Text) { case "Grayscale": gradient = GradientColors.Grayscale; break; case "Terrain": gradient = GradientColors.Terrain; break; } // Create module tree ------------------------------------------------------------------------------------ PrimitiveModule pModule = null; switch (primitive) { case NoisePrimitive.Constant: pModule = new Constant(offset); break; case NoisePrimitive.Cylinders: pModule = new Cylinders(offset); seamless = false; break; case NoisePrimitive.Spheres: pModule = new Spheres(offset); seamless = false; break; case NoisePrimitive.BevinsGradient: pModule = new BevinsGradient(); break; case NoisePrimitive.BevinsValue: pModule = new BevinsValue(); break; case NoisePrimitive.ImprovedPerlin: pModule = new ImprovedPerlin(); break; case NoisePrimitive.SimplexPerlin: pModule = new SimplexPerlin(); break; } pModule.Quality = quality; pModule.Seed = seed; FilterModule fModule = null; ScaleBias scale = null; switch (filter) { case NoiseFilter.Pipe: fModule = new Pipe(); break; case NoiseFilter.SumFractal: fModule = new SumFractal(); break; case NoiseFilter.SinFractal: fModule = new SinFractal(); break; case NoiseFilter.MultiFractal: fModule = new MultiFractal(); // Used to show the difference with our gradient color (-1 + 1) scale = new ScaleBias(fModule, 1, -0.8); break; case NoiseFilter.Billow: fModule = new Billow(); ((Billow)fModule).Bias = -0.2; ((Billow)fModule).Scale = 2; break; case NoiseFilter.HeterogeneousMultiFractal: fModule = new HeterogeneousMultiFractal(); // Used to show the difference with our gradient color (-1 + 1) scale = new ScaleBias(fModule, -1, 2); break; case NoiseFilter.HybridMultiFractal: fModule = new HybridMultiFractal(); // Used to show the difference with our gradient color (-1 + 1) scale = new ScaleBias(fModule, 0.7, -2); break; case NoiseFilter.RidgedMultiFractal: fModule = new RidgedMultiFractal(); // Used to show the difference with our gradient color (-1 + 1) scale = new ScaleBias(fModule, 0.9, -1.25); break; case NoiseFilter.Voronoi: fModule = new Voronoi(); break; } fModule.Frequency = frequency; fModule.Lacunarity = lacunarity; fModule.OctaveCount = octaveCount; fModule.Offset = offset; fModule.Offset = offset; fModule.Gain = gain; fModule.Primitive3D = (IModule3D)pModule; IModule3D finalModule; if (scale == null) { finalModule = (IModule3D)fModule; } else { finalModule = scale; } NoiseMapBuilder projection; switch (_cbxProjection.Text) { case "Spherical": projection = new NoiseMapBuilderSphere(); ((NoiseMapBuilderSphere)projection).SetBounds(-90, 90, -180, 180); // degrees break; case "Cylindrical": projection = new NoiseMapBuilderCylinder(); ((NoiseMapBuilderCylinder)projection).SetBounds(-180, 180, -10, 10); break; case "Planar": default: double bound = 2; projection = new NoiseMapBuilderPlane(bound, bound * 2, bound, bound * 2, seamless); //projection = new NoiseMapBuilderPlane(-bound, bound, -bound, bound, seamless); //projection = new NoiseMapBuilderPlane(0, bound, 0, bound, seamless); break; } int width = 0; int height = 0; switch (_cbxSize.Text) { case "256 x 256": width = 256; height = 256; break; case "512 x 512": width = 512; height = 512; break; case "1024 x 1024": width = 1024; height = 1024; break; case "256 x 128": width = 256; height = 128; break; case "512 x 256": width = 512; height = 256; break; case "1024 x 512": width = 1024; height = 512; break; case "2048 x 1024": width = 2048; height = 1024; break; default: case "128 x 128": width = 128; height = 128; break; } // ------------------------------------------------------------------------------------------------ // 0 - Initializing _prbarRenderProgression.Visible = true; _lblProgressPercent.Visible = true; _prbarRenderProgression.Value = 0; ; _lblProgressPercent.Text = ""; _lblLog.Text = String.Format("Create a {0} image with a {1} projection\n", _cbxSize.Text, _cbxProjection.Text); var watchDog = new Stopwatch(); TimeSpan ts; double elaspedTime = 0; // // ------------------------------------------------------------------------------------------------ // 1 - Build the noise map watchDog.Reset(); _prbarRenderProgression.Value = 0; _lblLog.Text += "Building noise map ... "; var noiseMap = new NoiseMap(); /* * // ShapeFilter test * Bitmap bmpShape = new Bitmap("smileyShape.bmp"); * BitmapAdaptater bmShapeAdaptater = new BitmapAdaptater(bmpShape); * * ShapeFilter shapeFilter = new ShapeFilter(); * shapeFilter.Shape = bmShapeAdaptater; * * projection.Filter = shapeFilter; */ projection.SetSize(width, height); projection.SourceModule = finalModule; projection.NoiseMap = noiseMap; projection.CallBack = delegate(int line) { line++; watchDog.Stop(); //Process message Application.DoEvents(); _prbarRenderProgression.Value = (line * 100 / height); _lblProgressPercent.Text = String.Format("{0} % - {1} line(s)", _prbarRenderProgression.Value, line); watchDog.Start(); }; watchDog.Start(); projection.Build(); watchDog.Stop(); ts = watchDog.Elapsed; elaspedTime += ts.TotalMilliseconds; _lblLog.Text += String.Format("{0:00}:{1:00} {2:00},{3:0000}\n", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds * 10 ); // ------------------------------------------------------------------------------------------------ // 2 - Render image // Create a renderer, BitmapAdaptater create a System.Drawing.Bitmap on the fly watchDog.Reset(); _prbarRenderProgression.Value = 0; _lblLog.Text += "Rendering image ... "; var renderer = new ImageRenderer(); renderer.NoiseMap = noiseMap; renderer.Gradient = gradient; renderer.LightBrightness = 2; renderer.LightContrast = 8; //renderer.LightEnabled = true; // Libnoise image struct strategy //Graphics.Tools.Noise.Renderer.Image image = new Graphics.Tools.Noise.Renderer.Image(); //renderer.Image = image; // Dotnet Bitmap Strategy var bmpAdaptater = new BitmapAdaptater(width, height); renderer.Image = bmpAdaptater; renderer.CallBack = delegate(int line) { line++; watchDog.Stop(); //Process message Application.DoEvents(); _prbarRenderProgression.Value = (line * 100 / height); _lblProgressPercent.Text = String.Format("{0} % - {1} line(s)", _prbarRenderProgression.Value, line); watchDog.Start(); }; // Render the texture. watchDog.Start(); renderer.Render(); watchDog.Stop(); ts = watchDog.Elapsed; elaspedTime += ts.TotalMilliseconds; _lblLog.Text += String.Format("{0:00}:{1:00} {2:00},{3:0000}\n", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds * 10 ); //---------------------------------------- // Normalmap rendering test // /* * BitmapAdaptater nmapAdaptater = new BitmapAdaptater(width, height); * NormalMapRenderer nmap = new NormalMapRenderer(); * nmap.Image = nmapAdaptater; * nmap.BumpHeight = 30.0; * nmap.NoiseMap = noiseMap; * nmap.Render(); * nmapAdaptater.Bitmap.Save("normalMap.png", ImageFormat.Png); */ //---------------------------------------- /* * Heightmap8 heightmap8 = new Heightmap8(); * Heightmap8Renderer heightmapRenderer = new Heightmap8Renderer(); * heightmapRenderer.Heightmap = heightmap8; */ /* * Heightmap16 heightmap16 = new Heightmap16(); * Heightmap16Renderer heightmapRenderer = new Heightmap16Renderer(); * heightmapRenderer.Heightmap = heightmap16; */ /* * Heightmap32 heightmap32 = new Heightmap32(); * Heightmap32Renderer heightmapRenderer = new Heightmap32Renderer(); * heightmapRenderer.Heightmap = heightmap32; */ /* * heightmapRenderer.NoiseMap = noiseMap; * heightmapRenderer.ExactFit(); * heightmapRenderer.Render(); */ /* * Heightmap16RawWriter rawWriter = new Heightmap16RawWriter(); * rawWriter.Heightmap = heightmap16; * rawWriter.Filename = "heightmap16.raw"; * rawWriter.WriteFile(); */ // ------------------------------------------------------------------------------------------------ // 3 - Painting // Save the file //bmpAdaptater.Bitmap.Save("rendered.png",ImageFormat.Png); _imageRendered.Width = width; _imageRendered.Height = height; //_imageRendered.Image = _bitmap; _imageRendered.Image = bmpAdaptater.Bitmap; if (_imageRendered.Width > _panImageViewport.Width) { _imageRendered.Left = 0; } else { _imageRendered.Left = (_panImageViewport.Width - _imageRendered.Width) / 2; } if (_imageRendered.Height > _panImageViewport.Height) { _imageRendered.Top = 0; } else { _imageRendered.Top = (_panImageViewport.Height - _imageRendered.Height) / 2; } if (_imageRendered.Width > _panImageViewport.Width || _imageRendered.Height > _panImageViewport.Height) { _imageRendered.Anchor = (AnchorStyles.Left | AnchorStyles.Top); _panImageViewport.AutoScroll = true; } else { _panImageViewport.AutoScroll = false; } // ---------------------------------------------------------------- ts = TimeSpan.FromMilliseconds(elaspedTime); // Format and display the TimeSpan value. _lblLog.Text += String.Format("Duration : {0:00}:{1:00} {2:00},{3:0000}\n", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds * 10 ); EnabledInterface(true); _prbarRenderProgression.Value = 0; _lblProgressPercent.Text = ""; _prbarRenderProgression.Visible = false; _lblProgressPercent.Visible = false; }
private static List<LoadedModule> GetModules(XmlNodeList moduleList) { List<LoadedModule> loadedModules = new List<LoadedModule>(); foreach (XmlNode node in moduleList) { string id = node.Attributes["guid"].Value; Point position = new Point(double.Parse(node.Attributes["position"].Value.Split(',')[0]), double.Parse(node.Attributes["position"].Value.Split(',')[1])); ModuleBase module = null; List<string> links = new List<string>(); switch (node.Attributes["type"].Value) { case "Billow": Billow billow = new Billow(); billow.Frequency = double.Parse(node.SelectSingleNode("Frequency").InnerText); billow.Lacunarity = double.Parse(node.SelectSingleNode("Lacunarity").InnerText); billow.OctaveCount = int.Parse(node.SelectSingleNode("OctaveCount").InnerText); billow.Persistence = double.Parse(node.SelectSingleNode("Persistence").InnerText); billow.Quality = (QualityMode)Enum.Parse(typeof(QualityMode), node.SelectSingleNode("Quality").InnerText); billow.Seed = int.Parse(node.SelectSingleNode("Seed").InnerText); module = billow; break; case "Checker": module = new Checker(); break; case "Const": Const con = new Const(); con.Value = double.Parse(node.SelectSingleNode("Value").InnerText); module = con; break; case "Cylinders": Cylinders cylinder = new Cylinders(); cylinder.Frequency = double.Parse(node.SelectSingleNode("Frequency").InnerText); module = cylinder; break; case "Perlin": Perlin perlin = new Perlin(); perlin.Frequency = double.Parse(node.SelectSingleNode("Frequency").InnerText); perlin.Lacunarity = double.Parse(node.SelectSingleNode("Lacunarity").InnerText); perlin.OctaveCount = int.Parse(node.SelectSingleNode("OctaveCount").InnerText); perlin.Persistence = double.Parse(node.SelectSingleNode("Persistence").InnerText); perlin.Quality = (QualityMode)Enum.Parse(typeof(QualityMode), node.SelectSingleNode("Quality").InnerText); perlin.Seed = int.Parse(node.SelectSingleNode("Seed").InnerText); module = perlin; break; case "RidgedMultifractal": RidgedMultifractal ridgedMF = new RidgedMultifractal(); ridgedMF.Frequency = double.Parse(node.SelectSingleNode("Frequency").InnerText); ridgedMF.Lacunarity = double.Parse(node.SelectSingleNode("Lacunarity").InnerText); ridgedMF.OctaveCount = int.Parse(node.SelectSingleNode("OctaveCount").InnerText); ridgedMF.Quality = (QualityMode)Enum.Parse(typeof(QualityMode), node.SelectSingleNode("Quality").InnerText); ridgedMF.Seed = int.Parse(node.SelectSingleNode("Seed").InnerText); module = ridgedMF; break; case "Spheres": Spheres spheres = new Spheres(); spheres.Frequency = double.Parse(node.SelectSingleNode("Frequency").InnerText); module = spheres; break; case "Voronoi": Voronoi voronoi = new Voronoi(); voronoi.Frequency = double.Parse(node.SelectSingleNode("Frequency").InnerText); voronoi.Displacement = double.Parse(node.SelectSingleNode("Displacement").InnerText); voronoi.UseDistance = bool.Parse(node.SelectSingleNode("UseDistance").InnerText); voronoi.Seed = int.Parse(node.SelectSingleNode("Seed").InnerText); module = voronoi; break; case "Abs": module = new Abs(); XmlNode absInputs = node.SelectSingleNode("ModuleInputs"); links.Add(absInputs.SelectSingleNode("Input").InnerText); break; case "Add": module = new Add(); XmlNode addInputs = node.SelectSingleNode("ModuleInputs"); links.Add(addInputs.SelectSingleNode("Left").InnerText); links.Add(addInputs.SelectSingleNode("Right").InnerText); break; case "Blend": module = new Blend(); XmlNode blendInputs = node.SelectSingleNode("ModuleInputs"); links.Add(blendInputs.SelectSingleNode("Left").InnerText); links.Add(blendInputs.SelectSingleNode("Right").InnerText); links.Add(blendInputs.SelectSingleNode("Operator").InnerText); break; case "Cache": module = new Cache(); XmlNode cacheInputs = node.SelectSingleNode("ModuleInputs"); links.Add(cacheInputs.SelectSingleNode("Input").InnerText); break; case "Clamp": Clamp clamp = new Clamp(); clamp.Maximum = double.Parse(node.SelectSingleNode("Maximum").InnerText); clamp.Minimum = double.Parse(node.SelectSingleNode("Minimum").InnerText); module = clamp; XmlNode clampInputs = node.SelectSingleNode("ModuleInputs"); links.Add(clampInputs.SelectSingleNode("Input").InnerText); break; case "Curve": Curve curve = new Curve(); module = curve; foreach (XmlNode cpNode in node.SelectSingleNode("ControlPoints").ChildNodes) { double x = double.Parse(cpNode.InnerText.Split(',')[0]); double y = double.Parse(cpNode.InnerText.Split(',')[1]); curve.Add(x, y); } XmlNode curveInputs = node.SelectSingleNode("ModuleInputs"); links.Add(curveInputs.SelectSingleNode("Input").InnerText); break; case "Displace": module = new Displace(); XmlNode displaceInputs = node.SelectSingleNode("ModuleInputs"); links.Add(displaceInputs.SelectSingleNode("Primary").InnerText); links.Add(displaceInputs.SelectSingleNode("X").InnerText); links.Add(displaceInputs.SelectSingleNode("Y").InnerText); links.Add(displaceInputs.SelectSingleNode("Z").InnerText); break; case "Exponent": Exponent exponent = new Exponent(); exponent.Value = double.Parse(node.SelectSingleNode("Value").InnerText); module = exponent; XmlNode exponentInputs = node.SelectSingleNode("ModuleInputs"); links.Add(exponentInputs.SelectSingleNode("Input").InnerText); break; case "Invert": module = new Invert(); XmlNode invertInputs = node.SelectSingleNode("ModuleInputs"); links.Add(invertInputs.SelectSingleNode("Input").InnerText); break; case "Max": module = new Max(); XmlNode maxInputs = node.SelectSingleNode("ModuleInputs"); links.Add(maxInputs.SelectSingleNode("Left").InnerText); links.Add(maxInputs.SelectSingleNode("Right").InnerText); break; case "Min": module = new Min(); XmlNode minInputs = node.SelectSingleNode("ModuleInputs"); links.Add(minInputs.SelectSingleNode("Left").InnerText); links.Add(minInputs.SelectSingleNode("Right").InnerText); break; case "Multiply": module = new Multiply(); XmlNode multiplyInputs = node.SelectSingleNode("ModuleInputs"); links.Add(multiplyInputs.SelectSingleNode("Left").InnerText); links.Add(multiplyInputs.SelectSingleNode("Right").InnerText); break; case "Power": module = new Power(); XmlNode powerInputs = node.SelectSingleNode("ModuleInputs"); links.Add(powerInputs.SelectSingleNode("Left").InnerText); links.Add(powerInputs.SelectSingleNode("Right").InnerText); break; case "Rotate": Rotate rotate = new Rotate(); rotate.X = double.Parse(node.SelectSingleNode("X").InnerText); rotate.Y = double.Parse(node.SelectSingleNode("Y").InnerText); rotate.Z = double.Parse(node.SelectSingleNode("Z").InnerText); module = rotate; XmlNode rotateInputs = node.SelectSingleNode("ModuleInputs"); links.Add(rotateInputs.SelectSingleNode("Input").InnerText); break; case "Scale": Scale scale = new Scale(); scale.X = double.Parse(node.SelectSingleNode("X").InnerText); scale.Y = double.Parse(node.SelectSingleNode("Y").InnerText); scale.Z = double.Parse(node.SelectSingleNode("Z").InnerText); module = scale; XmlNode scaleInputs = node.SelectSingleNode("ModuleInputs"); links.Add(scaleInputs.SelectSingleNode("Input").InnerText); break; case "ScaleBias": ScaleBias scaleBias = new ScaleBias(); scaleBias.Scale = double.Parse(node.SelectSingleNode("Scale").InnerText); scaleBias.Bias = double.Parse(node.SelectSingleNode("Bias").InnerText); module = scaleBias; XmlNode scaleBiasInputs = node.SelectSingleNode("ModuleInputs"); links.Add(scaleBiasInputs.SelectSingleNode("Input").InnerText); break; case "Select": Select select = new Select(); select.Minimum = double.Parse(node.SelectSingleNode("Minimum").InnerText); select.Maximum = double.Parse(node.SelectSingleNode("Maximum").InnerText); select.FallOff = double.Parse(node.SelectSingleNode("FallOff").InnerText); module = select; XmlNode selectInputs = node.SelectSingleNode("ModuleInputs"); links.Add(selectInputs.SelectSingleNode("Primary").InnerText); links.Add(selectInputs.SelectSingleNode("Secondary").InnerText); links.Add(selectInputs.SelectSingleNode("Controller").InnerText); break; case "Subtract": module = new Subtract(); XmlNode subtractInputs = node.SelectSingleNode("ModuleInputs"); links.Add(subtractInputs.SelectSingleNode("Left").InnerText); links.Add(subtractInputs.SelectSingleNode("Right").InnerText); break; case "Terrace": Terrace terrace = new Terrace(); module = terrace; foreach (XmlNode cpNode in node.SelectSingleNode("ControlPoints").ChildNodes) { terrace.Add(double.Parse(cpNode.InnerText)); } XmlNode terraceInputs = node.SelectSingleNode("ModuleInputs"); links.Add(terraceInputs.SelectSingleNode("Input").InnerText); break; case "Translate": Translate translate = new Translate(); translate.X = double.Parse(node.SelectSingleNode("X").InnerText); translate.Y = double.Parse(node.SelectSingleNode("Y").InnerText); translate.Z = double.Parse(node.SelectSingleNode("Z").InnerText); module = translate; XmlNode translateInputs = node.SelectSingleNode("ModuleInputs"); links.Add(translateInputs.SelectSingleNode("Input").InnerText); break; case "Turbulence": Turbulence turbulence = new Turbulence(); turbulence.Frequency = double.Parse(node.SelectSingleNode("Frequency").InnerText); turbulence.Power = double.Parse(node.SelectSingleNode("Power").InnerText); turbulence.Roughness = int.Parse(node.SelectSingleNode("Roughness").InnerText); turbulence.Seed = int.Parse(node.SelectSingleNode("Seed").InnerText); module = turbulence; XmlNode turbulenceInputs = node.SelectSingleNode("ModuleInputs"); links.Add(turbulenceInputs.SelectSingleNode("Input").InnerText); break; case "Final": module = new Final(); XmlNode finalInputs = node.SelectSingleNode("ModuleInputs"); links.Add(finalInputs.SelectSingleNode("Input").InnerText); break; default: break; } LoadedModule lm = new LoadedModule(id, module, position, links); loadedModules.Add(lm); } return loadedModules; }