Exemple #1
0
    public override void OnVertexBuild(PQS.VertexBuildData data)
    {
        var height = (data.vertHeight - sphere.radiusMin) / (sphere.radiusMax - sphere.radiusMin);

        height = Mathf.Clamp((float)height, 0, 1);
        LandClass curLandClass = null;
        LandClass nextLandClass = null;
        for (var i = 0; i < landClasses.Length; i++)
        {
            var lc = landClasses[i];
            if (height >= lc.altStart && height <= lc.altEnd)
            {
                curLandClass = lc;
                if (lerp && i + 1 < landClasses.Length)
                    nextLandClass = landClasses[i + 1];

                break;
            }

        }
        if (curLandClass == null)
        {
            data.vertColor = Color.red;
        }
        else if (nextLandClass == null)
        {
            data.vertColor = Color.Lerp(data.vertColor, curLandClass.color, blend);
        }
        else
        {
            data.vertColor = Color.Lerp(data.vertColor, Color.Lerp(curLandClass.color, nextLandClass.color,
                (float)((height - curLandClass.altStart) / (curLandClass.altEnd - curLandClass.altStart))), blend);
        }
    }
            // Manipulate the terrain
            public override void OnVertexBuildHeight(PQS.VertexBuildData data)
            {
                // Loop through the Deformations
                foreach (Deformation deformation in deformations)
                {
                    // Normalize the deformation position
                    Vector3d positionNorm = deformation.position.normalized;

                    // Get a "normalizer"
                    double normalized = deformation.position.normalized.x / deformation.position.x;

                    // Get the distance between the deformation and the VertexBuildData
                    float distance = (float)Vector3d.Distance(deformation.position.normalized, data.directionFromCenter);

                    // If we are near enough...
                    if (distance <= (deformation.width * 0.5) * normalized)
                    {
                        // ... lower height
                        double vertHeight = data.vertHeight - deformation.depth;
                        // If the body has an ocean, set a limit
                        if (sphere.mapOcean)
                            vertHeight = Math.Max(sphere.radius + 5d, vertHeight);

                        // Set the new height
                        data.vertHeight = vertHeight;
                    }
                }
            }
 public new void OnVertexBuild(PQS.VertexBuildData data)
 {
     if (data.vertHeight < sphere.radius+5)
     {
         data.vertColor = Color.red;
     }
 }
 public void OnVertexBuildHeight(PQS.VertexBuildData vbData)
 {
     if(vbData.vertHeight<minAlt)
     {
         minAlt=vbData.vertHeight;
         //print("new minAlt "+minAlt);
     }
 }
		internal void CloneFrom(PQS ocean)
			{
				FieldInfo[] fields = typeof(PQS).GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
				foreach (FieldInfo f in fields)
				{
					f.SetValue(this, f.GetValue(ocean));
				}
			}
 private PQS GetOcean()
 {
     if (_ocean == null || mainBody != part.vessel.mainBody)
     {
         mainBody = part.vessel.mainBody;
         _ocean = mainBody.GetComponentsInChildren<PQS>(true).FirstOrDefault(p => p.name == mainBody.transform.name + "Ocean");
     }
     return _ocean;
 }
 // Add the management handler to the PQS
 public static void AddHandler(PQS pqsVersion)
 {
     PQSMod_OnDemandHandler handler = new GameObject("OnDemandHandler").AddComponent<PQSMod_OnDemandHandler>();
     handler.transform.parent = pqsVersion.transform;
     UnityEngine.Object.DontDestroyOnLoad(handler);
     handler.sphere = pqsVersion;
     handler.order = 1;
     handlers[pqsVersion] = handler;
 }
Exemple #8
0
        /// <summary>
        ///  Returns the ground's altitude above sea level at this geo position.
        /// </summary>
        /// <returns></returns>
        public ScalarValue GetTerrainAltitude()
        {
            double alt     = 0.0;
            PQS    bodyPQS = Body.pqsController;

            if (bodyPQS != null) // The sun has no terrain.  Everything else has a PQScontroller.
            {
                // The PQS controller gives the theoretical ideal smooth surface curve terrain.
                // The actual ground that exists in-game that you land on, however, is the terrain
                // polygon mesh which is built dynamically from the PQS controller's altitude values,
                // and it only approximates the PQS controller.  The discrepancy between the two
                // can be as high as 20 meters on relatively mild rolling terrain and is probably worse
                // in mountainous terrain with steeper slopes.  It also varies with the user terrain detail
                // graphics setting.

                // Therefore the algorithm here is this:  Get the PQS ideal terrain altitude first.
                // Then try using RayCast to get the actual terrain altitude, which will only work
                // if the LAT/LONG is near the active vessel so the relevant terrain polygons are
                // loaded.  If the RayCast hit works, it overrides the PQS altitude.

                // PQS controller ideal altitude value:
                // -------------------------------------

                // The vector the pqs GetSurfaceHeight method expects is a vector in the following
                // reference frame:
                //     Origin = body center.
                //     X axis = LATLNG(0,0), Y axis = LATLNG(90,0)(north pole), Z axis = LATLNG(0,-90).
                // Using that reference frame, you tell GetSurfaceHeight what the "up" vector is pointing through
                // the spot on the surface you're querying for.
                var bodyUpVector = new Vector3d(1, 0, 0);
                bodyUpVector = QuaternionD.AngleAxis(Latitude, Vector3d.forward /*around Z axis*/) * bodyUpVector;
                bodyUpVector = QuaternionD.AngleAxis(Longitude, Vector3d.down /*around -Y axis*/) * bodyUpVector;

                alt = bodyPQS.GetSurfaceHeight(bodyUpVector) - bodyPQS.radius;

                // Terrain polygon raycasting:
                // ---------------------------
                const double HIGH_AGL  = 1000.0;
                const double POINT_AGL = 800.0;
                // a point hopefully above the terrain:
                Vector3d worldRayCastStart = Body.GetWorldSurfacePosition(Latitude, Longitude, alt + HIGH_AGL);
                // a point a bit below it, to aim down to the terrain:
                Vector3d   worldRayCastStop = Body.GetWorldSurfacePosition(Latitude, Longitude, alt + POINT_AGL);
                RaycastHit hit;
                if (Physics.Raycast(worldRayCastStart, (worldRayCastStop - worldRayCastStart), out hit, float.MaxValue, 1 << TERRAIN_MASK_BIT))
                {
                    // Ensure hit is on the topside of planet, near the worldRayCastStart, not on the far side.
                    if (Mathf.Abs(hit.distance) < 3000)
                    {
                        // Okay a hit was found, use it instead of PQS alt:
                        alt = ((alt + HIGH_AGL) - hit.distance);
                    }
                }
            }
            return(alt);
        }
Exemple #9
0
        // Add the management handler to the PQS
        public static void AddHandler(PQS pqsVersion)
        {
            PQSMod_OnDemandHandler handler = new GameObject("OnDemandHandler").AddComponent <PQSMod_OnDemandHandler>();

            handler.transform.parent = pqsVersion.transform;
            Object.DontDestroyOnLoad(handler);
            handler.sphere       = pqsVersion;
            handler.order        = 1;
            Handlers[pqsVersion] = handler;
        }
Exemple #10
0
        public static T[] GetPQSMods <T>(this PQS pqs) where T : PQSMod
        {
            List <T> mods = new List <T> ();

            foreach (var mod in pqs.GetComponentsInChildren <T>())
            {
                mods.Add(mod);
            }
            return(mods.ToArray());
        }
                // Create the mod
                public override void Create(PQS pqsVersion)
                {
                    base.Create(pqsVersion);

                    // Construct the internal objects.
                    mod.curveMultiplier = new PQSMod_VertexHeightNoiseVertHeightCurve3.SimplexNoise();
                    mod.deformity       = new PQSMod_VertexHeightNoiseVertHeightCurve3.SimplexNoise();
                    mod.ridgedAdd       = new PQSMod_VertexHeightNoiseVertHeightCurve3.RidgedNoise();
                    mod.ridgedSub       = new PQSMod_VertexHeightNoiseVertHeightCurve3.RidgedNoise();
                }
Exemple #12
0
        }         // So many ifs.....

        // Cinically stolen from Waypoint Manager source code :D
        private void PlaceTargetAtCursor()
        {
            CelestialBody targetBody = this.vessel.mainBody;

            if (targetBody.pqsController == null)
            {
                return;
            }

            Ray mouseRay = PlanetariumCamera.Camera.ScreenPointToRay(Input.mousePosition);

            mouseRay.origin = ScaledSpace.ScaledToLocalSpace(mouseRay.origin);
            var    bodyToOrigin = mouseRay.origin - targetBody.position;
            double curRadius    = targetBody.pqsController.radiusMax;
            double lastRadius   = 0;
            int    loops        = 0;

            while (loops < 50)
            {
                Vector3d relSurfacePosition;
                if (PQS.LineSphereIntersection(bodyToOrigin, mouseRay.direction, curRadius, out relSurfacePosition))
                {
                    var    surfacePoint = targetBody.position + relSurfacePosition;
                    double alt          = targetBody.pqsController.GetSurfaceHeight(
                        QuaternionD.AngleAxis(targetBody.GetLongitude(surfacePoint), Vector3d.down) * QuaternionD.AngleAxis(targetBody.GetLatitude(surfacePoint), Vector3d.forward) * Vector3d.right);
                    double error = Math.Abs(curRadius - alt);
                    if (error < (targetBody.pqsController.radiusMax - targetBody.pqsController.radiusMin) / 100)
                    {
                        targetLatitude  = (targetBody.GetLatitude(surfacePoint) + 360) % 360;
                        targetLongitude = (targetBody.GetLongitude(surfacePoint) + 360) % 360;
                        return;
                    }
                    else
                    {
                        lastRadius = curRadius;
                        curRadius  = alt;
                        loops++;
                    }
                }
                else
                {
                    if (loops == 0)
                    {
                        break;
                    }
                    // Went too low, needs to try higher
                    else
                    {
                        curRadius = (lastRadius * 9 + curRadius) / 10;
                        loops++;
                    }
                }
            }
        }
Exemple #13
0
        // Create the mod
        public override void Create(PQS pqsVersion)
        {
            base.Create(pqsVersion);

            // Create the base mod
            PQSMod_VoronoiCraters clone =
                Utility.FindBody(Injector.StockSystemPrefab.rootBody, "Mun").pqsVersion
                .GetComponentsInChildren <PQSMod_VoronoiCraters>(true)[0];

            Utility.CopyObjectFields(clone, Mod, false);
        }
Exemple #14
0
        //HackHack
        public static PQSMod AddPQSMod(PQS mainSphere, Type ofType)
        {
            var newgob       = new GameObject();
            var newComponent = (PQSMod)newgob.AddComponent(ofType);

            newgob.name             = ("" + ofType);
            newgob.transform.parent = mainSphere.gameObject.transform;
            newComponent.sphere     = mainSphere;

            return(newComponent);
        }
 /// <summary>
 /// Corutine to rebuild parts of a PQS sphere
 /// </summary>
 public static IEnumerator RebuildSphere(PQ[] quads, PQS pqs)
 {
     for (Int32 i = 0; i < quads.Length; i++)
     {
         PQ quad = quads[i];
         quad.isBuilt = false;
         quad.isBuilt = pqs.BuildQuad(quad);
         pqs.GetType().GetMethod("UpdateEdgeNormals", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(pqs, new[] { quad });
         yield return null;
     }
 }
Exemple #16
0
        public static void removeStockOceans()
        {
            Material invisibleOceanMaterial = new Material(ShaderReplacer.Instance.LoadedShaders[("Scatterer/invisible")]);

            FakeOceanPQS[] fakes = (FakeOceanPQS[])FakeOceanPQS.FindObjectsOfType(typeof(FakeOceanPQS));

            // if we haven't already added ocean disablers
            if (fakes.Length == 0)
            {
                foreach (ScattererCelestialBody sctBody in Scatterer.Instance.planetsConfigsReader.scattererCelestialBodies)
                {
                    if (sctBody.hasOcean)
                    {
                        bool removed = false;
                        var  celBody = Scatterer.Instance.scattererCelestialBodiesManager.CelestialBodies.SingleOrDefault(_cb => _cb.bodyName == sctBody.celestialBodyName);
                        if (celBody == null)
                        {
                            celBody = Scatterer.Instance.scattererCelestialBodiesManager.CelestialBodies.SingleOrDefault(_cb => _cb.bodyName == sctBody.transformName);
                        }

                        if (celBody != null)
                        {
                            PQS pqs = celBody.pqsController;
                            if ((pqs != null) && (pqs.ChildSpheres != null) && (pqs.ChildSpheres.Count() != 0))
                            {
                                PQS ocean = pqs.ChildSpheres [0];
                                if (ocean != null)
                                {
                                    //Add the material to hide it in the first few frames when switching back from map mode, and also just in case
                                    ocean.surfaceMaterial = invisibleOceanMaterial;
                                    ocean.surfaceMaterial.SetOverrideTag("IgnoreProjector", "True");
                                    ocean.surfaceMaterial.SetOverrideTag("ForceNoShadowCasting", "True");

                                    GameObject   go        = new GameObject();
                                    FakeOceanPQS fakeOcean = go.AddComponent <FakeOceanPQS> ();
                                    fakeOcean.Apply(ocean);

                                    removed = true;
                                }
                            }
                        }
                        if (!removed)
                        {
                            Utils.LogDebug("Couldn't remove stock ocean for " + sctBody.celestialBodyName);
                        }
                    }
                }
                Utils.LogDebug("Removed stock oceans");
            }
            else
            {
                Utils.LogDebug("Stock oceans already removed");
            }
        }
Exemple #17
0
        public static PQSMod AddPQSMod( PQS mainSphere, Type ofType )
        {
            //HackHack
            var newGObj = new GameObject();
            var newComponent = (PQSMod)newGObj.AddComponent(ofType);
            newGObj.name = (""+ofType);
            newGObj.name.Replace( "PQSMod_", "_");
            newGObj.transform.parent = mainSphere.gameObject.transform;
            newComponent.sphere = mainSphere;

            return newComponent;
        }
Exemple #18
0
            // Runtime Constructor
            public OceanLoader(PQS ocean)
            {
                this.ocean = ocean;

                ocean.surfaceMaterial = new PQSOceanSurfaceQuadLoader(ocean.surfaceMaterial);
                surfaceMaterial       = ocean.surfaceMaterial;
                surfaceMaterial.name  = Guid.NewGuid().ToString();

                fallbackMaterial       = new PQSOceanSurfaceQuadFallbackLoader(ocean.fallbackMaterial);
                ocean.fallbackMaterial = fallbackMaterial;
                fallbackMaterial.name  = Guid.NewGuid().ToString();
            }
Exemple #19
0
        public static T AddMod <T>(PQS sphere, Int32 order) where T : PQSMod
        {
            GameObject modObject = new GameObject(typeof(T).Name);

            modObject.transform.parent = sphere.transform;
            T mod = modObject.AddComponent <T>();

            mod.modEnabled = true;
            mod.order      = order;
            mod.sphere     = sphere;
            return(mod);
        }
Exemple #20
0
 public static void DumpPQS(PQS pqs)
 {
     // bool
     print("PQS " + pqs.name);
     print("buildTangents = " + pqs.buildTangents);
     print("isActive = " + pqs.isActive);
     print("isAlive = " + pqs.isAlive);
     print("isBuildingMaps = " + pqs.isBuildingMaps);
     print("isDisabled = " + pqs.isDisabled);
     print("isStarted = " + pqs.isStarted);
     print("isSubdivisionEnabled = " + pqs.isSubdivisionEnabled);
     print("isThinking = " + pqs.isThinking);
     print("quadAllowBuild = " + pqs.quadAllowBuild);
     print("surfaceRelativeQuads = " + pqs.surfaceRelativeQuads);
     print("useSharedMaterial = " + pqs.useSharedMaterial);
     print("circumference = " + pqs.circumference);
     // double
     print("collapseAltitudeMax = " + pqs.collapseAltitudeMax);
     print("collapseAltitudeValue = " + pqs.collapseAltitudeValue);
     print("collapseDelta = " + pqs.collapseDelta);
     print("collapseSeaLevelValue = " + pqs.collapseSeaLevelValue);
     print("collapseThreshold = " + pqs.collapseThreshold);
     print("detailAltitudeMax = " + pqs.detailAltitudeMax);
     print("detailAltitudeQuads = " + pqs.detailAltitudeQuads);
     print("detailDelta = " + pqs.detailDelta);
     print("detailRad = " + pqs.detailRad);
     print("detailSeaLevelQuads = " + pqs.detailSeaLevelQuads);
     print("horizonAngle = " + pqs.horizonAngle);
     print("horizonDistance = " + pqs.horizonDistance);
     print("mapMaxHeight = " + pqs.mapMaxHeight);
     print("mapOceanHeight = " + pqs.mapOceanHeight);
     print("maxDetailDistance = " + pqs.maxDetailDistance);
     print("minDetailDistance = " + pqs.minDetailDistance);
     print("radius = " + pqs.radius);
     print("radiusDelta = " + pqs.radiusDelta);
     print("radiusMax = " + pqs.radiusMax);
     print("radiusMin = " + pqs.radiusMin);
     print("radiusSquared = " + pqs.radiusSquared);
     print("subdivisionThreshold = " + pqs.subdivisionThreshold);
     print("sx = " + pqs.sx);
     print("sy = " + pqs.sy);
     print("targetHeight = " + pqs.targetHeight);
     print("targetSpeed = " + pqs.targetSpeed);
     print("visibleAltitude = " + pqs.visibleAltitude);
     print("visibleRadius = " + pqs.visibleRadius);
     print("visRad = " + pqs.visRad);
     print("visRadAltitudeMax = " + pqs.visRadAltitudeMax);
     print("visRadAltitudeValue = " + pqs.visRadAltitudeValue);
     print("visRadDelta = " + pqs.visRadDelta);
     print("visRadSeaLevelValue = " + pqs.visRadSeaLevelValue);
     print("parentSphere = " + pqs.parentSphere);
     print("****************************************");
 }
Exemple #21
0
        protected override void SetupPQS(PQS pqs)
        {
            //new heightmap
            var height = pqs.GetPQSMod <PQSMod_VertexHeightMap> ();

            height.heightMap          = MapSO.CreateInstance <MapSO> ();
            height.heightMapDeformity = 20000;
            var heightMap = Utils.LoadTexture("Height/Moho_height.png");

            height.heightMap.CreateMap(MapSO.MapDepth.Greyscale, heightMap);
            GameObject.Destroy(heightMap);

            //setup fine details
            var simplexAbsolute = pqs.GetPQSMod <PQSMod_VertexSimplexHeightAbsolute> ();

            simplexAbsolute.deformity = 100;
            var simplex = pqs.GetPQSMod <PQSMod_VertexSimplexHeight> ();

            simplex.modEnabled = false;


            //remove old colormap
            var noiseColor = pqs.GetPQSMod <PQSMod_VertexSimplexNoiseColor> ();

            noiseColor.modEnabled = false;
            var heightColor = pqs.GetPQSMod <PQSMod_HeightColorMap> ();

            heightColor.modEnabled = false;

            var _Color    = pqs.transform.FindChild("_Color").gameObject;
            var colorRamp = _Color.AddComponent <PQSMod_HeightColorRamp> ();

            var ramp = new PQSMod_HeightColorRamp.ColorRamp();

            ramp.Add(Utils.Color(101, 48, 37), Utils.Color(104, 65, 58), -100f);
            ramp.Add(Utils.Color(118, 40, 25), Utils.Color(129, 64, 50), 3900f);
            ramp.Add(Utils.Color(155, 123, 105), Utils.Color(121, 102, 91), 13000f);
            ramp.Add(Utils.Color(90, 69, 57), Utils.Color(95, 79, 70), 17000f);
            ramp.Add(Utils.Color(115, 105, 100), Utils.Color(152, 148, 145), 20000f);
            ramp.Add(Utils.Color(115, 105, 100), Utils.Color(152, 148, 145), 100000f);

            //TODO: make ramp

            colorRamp.Ramp          = ramp;
            colorRamp.simplex       = new Simplex(666, 6, 0.6, 6);       //>:D
            colorRamp.BaseColorBias = 0.1f;
            colorRamp.modEnabled    = true;
            colorRamp.order         = 202;
            colorRamp.sphere        = pqs;

            pqs.RebuildSphere();
        }
Exemple #22
0
        /// <summary>
        /// Get the altitude of the surface at a point directly under where the vessel will be at
        /// the specified time.
        /// </summary>
        /// <param name="vessel"></param>
        /// <param name="universalTime"></param>
        /// <param name="currentUniversalTime"></param>
        /// <returns></returns>
        private static double SurfaceAltitudeAtTime(Vessel vessel, double universalTime, double currentUniversalTime)
        {
            // Note that the actual *exact* surface height will be different from what this function returns.
            // That's because this function simply uses the PQS controller, which gives a theoretical ideal
            // smooth-surface-curve terrain.  The actual game adds polygons into the mix, which can throw the
            // number off by 20 meters or more.  Useful discussion (and code to work around it) is here,
            // in the GetTerrainAltitude function:
            // https://github.com/KSP-KOS/KOS/blob/develop/src/kOS/Suffixed/GeoCoordinates.cs#L136
            // Solving the problem to get a perfectly accurate number requires doing physics ray-casting.
            // For the purposes of *this* mod, the ballpark figure from PQS is good enough, so we don't
            // bother with the extra computation to get an exact number.

            // Thanks to DMagic for pointing me at how SCANSat does these calculations:
            // https://github.com/S-C-A-N/SCANsat/blob/release/SCANsat/SCANcontroller.cs#L2065-L2073

            // If the main body has no PQS controller (e.g. the sun), all surface altitudes are implicitly zero.
            PQS pqs = vessel.mainBody.pqsController;

            if (pqs == null)
            {
                return(0);
            }

            // Where will the vessel be at that time?
            Vector3d position = vessel.orbit.getPositionAtUT(universalTime);

            // How much will the body have rotated by then?
            double rotationDegrees = 0;

            if (vessel.mainBody.rotates)
            {
                double numRotations = (universalTime - currentUniversalTime) / vessel.mainBody.rotationPeriod;
                rotationDegrees = 360.0 * numRotations;
            }

            // What will the latitude and longitude be at that time, in radians?
            double latitude  = vessel.mainBody.GetLatitude(position);
            double longitude = vessel.mainBody.GetLongitude(position) - rotationDegrees;

            // Convert that to a unit radial vector.
            Vector3d radialVector = new Vector3d(1, 0, 0);

            radialVector = QuaternionD.AngleAxis(latitude, Vector3d.forward) * radialVector;
            radialVector = QuaternionD.AngleAxis(longitude, Vector3d.down) * radialVector;

            // Now we can get the surface height.
            double surfaceHeight = pqs.GetSurfaceHeight(radialVector) - pqs.radius;

            // If we're over water, then this altitude will be the height of the ocean floor,
            // which we're not interested in.  Report that as zero.
            return((vessel.mainBody.ocean && (surfaceHeight < 0)) ? 0 : surfaceHeight);
        }
Exemple #23
0
        private PQS GetOcean()
        {
            if (_ocean != null && _mainBody == Part.vessel.mainBody)
            {
                return(_ocean);
            }

            _mainBody = Part.vessel.mainBody;
            _ocean    = _mainBody.GetComponentsInChildren <PQS>(true)
                        .FirstOrDefault(p => p.name == _mainBody.transform.name + "Ocean");

            return(_ocean);
        }
Exemple #24
0
            /**
             * Constructor for pre-existing PQS
             *
             * @param pqsVersion Existing PQS to augment
             **/
            public PQSLoader(PQS pqsVersion)
            {
                this.pqsVersion = pqsVersion;

                // Get the required PQS information
                transform      = pqsVersion.GetComponentsInChildren <PQSMod_CelestialBodyTransform> (true).Where(mod => mod.transform.parent == pqsVersion.transform).FirstOrDefault();
                lightDirection = pqsVersion.GetComponentsInChildren <PQSMod_MaterialSetDirection>(true).Where(mod => mod.transform.parent == pqsVersion.transform).FirstOrDefault();
                uvs            = pqsVersion.GetComponentsInChildren <PQSMod_UVPlanetRelativePosition>(true).Where(mod => mod.transform.parent == pqsVersion.transform).FirstOrDefault();
                collider       = pqsVersion.GetComponentsInChildren <PQSMod_QuadMeshColliders>(true).Where(mod => mod.transform.parent == pqsVersion.transform).FirstOrDefault();

                // Create physics material editor
                physicsMaterial = new PhysicsMaterialParser(collider.physicsMaterial);
            }
Exemple #25
0
                // Create the mod
                public override void Create(PQSMod_VoronoiCraters _mod, PQS pqsVersion)
                {
                    base.Create(_mod, pqsVersion);

                    // Create the base mod if needed
                    if (mod.craterColourRamp == null)
                    {
                        PQSMod_VoronoiCraters clone =
                            Utility.FindBody(Injector.StockSystemPrefab.rootBody, "Mun").pqsVersion
                            .GetComponentsInChildren <PQSMod_VoronoiCraters>(true)[0] as PQSMod_VoronoiCraters;
                        Utility.CopyObjectFields(clone, base.mod, false);
                    }
                }
Exemple #26
0
        // Creates the a PQSMod of type T with given PQS
        public override void Create(PQS pqsVersion)
        {
            base.Create(pqsVersion);

            // Create the callback list
            LandClasses = new CallbackList <LandClassLoader>(e =>
            {
                Mod.landClasses = LandClasses.Where(landClass => !landClass.Delete)
                                  .Select(landClass => landClass.Value).ToArray();
                Mod.lcCount = Mod.landClasses.Length;
            });
            Mod.landClasses = new PQSMod_HeightBiomeMap.LandClass[Mod.lcCount = 0];
        }
Exemple #27
0
                // Creates the a PQSMod of type T with given PQS
                public override void Create(PQS pqsVersion)
                {
                    base.Create(pqsVersion);

                    // Create the callback list
                    landClasses = new CallbackList <LandClassLoader> ((e) =>
                    {
                        mod.landClasses = landClasses.Where(landClass => !landClass.delete)
                                          .Select(landClass => landClass.Value).ToArray();
                        mod.lcCount = mod.landClasses.Length;
                    });
                    mod.landClasses = new PQSMod_HeightColorMap2.LandClass[mod.lcCount = 0];
                }
Exemple #28
0
            // Post apply event
            void IParserEventSubscriber.PostApply(ConfigNode node)
            {
                // Should we remove the atmosphere
                if (body.celestialBody.atmosphere && removeAtmosphere.value)
                {
                    // Find atmosphere from ground and destroy the game object
                    AtmosphereFromGround atmosphere = body.scaledVersion.GetComponentsInChildren <AtmosphereFromGround>(true)[0];
                    atmosphere.transform.parent = null;
                    UnityEngine.Object.Destroy(atmosphere.gameObject);

                    // Destroy the light controller
                    MaterialSetDirection light = body.scaledVersion.GetComponentsInChildren <MaterialSetDirection>(true)[0];
                    UnityEngine.Object.Destroy(light);

                    // No more atmosphere :(
                    body.celestialBody.atmosphere = false;
                }

                // Should we remove the ocean?
                if (body.celestialBody.ocean && removeOcean.value)
                {
                    // Find atmosphere the ocean PQS
                    PQS ocean = body.pqsVersion.GetComponentsInChildren <PQS>(true).Where(pqs => pqs != body.pqsVersion).First();
                    PQSMod_CelestialBodyTransform cbt = body.pqsVersion.GetComponentsInChildren <PQSMod_CelestialBodyTransform>(true).First();

                    // Destroy the ocean PQS (this could be bad - destroying the secondary fades...)
                    cbt.planetFade.secondaryRenderers.Remove(ocean.gameObject);
                    cbt.secondaryFades     = null;
                    ocean.transform.parent = null;
                    UnityEngine.Object.Destroy(ocean);

                    // No more ocean :(
                    body.celestialBody.ocean = false;
                }

                // Figure out what kind of body we are
                if (body.scaledVersion.GetComponentsInChildren(typeof(ScaledSun), true).Length > 0)
                {
                    type = BodyType.Star;
                }
                else if (body.celestialBody.atmosphere)
                {
                    type = BodyType.Atmospheric;
                }
                else
                {
                    type = BodyType.Vacuum;
                }

                Debug.Log("[Kopernicus]: Configuration.Template: Using Template \"" + body.celestialBody.bodyName + "\"");
            }
Exemple #29
0
            // Runtime Constructor
            public OceanLoader(PQS ocean)
            {
                this.ocean = ocean;
                this.body  = Part.GetComponentUpwards <CelestialBody>(ocean.gameObject);
                pqsVersion = body.pqsController;

                ocean.surfaceMaterial = new PQSOceanSurfaceQuadLoader(ocean.surfaceMaterial);
                surfaceMaterial       = ocean.surfaceMaterial;
                surfaceMaterial.name  = Guid.NewGuid().ToString();

                fallbackMaterial       = new PQSOceanSurfaceQuadFallbackLoader(ocean.fallbackMaterial);
                ocean.fallbackMaterial = fallbackMaterial;
                fallbackMaterial.name  = Guid.NewGuid().ToString();
            }
        static Coordinates Search(CelestialBody body, Ray mouseRay)
        {
            if (body == null || body.pqsController == null)
            {
                return(null);
            }
            Vector3d relSurfacePosition;
            Vector3d relOrigin  = mouseRay.origin - body.position;
            double   curRadius  = body.pqsController.radiusMax;
            double   lastRadius = 0;
            double   error      = 0;
            int      loops      = 0;
            float    st         = Time.time;

            while (loops < 50)
            {
                if (PQS.LineSphereIntersection(relOrigin, mouseRay.direction, curRadius, out relSurfacePosition))
                {
                    var alt = body.pqsController.GetSurfaceHeight(relSurfacePosition);
                    if (body.ocean && alt < body.Radius)
                    {
                        alt = body.Radius;
                    }
                    error = Math.Abs(curRadius - alt);
                    if (error < (body.pqsController.radiusMax - body.pqsController.radiusMin) / 100)
                    {
                        return(Coordinates.SurfacePoint(body.position + relSurfacePosition, body));
                    }
                    else
                    {
                        lastRadius = curRadius;
                        curRadius  = alt;
                        loops++;
                    }
                }
                else
                {
                    if (loops == 0)
                    {
                        break;
                    }
                    else
                    {                     // Went too low, needs to try higher
                        curRadius = (lastRadius * 9 + curRadius) / 10;
                        loops++;
                    }
                }
            }
            return(null);
        }
Exemple #31
0
            // Constructor for pre-existing PQS
            public PQSLoader(PQS pqsVersion)
            {
                this.pqsVersion = pqsVersion;

                // Get the required PQS information
                transform      = pqsVersion.GetComponentsInChildren <PQSMod_CelestialBodyTransform> (true).Where(mod => mod.transform.parent == pqsVersion.transform).FirstOrDefault();
                lightDirection = pqsVersion.GetComponentsInChildren <PQSMod_MaterialSetDirection>(true).Where(mod => mod.transform.parent == pqsVersion.transform).FirstOrDefault();
                uvs            = pqsVersion.GetComponentsInChildren <PQSMod_UVPlanetRelativePosition>(true).Where(mod => mod.transform.parent == pqsVersion.transform).FirstOrDefault();
                collider       = pqsVersion.GetComponentsInChildren <PQSMod_QuadMeshColliders>(true).Where(mod => mod.transform.parent == pqsVersion.transform).FirstOrDefault();

                // Create physics material editor
                physicsMaterial = new PhysicsMaterialParser(collider.physicsMaterial);

                // Clone the surface material of the PQS
                if (PQSMainOptimised.UsesSameShader(pqsVersion.surfaceMaterial))
                {
                    pqsVersion.surfaceMaterial = new PQSMainOptimisedLoader(pqsVersion.surfaceMaterial);
                    if (((PQSMainOptimisedLoader)pqsVersion.surfaceMaterial).globalDensity < 2)
                    {
                        ((PQSMainOptimisedLoader)pqsVersion.surfaceMaterial).globalDensity = -8E-06f;
                    }
                }
                else if (PQSMainShader.UsesSameShader(pqsVersion.surfaceMaterial))
                {
                    pqsVersion.surfaceMaterial = new PQSMainShaderLoader(pqsVersion.surfaceMaterial);
                    if (((PQSMainShaderLoader)pqsVersion.surfaceMaterial).globalDensity < 2)
                    {
                        ((PQSMainShaderLoader)pqsVersion.surfaceMaterial).globalDensity = -8E-06f;
                    }
                }
                else if (PQSProjectionAerialQuadRelative.UsesSameShader(pqsVersion.surfaceMaterial))
                {
                    pqsVersion.surfaceMaterial = new PQSProjectionAerialQuadRelativeLoader(pqsVersion.surfaceMaterial);
                    if (((PQSProjectionAerialQuadRelativeLoader)pqsVersion.surfaceMaterial).globalDensity < 2)
                    {
                        ((PQSProjectionAerialQuadRelativeLoader)pqsVersion.surfaceMaterial).globalDensity = -8E-06f;
                    }
                }
                else if (PQSProjectionSurfaceQuad.UsesSameShader(pqsVersion.surfaceMaterial))
                {
                    pqsVersion.surfaceMaterial = new PQSProjectionSurfaceQuadLoader(pqsVersion.surfaceMaterial);
                }
                surfaceMaterial      = pqsVersion.surfaceMaterial;
                surfaceMaterial.name = Guid.NewGuid().ToString();

                // Clone the fallback material of the PQS
                fallbackMaterial            = new PQSProjectionFallbackLoader(pqsVersion.fallbackMaterial);
                pqsVersion.fallbackMaterial = fallbackMaterial;
                fallbackMaterial.name       = Guid.NewGuid().ToString();
            }
Exemple #32
0
        public override void Create(PQS pqsVersion)
        {
            base.Create(pqsVersion);

            Shader blend1 = Shader.Find("Terrain/PQS/PQS Triplanar Zoom Rotation Texture Array - 1 Blend");
            Shader blend2 = Shader.Find("Terrain/PQS/PQS Triplanar Zoom Rotation Texture Array - 2 Blend");
            Shader blend3 = Shader.Find("Terrain/PQS/PQS Triplanar Zoom Rotation Texture Array - 3 Blend");
            Shader blend4 = Shader.Find("Terrain/PQS/PQS Triplanar Zoom Rotation Texture Array - 4 Blend");

            Mod.material1Blend = new Material(blend1);
            Mod.material2Blend = new Material(blend2);
            Mod.material3Blend = new Material(blend3);
            Mod.material4Blend = new Material(blend4);
        }
Exemple #33
0
        // Inspired by Hyperedit landing functions
        // https://github.com/Ezriilc/HyperEdit

        private Vector3d GetVesselPosition()
        {
            PQS pqs = vessel.mainBody.pqsController;

            if (null == pqs)
            {
                return(ZERO);
            }

            double alt = pqs.GetSurfaceHeight(vessel.mainBody.GetRelSurfaceNVector(0, 0)) - vessel.mainBody.Radius;

            alt = Math.Max(alt, 0); // Underwater!

            return(vessel.mainBody.GetRelSurfacePosition(0, 0, alt));
        }
Exemple #34
0
        public void Apply(PQS pqs)
        {
            if (pqs != null)
            {
                this.sphere           = pqs;
                this.transform.parent = pqs.transform;
                this.requirements     = PQS.ModiferRequirements.Default;
                this.modEnabled       = true;
                this.order            = 10;

                this.transform.localPosition = Vector3.zero;
                this.transform.localRotation = Quaternion.identity;
                this.transform.localScale    = Vector3.one;
            }
        }
        public static void Button_Select( int i )
        {
            List<PQS> norm_PqsList = new List<PQS>();
            foreach( PQS pqs in GameObject.FindObjectsOfType(typeof( PQS )) )
            {
                norm_PqsList.Add( pqs );
            }

            ReturnedPQS = norm_PqsList[i];

            Debug.Log( "DEBUG: Selected "+ReturnedPQS.name+"\n");

            PlanetToolsUiController.NewWindows[ "PQSSelector" ].ToggleWindow();

            //PlanetToolsUiController.NewWindows[ "PQSSelector" ].ToggleWindow();
        }
Exemple #36
0
 public static void Init()
 {
     if (!setup)
     {
         UnityEngine.Object[] celestialBodies = CelestialBody.FindObjectsOfType(typeof(CelestialBody));
         foreach (CelestialBody cb in celestialBodies)
         {
             CelestialBodyList.Add(cb);
             if (cb.name == "Kerbin")
             {
                 CurrentPQS = cb.pqsController;
             }
         }
         setup = true;
     }
 }
        public void Update()
        {
            mainPQS = attachedTo.mainBody.gameObject.GetComponent <PQS>();
            curPos  = attachedTo.transform.position;

            if (attachedTo.heightFromSurface < 100 && attachedTo.verticalSpeed > 100)              //Allow planet impact if within range...
            {
                CanImpact = true;
                attachedTo.rootPart.explode();
            }

            if (AsteriodType == 1)
            {
                //Comet stuff
            }
        }
Exemple #38
0
        // Create the mod
        public override void Create(PQS pqsVersion)
        {
            // Call base
            base.Create(pqsVersion);

            // Create the base mod (I need to instance this one, because some parameters aren't loadable. :( )
            PSystemBody body = Utility.FindBody(Injector.StockSystemPrefab.rootBody, "Laythe");

            foreach (PQS ocean in body.pqsVersion.GetComponentsInChildren <PQS>(true))
            {
                if (ocean.name == "LaytheOcean")
                {
                    Utility.CopyObjectFields(ocean.GetComponentsInChildren <PQSMod_OceanFX>(true)[0], Mod);
                }
            }
        }
Exemple #39
0
        public static Coordinates GetMouseCoordinates(CelestialBody body)
        {
            Ray mouseRay = PlanetariumCamera.Camera.ScreenPointToRay(Input.mousePosition);

            mouseRay.origin = ScaledSpace.ScaledToLocalSpace(mouseRay.origin);
            Vector3d relOrigin = mouseRay.origin - body.position;
            Vector3d relSurfacePosition;
            double   curRadius  = body.pqsController.radiusMax;
            double   lastRadius = 0;
            double   error      = 0;
            int      loops      = 0;
            float    st         = Time.time;

            while (loops < 50)
            {
                if (PQS.LineSphereIntersection(relOrigin, mouseRay.direction, curRadius, out relSurfacePosition))
                {
                    Vector3d surfacePoint = body.position + relSurfacePosition;
                    double   alt          = body.pqsController.GetSurfaceHeight(QuaternionD.AngleAxis(body.GetLongitude(surfacePoint), Vector3d.down) * QuaternionD.AngleAxis(body.GetLatitude(surfacePoint), Vector3d.forward) * Vector3d.right);
                    error = Math.Abs(curRadius - alt);
                    if (error < (body.pqsController.radiusMax - body.pqsController.radiusMin) / 100)
                    {
                        return(new Coordinates(body.GetLatitude(surfacePoint), MuUtils.ClampDegrees180(body.GetLongitude(surfacePoint))));
                    }
                    else
                    {
                        lastRadius = curRadius;
                        curRadius  = alt;
                        loops++;
                    }
                }
                else
                {
                    if (loops == 0)
                    {
                        break;
                    }
                    else
                    { // Went too low, needs to try higher
                        curRadius = (lastRadius * 9 + curRadius) / 10;
                        loops++;
                    }
                }
            }

            return(null);
        }
        static public void Button_Select(int i)
        {
            List <PQS> norm_PqsList = new List <PQS>();

            foreach (PQS pqs in GameObject.FindObjectsOfType(typeof(PQS)))
            {
                norm_PqsList.Add(pqs);
            }

            ReturnedPQS = norm_PqsList[i];

            Debug.Log("DEBUG: Selected " + ReturnedPQS.name + "\n");

            PlanetToolsUiController.NewWindows["PQSSelector"].ToggleWindow();

            //PlanetToolsUiController.NewWindows[ "PQSSelector" ].ToggleWindow();
        }
        // Manipulate the terrain
        public override void OnVertexBuildHeight(PQS.VertexBuildData data)
        {
            // Loop through the Deformations
            foreach (Deformation deformation in deformations)
            {
                // Get the angle between the two directions
                Double cos = Vector3d.Dot(deformation.position.normalized, data.directionFromCenter);

                // Determine the distance between the two points
                Double distance = Math.Sqrt(data.vertHeight * data.vertHeight + deformation.altitude * deformation.altitude - 2 * data.vertHeight * deformation.altitude * cos);

                // Determine whether the two positions are near enough
                if (distance <= deformation.GetDiameter() * 10)
                {
                    data.vertHeight -= deformation.GetDiameter() * (distance / deformation.GetDiameter()) * 0.5;
                }
            }
        }
Exemple #42
0
            public CelestialObject(GameObject parentObject)
            {
                CelestialGameObject = parentObject;
                CelestialBodyComponent = parentObject.GetComponentInChildren<CelestialBody>();
                PQSComponent = parentObject.GetComponentInChildren<PQS>();

                if (CelestialBodyComponent == null)
                    Extensions.LogError("Could not obtain CelestialBody component from: " + parentObject.name);

                if (PQSComponent == null)
                    Extensions.LogError("Could not obtain PQS component from: " + parentObject.name);
            }
Exemple #43
0
        private void InstantiateStatic(PQS celestialPQS, StaticObject stObject, bool freshObject = false)
        {
            #region Staitc Object Core Parameters

            float visibilityRange = stObject.VisRange;
            float localRotationAngle = stObject.RotAngle;
            float radiusOffset = stObject.RadOffset;
            string modelUrl = stObject.ModelUrl;
            Vector3 orientDirection = stObject.Orientation;
            Vector3 radialPosition = stObject.RadPosition;

            if (radialPosition == Vector3.zero)
            {
                radialPosition =
                    _currentCelestialObj.CelestialBodyComponent.transform.InverseTransformPoint(
                        FlightGlobals.ActiveVessel.transform.position);

                stObject.RadPosition = radialPosition;
            }

            if (orientDirection == Vector3.zero)
            {
                orientDirection = Vector3.up;
                stObject.Orientation = orientDirection;
            }

            stObject.Latitude = GetLatitude(radialPosition);
            stObject.Longitude = GetLongitude(radialPosition);

            #endregion

            // Instantiate
            GameObject ktGameObject = GameDatabase.Instance.GetModel(modelUrl);

            // Add the reference component.
            var soModule = ktGameObject.AddComponent<StaticObjectModule>();

            // Active the game object.
            ktGameObject.SetActive(true);

            // Set objects to layer 15 so that they collide correctly with Kerbals.
            SetLayerRecursively(ktGameObject, 15);

            // Set the parent object to the celestial component's GameObject.
            ktGameObject.transform.parent = celestialPQS.transform;

            // Obtain all active transforms in the static game object.
            Transform[] gameObjectList = ktGameObject.GetComponentsInChildren<Transform>();

            // Create a list of renderers to be manipulated by the default PQSCity class.
            List<GameObject> rendererList =
                (from t in gameObjectList where t.gameObject.renderer != null select t.gameObject).ToList();

            // Create the LOD range.
            _myLodRange = new PQSCity.LODRange
                          {
                              renderers = rendererList.ToArray(),
                              objects = new GameObject[0],
                              //new[] {staticGameObject},  // Todo: change to GameObject children.
                              visibleRange = visibilityRange
                          };

            // Add the PQSCity class (extended by KerbTown).
            var myCity = ktGameObject.AddComponent<PQSCityEx>();

            // Assign PQSCity variables.
            myCity.lod = new[] {_myLodRange};
            myCity.frameDelta = 1;
            myCity.repositionToSphere = true;
            myCity.repositionToSphereSurface = false;
            myCity.repositionRadial = radialPosition;
            myCity.repositionRadiusOffset = radiusOffset;
            myCity.reorientFinalAngle = localRotationAngle;
            myCity.reorientToSphere = true;
            myCity.reorientInitialUp = orientDirection;
            myCity.sphere = celestialPQS;
            myCity.order = 100;
            myCity.modEnabled = true;

            // Assign custom variables.
            myCity.StaticObjectRef = stObject;

            // Setup and orientate the PQSCity instanced object.
            myCity.OnSetup();
            myCity.Orientate();

            // If the object was instantiated by "Create", override all renderers to active.
            if (freshObject)
            {
                foreach (GameObject renObj in rendererList)
                    renObj.renderer.enabled = true;
            }

            // Add component references to the static object.
            stObject.PQSCityComponent = myCity;
            stObject.StaticGameObject = ktGameObject;
            //stObject.ModuleReference = soModule;

            // Add the static object as a reference to the StaticObjectModule
            soModule.StaticObjectRef = stObject;

            // Add remaining modules.
            switch (stObject.ObjectID)
            {
                case "MushroomCave":
                    AddNativeComponent(ktGameObject, typeof (MushroomCave));
                    break;

                case "PurplePathway":
                    AddNativeComponent(ktGameObject, typeof (PurplePathway));
                    break;

                default:
                    AddModuleComponents(stObject);
                    break;
            }

            // Alter the Launch Site spawn object name if necessary.
            // Todo: optimize
            if (stObject.LaunchSiteName != "")
            {
                Transform launchSiteObject =
                    ktGameObject.transform.Cast<Transform>().FirstOrDefault(t => t.name.EndsWith("_spawn"));
                if (launchSiteObject != null)
                {
                    launchSiteObject.name = stObject.LaunchSiteName + "_spawn";
                }
                else
                {
                    Extensions.LogWarning("Launch Site '" + ktGameObject.name + "'does not have a spawn transform.");
                }
            }
        }
Exemple #44
0
        private bool PatchPQS(PQS pqs, ConfigNode node)
        {
            bool pqsChanged = false;
            double oldR = pqs.radius;
            if (node.HasValue("radius"))
                double.TryParse(node.GetValue("radius"), out pqs.radius);
            if (pqs.radius != oldR)
                pqsChanged = true;

            List<PQSMod> mods;
            if (node.HasNode("Mods"))
            {
                mods = pqs.transform.GetComponentsInChildren<PQSMod>(true).Where(m => m.sphere == pqs).ToList<PQSMod>();
                foreach (ConfigNode modNode in node.GetNode("Mods").nodes)
                {
                    PQSMod delMod = null;
                    foreach (PQSMod m in mods)
                    {
                        Type mType = m.GetType();
                        if (mType.ToString() != modNode.name)
                            continue;
                        if (modNode.HasValue("name"))
                            if (m.name != modNode.GetValue("name"))
                                continue;
                        if(modNode.name != "PQSMod_CelestialBodyTransform") // not really a change
                            pqsChanged = true;
                        ParseObject(m, modNode);
                        if (mType == typeof(PQSCity) || mType == typeof(PQSMod_MapDecal) || mType == typeof(PQSMod_MapDecalTangent))
                            ModDecal(m, modNode);
                        delMod = m;
                        break;
                    }
                    // If we found the mod, remove from the list since we edited it.
                    if (delMod != null)
                        mods.Remove(delMod);
                }
            }
            // Get the whole list again.
            mods = pqs.transform.GetComponentsInChildren<PQSMod>(true).Where(m => m.sphere == pqs).ToList<PQSMod>();
            if (node.HasNode("RemoveMods"))
            {
                List<GameObject> toCheck = new List<GameObject>();
                foreach (ConfigNode modNode in node.GetNode("RemoveMods").nodes)
                {
                    PQSMod delMod = null;
                    foreach (PQSMod m in mods)
                    {
                        Type mType = m.GetType();
                        if (mType.ToString() != modNode.name)
                            continue;
                        if (modNode.HasValue("name"))
                            if (m.name != modNode.GetValue("name"))
                                continue;
                        delMod = m;
                        break;
                    }
                    // If we found the mod, remove from the list since we edited it.
                    if (delMod != null)
                    {
                        pqsChanged = true;
                        toCheck.Add(delMod.gameObject);
                        mods.Remove(delMod);
                        delMod.sphere = null;
                        PQSMod.DestroyImmediate(delMod);
                    }
                }
                Utility.RemoveEmptyGO(toCheck);
            }
            // add some mods
            if(node.HasNode("AddMods"))
            {
                AddModLoader newMods = Parser.CreateObjectFromConfigNode<AddModLoader>(node);
                if (newMods.mods != null)
                {
                    foreach (ModLoader loader in newMods.mods)
                    {
                        loader.mod.transform.parent = pqs.transform;
                        loader.mod.sphere = pqs;
                        loader.mod.transform.gameObject.SetLayerRecursive(Constants.GameLayers.LocalSpace);
                    }
                }
            }
            // just in case, run setup for everyone.
            mods = pqs.transform.GetComponentsInChildren<PQSMod>(true).Where(m => m.sphere == pqs).ToList<PQSMod>();
            foreach (var m in mods)
            {
                m.OnSetup();
                m.OnPostSetup();
            }
            try
            {
                pqs.RebuildSphere();
            }
            catch (Exception e)
            {
                Logger.Active.Log("Rebuild sphere for " + node.name + " failed: " + e.Message);
            }

            return pqsChanged;
        }
 // Re-arrange the Vertex Build order
 public override void OnVertexBuild(PQS.VertexBuildData data)
 {
     // Do nothing
     // base.OnVertexBuild(data);
 }
Exemple #46
0
		static bool PQSisNotNull (PQS pqs)
		{
			return pqs;
		}
        //HackHack
        public static PQSMod AddPQSMod( PQS mainSphere, Type ofType )
        {
            var newgob = new GameObject();
            var newComponent = (PQSMod)newgob.AddComponent(ofType);
            newgob.name = (""+ofType);
            newgob.transform.parent = mainSphere.gameObject.transform;
            newComponent.sphere = mainSphere;

            return newComponent;
        }
Exemple #48
0
 public override void OnVertexBuildHeight(PQS.VertexBuildData vbData)
 {
     var hei = Math.Sin(3.14159265358979 * vbData.v);
     hei = Math.Pow(hei, power);
     vbData.vertHeight = vbData.vertHeight + hei * offset;
 }
 /// <summary>
 /// Find quads that are near a transform
 /// </summary>
 public static PQ[] FindNearbyQuads(PQS pqsVersion, Vector3d position, Int32 count)
 {
     IEnumerable<PQ> quads = pqsVersion.GetComponentsInChildren<PQ>(true);
     quads = quads.OrderBy(q => Vector3.Distance(q.quadTransform.position, position)).Take(count);
     return quads.ToArray();
 }
        //PQS Modder PT1
        private void PQSModderPT1()
        {
            //Todo: swap with switch?
            if( pqsModderStage == 1 )
            {
                PQSModderPT2();
                return;
            }
            if( pqsModderStage == 2 )
            {
                PQSModderPT3();
                return;
            }
            if( pqsModderStage == 3 )
            {
                PQSAdderFunc();
                return;
            }

            int yoffset = 280;
            if( TemplateName == "" )
            {
                GUI.Label( new Rect( 20 , yoffset, 200, 20), "No planet selected!" );
                return;
            }
            List<PQS> norm_PqsList = new List<PQS>();
            foreach( PQS pqs in Utils.FindLocal(TemplateName).GetComponentsInChildren<PQS>() )
            {
                norm_PqsList.Add( pqs );
            }

            List<PQSMod> PqsList = new List<PQSMod>();
            foreach( PQSMod pqs in Utils.FindLocal(TemplateName).GetComponentsInChildren(typeof( PQSMod )) )
            {
                PqsList.Add( pqs );
            }

            int trimmedScrollSize = ((PqsList.Count() + norm_PqsList.Count() )*30) + 90;
            ScrollPosition2 = GUI.BeginScrollView( new Rect( 0, 260, 420, 250 ), ScrollPosition2 ,new Rect( 0,250,450,trimmedScrollSize));
            foreach (PQS pqs in norm_PqsList)
            {
                if( GUI.Button( new Rect( 20, yoffset, 400, 20 ), ""+pqs ) )
                {
                    //TemplateName = body.celestialBody.name;
                    pqstoMod = pqs;
                    pqsModderStage = 2;
                }
                yoffset += 30;
            }
            foreach (PQSMod pqs in PqsList)
            {
                if( GUI.Button( new Rect( 20, yoffset, 400, 20 ), ""+pqs ) )
                {
                    //TemplateName = body.celestialBody.name;
                    pqsmodtoMod = pqs;
                    pqsModderStage = 1;
                }if( GUI.Button( new Rect( 420, yoffset, 20, 20 ), "?" ) ){(NewWindows[ "HelpWindow" ] as HelpWindow).CustomToggle( ""+pqs.GetType() ); }

                yoffset += 30;
            }
            yoffset += 30;
            if( GUI.Button( new Rect( 20, yoffset, 400, 20 ), "Add new PQSMod" ) )
            {
                pqsModderStage = 3;
            }if( GUI.Button( new Rect( 420, yoffset, 20, 20 ), "?" ) ){(NewWindows[ "HelpWindow" ] as HelpWindow).CustomToggle( "PQSAdder" ); }

            GUI.EndScrollView();
        }
Exemple #51
0
        //Initialization
        public void Start()
        {
            m_radius=m_manager.GetRadius();

            Rt = (Rt / Rg) * m_radius;
            RL = (RL / Rg) * m_radius;
            Rg = m_radius;

            //			old mesh, causes artifacts with aniso
            //			m_mesh = MeshFactory.MakePlane(2, 2, MeshFactory.PLANE.XY, false,false);
            //			m_mesh.bounds = new Bounds(parentCelestialBody.transform.position, new Vector3(1e8f,1e8f, 1e8f));

            m_mesh = isoSphere.Create ();
            m_mesh.bounds = new Bounds(parentCelestialBody.transform.position, new Vector3(1e8f,1e8f, 1e8f));

            //The sky map is used to create a reflection of the sky for objects that need it (like the ocean)
            //			m_skyMap = new RenderTexture(512, 512, 0, RenderTextureFormat.ARGBHalf);
            //			m_skyMap.filterMode = FilterMode.Trilinear;
            //			m_skyMap.wrapMode = TextureWrapMode.Clamp;
            //			m_skyMap.anisoLevel = 9;
            //			m_skyMap.useMipMap = true;
            //			//m_skyMap.mipMapBias = -0.5f;
            //			m_skyMap.Create();

            //Inscatter is responsible for the change in the sky color as the sun moves
            //The raw file is a 4D array of 32 bit floats with a range of 0 to 1.589844
            //As there is not such thing as a 4D texture the data is packed into a 3D texture
            //and the shader manually performs the sample for the 4th dimension
            m_inscatter = new RenderTexture(RES_MU_S * RES_NU, RES_MU * RES_R, 0, RenderTextureFormat.ARGBHalf);
            m_inscatter.wrapMode = TextureWrapMode.Clamp;
            m_inscatter.filterMode = FilterMode.Bilinear;

            //Transmittance is responsible for the change in the sun color as it moves
            //The raw file is a 2D array of 32 bit floats with a range of 0 to 1
            m_transmit = new RenderTexture(TRANSMITTANCE_W, TRANSMITTANCE_H, 0, RenderTextureFormat.ARGBHalf);
            m_transmit.wrapMode = TextureWrapMode.Clamp;
            m_transmit.filterMode = FilterMode.Bilinear;

            //Irradiance is responsible for the change in the sky color as the sun moves
            //The raw file is a 2D array of 32 bit floats with a range of 0 to 1
            m_irradiance = new RenderTexture(SKY_W, SKY_H, 0, RenderTextureFormat.ARGBHalf);
            m_irradiance.wrapMode = TextureWrapMode.Clamp;
            m_irradiance.filterMode = FilterMode.Bilinear;

            initiateOrRestart ();
            m_skyMaterial=new Material(ShaderTool.GetMatFromShader2("CompiledSky.shader"));
            m_skyMaterialScaled=new Material(ShaderTool.GetMatFromShader2("CompiledSkyScaled.shader"));
            //m_skyMapMaterial=new Material(ShaderTool.GetMatFromShader2("CompiledSkyMap.shader"));
            //m_skyMaterial.renderQueue = 2000;

            sunGlare = new Texture2D (512, 512);
            black = new Texture2D (512, 512);

            string codeBase = Assembly.GetExecutingAssembly().CodeBase;
            UriBuilder uri = new UriBuilder(codeBase);
            string path = Uri.UnescapeDataString(uri.Path);
            path=Path.GetDirectoryName (path);

            sunGlare.LoadImage(System.IO.File.ReadAllBytes(String.Format("{0}/{1}", path + m_filePath, "sunglare.png")));
            black.LoadImage(System.IO.File.ReadAllBytes(String.Format("{0}/{1}", path + m_filePath, "black.png")));

            if (sunGlare == null)
            {
                print ("SUNGLARE NULL");

            }
            else
            {
                sunGlare.wrapMode = TextureWrapMode.Clamp;
                m_skyMaterial.SetTexture("_Sun_Glare", sunGlare);
            }

            m_skyMaterialScaled.SetTexture("_Sun_Glare", black);

            InitUniforms(m_skyMaterial);
            InitUniforms(m_skyMaterialScaled);
            //			InitUniforms(m_skyMapMaterial);

            m_atmosphereMaterial = ShaderTool.GetMatFromShader2 ("CompiledAtmosphericScatter.shader");

            //aniso defaults to to forceEnable on higher visual settings and causes artifacts
            //no longer needed since I switched to the new mesh
            //QualitySettings.anisotropicFiltering = AnisotropicFiltering.Enable;

            CurrentPQS = parentCelestialBody.pqsController;
            testPQS = parentCelestialBody.pqsController;

            for (int j=0; j<7; j++)
            {
                debugSettings[j]=true;
            }

            //			idekk = m_skyMaterial;
            //			Material[] materials = Resources.FindObjectsOfTypeAll<Material>();
            //			foreach(Material mat in materials)
            //			{
            //				if(mat.name == "EVE/Diffuse")
            //				{idekk=mat;
            //					print("DIFFUSE MATERIAL FOUND");}
            //
            //
            //			}
            //

            for (int j=0; j<10; j++)
            {
                additionalScales[j]=1f;
            }

            tester = new GameObject ();
            MF = tester.AddComponent<MeshFilter>();
            Mesh idmesh = MF.mesh;
            idmesh.Clear ();
            idmesh = m_mesh;
            //
            tester.layer = layer;
            Transform celestialTransform = ScaledSpace.Instance.scaledSpaceTransforms.Single(t => t.name == parentCelestialBody.name);
            //			tester.transform.parent = parentCelestialBody.transform;
            tester.transform.parent = celestialTransform;

            MR = tester.AddComponent<MeshRenderer>();

            //			InitUniforms (m_skyMaterialScaled);
            //			SetUniforms(m_skyMaterialScaled);
            //
            //			MR.sharedMaterial = m_skyMaterialScaled;
            //			MR.material =m_skyMaterialScaled;

            MR.sharedMaterial = m_skyMaterial;
            MR.material =m_skyMaterial;

            MR.castShadows = false;
            MR.receiveShadows = false;

            MR.enabled = true;

            //			tester.transform.localPosition = Vector3.zero;
            //			tester.transform.localRotation = Quaternion.identity;
            //			tester.transform.localScale = Vector3.one;

            //			MR.enabled = true;

            //			pSystemBodies = (PSystemBody[])UnityEngine.Object.FindObjectsOfType(typeof(PSystemBody));
            //			print ("NUMBER FOUND");
            //			print (pSystemBodies.Length);
            //
            //			kerbinPsystemBody=ScaledSpace.Instance.transform.FindChild("Kerbin").gameObject.GetComponentInChildren<ScaledSpaceFader>();
            //
            //			if (kerbinPsystemBody == null) {
            //				print ("NULL");
            //			}
            //				else{
            //					print ("NOT NULL");
            //				print("fadeStart");
            //
            //				print(kerbinPsystemBody.fadeStart);
            //
            //				print("fadeEnd");
            //
            //				print(kerbinPsystemBody.fadeEnd);
            //
            //
            //			}
        }
 // Build the height in the correct function
 public override void OnVertexBuildHeight(PQS.VertexBuildData data)
 {
     // Tricky...
     base.OnVertexBuild(data);
 }
            // Runtime Constructor
            public OceanLoader(PQS ocean)
            {
                this.ocean = ocean;

                ocean.surfaceMaterial = new PQSOceanSurfaceQuadLoader(ocean.surfaceMaterial);
                surfaceMaterial = ocean.surfaceMaterial;
                surfaceMaterial.name = Guid.NewGuid().ToString();

                fallbackMaterial = new PQSOceanSurfaceQuadFallbackLoader(ocean.fallbackMaterial);
                ocean.fallbackMaterial = fallbackMaterial;
                fallbackMaterial.name = Guid.NewGuid().ToString();
            }
        //Scaled Space Updater
        private void RegenerateModel(PQS bodyPQS, MeshFilter meshfilter_input)
        {
            var originalVert = meshfilter_input.mesh.vertices[0];
            var originalHeight = (float)bodyPQS.GetSurfaceHeight(originalVert);
            var scale = originalHeight / originalVert.magnitude;

            bodyPQS.isBuildingMaps = true;
            var newVerts = new Vector3[meshfilter_input.mesh.vertices.Count()];
            for (int i = 0; i < meshfilter_input.mesh.vertices.Count(); i++)
            {
                var vertex = meshfilter_input.mesh.vertices[i];
                var rootrad = (float)Math.Sqrt(vertex.x * vertex.x +
                                vertex.y * vertex.y +
                                vertex.z * vertex.z);
                var radius = (float)bodyPQS.GetSurfaceHeight(vertex)/scale;
                //radius = 1000;
                newVerts[i] = vertex * (radius / rootrad);
            }
            bodyPQS.isBuildingMaps = false;

            meshfilter_input.mesh.vertices = newVerts;

            meshfilter_input.mesh.RecalculateNormals();
            Utils.RecalculateTangents(meshfilter_input.mesh);
        }
Exemple #55
0
        //Initialization
        public void Start()
        {
            m_radius = m_manager.GetRadius();

            Rt = (Rt / Rg) * m_radius;
            RL = (RL / Rg) * m_radius;
            Rg = m_radius;

            m_mesh = MeshFactory.MakePlane(2, 2, MeshFactory.PLANE.XY, false, false);
            m_mesh.bounds = new Bounds(parentCelestialBody.transform.position, new Vector3(1e8f, 1e8f, 1e8f));

            //Inscatter is responsible for the change in the sky color as the sun moves
            //The raw file is a 4D array of 32 bit floats with a range of 0 to 1.589844
            //As there is not such thing as a 4D texture the data is packed into a 3D texture
            //and the shader manually performs the sample for the 4th dimension
            m_inscatter = new RenderTexture(RES_MU_S * RES_NU, RES_MU * RES_R, 0, RenderTextureFormat.ARGBHalf);
            m_inscatter.wrapMode = TextureWrapMode.Clamp;
            m_inscatter.filterMode = FilterMode.Bilinear;

            //Transmittance is responsible for the change in the sun color as it moves
            //The raw file is a 2D array of 32 bit floats with a range of 0 to 1
            m_transmit = new RenderTexture(TRANSMITTANCE_W, TRANSMITTANCE_H, 0, RenderTextureFormat.ARGBHalf);
            m_transmit.wrapMode = TextureWrapMode.Clamp;
            m_transmit.filterMode = FilterMode.Bilinear;

            //Irradiance is responsible for the change in the sky color as the sun moves
            //The raw file is a 2D array of 32 bit floats with a range of 0 to 1
            m_irradiance = new RenderTexture(SKY_W, SKY_H, 0, RenderTextureFormat.ARGBHalf);
            m_irradiance.wrapMode = TextureWrapMode.Clamp;
            m_irradiance.filterMode = FilterMode.Bilinear;

            initiateOrRestart();
            m_skyMaterialScaled = new Material(ShaderTool.GetMatFromShader2("CompiledSkyScaled.shader"));
            m_skyMaterialScaled.renderQueue = 2004;

            m_skyExtinction = new Material(ShaderTool.GetMatFromShader2("CompiledSkyExtinction.shader"));
            m_skyExtinction.renderQueue = 2002;

            sunGlare = new Texture2D(512, 512);
            black = new Texture2D(512, 512);

            //			string codeBase = Assembly.GetExecutingAssembly().CodeBase;
            //			UriBuilder uri = new UriBuilder(codeBase);
            //			path = Uri.UnescapeDataString(uri.Path);
            //			path=Path.GetDirectoryName (path);
            path = m_manager.GetCore().path;

            sunGlare.LoadImage(System.IO.File.ReadAllBytes(String.Format("{0}/{1}", path + "/config/" + parentCelestialBody.name + m_filePath, "sunglare.png")));

            black.LoadImage(System.IO.File.ReadAllBytes(String.Format("{0}/{1}", path + "/config/" + parentCelestialBody.name + m_filePath, "black.png")));

            sunGlare.wrapMode = TextureWrapMode.Clamp;
            m_skyMaterialScaled.SetTexture("_Sun_Glare", sunGlare);

            InitUniforms(m_skyMaterialScaled);
            InitUniforms(m_skyExtinction);

            m_atmosphereMaterial = ShaderTool.GetMatFromShader2("CompiledAtmosphericScatter.shader");

            CurrentPQS = parentCelestialBody.pqsController;
            testPQS = parentCelestialBody.pqsController;

            for (int j = 0; j < 10; j++) {
                debugSettings[j] = true;
            }

            for (int j = 0; j < 10; j++) {
                additionalScales[j] = 1f;
            }

            skyObject = new GameObject();
            skyMF = skyObject.AddComponent < MeshFilter > ();
            Mesh idmesh = skyMF.mesh;
            idmesh.Clear();
            idmesh = m_mesh;
            //
            skyObject.layer = layer;
            //			celestialTransform = ScaledSpace.Instance.scaledSpaceTransforms.Single(t => t.name == parentCelestialBody.name);
            celestialTransform = ParentPlanetTransform;
            //			skyObject.transform.parent = parentCelestialBody.transform;
            skyObject.transform.parent = celestialTransform;

            skyMR = skyObject.AddComponent < MeshRenderer > ();
            skyMR.sharedMaterial = m_skyMaterialScaled;
            skyMR.material = m_skyMaterialScaled;
            skyMR.castShadows = false;
            skyMR.receiveShadows = false;

            ///same for skyextinct
            skyExtinctObject = new GameObject();
            skyExtinctMF = skyExtinctObject.AddComponent < MeshFilter > ();
            idmesh = skyExtinctMF.mesh;
            idmesh.Clear();
            idmesh = m_mesh;
            //
            skyExtinctObject.layer = layer;
            skyExtinctObject.transform.parent = celestialTransform;

            skyExtinctMR = skyExtinctObject.AddComponent < MeshRenderer > ();
            skyExtinctMR.sharedMaterial = m_skyExtinction;
            skyExtinctMR.material = m_skyExtinction;
            skyExtinctMR.castShadows = false;
            skyExtinctMR.receiveShadows = false;

            hp = new SimplePostProcessCube(10000, m_atmosphereMaterial);
            atmosphereMesh = hp.GameObject;
            atmosphereMesh.layer = 15;
            atmosphereMeshrenderer = hp.GameObject.GetComponent < MeshRenderer > ();
            atmosphereMeshrenderer.material = m_atmosphereMaterial;

            celestialBodies = (CelestialBody[]) CelestialBody.FindObjectsOfType(typeof(CelestialBody));
        }
Exemple #56
0
 public static void DumpPQS(PQS pqs)
 {
     // bool
     print("PQS " + pqs.name);
     print("buildTangents = " + pqs.buildTangents);
     print("isActive = " + pqs.isActive);
     print("isAlive = " + pqs.isAlive);
     print("isBuildingMaps = " + pqs.isBuildingMaps);
     print("isDisabled = " + pqs.isDisabled);
     print("isStarted = " + pqs.isStarted);
     print("isSubdivisionEnabled = " + pqs.isSubdivisionEnabled);
     print("isThinking = " + pqs.isThinking);
     print("quadAllowBuild = " + pqs.quadAllowBuild);
     print("surfaceRelativeQuads = " + pqs.surfaceRelativeQuads);
     print("useSharedMaterial = " + pqs.useSharedMaterial);
     print("circumference = " + pqs.circumference);
     // double
     print("collapseAltitudeMax = " + pqs.collapseAltitudeMax);
     print("collapseAltitudeValue = " + pqs.collapseAltitudeValue);
     print("collapseDelta = " + pqs.collapseDelta);
     print("collapseSeaLevelValue = " + pqs.collapseSeaLevelValue);
     print("collapseThreshold = " + pqs.collapseThreshold);
     print("detailAltitudeMax = " + pqs.detailAltitudeMax);
     print("detailAltitudeQuads = " + pqs.detailAltitudeQuads);
     print("detailDelta = " + pqs.detailDelta);
     print("detailRad = " + pqs.detailRad);
     print("detailSeaLevelQuads = " + pqs.detailSeaLevelQuads);
     print("horizonAngle = " + pqs.horizonAngle);
     print("horizonDistance = " + pqs.horizonDistance);
     print("mapMaxHeight = " + pqs.mapMaxHeight);
     print("mapOceanHeight = " + pqs.mapOceanHeight);
     print("maxDetailDistance = " + pqs.maxDetailDistance);
     print("minDetailDistance = " + pqs.minDetailDistance);
     print("radius = " + pqs.radius);
     print("radiusDelta = " + pqs.radiusDelta);
     print("radiusMax = " + pqs.radiusMax);
     print("radiusMin = " + pqs.radiusMin);
     print("radiusSquared = " + pqs.radiusSquared);
     print("subdivisionThreshold = " + pqs.subdivisionThreshold);
     print("sx = " + pqs.sx);
     print("sy = " + pqs.sy);
     print("targetHeight = " + pqs.targetHeight);
     print("targetSpeed = " + pqs.targetSpeed);
     print("visibleAltitude = " + pqs.visibleAltitude);
     print("visibleRadius = " + pqs.visibleRadius);
     print("visRad = " + pqs.visRad);
     print("visRadAltitudeMax = " + pqs.visRadAltitudeMax);
     print("visRadAltitudeValue = " + pqs.visRadAltitudeValue);
     print("visRadDelta = " + pqs.visRadDelta);
     print("visRadSeaLevelValue = " + pqs.visRadSeaLevelValue);
     print("parentSphere = " + pqs.parentSphere);
     print("****************************************");
 }
Exemple #57
0
 public override void OnVertexBuildHeight(PQS.VertexBuildData vbData)
 {
     vbData.vertHeight = vbData.vertHeight + offset;
 }
Exemple #58
0
        public static void MatchVerts(Mesh mesh, PQS pqs, double oceanHeight, float scaleFactor)
        {
            ProfileTimer.Push("MatchVerts");
            if (pqs == null)
            {
                MonoBehaviour.print("ERROR matching verts: pqs is null!");
                return;
            }
            char sep = System.IO.Path.DirectorySeparatorChar;
            pqs.isBuildingMaps = true;

            Vector3[] vertices = new Vector3[mesh.vertexCount];
            for (int i = 0; i < mesh.vertexCount; i++)
            {
                Vector3 v = mesh.vertices[i];
                double height = pqs.GetSurfaceHeight(v);
                if (height < oceanHeight)
                    height = oceanHeight;
                vertices[i] = v.normalized * (float)(1000.0 * height / pqs.radius * scaleFactor);
            }
            pqs.isBuildingMaps = false;
            mesh.vertices = vertices;
            ProfileTimer.Pop("MatchVerts");
        }
Exemple #59
0
            // Constructor for pre-existing PQS
            public PQSLoader(PQS pqsVersion)
            {
                this.pqsVersion = pqsVersion;

                // Get the required PQS information
                transform = pqsVersion.GetComponentsInChildren<PQSMod_CelestialBodyTransform> (true).FirstOrDefault (mod => mod.transform.parent == pqsVersion.transform);
                lightDirection = pqsVersion.GetComponentsInChildren<PQSMod_MaterialSetDirection> (true).FirstOrDefault (mod => mod.transform.parent == pqsVersion.transform);
                uvs = pqsVersion.GetComponentsInChildren<PQSMod_UVPlanetRelativePosition> (true).FirstOrDefault (mod => mod.transform.parent == pqsVersion.transform);
                collider = pqsVersion.GetComponentsInChildren<PQSMod_QuadMeshColliders> (true).FirstOrDefault (mod => mod.transform.parent == pqsVersion.transform);

                // Create physics material editor
                physicsMaterial = new PhysicsMaterialParser (collider.physicsMaterial);

                // Clone the surface material of the PQS
                if (PQSMainOptimised.UsesSameShader(pqsVersion.surfaceMaterial))
                {
                    pqsVersion.surfaceMaterial = new PQSMainOptimisedLoader(pqsVersion.surfaceMaterial);
                    if (((PQSMainOptimisedLoader)pqsVersion.surfaceMaterial).globalDensity < 2)
                        ((PQSMainOptimisedLoader)pqsVersion.surfaceMaterial).globalDensity = -8E-06f;
                }
                else if (PQSMainShader.UsesSameShader(pqsVersion.surfaceMaterial))
                {
                    pqsVersion.surfaceMaterial = new PQSMainShaderLoader(pqsVersion.surfaceMaterial);
                    if (((PQSMainShaderLoader)pqsVersion.surfaceMaterial).globalDensity < 2)
                        ((PQSMainShaderLoader)pqsVersion.surfaceMaterial).globalDensity = -8E-06f;
                }
                else if (PQSProjectionAerialQuadRelative.UsesSameShader(pqsVersion.surfaceMaterial))
                {
                    pqsVersion.surfaceMaterial = new PQSProjectionAerialQuadRelativeLoader(pqsVersion.surfaceMaterial);
                    if (((PQSProjectionAerialQuadRelativeLoader)pqsVersion.surfaceMaterial).globalDensity < 2)
                        ((PQSProjectionAerialQuadRelativeLoader)pqsVersion.surfaceMaterial).globalDensity = -8E-06f;
                }
                else if (PQSProjectionSurfaceQuad.UsesSameShader(pqsVersion.surfaceMaterial))
                {
                    pqsVersion.surfaceMaterial = new PQSProjectionSurfaceQuadLoader(pqsVersion.surfaceMaterial);
                }
                surfaceMaterial = pqsVersion.surfaceMaterial;
                surfaceMaterial.name = Guid.NewGuid ().ToString ();

                // Clone the fallback material of the PQS
                fallbackMaterial = new PQSProjectionFallbackLoader (pqsVersion.fallbackMaterial);
                pqsVersion.fallbackMaterial = fallbackMaterial;
                fallbackMaterial.name = Guid.NewGuid ().ToString ();
            }
Exemple #60
0
 private static void AddMapSOs(List<MapSO> list, PQS pqs)
 {
     PQSMod[] mods = pqs.GetComponentsInChildren<PQSMod>(true) as PQSMod[];
     foreach (PQSMod m in mods)
     {
         foreach (FieldInfo fi in m.GetType().GetFields())
         {
             // this _should_ get everything derived from it.
             MapSO val = fi.GetValue(m) as MapSO;
             if(val != null)
                 if(!list.Contains(val))
                     list.Add(val);
         }
     }
 }