Example #1
0
 public Ch0nk(Dimension dimension, Vector3i position, IMaterial material)
 {
     _dimension = dimension;
     _position = position;
     _eightFoldTree = new EightFoldTree(Size, material);
     //_eightFoldTree[0, 0, 0] = new SandMaterial();
 }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Model"/> class.
        /// </summary>
        /// <param name="availableAnimations">
        /// The available animations.
        /// </param>
        /// <param name="rootBone">
        /// The root bone, or null if there's no skeletal information.
        /// </param>
        /// <param name="vertexes">
        /// The vertexes associated with this model.
        /// </param>
        /// <param name="indices">
        /// The indices associated with the model.
        /// </param>
        public Model(
            IModelRenderConfiguration[] modelRenderConfigurations,
            IRenderBatcher renderBatcher,
            string name,
            IAnimationCollection availableAnimations,
            IMaterial material,
            IModelBone rootBone,
            ModelVertex[] vertexes,
            int[] indices)
        {
            Name = name;
            AvailableAnimations = availableAnimations;
            Root = rootBone;
            Vertexes = vertexes;
            Indices = indices;
            Material = material;

            _cachedVertexBuffers = new Dictionary<object, VertexBuffer>();
            _modelRenderConfigurations = modelRenderConfigurations;
            _renderBatcher = renderBatcher;

            if (Root != null)
            {
                _flattenedBones = Root.Flatten();
                Bones = _flattenedBones.ToDictionary(k => k.Name, v => v);
            }
        }
Example #3
0
 public SetMaterialCmd(PhysxPrim target, IMaterial material, bool applyToObject, MaterialChanges changes)
 {
     _target = target;
     _material = material;
     _applyToObject = applyToObject;
     _changes = changes;
 }
Example #4
0
 public Block(Ch0nk ch0Nk, Vector3b relativePosition, IMaterial material, byte size)
 {
     this.ch0Nk = ch0Nk;
     this.relativePosition = relativePosition;
     this.material = material;
     this.size = size;
 }
Example #5
0
		public MaterialKey(IMaterial material)
		{
			if (null == material)
				throw new ArgumentNullException(nameof(material));

			this.Material = material;
		}
Example #6
0
			public void RemoveAndDispose()
			{
				Disposer.RemoveAndDispose(ref VertexBuffer);
				Disposer.RemoveAndDispose(ref IndexBuffer);
				VertexCount = 0;
				IndexCount = 0;
				Material = null;
			}
		public MaterialPlusClippingPlusColorProviderKey(IMaterial material, PlaneD3D[] clipPlanes, Gdi.Plot.IColorProvider colorProvider)
			: base(material, clipPlanes)
		{
			if (null == colorProvider)
				throw new ArgumentNullException(nameof(colorProvider));

			this.ColorProvider = colorProvider;
		}
Example #8
0
 public void ChangeMaterial(BoundingShape boundingShape, IMaterial material)
 {
     //ONLY FOR NOW: check all, but it can be optimized
     foreach (Ch0nk ch0Nk in _chonks.Values)
     {
         //if the ch0nk bounding box intersects, then go deeper
         if (ch0Nk.BoundingCube.Intersects(boundingShape))
             ch0Nk.ChangeMaterial(boundingShape, material);
     }
 }
Example #9
0
 public RenderCommand(Renderer renderer, IMaterial material, RenderableCollection sceneNodeCollection)
     : base(CommandType.Render)
 {
     Contract.Requires<NullReferenceException>(renderer != null);
     Contract.Requires<NullReferenceException>(material != null);
     CommandAttributes |= CommandAttributes.MonoRendering;
     Renderer = renderer;
     Items = sceneNodeCollection;
     Material = material;
     Technique = Material.EffectDescription.Technique;
     Pass = Technique.GetPassByIndex(Material.EffectDescription.Pass);
     InputLayout = new InputLayout(Game.Context.Device, Pass.Description.Signature, Items.Description.InputElements);
 }
Example #10
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <param name="material"></param>
        /// <param name="crossSection"></param>
        /// <returns></returns>
        public Linear1DBeam CreateLinear1DBeam(IFiniteElementNode start, IFiniteElementNode end, IMaterial material, ICrossSection crossSection)
        {
            Guard.AgainstInvalidState(() => { return !Linear1DBeam.IsASupportedModelType(this.ModelType); },
                                      "Linear1DBeams are not available in a model of type {0}",
                                      this.ModelType);

            Linear1DBeam newBeam = new Linear1DBeam(start, end, material, crossSection);
            if (this.repository != null)
            {
                this.repository.Add(newBeam);
            }

            return newBeam;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="node0"></param>
        /// <param name="node1"></param>
        /// <param name="node2"></param>
        /// <param name="elementMaterial"></param>
        /// <param name="elementThickness"></param>
        public LinearConstantStrainTriangle(IFiniteElementNode node0, IFiniteElementNode node1, IFiniteElementNode node2, IMaterial elementMaterial, double elementThickness)
        {
            this.AddNode(node0);
            this.AddNode(node1);
            this.AddNode(node2);

            Guard.AgainstNullArgument(elementMaterial, "elementMaterial");
            Guard.AgainstBadArgument(
                "elementThickness",
                () => { return elementThickness <= 0; },
                "thickness has to be greater than zero");
            this.Material = elementMaterial;
            this.Thickness = elementThickness;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="node0"></param>
        /// <param name="node1"></param>
        /// <param name="node2"></param>
        /// <param name="node3"></param>
        /// <param name="mat"></param>
        /// <param name="elementThickness"></param>
        public LinearConstantStressQuadrilateral(IFiniteElementNode node0, IFiniteElementNode node1, IFiniteElementNode node2, IFiniteElementNode node3, IMaterial mat, double elementThickness)
        {
            this.AddNode(node0);
            this.AddNode(node1);
            this.AddNode(node2);
            this.AddNode(node3);

            Guard.AgainstNullArgument(mat, "mat");
            Guard.AgainstBadArgument(
                "t",
                () => { return elementThickness <= 0; },
                "thickness has to be greater than zero");
            this.Material = mat;
            this.Thickness = elementThickness;
        }
 public UserInterfaceRenderCommand(Renderer renderer, Hud hud, RenderableNode rNode)
     : base(renderer, new UIMaterial(),
         new RenderableCollection(UIMaterial.ItemsDescription, new [] {rNode}))
 {
     CommandType = CommandType.UserInterfaceRenderCommand;
     CommandAttributes |= Graphics.CommandAttributes.MonoRendering;
     this.hud = hud;
     textMaterial = new TextMaterial();
     this.rNode = rNode;
     this.rNode.RenderableObject.Material = Material;
     tNode = (TransformNode)rNode.Parent;
     UpdateSprites(hud.SpriteControls);
     textTechnique = textMaterial.EffectDescription.Technique;
     textPass = textTechnique.GetPassByIndex(textMaterial.EffectDescription.Pass);
     textLayout = new InputLayout(Game.Context.Device, textPass.Description.Signature,
         TextItems.Description.InputElements);
 }
Example #14
0
		public static ImageSource GetImageSourceFromBrushX(IMaterial val, int width, int height)
		{
			//
			// Create the Geometry to draw.
			//

			if (val.IsVisible == false)
			{
				return GetImageSourceFromAxoColor(AxoColors.Transparent, width, height);
			}
			else if (val.HasColor)
			{
				return GetImageSourceFromAxoColor(val.Color.Color, width, height);
			}
			else
			{
				return GetImageSourceFromAxoColor(NamedColors.Black, width, height);
			}
		}
Example #15
0
        public IMaterial this[Vector3i vectorLocation]
        {
            get
            {
                if (_children == null || _middle == 0)
                    return _material;

                EightFoldTree childTree = _children[vectorLocation.X / _middle, vectorLocation.Y / _middle, vectorLocation.Z / _middle];
                if (childTree == null)
                    return _material;

                return childTree[vectorLocation.X % _middle, vectorLocation.Y % _middle, vectorLocation.Z % _middle];

                //Vector3i[] vectors = GetIndexAndLocation(vectorLocation);

                //return _children[vectors[0].X, vectors[0].Y, vectors[0].Z][vectors[1]];
            }
            set
            {
                if (Size == 1)
                    _material = value;
                else
                {
                    //if there are no children, expand now
                    if (_children == null)
                        //Expand();
                        _children = new EightFoldTree[2, 2, 2];

                    //determine the child tree index
                    Vector3i location = new Vector3i(vectorLocation.X / _middle, vectorLocation.Y / _middle, vectorLocation.Z / _middle);

                    //if that index has not yet been allocated, do it now
                    if (_children[location.X, location.Y, location.Z] == null)
                        _children[location.X, location.Y, location.Z] = new EightFoldTree(_middle, _material);

                    _children[location.X, location.Y, location.Z][vectorLocation.X % _middle, vectorLocation.Y % _middle, vectorLocation.Z % _middle] = value;

                    //Vector3i[] vectors = GetIndexAndLocation(vectorLocation);
                    //_children[vectors[0].X, vectors[0].Y, vectors[0].Z][vectors[1]] = value;
                }
            }
        }
Example #16
0
		public override void Paint(IGraphicsContext3D g, IMaterial material, PointD3D centerLocation, double symbolSize)
		{
			// Note: the symbolSize provided in the argument is the diameter of an imaginary sphere in which the cube has to fit in
			// thus the cube's diagonal should be equal to the sphere's diameter

			var size = symbolSize * Sqrt1By3; // size of the cube
			var sizeBy2 = size * 0.5;
			var buffers = g.GetPositionNormalIndexedTriangleBuffer(material);
			if (null != buffers.PositionNormalIndexedTriangleBuffer)
			{
				var buf = buffers.PositionNormalIndexedTriangleBuffer;
				var voffs = buffers.PositionNormalIndexedTriangleBuffer.VertexCount;
				SolidCube.Add(
					centerLocation.X - sizeBy2, centerLocation.Y - sizeBy2, centerLocation.Z - sizeBy2,
					size, size, size,
					(point, normal) => buf.AddTriangleVertex(point.X, point.Y, point.Z, normal.X, normal.Y, normal.Z),
					(i1, i2, i3) => buf.AddTriangleIndices(i1 + voffs, i2 + voffs, i3 + voffs),
					ref voffs);
			}
		}
Example #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IObject"/> class.
        /// </summary>
        /// <param name="Material">The material. (cannot be null, use the InvisibleMaterial.GetInstance when you dont need Material)</param>
        /// <param name="Modelo">The modelo. (can be null)</param>
        /// <param name="PhysicObject">The physic object. (cannot be null)</param>
        /// <param name="name">The name of the IObject (just an identifier).</param>
        public IObject(IMaterial Material, IModelo Modelo, IPhysicObject PhysicObject,String name = null)
        {            
            System.Diagnostics.Debug.Assert(Material != null);
            System.Diagnostics.Debug.Assert(PhysicObject != null);            

            this.Material = Material;
            this.Modelo = Modelo;
            this.PhysicObject = PhysicObject;
            this.Name = name;
            IObjectAttachment = new List<IObjectAttachment>();

            if (this.Modelo == null && this.Material != null)
            {
                Material.IsVisible = false;
#if !WINDOWS_PHONE && !REACH
                Material.CanAppearOfReflectionRefraction = false;
                Material.CanCreateShadow = false;
#endif
            }

        }
Example #18
0
		public override void Paint(IGraphicsContext3D g, IMaterial material, PointD3D centerLocation, double symbolSize)
		{
			var radius = symbolSize / 2;
			var buffers = g.GetPositionNormalIndexedTriangleBuffer(material);

			if (null != buffers.PositionNormalIndexedTriangleBuffer)
			{
				var buffer = buffers.PositionNormalIndexedTriangleBuffer;
				var offs = buffer.VertexCount;

				foreach (var entry in GetVerticesAndNormals())
				{
					var pt = centerLocation + radius * entry.Item1;
					var nm = entry.Item2;
					buffer.AddTriangleVertex(pt.X, pt.Y, pt.Z, nm.X, nm.Y, nm.Z);
				}
				foreach (var idx in GetTriangleIndices())
				{
					buffer.AddTriangleIndices(idx.Item1 + offs, idx.Item2 + offs, idx.Item3 + offs);
				}
			}
		}
Example #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IObject"/> class.
        /// </summary>
        /// <param name="Material">The material.</param>
        /// <param name="Modelo">The modelo.</param>
        /// <param name="PhysicObject">The physic object.</param>
        public ISpriteObject(IMaterial Material, SpriteAnimated Modelo, CharacterObject PhysicObject, float animationSpeed = 20)
        {
            System.Diagnostics.Debug.Assert(Modelo != null);
            System.Diagnostics.Debug.Assert(Material != null);
            System.Diagnostics.Debug.Assert(PhysicObject != null);

            this.CharacterObject = PhysicObject;
            this.Material = Material;
            this.Modelo = null;
            this.SpriteAnimated = Modelo;
            this.PhysicObject = PhysicObject;
            IObjectAttachment = new List<IObjectAttachment>();
            Name = null;
            TaskResult = BehaviorTrees.TaskResult.Success;

            anims = new String[Modelo.NumberAnimations];
            for (int i = 0; i < Modelo.NumberAnimations ; i++)
            {
                String name = i.ToString();
                SpriteAnimated.AddAnimation(name, i + 1, Modelo.Frame, 0, true, animationSpeed);
                anims[i] = name;
            }
        }
Example #20
0
 public void Watch(IMaterial material)
 {
     material.MaterialChanged += OnMaterialChanged;
 }
Example #21
0
		///	<summary> This method copy's each database field from the <paramref name="source"/> interface to this data row.</summary>
		public void Copy_From(IMaterial source, bool includePrimaryKey = false)
		{
			if (includePrimaryKey) this.Id = source.Id;
			this.NameId = source.NameId;
			this.InformationenId = source.InformationenId;
			this.InformationenAddOnId = source.InformationenAddOnId;
			this.Tabelle = source.Tabelle;
			this.TabelleId = source.TabelleId;
			this.Typ = source.Typ;
			this.SubEntryId = source.SubEntryId;
			this.OriginalMaterialName = source.OriginalMaterialName;
			this.BlobLength = source.BlobLength;
			this.BlobContent = source.BlobContent;
			this.ModifyTimeStamp = source.ModifyTimeStamp;
			this.ProcessingStatus = source.ProcessingStatus;
			this.CreatedBy = source.CreatedBy;
			this.LastModifiedBy = source.LastModifiedBy;
			this.AccessRightsId = source.AccessRightsId;
			this.LastUpdateToken = source.LastUpdateToken;
		}
Example #22
0
 public virtual void SetMaterial(IMaterial materialDesc, bool applyToEntireObject, MaterialChanges changes)
 {
 }
Example #23
0
		public bool HasSameSpecularPropertiesAs(IMaterial anotherMaterial)
		{
			return anotherMaterial is MaterialInvisible;
		}
Example #24
0
 public ICommand FindByMaterial(IMaterial material)
 {
     return commandList.OfType<IRenderCommand>().First(rCommand => rCommand.Material.TechniqueName == material.TechniqueName);
 }
        public unsafe IModel LoadModel(GloModelFileBundle gloModelFileBundle)
        {
            var gloFile            = gloModelFileBundle.GloFile;
            var textureDirectories = gloModelFileBundle.TextureDirectories;
            var fps = 20;

            var glo = gloFile.Impl.ReadNew <Glo>(Endianness.LittleEndian);

            var textureFilesByName = new Dictionary <string, IFileHierarchyFile>();

            foreach (var textureDirectory in textureDirectories)
            {
                foreach (var textureFile in textureDirectory.Files)
                {
                    textureFilesByName[textureFile.Name.ToLower()] = textureFile;
                }
            }

            /*new MeshCsvWriter().WriteToFile(
             *  glo, new FinFile(Path.Join(outputDirectory.FullName, "mesh.csv")));
             * new FaceCsvWriter().WriteToFile(
             *  glo, new FinFile(Path.Join(outputDirectory.FullName, "face.csv")));
             * new VertexCsvWriter().WriteToFile(
             *  glo, new FinFile(Path.Join(outputDirectory.FullName, "vertex.csv")));*/

            var finModel = new ModelImpl();
            var finSkin  = finModel.Skin;

            var finRootBone = finModel.Skeleton.Root;

            var finTextureMap = new LazyDictionary <string, ITexture?>(
                textureFilename => {
                if (!textureFilesByName.TryGetValue(textureFilename.ToLower(),
                                                    out var textureFile))
                {
                    return(null);
                }

                using var rawTextureImage = FinImage.FromFile(textureFile.Impl);
                var textureImageWithAlpha =
                    GloModelLoader.AddTransparencyToGloImage_(rawTextureImage);

                var finTexture = finModel.MaterialManager.CreateTexture(
                    textureImageWithAlpha);
                finTexture.Name = textureFilename;

                if (this.mirrorTextures_.Contains(textureFilename))
                {
                    finTexture.WrapModeU = WrapMode.MIRROR_REPEAT;
                    finTexture.WrapModeV = WrapMode.MIRROR_REPEAT;
                }
                else
                {
                    finTexture.WrapModeU = WrapMode.REPEAT;
                    finTexture.WrapModeV = WrapMode.REPEAT;
                }

                return(finTexture);
            });
            var withCullingMap =
                new LazyDictionary <string, IMaterial>(textureFilename => {
                var finTexture = finTextureMap[textureFilename];
                if (finTexture == null)
                {
                    return(finModel.MaterialManager.AddStandardMaterial());
                }
                return(finModel.MaterialManager.AddTextureMaterial(finTexture));
            });
            var withoutCullingMap = new LazyDictionary <string, IMaterial>(
                textureFilename => {
                var finTexture        = finTextureMap[textureFilename];
                IMaterial finMaterial = finTexture == null
                                        ? finModel.MaterialManager
                                        .AddStandardMaterial()
                                        : finModel.MaterialManager
                                        .AddTextureMaterial(
                    finTexture);
                finMaterial.CullingMode = CullingMode.SHOW_BOTH;
                return(finMaterial);
            });

            var firstMeshMap = new Dictionary <string, GloMesh>();

            // TODO: Consider separating these out as separate models
            foreach (var gloObject in glo.Objects)
            {
                var finObjectRootBone = finRootBone.AddRoot(0, 0, 0);
                var meshQueue         = new Queue <(GloMesh, IBone)>();
                foreach (var topLevelGloMesh in gloObject.Meshes)
                {
                    meshQueue.Enqueue((topLevelGloMesh, finObjectRootBone));
                }

                List <(IAnimation, int, int)> finAndGloAnimations = new();
                foreach (var animSeg in gloObject.AnimSegs)
                {
                    var startFrame = (int)animSeg.StartFrame;
                    var endFrame   = (int)animSeg.EndFrame;

                    var finAnimation = finModel.AnimationManager.AddAnimation();
                    finAnimation.Name       = animSeg.Name;
                    finAnimation.FrameCount =
                        (int)(animSeg.EndFrame - animSeg.StartFrame + 1);

                    finAnimation.FrameRate = fps * animSeg.Speed;

                    finAndGloAnimations.Add((finAnimation, startFrame, endFrame));
                }

                while (meshQueue.Count > 0)
                {
                    var(gloMesh, parentFinBone) = meshQueue.Dequeue();

                    var name = gloMesh.Name;

                    GloMesh idealMesh;
                    if (!firstMeshMap.TryGetValue(name, out idealMesh))
                    {
                        firstMeshMap[name] = idealMesh = gloMesh;
                    }

                    var position = gloMesh.MoveKeys[0].Xyz;

                    var rotation   = gloMesh.RotateKeys[0];
                    var quaternion =
                        new Quaternion(rotation.X, rotation.Y, rotation.Z, rotation.W);
                    var xyzRadians = QuaternionUtil.ToEulerRadians(quaternion);

                    var scale = gloMesh.ScaleKeys[0].Scale;

                    var finBone = parentFinBone
                                  .AddChild(position.X, position.Y, position.Z)
                                  .SetLocalRotationRadians(
                        xyzRadians.X, xyzRadians.Y, xyzRadians.Z)
                                  .SetLocalScale(scale.X, scale.Y, scale.Z);
                    finBone.Name = name + "_bone";

                    var child = gloMesh.Pointers.Child;
                    if (child != null)
                    {
                        meshQueue.Enqueue((child, finBone));
                    }

                    var next = gloMesh.Pointers.Next;
                    if (next != null)
                    {
                        meshQueue.Enqueue((next, parentFinBone));
                    }

                    foreach (var(finAnimation, startFrame, endFrame) in
                             finAndGloAnimations)
                    {
                        var finBoneTracks = finAnimation.AddBoneTracks(finBone);

                        long prevTime = -1;
                        foreach (var moveKey in gloMesh.MoveKeys)
                        {
                            Asserts.True(moveKey.Time > prevTime);
                            prevTime = moveKey.Time;

                            if (!(moveKey.Time >= startFrame && moveKey.Time <= endFrame))
                            {
                                continue;
                            }

                            var time = (int)(moveKey.Time - startFrame);
                            Asserts.True(time >= 0 && time < finAnimation.FrameCount);

                            var moveValue = moveKey.Xyz;
                            finBoneTracks.Positions.Set(time, 0, moveValue.X);
                            finBoneTracks.Positions.Set(time, 1, moveValue.Y);
                            finBoneTracks.Positions.Set(time, 2, moveValue.Z);
                        }

                        prevTime = -1;
                        foreach (var rotateKey in gloMesh.RotateKeys)
                        {
                            Asserts.True(rotateKey.Time > prevTime);
                            prevTime = rotateKey.Time;

                            if (!(rotateKey.Time >= startFrame &&
                                  rotateKey.Time <= endFrame))
                            {
                                continue;
                            }

                            var time = (int)(rotateKey.Time - startFrame);
                            Asserts.True(time >= 0 && time < finAnimation.FrameCount);

                            var quaternionKey =
                                new Quaternion(rotateKey.X, rotateKey.Y, rotateKey.Z,
                                               rotateKey.W);
                            var xyzRadiansKey = QuaternionUtil.ToEulerRadians(quaternionKey);

                            finBoneTracks.Rotations.Set(time, 0,
                                                        xyzRadiansKey.X);
                            finBoneTracks.Rotations.Set(time, 1,
                                                        xyzRadiansKey.Y);
                            finBoneTracks.Rotations.Set(time, 2,
                                                        xyzRadiansKey.Z);
                        }

                        prevTime = -1;
                        foreach (var scaleKey in gloMesh.ScaleKeys)
                        {
                            Asserts.True(scaleKey.Time > prevTime);
                            prevTime = scaleKey.Time;

                            if (!(scaleKey.Time >= startFrame && scaleKey.Time <= endFrame))
                            {
                                continue;
                            }

                            var time = (int)(scaleKey.Time - startFrame);
                            Asserts.True(time >= 0 && time < finAnimation.FrameCount);

                            var scaleValue = scaleKey.Scale;
                            finBoneTracks.Scales.Set(time, 0, scaleValue.X);
                            finBoneTracks.Scales.Set(time, 1, scaleValue.Y);
                            finBoneTracks.Scales.Set(time, 2, scaleValue.Z);
                        }
                    }

                    // Anything with these names are debug objects and can be ignored.
                    if (this.hiddenNames_.Contains(name))
                    {
                        continue;
                    }

                    var finMesh = finSkin.AddMesh();
                    finMesh.Name = name;

                    var gloVertices = idealMesh.Vertices;

                    string    previousTextureName = null;
                    IMaterial?previousMaterial    = null;

                    foreach (var gloFace in idealMesh.Faces)
                    {
                        // TODO: What can we do if texture filename is empty?
                        var textureFilename = gloFace.TextureFilename;

                        var gloFaceColor = gloFace.Color;
                        var finFaceColor = ColorImpl.FromRgbaBytes(
                            gloFaceColor.R, gloFaceColor.G, gloFaceColor.B, gloFaceColor.A);

                        var enableBackfaceCulling = (gloFace.Flags & 1 << 2) == 0;

                        IMaterial?finMaterial;
                        if (textureFilename == previousTextureName)
                        {
                            finMaterial = previousMaterial;
                        }
                        else
                        {
                            previousTextureName = textureFilename;
                            finMaterial         = enableBackfaceCulling
                                ? withCullingMap[textureFilename]
                                : withoutCullingMap[textureFilename];
                            previousMaterial = finMaterial;
                        }

                        // Face flag:
                        // 0: potentially some kind of repeat mode??

                        var color = (gloFace.Flags & 1 << 6) != 0
                            ? ColorImpl.FromRgbaBytes(255, 0, 0, 255)
                            : ColorImpl.FromRgbaBytes(0, 255, 0, 255);

                        var finFaceVertices = new IVertex[3];
                        for (var v = 0; v < 3; ++v)
                        {
                            var gloVertexRef = gloFace.VertexRefs[v];
                            var gloVertex    = gloVertices[gloVertexRef.Index];

                            var finVertex = finSkin
                                            .AddVertex(gloVertex.X, gloVertex.Y, gloVertex.Z)
                                            .SetUv(gloVertexRef.U, gloVertexRef.V);
                            //.SetColor(color);
                            finVertex.SetBoneWeights(finSkin.GetOrCreateBoneWeights(
                                                         PreprojectMode.BONE, finBone));
                            finFaceVertices[v] = finVertex;
                        }

                        // TODO: Merge triangles together
                        var finTriangles = new (IVertex, IVertex, IVertex)[1];
 public SphereFigure(Tuple4 center, double radius, IMaterial material)
 {
     this.sphere   = new Sphere(center, radius);
     this.Material = material;
 }
Example #27
0
 public void Init(Blending blending, ShaderId shader)
 {
     material = WidgetMaterial.GetInstance(blending, shader, 1);
 }
Example #28
0
 public static IMaterialScatter GetMaterialScatter(IMaterial material)
 {
     return(GetMaterialScatter(material.TypeName));
 }
Example #29
0
        public Vector3 Emit(IMaterial material, Ray ray, HitData hit_data)
        {
            DiffuseLightMaterial diffuse_light_material = material as DiffuseLightMaterial;

            return(diffuse_light_material.Emit.Value(hit_data.UV.X, hit_data.UV.Y, hit_data.Point));
        }
Example #30
0
 public Sphere(Vec3 center, float radius, IMaterial material) : this()
 {
     Center   = center;
     Radius   = radius;
     Material = material;
 }
 public TestFigure(IMatrix transformation, IMaterial material)
 {
     Transformation = transformation;
     Material       = material;
 }
 public SphereFigure(Sphere sphere, IMaterial material)
 {
     this.sphere   = sphere;
     this.Material = material;
 }
Example #33
0
File: Order.cs Project: prof1A/OOP
        public Baguet MakeOrder(int Width, int Height, params Type[] materials)
        {
            IMaterial mt = new Wood();

            IMaterial[] arr = new IMaterial[materials.Length];

            for (int i = 0; i < materials.Length; i++)
            {
                if (materials[i].ToString() == "BaguetFactory.Wood")
                {
                    mt = new Wood();
                    if (del(typeof(Wood), (Width * Height * mt.NeededToCreate)))
                    {
                        Cost  += Width * Height * mt.NeededToCreate * mt.Cost;
                        arr[i] = new Wood();
                        Storage.MaterialTakingPerWeek(Width * Height * mt.NeededToCreate);
                    }
                    else
                    {
                        Cost = -1;
                        break;
                    }
                }
                else if (materials[i].ToString() == "BaguetFactory.MetalProfile")
                {
                    mt = new MetalProfile();
                    if (del(typeof(MetalProfile), (Width * Height * mt.NeededToCreate)))
                    {
                        Cost  += Width * Height * mt.NeededToCreate * mt.Cost;
                        arr[i] = new MetalProfile();
                        Storage.MaterialTakingPerWeek(Width * Height * mt.NeededToCreate);
                    }
                    else
                    {
                        Cost = -1;
                        break;
                    }
                }
                else if (materials[i].ToString() == "BaguetFactory.PlasticProfile")
                {
                    mt = new PlasticProfile();
                    if (del(typeof(PlasticProfile), (Width * Height * mt.NeededToCreate)))
                    {
                        Cost  += Width * Height * mt.NeededToCreate * mt.Cost;
                        arr[i] = new PlasticProfile();
                        Storage.MaterialTakingPerWeek(Width * Height * mt.NeededToCreate);
                    }
                    else
                    {
                        Cost = -1;
                        break;
                    }
                }
                else if (materials[i].ToString() == "BaguetFactory.Dye")
                {
                    mt = new Dye();
                    if (del(typeof(Dye), (Width * Height * mt.NeededToCreate)))
                    {
                        Cost  += Width * Height * mt.NeededToCreate * mt.Cost;
                        arr[i] = new Dye();
                        Storage.MaterialTakingPerWeek(Width * Height * mt.NeededToCreate);
                    }
                    else
                    {
                        Cost = -1;
                        break;
                    }
                }
                else if (materials[i].ToString() == "BaguetFactory.Polish")
                {
                    mt = new Polish();
                    if (del(typeof(Polish), (Width * Height * mt.NeededToCreate)))
                    {
                        Cost  += Width * Height * mt.NeededToCreate * mt.Cost;
                        arr[i] = new Polish();
                        Storage.MaterialTakingPerWeek(Width * Height * mt.NeededToCreate);
                    }
                    else
                    {
                        Cost = -1;
                        break;
                    }
                }
            }
            return(new Baguet
            {
                Width = Width,
                Height = Height,
                Cost = Cost
            });
        }
Example #34
0
 public MaterialController(IMaterial material)
 {
     _material = material;
 }
Example #35
0
 public void AddRenderCommand(IMaterial material, RenderableCollection rNodeCollection)
 {
     Type renderCommandType = rNodeCollection.Description.PreferredRenderCommandType;
     RenderCommand rCommand = (RenderCommand)Activator.CreateInstance(renderCommandType, new object[] {material, rNodeCollection});
     rCommand.Init();
     commandList.AddLast(rCommand);
 }
Example #36
0
		public bool Equals(IMaterial other)
		{
			return (other is MaterialInvisible);
		}
Example #37
0
 public bool Scatter(IMaterial material, Ray ray, HitData hit_data, ref Vector3 attenuation, ref Ray scattered)
 {
     return(false);
 }
        private IEffectParameterSet GetEffectParameterSet(IMaterial material, ref bool changedRenderRequest, ref string changedRenderRequestBy)
        {
            if (_effectUsedForParameterSetCache == _cachedEffect &&
                changedRenderRequest == false &&
                (!_lastDidSetDiffuseTexture || _lastSetDiffuseTexture == _lastCachedDiffuseTexture?.Texture) &&
                (!_lastDidSetNormalMap || _lastSetNormalMap == _lastCachedNormalMapTexture?.Texture) &&
                (!_lastDidSetSpecularPower || _lastSetSpecularPower == _lastCachedSpecularPower) &&
                (!_lastDidSetSpecularColorMap || _lastSetSpecularColorMap == _lastCachedSpecularColorMapTexture?.Texture) &&
                (!_lastDidSetSpecularColor || _lastSetSpecularColor == _lastCachedSpecularColor) &&
                (!_lastDidSetDiffuseColor || _lastSetDiffuseColor == (material.ColorDiffuse ?? Color.Black)))
            {
                // Reuse the existing parameter set.
                return _cachedEffectParameterSet;
            }

            changedRenderRequest = true;
            changedRenderRequestBy += ":parameterset";

            // Create a new parameter set and cache it.
            _cachedEffectParameterSet = _cachedEffect.CreateParameterSet();
            _effectUsedForParameterSetCache = _cachedEffect;

            _lastSetDiffuseTexture = null;
            _lastSetNormalMap = null;
            _lastSetSpecularPower = null;
            _lastSetSpecularColorMap = null;
            _lastSetSpecularColor = null;
            _lastSetDiffuseColor = null;
            _lastDidSetDiffuseTexture = false;
            _lastDidSetNormalMap = false;
            _lastDidSetSpecularPower = false;
            _lastDidSetSpecularColorMap = false;
            _lastDidSetSpecularColor = false;
            _lastDidSetDiffuseColor = false;

            if (_cachedEffectParameterSet.HasSemantic<ITextureEffectSemantic>())
            {
                if (_lastCachedDiffuseTexture?.Texture != null)
                {
                    _cachedEffectParameterSet.GetSemantic<ITextureEffectSemantic>().Texture =
                        _lastCachedDiffuseTexture.Texture;
                    _lastSetDiffuseTexture = _lastCachedDiffuseTexture.Texture;
                    _lastDidSetDiffuseTexture = true;
                }
            }

            if (_cachedEffectParameterSet.HasSemantic<INormalMapEffectSemantic>())
            {
                if (_lastCachedNormalMapTexture?.Texture != null)
                {
                    _cachedEffectParameterSet.GetSemantic<INormalMapEffectSemantic>().NormalMap =
                        _lastCachedNormalMapTexture.Texture;
                    _lastSetNormalMap = _lastCachedNormalMapTexture.Texture;
                    _lastDidSetNormalMap = true;
                }
            }

            if (_cachedEffectParameterSet.HasSemantic<ISpecularEffectSemantic>())
            {
                if (_lastCachedSpecularPower != null)
                {
                    var semantic = _cachedEffectParameterSet.GetSemantic<ISpecularEffectSemantic>();
                    semantic.SpecularPower = _lastCachedSpecularPower.Value;
                    _lastSetSpecularPower = _lastCachedSpecularPower.Value;
                    _lastDidSetSpecularPower = true;

                    if (_lastCachedSpecularColorMapTexture != null)
                    {
                        semantic.SpecularColorMap = _lastCachedSpecularColorMapTexture.Texture;
                        _lastSetSpecularColorMap = _lastCachedSpecularColorMapTexture.Texture;
                        _lastDidSetSpecularColorMap = true;
                    }
                    else if (_lastCachedSpecularColor != null)
                    {
                        semantic.SpecularColor = _lastCachedSpecularColor.Value;
                        _lastSetSpecularColor = _lastCachedSpecularColor.Value;
                        _lastDidSetSpecularColor = true;
                    }
                }
            }

            if (_cachedEffectParameterSet.HasSemantic<IColorDiffuseEffectSemantic>())
            {
                var v = material.ColorDiffuse ?? Color.Black;
                _cachedEffectParameterSet.GetSemantic<IColorDiffuseEffectSemantic>().Diffuse = v;
                _lastSetDiffuseColor = v;
                _lastDidSetDiffuseColor = true;
            }

            return _cachedEffectParameterSet;
        }
Example #39
0
 private static void AddScatter(IMaterial material, IMaterialScatter scatter)
 {
     material_scatters.Add(material.TypeName, scatter);
 }
        private void UpdateCachedModel(IMaterial material, ref bool changedRenderRequest, ref string changedRenderRequestBy)
        {
            if (_lastCachedModel != _model)
            {
                changedRenderRequest = true;
                changedRenderRequestBy += ":model";

                if (material.TextureDiffuse != null && material.TextureNormal != null)
                {
                    if (material.TextureDiffuse.TextureAsset != null)
                    {
                        _lastCachedDiffuseTexture = material.TextureDiffuse.TextureAsset;
                    }
                    else
                    {
                        _lastCachedDiffuseTexture =
                            _textureFromHintPath.GetTextureFromHintPath(material.TextureDiffuse);
                    }

                    if (material.TextureNormal != null)
                    {
                        if (material.TextureNormal.TextureAsset != null)
                        {
                            _lastCachedNormalMapTexture = material.TextureNormal.TextureAsset;
                        }
                        else
                        {
                            _lastCachedNormalMapTexture =
                                _textureFromHintPath.GetTextureFromHintPath(material.TextureNormal);
                        }
                    }
                    else
                    {
                        _lastCachedNormalMapTexture = null;
                    }

                    if (material.PowerSpecular != null)
                    {
                        _lastCachedSpecularPower = material.PowerSpecular.Value;

                        if (material.TextureSpecular != null)
                        {
                            if (material.TextureSpecular.TextureAsset != null)
                            {
                                _lastCachedSpecularColorMapTexture = material.TextureSpecular.TextureAsset;
                            }
                            else
                            {
                                _lastCachedSpecularColorMapTexture =
                                    _textureFromHintPath.GetTextureFromHintPath(material.TextureSpecular);
                            }
                        }
                        else if (material.ColorSpecular != null)
                        {
                            _lastCachedSpecularColor = material.ColorSpecular.Value;
                        }
                        else
                        {
                            _lastCachedSpecularColor = null;
                        }
                    }
                    else
                    {
                        _lastCachedSpecularPower = null;
                    }

                    _mode = "texture";
                }
                else if (material.ColorDiffuse != null)
                {
                    _mode = "diffuse";
                }
                else
                {
                    _mode = "color";
                }
                _lastCachedModel = _model;
            }
        }
Example #41
0
 public Vector3 Emit(IMaterial material, Ray ray, HitData hit_data)
 {
     return(Vector3.Zero);
 }
Example #42
0
        private static RenderBatch <Vertex> DrawTrianglesHelper(ITexture texture1, ITexture texture2, IMaterial material, Vertex[] vertices, int numVertices)
        {
            var batch     = CurrentRenderList.GetBatch <Vertex>(texture1, texture2, material, numVertices, (numVertices - 2) * 3);
            var transform = GetEffectiveTransform();
            var vd        = batch.Mesh.Vertices;

            batch.Mesh.DirtyFlags |= MeshDirtyFlags.Vertices;
            int j = batch.LastVertex;

            for (int i = 0; i < numVertices; i++, j++)
            {
                var v = vertices[i];
                v.Pos = transform * v.Pos;
                texture1?.TransformUVCoordinatesToAtlasSpace(ref v.UV1);
                texture2?.TransformUVCoordinatesToAtlasSpace(ref v.UV2);
                vd[j] = v;
            }
            return(batch);
        }
Example #43
0
 public Tracer(Construction construction, IMaterial ambient, IRandomFactory randomFactory,
               IHemispherecalSamplerFactory samplerFactory)
     : this(construction, ambient, randomFactory, samplerFactory, 1.0)
 {
 }
Example #44
0
        public static void DrawSprite(ITexture texture1, ITexture texture2, IMaterial material, Color4 color, Vector2 position, Vector2 size, Vector2 uv0t1, Vector2 uv1t1, Vector2 uv0t2, Vector2 uv1t2)
        {
            texture1?.TransformUVCoordinatesToAtlasSpace(ref uv0t1);
            texture1?.TransformUVCoordinatesToAtlasSpace(ref uv1t1);
            texture2?.TransformUVCoordinatesToAtlasSpace(ref uv0t2);
            texture2?.TransformUVCoordinatesToAtlasSpace(ref uv1t2);
            var batch = CurrentRenderList.GetBatch <Vertex>(texture1, texture2, material, 4, 6);

            batch.Mesh.DirtyFlags |= MeshDirtyFlags.VerticesIndices;
            int v = batch.LastVertex;
            int i = batch.LastIndex;

            batch.LastIndex  += 6;
            batch.LastVertex += 4;
            var indices = batch.Mesh.Indices;

            indices[i++] = (ushort)(v + 1);
            indices[i++] = (ushort)v;
            indices[i++] = (ushort)(v + 2);
            indices[i++] = (ushort)(v + 2);
            indices[i++] = (ushort)(v + 3);
            indices[i++] = (ushort)(v + 1);
            float x0       = position.X;
            float y0       = position.Y;
            float x1       = position.X + size.X;
            float y1       = position.Y + size.Y;
            var   matrix   = GetEffectiveTransform();
            float x0ux     = x0 * matrix.UX;
            float x0uy     = x0 * matrix.UY;
            float y0vx     = y0 * matrix.VX;
            float y0vy     = y0 * matrix.VY;
            float x1ux     = x1 * matrix.UX;
            float x1uy     = x1 * matrix.UY;
            float y1vx     = y1 * matrix.VX;
            float y1vy     = y1 * matrix.VY;
            var   vertices = batch.Mesh.Vertices;

            vertices[v].Pos = new Vector2 {
                X = x0ux + y0vx + matrix.TX, Y = x0uy + y0vy + matrix.TY
            };
            vertices[v].Color = color;
            vertices[v].UV1   = uv0t1;
            vertices[v++].UV2 = uv0t2;
            vertices[v].Pos   = new Vector2 {
                X = x1ux + y0vx + matrix.TX, Y = x1uy + y0vy + matrix.TY
            };
            vertices[v].Color = color;
            vertices[v].UV1   = new Vector2 {
                X = uv1t1.X, Y = uv0t1.Y
            };
            vertices[v++].UV2 = new Vector2 {
                X = uv1t2.X, Y = uv0t2.Y
            };
            vertices[v].Pos = new Vector2 {
                X = x0ux + y1vx + matrix.TX, Y = x0uy + y1vy + matrix.TY
            };
            vertices[v].Color = color;
            vertices[v].UV1   = new Vector2 {
                X = uv0t1.X, Y = uv1t1.Y
            };
            vertices[v++].UV2 = new Vector2 {
                X = uv0t2.X, Y = uv1t2.Y
            };
            vertices[v].Pos = new Vector2 {
                X = x1ux + y1vx + matrix.TX, Y = x1uy + y1vy + matrix.TY
            };
            vertices[v].Color = color;
            vertices[v].UV1   = uv1t1;
            vertices[v].UV2   = uv1t2;
        }
 public SphereFigure(IMatrix transformation, IMaterial material)
 {
     this.sphere         = new Sphere();
     this.Material       = material;
     this.Transformation = transformation;
 }
Example #46
0
 public ISurface WithMaterial(IMaterial material)
 => this;
Example #47
0
 internal static FabPlanWip ToFabPlanWip(this IMaterial m)
 {
     return(m as FabPlanWip);
 }
Example #48
0
 public void Init(Blending blending, int gradientMapIndex)
 {
     material = ColorfulTextMaterial.GetInstance(blending, gradientMapIndex);
 }
Example #49
0
 public MaterialPlusClippingKey(IMaterial material, PlaneD3D[] clipPlanes)
     : base(material)
 {
     ClipPlanes = clipPlanes;
 }
Example #50
0
        public static Model ToLadybugTools(this AnalyticalModel analyticalModel, double silverSpacing = Tolerance.MacroDistance, double tolerance = Tolerance.Distance)
        {
            if (analyticalModel == null)
            {
                return(null);
            }

            AnalyticalModel analyticalModel_Temp = new AnalyticalModel(analyticalModel);

            analyticalModel_Temp.OffsetAperturesOnEdge(0.1, tolerance);
            analyticalModel_Temp.ReplaceTransparentPanels(0.1);

            string uniqueName = Core.LadybugTools.Query.UniqueName(analyticalModel_Temp);

            AdjacencyCluster adjacencyCluster = analyticalModel_Temp.AdjacencyCluster;

            List <Room> rooms = null;
            List <AnyOf <IdealAirSystemAbridged, VAV, PVAV, PSZ, PTAC, ForcedAirFurnace, FCUwithDOASAbridged, WSHPwithDOASAbridged, VRFwithDOASAbridged, FCU, WSHP, VRF, Baseboard, EvaporativeCooler, Residential, WindowAC, GasUnitHeater> > hvacs = null;

            List <Space> spaces = adjacencyCluster?.GetSpaces();

            if (spaces != null)
            {
                hvacs = new List <AnyOf <IdealAirSystemAbridged, VAV, PVAV, PSZ, PTAC, ForcedAirFurnace, FCUwithDOASAbridged, WSHPwithDOASAbridged, VRFwithDOASAbridged, FCU, WSHP, VRF, Baseboard, EvaporativeCooler, Residential, WindowAC, GasUnitHeater> >();
                rooms = new List <Room>();

                Dictionary <double, List <Panel> > dictionary_elevations = Analytical.Query.MinElevationDictionary(adjacencyCluster.GetPanels(), true);
                List <Level> levels = dictionary_elevations?.Keys.ToList().ConvertAll(x => Architectural.Create.Level(x));

                for (int i = 0; i < spaces.Count; i++)
                {
                    Space space = spaces[i];
                    if (space == null)
                    {
                        continue;
                    }

                    Room room = space.ToLadybugTools(analyticalModel_Temp, silverSpacing, tolerance);
                    if (room == null)
                    {
                        continue;
                    }

                    if (levels != null && levels.Count > 0)
                    {
                        double elevation_Min = space.MinElevation(adjacencyCluster);
                        if (!double.IsNaN(elevation_Min))
                        {
                            double difference_Min = double.MaxValue;
                            Level  level_Min      = null;
                            foreach (Level level in levels)
                            {
                                double difference = System.Math.Abs(elevation_Min - level.Elevation);
                                if (difference < difference_Min)
                                {
                                    difference_Min = difference;
                                    level_Min      = level;
                                }
                            }

                            room.Story = level_Min.Name;
                        }
                    }

                    InternalCondition internalCondition = space.InternalCondition;
                    if (internalCondition != null)
                    {
                        //Michal Idea of filtering Uncondition Spaces
                        string name_InternalCondition = internalCondition.Name;

                        if (name_InternalCondition == null || (name_InternalCondition != null && !name_InternalCondition.ToLower().Contains("unconditioned") && !name_InternalCondition.ToLower().Contains("external")))
                        {
                            IdealAirSystemAbridged idealAirSystemAbridged = new IdealAirSystemAbridged(string.Format("{0}__{1}", i.ToString(), "IdealAir"), string.Format("Ideal Air System Abridged {0}", space.Name));
                            hvacs.Add(idealAirSystemAbridged);

                            if (room.Properties == null)
                            {
                                room.Properties = new RoomPropertiesAbridged();
                            }

                            if (room.Properties.Energy == null)
                            {
                                room.Properties.Energy = new RoomEnergyPropertiesAbridged();
                            }

                            room.Properties.Energy.Hvac = idealAirSystemAbridged.Identifier;
                        }
                    }

                    rooms.Add(room);
                }
            }

            List <Shade> shades         = null;
            List <Face>  faces_Orphaned = null;

            List <Panel> panels_Shading = adjacencyCluster.GetShadingPanels();

            if (panels_Shading != null)
            {
                foreach (Panel panel_Shading in panels_Shading)
                {
                    if (panels_Shading == null)
                    {
                        continue;
                    }

                    if (panel_Shading.PanelType == PanelType.Shade)
                    {
                        Shade shade = panel_Shading.ToLadybugTools_Shade();
                        if (shade == null)
                        {
                            continue;
                        }

                        if (shades == null)
                        {
                            shades = new List <Shade>();
                        }

                        shades.Add(shade);
                    }
                    else
                    {
                        Face face_Orphaned = panel_Shading.ToLadybugTools_Face();
                        if (face_Orphaned == null)
                        {
                            continue;
                        }

                        if (faces_Orphaned == null)
                        {
                            faces_Orphaned = new List <Face>();
                        }

                        faces_Orphaned.Add(face_Orphaned);
                    }
                }
            }

            MaterialLibrary materialLibrary = analyticalModel_Temp?.MaterialLibrary;

            List <Construction>         constructions_AdjacencyCluster         = adjacencyCluster.GetConstructions();
            List <ApertureConstruction> apertureConstructions_AdjacencyCluster = adjacencyCluster.GetApertureConstructions();

            ConstructionSetAbridged constructionSetAbridged = Core.LadybugTools.Query.DefaultConstructionSetAbridged();
            List <HoneybeeSchema.AnyOf <ConstructionSetAbridged, ConstructionSet> > constructionSets = new List <HoneybeeSchema.AnyOf <ConstructionSetAbridged, ConstructionSet> >();// { constructionSetAbridged  };

            List <AnyOf <OpaqueConstructionAbridged, WindowConstructionAbridged, WindowConstructionShadeAbridged, AirBoundaryConstructionAbridged, OpaqueConstruction, WindowConstruction, WindowConstructionShade, WindowConstructionDynamicAbridged, WindowConstructionDynamic, AirBoundaryConstruction, ShadeConstruction> > constructions = new List <AnyOf <OpaqueConstructionAbridged, WindowConstructionAbridged, WindowConstructionShadeAbridged, AirBoundaryConstructionAbridged, OpaqueConstruction, WindowConstruction, WindowConstructionShade, WindowConstructionDynamicAbridged, WindowConstructionDynamic, AirBoundaryConstruction, ShadeConstruction> >();

            Dictionary <string, HoneybeeSchema.Energy.IMaterial> dictionary_Materials = new Dictionary <string, HoneybeeSchema.Energy.IMaterial>();

            if (constructions_AdjacencyCluster != null)
            {
                foreach (Construction construction in constructions_AdjacencyCluster)
                {
                    List <ConstructionLayer> constructionLayers = construction.ConstructionLayers;
                    if (constructionLayers == null)
                    {
                        continue;
                    }

                    constructions.Add(construction.ToLadybugTools());
                    constructions.Add(construction.ToLadybugTools(false));

                    foreach (ConstructionLayer constructionLayer in constructionLayers)
                    {
                        IMaterial material = constructionLayer.Material(materialLibrary);
                        if (material == null)
                        {
                            continue;
                        }

                        if (dictionary_Materials.ContainsKey(material.Name))
                        {
                            continue;
                        }

                        if (material is GasMaterial)
                        {
                            List <Panel>  panels = Analytical.Query.Panels(adjacencyCluster, construction);
                            List <double> tilts  = panels.ConvertAll(x => Analytical.Query.Tilt(x).Round(Tolerance.MacroDistance));
                            double        tilt   = tilts.Distinct().ToList().Average();

                            tilt = Units.Convert.ToRadians(tilt);

                            dictionary_Materials[material.Name] = ((GasMaterial)material).ToLadybugTools(tilt, constructionLayer.Thickness);
                        }
                        else if (material is OpaqueMaterial)
                        {
                            EnergyMaterial energyMaterial = ((OpaqueMaterial)material).ToLadybugTools();
                            dictionary_Materials[material.Name] = energyMaterial;
                            if (!double.IsNaN(constructionLayer.Thickness))
                            {
                                energyMaterial.Thickness = constructionLayer.Thickness;
                            }
                        }
                    }
                }
            }

            if (apertureConstructions_AdjacencyCluster != null)
            {
                foreach (ApertureConstruction apertureConstruction in apertureConstructions_AdjacencyCluster)
                {
                    List <ConstructionLayer> constructionLayers = null;

                    constructionLayers = apertureConstruction.PaneConstructionLayers;
                    if (constructionLayers != null)
                    {
                        MaterialType materialType = Analytical.Query.MaterialType(constructionLayers, materialLibrary);
                        if (materialType != MaterialType.Undefined && materialType != MaterialType.Gas)
                        {
                            if (materialType == MaterialType.Opaque)
                            {
                                constructions.Add(apertureConstruction.ToLadybugTools());
                                constructions.Add(apertureConstruction.ToLadybugTools(false));
                            }
                            else
                            {
                                constructions.Add(apertureConstruction.ToLadybugTools_WindowConstructionAbridged());
                                constructions.Add(apertureConstruction.ToLadybugTools_WindowConstructionAbridged(false));
                            }

                            foreach (ConstructionLayer constructionLayer in constructionLayers)
                            {
                                IMaterial material = constructionLayer.Material(materialLibrary);
                                if (material == null)
                                {
                                    continue;
                                }

                                string name = material.Name;

                                if (dictionary_Materials.ContainsKey(name))
                                {
                                    continue;
                                }

                                if (material is TransparentMaterial)
                                {
                                    dictionary_Materials[name] = ((TransparentMaterial)material).ToLadybugTools();
                                }
                                else if (material is GasMaterial)
                                {
                                    dictionary_Materials[name] = ((GasMaterial)material).ToLadybugTools_EnergyWindowMaterialGas();
                                }
                                else
                                {
                                    dictionary_Materials[name] = ((OpaqueMaterial)material).ToLadybugTools();
                                }
                            }
                        }
                    }
                }
            }


            ProfileLibrary profileLibrary = analyticalModel.ProfileLibrary;

            Dictionary <System.Guid, ProgramType> dictionary_InternalConditions = new Dictionary <System.Guid, ProgramType>();

            if (spaces != null)
            {
                foreach (Space space in spaces)
                {
                    InternalCondition internalCondition = space?.InternalCondition;
                    if (internalCondition == null)
                    {
                        continue;
                    }

                    if (dictionary_InternalConditions.ContainsKey(internalCondition.Guid))
                    {
                        continue;
                    }

                    ProgramType programType = space.ToLadybugTools(adjacencyCluster, profileLibrary);
                    if (programType != null)
                    {
                        dictionary_InternalConditions[internalCondition.Guid] = programType;
                    }
                }
            }

            List <AnyOf <EnergyMaterial, EnergyMaterialNoMass, EnergyWindowMaterialGas, EnergyWindowMaterialGasCustom, EnergyWindowMaterialGasMixture, EnergyWindowMaterialSimpleGlazSys, EnergyWindowMaterialBlind, EnergyWindowMaterialGlazing, EnergyWindowMaterialShade> > materials = new List <AnyOf <EnergyMaterial, EnergyMaterialNoMass, EnergyWindowMaterialGas, EnergyWindowMaterialGasCustom, EnergyWindowMaterialGasMixture, EnergyWindowMaterialSimpleGlazSys, EnergyWindowMaterialBlind, EnergyWindowMaterialGlazing, EnergyWindowMaterialShade> >();

            HoneybeeSchema.Helper.EnergyLibrary.DefaultMaterials?.ToList().ForEach(x => materials.Add(x as dynamic));
            dictionary_Materials.Values.ToList().ForEach(x => materials.Add(x as dynamic));

            List <AnyOf <ScheduleRulesetAbridged, ScheduleFixedIntervalAbridged, ScheduleRuleset, ScheduleFixedInterval> > schedules = new List <AnyOf <ScheduleRulesetAbridged, ScheduleFixedIntervalAbridged, ScheduleRuleset, ScheduleFixedInterval> >();

            HoneybeeSchema.Helper.EnergyLibrary.DefaultScheduleRuleset?.ToList().ForEach(x => schedules.Add(x));

            List <HoneybeeSchema.AnyOf <ProgramTypeAbridged, ProgramType> > programTypes = new List <HoneybeeSchema.AnyOf <ProgramTypeAbridged, ProgramType> >();

            HoneybeeSchema.Helper.EnergyLibrary.DefaultProgramTypes?.ToList().ForEach(x => programTypes.Add(x));
            dictionary_InternalConditions.Values.ToList().ForEach(x => programTypes.Add(x));

            List <ScheduleTypeLimit> scheduleTypeLimits = new List <ScheduleTypeLimit>();

            HoneybeeSchema.Helper.EnergyLibrary.DefaultScheduleTypeLimit?.ToList().ForEach(x => scheduleTypeLimits.Add(x));

            constructionSets.RemoveAll(x => x == null);
            constructions.RemoveAll(x => x == null);
            materials.RemoveAll(x => x == null);

            ModelEnergyProperties modelEnergyProperties = new ModelEnergyProperties(constructionSets, constructions, materials, hvacs, null, programTypes, schedules, scheduleTypeLimits);

            ModelProperties modelProperties = new ModelProperties(modelEnergyProperties);

            Model model = new Model(uniqueName, modelProperties, adjacencyCluster.Name, null, rooms, faces_Orphaned, shades);

            model.AngleTolerance = Units.Convert.ToDegrees(Tolerance.Angle);// 2;
            model.Tolerance      = Tolerance.MacroDistance;

            return(model);
        }
Example #51
0
		public IMaterial WithSpecularPropertiesAs(IMaterial templateMaterial)
		{
			return this;
		}
        public override void Render(Graphics2D.IRenderConfiguration renderConfig, RenderManager renderManager, IMaterial materialToUse)
        {
            /*if (StaticMesh.IsCollisionOnly)
             * {
             *  return;
             * }*/

            base.Render(renderConfig, renderManager, materialToUse);

            Performance.StartAppendAggreate("Setup");
            Matrix worldViewProj = WorldMatrix * renderManager.ViewTarget.ViewMatrix * renderManager.ViewTarget.ProjectionMatrix;

            materialToUse.ApplyParameters(worldViewProj);
            Performance.EndAppendAggreate("Setup");

            /*if (StaticMesh.DiffuseTexture != null)
             * {
             *  Performance.StartAppendAggreate("Setup Texture");
             *  materialToUse.Effect.Parameters["Texture"].SetValue(StaticMesh.DiffuseTexture);
             *  materialToUse.Effect.CurrentTechnique.Passes[0].Apply();
             *  Performance.EndAppendAggreate("Setup Texture");
             * }*/

            Performance.StartAppendAggreate("Render Mesh");
            StaticMesh.Render();
            Performance.EndAppendAggreate("Render Mesh");
        }
Example #53
0
 public void SetMaterial(IMaterial materialDesc, bool applyToEntireObject)
 {
     SetMaterial(materialDesc, applyToEntireObject, MaterialChanges.All);
 }
 public BaseObject(IMaterial mat, IPhysicObject py, IModelo model)
     : base(mat,model,py)
 {
 }
Example #55
0
		///	<summary> This method copy's each database field into the <paramref name="target"/> interface. </summary>
		public void Copy_To(IMaterial target, bool includePrimaryKey = false)
		{
			if (includePrimaryKey) target.Id = this.Id;
			target.NameId = this.NameId;
			target.InformationenId = this.InformationenId;
			target.InformationenAddOnId = this.InformationenAddOnId;
			target.Tabelle = this.Tabelle;
			target.TabelleId = this.TabelleId;
			target.Typ = this.Typ;
			target.SubEntryId = this.SubEntryId;
			target.OriginalMaterialName = this.OriginalMaterialName;
			target.BlobLength = this.BlobLength;
			target.BlobContent = this.BlobContent;
			target.ModifyTimeStamp = this.ModifyTimeStamp;
			target.ProcessingStatus = this.ProcessingStatus;
			target.CreatedBy = this.CreatedBy;
			target.LastModifiedBy = this.LastModifiedBy;
			target.AccessRightsId = this.AccessRightsId;
			target.LastUpdateToken = this.LastUpdateToken;
		}
Example #56
0
 public Material(IMaterial other)
     : this(other.Spec, other.Density, other.Elasticity, other.ThermalCoefficient)
 {
 }
Example #57
0
		///	<summary> 
		///		This method copy's each database field which is in the <paramref name="includedColumns"/> 
		///		from the <paramref name="source"/> interface to this data row.
		/// </summary>
		public void Copy_From_But_TakeOnly(IMaterial source, params string[] includedColumns)
		{
			if (includedColumns.Contains(MaterialienTable.IdCol)) this.Id = source.Id;
			if (includedColumns.Contains(MaterialienTable.NameIdCol)) this.NameId = source.NameId;
			if (includedColumns.Contains(MaterialienTable.InformationenIdCol)) this.InformationenId = source.InformationenId;
			if (includedColumns.Contains(MaterialienTable.InformationenAddOnIdCol)) this.InformationenAddOnId = source.InformationenAddOnId;
			if (includedColumns.Contains(MaterialienTable.TabelleCol)) this.Tabelle = source.Tabelle;
			if (includedColumns.Contains(MaterialienTable.TabelleIdCol)) this.TabelleId = source.TabelleId;
			if (includedColumns.Contains(MaterialienTable.TypCol)) this.Typ = source.Typ;
			if (includedColumns.Contains(MaterialienTable.SubEntryIdCol)) this.SubEntryId = source.SubEntryId;
			if (includedColumns.Contains(MaterialienTable.OriginalMaterialNameCol)) this.OriginalMaterialName = source.OriginalMaterialName;
			if (includedColumns.Contains(MaterialienTable.BlobLengthCol)) this.BlobLength = source.BlobLength;
			if (includedColumns.Contains(MaterialienTable.BlobContentCol)) this.BlobContent = source.BlobContent;
			if (includedColumns.Contains(MaterialienTable.ModifyTimeStampCol)) this.ModifyTimeStamp = source.ModifyTimeStamp;
			if (includedColumns.Contains(MaterialienTable.ProcessingStatusCol)) this.ProcessingStatus = source.ProcessingStatus;
			if (includedColumns.Contains(MaterialienTable.CreatedByCol)) this.CreatedBy = source.CreatedBy;
			if (includedColumns.Contains(MaterialienTable.LastModifiedByCol)) this.LastModifiedBy = source.LastModifiedBy;
			if (includedColumns.Contains(MaterialienTable.AccessRightsIdCol)) this.AccessRightsId = source.AccessRightsId;
			if (includedColumns.Contains(MaterialienTable.LastUpdateTokenCol)) this.LastUpdateToken = source.LastUpdateToken;
		}
Example #58
0
        internal void RenderToTexture(ITexture renderTargetTexture, ITexture sourceTexture, IMaterial material, Color4 color, Color4 backgroundColor, Size?customViewportSize = null, Vector2?customUV1 = null)
        {
            var vs  = customViewportSize ?? ViewportSize;
            var uv1 = customUV1 ?? ProcessedUV1;

            if (ProcessedViewport.Width != vs.Width || ProcessedViewport.Height != vs.Height)
            {
                Renderer.Viewport = ProcessedViewport = new Viewport(0, 0, vs.Width, vs.Height);
            }
            renderTargetTexture.SetAsRenderTarget();
            try {
                Renderer.Clear(backgroundColor);
                Renderer.DrawSprite(sourceTexture, null, material, color, Vector2.Zero, TextureSize, Vector2.Zero, uv1, Vector2.Zero, Vector2.Zero);
            } finally {
                renderTargetTexture.RestoreRenderTarget();
            }
        }
Example #59
0
 public void Ignore(IMaterial material)
 {
     material.MaterialChanged -= OnMaterialChanged;
 }
Example #60
0
 public PlaneFigure(IMatrix transformation, IMaterial material)
 {
     this.Material       = material;
     this.Transformation = transformation;
 }