예제 #1
0
        protected override VoxelHolder modifyVoxel(VoxelHolder original, int x, int y, int z)
        {
            double percentInside = 1;

            percentInside *= percentOverlapping(x, min.x);
            percentInside *= percentOverlapping(y, min.y);
            percentInside *= percentOverlapping(z, min.z);
            percentInside *= percentOverlapping(-x, -max.x);
            percentInside *= percentOverlapping(-y, -max.y);
            percentInside *= percentOverlapping(-z, -max.z);
            if (percentInside <= 0.001)
            {
                return(original);
            }
            if (percentInside >= 0.999)
            {
                return(new Voxel(value.averageMaterialType(), overwriteShape? value.averageOpacity(): original.averageOpacity()));
            }
            byte newOpacity   = (byte)((original.averageOpacity() * (1 - percentInside) + value.averageOpacity() * (percentInside)));
            byte newSubstance = original.averageMaterialType();

            if (newOpacity >= 2 * original.averageOpacity() ||
                (overwriteSubstance && percentInside > 0.5))
            {
                newSubstance = value.averageMaterialType();
            }
            if (!overwriteShape)
            {
                newOpacity = original.averageOpacity();
            }
            return(new Voxel(newSubstance, newOpacity));
        }
예제 #2
0
		public override Voxel mutate(LocalApplication app, Index p, LocalAction action, Voxel original) {
			CubeAction cAction = (CubeAction)action;
			byte newOpacity = (byte)((original.averageOpacity() * (1 - cAction.percentInside) + value.averageOpacity() * (cAction.percentInside)));
			byte newSubstance = original.averageMaterialType();
			if (overwriteSubstance && cAction.percentInside > 0.5)
				newSubstance = value.averageMaterialType();
			if (!overwriteShape)
				newOpacity = original.averageOpacity();
			return new Voxel(newSubstance, newOpacity);
		}
예제 #3
0
		protected override Voxel mutate(Application app, Index pos, Action action, Voxel original) {
			BlurApp bApp = (BlurApp)app;
			BlurAction bAction = (BlurAction)action;
			float dis = Mathf.Sqrt(bAction.disSqr);
			float actualStrength = strength * (1 - (dis / bApp.radius));
			if (actualStrength <= 0)
				return original;
			byte newOpacity = calculateOpacity(bApp.original, pos.x - app.min.x, pos.y - app.min.y, pos.z - app.min.z, actualStrength);
			return new Voxel(original.averageMaterialType(), newOpacity);
		}
예제 #4
0
		public override Voxel mutate(LocalApplication app, Index p, LocalAction action, Voxel original) {
			SphereApp sApp = (SphereApp)app;
			SphereAction sAction = (SphereAction)action;

			float dis = Mathf.Sqrt(sAction.disSqr);
			float percentInside = Mathf.Min((sAction.maxRadius -dis) /(sAction.maxRadius -sAction.minRadius), 1);
			byte newOpacity = (byte)(original.averageOpacity() * (1 -percentInside) + value.averageOpacity() * percentInside);
			byte newSubstance = original.averageMaterialType();
			if (overwriteSubstance && (dis < sApp.radius || percentInside > 0.5f))
				newSubstance = value.averageMaterialType();
			if (!overwriteShape)
				newOpacity = original.averageOpacity();
			return new Voxel(newSubstance, newOpacity);
		}
예제 #5
0
        protected override Voxel mutate(Application app, Index pos, Action action, Voxel original)
        {
            BlurApp    bApp           = (BlurApp)app;
            BlurAction bAction        = (BlurAction)action;
            float      dis            = Mathf.Sqrt(bAction.disSqr);
            float      actualStrength = strength * (1 - (dis / bApp.radius));

            if (actualStrength <= 0)
            {
                return(original);
            }
            byte newOpacity = calculateOpacity(bApp.original, pos.x - app.min.x, pos.y - app.min.y, pos.z - app.min.z, actualStrength);

            return(new Voxel(original.averageMaterialType(), newOpacity));
        }
예제 #6
0
        public override Voxel mutate(LocalApplication app, Index p, LocalAction action, Voxel original)
        {
            CubeAction cAction      = (CubeAction)action;
            byte       newOpacity   = (byte)((original.averageOpacity() * (1 - cAction.percentInside) + value.averageOpacity() * (cAction.percentInside)));
            byte       newSubstance = original.averageMaterialType();

            if (newOpacity >= 2 * original.averageOpacity() ||
                (overwriteSubstance && cAction.percentInside > 0.5))
            {
                newSubstance = value.averageMaterialType();
            }
            if (!overwriteShape)
            {
                newOpacity = original.averageOpacity();
            }
            return(new Voxel(newSubstance, newOpacity));
        }
예제 #7
0
        public override Voxel mutate(LocalApplication app, Index p, LocalAction action, Voxel original)
        {
            SphereApp sApp = (SphereApp)app;
            SphereAction sAction = (SphereAction)action;

            float dis = Mathf.Sqrt(sAction.disSqr);
            byte newOpacity = (dis <= sAction.minRadius) ?
                value.averageOpacity() :
                (byte)((original.averageOpacity() * (dis - sAction.minRadius) + value.averageOpacity() * (sAction.maxRadius - dis)) / 2);
            byte newSubstance = original.averageMaterialType();
            if (newOpacity >= 2 * original.averageOpacity() ||
                (overwriteSubstance && dis < sApp.radius))
                newSubstance = value.averageMaterialType();
            if (!overwriteShape)
                newOpacity = original.averageOpacity();
            return new Voxel(newSubstance, newOpacity);
        }
예제 #8
0
        public override Voxel mutate(LocalApplication app, Index p, LocalAction action, Voxel original)
        {
            SphereApp    sApp    = (SphereApp)app;
            SphereAction sAction = (SphereAction)action;

            float dis        = Mathf.Sqrt(sAction.disSqr);
            byte  newOpacity = (dis <= sAction.minRadius) ?
                               value.averageOpacity() :
                               (byte)((original.averageOpacity() * (dis - sAction.minRadius) + value.averageOpacity() * (sAction.maxRadius - dis)) / 2);
            byte newSubstance = original.averageMaterialType();

            if (newOpacity >= 2 * original.averageOpacity() ||
                (overwriteSubstance && dis < sApp.radius))
            {
                newSubstance = value.averageMaterialType();
            }
            if (!overwriteShape)
            {
                newOpacity = original.averageOpacity();
            }
            return(new Voxel(newSubstance, newOpacity));
        }