public void TestInitialize()
        {
            repository = new UserRepository();
            repository.Clear();
            blueprintPortfolio = new BlueprintRepository();
            blueprintPortfolio.Clear();

            conn = new SessionConnector();

            Session session = conn.LogIn("admin", "admin", (IUserRepository)repository);

            administrator = new UserAdministrator(session, repository);

            user1     = new Client("client1N", "client1S", "client1UN", "client1P", "999000111", "dir", "55555555", DateTime.Now);
            user2     = new Client("client2N", "client2S", "client2UN", "client2P", "999000111", "dir", "55555556", DateTime.Now);
            user3     = new Designer("d1", "d1", "designer3", "12345", DateTime.Now);
            user4     = new Designer("designer2N", "designer2S", "designer2UN", "designer2P", DateTime.Now);
            architect = new Architect("Archi", "Tect", "architect", "architect", DateTime.Now);

            materials     = new MaterialContainer();
            blueprintTest = new Blueprint(12, 12, "Blueprint1", materials);
            blueprint2    = new Blueprint(10, 10, "Blueprint2");
            blueprint3    = new Blueprint(11, 11, "Blueprint2");

            blueprintTest.Owner = user1;
            blueprint2.Owner    = user2;
            blueprint3.Owner    = user1;

            administrator.Add(user1);
            administrator.Add(user2);
            administrator.Add(user3);
            administrator.Add(user4);
            administrator.Add(architect);
        }
Esempio n. 2
0
    private void DrawGridOptionsPanel()
    {
        Vector2 matContainerSize = new Vector2(335, 20);

        baseMaterialContainer = (MaterialContainer)EditorGUI.ObjectField(new Rect(screenMiddle - matContainerSize / 2 - new Vector2(0, 70), matContainerSize), "Add a Material container:", baseMaterialContainer, typeof(MaterialContainer));
        // Grid input
        gridDimensions = EditorGUI.Vector2IntField(new Rect(screenMiddle - new Vector2(110, 100) / 2, new Vector2(110, 15)), "Grid dimensions:",
                                                   new Vector2Int(Mathf.Clamp(gridDimensions.x, 0, 25), Mathf.Clamp(gridDimensions.y, 0, 25))); // Clamped to max 10

        // Tile size input
        Vector2 tileSize = new Vector2(110, 30);

        GUILayout.BeginArea(new Rect(screenMiddle - tileSize / 2 + new Vector2(0, tileSize.y / 2), new Vector2(tileSize.x, 160)));
        GUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Tile size (m):", GUILayout.Width(78));
        cellSize = EditorGUILayout.FloatField(cellSize, GUILayout.Width(30));
        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        // Button
        GUILayout.BeginArea(new Rect(screenMiddle - buttonSize / 2 + new Vector2(0, buttonSize.y / 2), new Vector2(buttonSize.x, 160)));
        GUILayout.Space(30);
        if (baseMaterialContainer != null)
        {
            _gridDesign = GUILayout.Button("Generate Grid", buttonParams);
        }
        else
        {
            GUILayout.Button("Generate Grid", buttonParams);
        }
        GUILayout.EndArea();
    }
        public MaterialElem(MaterialContainer c)
        {
            this.container = c;
            Name           = c.Name;

            const string defaultType = "MeshStandardMaterial";
            var          table       = new Dictionary <string, string>()
            {
                { "Standard", "MeshStandardMaterial" },
                { "Standard (Specular setup)", defaultType },
                { "Mobile/Diffuse", "MeshPhongMaterial" },
                { "Mobile/VertexLit", "MeshLambertMaterial" },
                { "Mobile/Bumped Diffuse", "MeshPhongMaterial" },
                { "Mobile/Bumped Specular", "MeshPhongMaterial" },
                { "Unlit/Texture", "MeshBasicMaterial" },
                { "Unlit/Color", "MeshBasicMaterial" },
            };

            var    shadername = c.Material.shader.name;
            string materialname;

            if (table.TryGetValue(shadername, out materialname))
            {
                type = materialname;
            }
            else
            {
                type = defaultType;
            }
        }
Esempio n. 4
0
    // This function is called when a robot is build from a .robi file
    // Initializes required variables (Prefab vars set in editor)
    public void PostBuild()
    {
        physContainer = new List <PhysicalContainer>();
        matContainer  = new List <MaterialContainer>();

        // Get all renderers
        Renderer[] rends = GetComponentsInChildren <Renderer>();
        foreach (Renderer r in rends)
        {
            MaterialContainer m = new MaterialContainer();
            m.modelRend   = r;
            m.defaultMats = r.materials;
            matContainer.Add(m);
        }

        // Get all bodies
        Rigidbody[] bodies = GetComponentsInChildren <Rigidbody>();
        foreach (Rigidbody rb in bodies)
        {
            PhysicalContainer p = new PhysicalContainer();
            p.rigidBody = rb;
            p.collider  = rb.gameObject.GetComponents <Collider>();
            physContainer.Add(p);
        }
    }
        public MaterialElem(MaterialContainer c)
        {
            this.container = c;
            Name = c.Name;

            const string defaultType = "MeshStandardMaterial";
            var table = new Dictionary<string, string>()
            {
                { "Standard", "MeshStandardMaterial" },
                { "Standard (Specular setup)", defaultType },
                { "Mobile/Diffuse", "MeshPhongMaterial" },
                { "Mobile/VertexLit", "MeshLambertMaterial" },
                { "Mobile/Bumped Diffuse", "MeshPhongMaterial" },
                { "Mobile/Bumped Specular", "MeshPhongMaterial" },
                { "Unlit/Texture", "MeshBasicMaterial" },
                { "Unlit/Color", "MeshBasicMaterial" },
            };

            var shadername = c.Material.shader.name;
            string materialname;
            if(table.TryGetValue(shadername, out materialname)) {
                type = materialname;
            } else {
                type = defaultType;
            }
        }
Esempio n. 6
0
    private void Awake()
    {
        MC = GameObject.Find("DataContainer").GetComponent <MaterialContainer>();
        PrefabBlockStat = PrefabBlock;
        Vector3 NewPosition = new Vector3(0, 0, 0);

        CreateBlock(NewPosition, 1);
    }
Esempio n. 7
0
        public void SetUp()
        {
            owner      = new Client("Carl", "Ownerhood", "owner", "owner", "12345", "addd", "1234455", DateTime.Now);
            architect  = new Architect("Manameeh", "Jefferson", "jeff", "12345", DateTime.Now);
            architectA = new Architect("A", "A", "jeffA", "12345", DateTime.Now);
            architectB = new Architect("B", "B", "jeffB", "12345", DateTime.Now);

            materials = new MaterialContainer();
            instance  = new Blueprint(20, 20, "TestBlueprint", materials);
        }
Esempio n. 8
0
        MaterialElem CreateMaterialElem(MaterialContainer n)
        {
            var mtl = new MaterialElem(n);

            mtl.Uuid = n.Guid;

            if (n.MainTexture)
            {
                var instanceId = n.MainTexture.GetInstanceID().ToString();
                mtl.Map = root.SharedNodeTable.Get <TextureElem>(instanceId);
            }

            if (n.BumpMap)
            {
                var instanceId = n.BumpMap.GetInstanceID().ToString();
                mtl.BumpMap = root.SharedNodeTable.Get <TextureElem>(instanceId);
            }

            if (n.DetailNormalMap)
            {
                var uid = n.DetailNormalMap.GetInstanceID().ToString();
                mtl.NormalMap = root.SharedNodeTable.Get <TextureElem>(uid);
            }

            if (n.ParallaxMap)
            {
                var uid = n.ParallaxMap.GetInstanceID().ToString();
                mtl.DisplacementMap = root.SharedNodeTable.Get <TextureElem>(uid);
            }
            if (n.OcclusionMap)
            {
                var uid = n.OcclusionMap.GetInstanceID().ToString();
                mtl.AoMap = root.SharedNodeTable.Get <TextureElem>(uid);
            }
            if (n.EmissionMap)
            {
                var uid = n.EmissionMap.GetInstanceID().ToString();
                mtl.EmissiveMap = root.SharedNodeTable.Get <TextureElem>(uid);
            }

            if (n.MetallicGlossMap)
            {
                var uid = n.MetallicGlossMap.GetInstanceID().ToString();
                mtl.MetalnessMap = root.SharedNodeTable.Get <TextureElem>(uid);
            }

            if (n.SpecGlossMap)
            {
                var uid = n.SpecGlossMap.GetInstanceID().ToString();
                mtl.SpecularMap = root.SharedNodeTable.Get <TextureElem>(uid);
            }

            return(mtl);
        }
        private MaterialContainer BuildUpContainer(ICollection <WallEntity> wallEnts, ICollection <OpeningEntity> openEnts, ICollection <ColumnEntity> colEnts)
        {
            MaterialAndEntityConverter translator = new MaterialAndEntityConverter();

            ICollection <Wall>    walls    = wallEnts.Select(w => translator.EntityToWall(w)).ToList();
            ICollection <Opening> openings = openEnts.Select(o => translator.EntityToOpening(o)).ToList();
            ICollection <ISinglePointComponent> columns = colEnts.Select(c => (ISinglePointComponent)translator.EntityToColumn(c)).ToList();
            MaterialContainer container = new MaterialContainer(walls, openings, columns);

            return(container);
        }
Esempio n. 10
0
    /// <summary>
    /// Transforms the pixel perfect RT to fit the destination camera render texture and blits to the destination.
    /// Uses the camera to figure out the needed parameters to perform the transformation
    /// </summary>
    /// <param name="source">source PPRT</param>
    /// <param name="destination">destination camera render texture</param>
    /// <param name="destinationCamera">camera to use to determine the transformation properties</param>
    /// <param name="materialContainer">container to get the PPRT transform material from to perform the transformation</param>
    public static void Transform(
        PixelPerfectRT source,
        RenderTexture destination,
        Camera destinationCamera,
        MaterialContainer materialContainer)
    {
        materialContainer.PPRTTransformMaterial.SetVector("_Transform", source.GetTransformation(destinationCamera));
        materialContainer.PPRTTransformMaterial.SetTexture("_SourceTex", source.renderTexture);

        Graphics.Blit(source.renderTexture, destination, materialContainer.PPRTTransformMaterial);
    }
Esempio n. 11
0
    /// <summary>
    /// Transforms the pixel perfect RT to fit the destination and blits to the destination.
    /// </summary>
    /// <param name="source">source PPRT</param>
    /// <param name="destination">destination PPRT</param>
    /// <param name="materialContainer">container to get the PPRT transform material from to perform the transformation</param>
    public static void Transform(
        PixelPerfectRT source,
        PixelPerfectRT destination,
        MaterialContainer materialContainer)
    {
        destination.renderPosition = source.renderPosition;

        materialContainer.PPRTTransformMaterial.SetVector("_Transform", source.GetTransformation(destination));
        materialContainer.PPRTTransformMaterial.SetTexture("_SourceTex", source.renderTexture);

        Graphics.Blit(source.renderTexture, destination.renderTexture, materialContainer.PPRTTransformMaterial);
    }
Esempio n. 12
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.R))
        {
            CreateBlock(Vec, Mater);
        }

        if (!MC)
        {
            MC = GameObject.Find("DataContainer").GetComponent <MaterialContainer>();
        }
    }
        public IBlueprint EntityToBlueprint(BlueprintEntity toConvert, ICollection <WallEntity> wallEnts, ICollection <OpeningEntity> openEnts, ICollection <ColumnEntity> colEnts)
        {
            UserAndEntityConverter userEntityConverter = new UserAndEntityConverter();

            User convertedUser = userEntityConverter.ToUser(toConvert.Owner);
            ICollection <Signature> convertedSignatures = GetBlueprintSignatures(toConvert);

            MaterialContainer materials = BuildUpContainer(wallEnts, openEnts, colEnts);

            IBlueprint conversion = new Blueprint(toConvert.Length, toConvert.Width, toConvert.Name, convertedUser, materials, convertedSignatures, toConvert.Id);

            return(conversion);
        }
        void VisitToCreateMaterial_r(GameObject go)
        {
            if (go.GetComponent <Renderer>())
            {
                var material = go.GetComponent <Renderer>().sharedMaterial;
                if (!containerTable.Contains <MaterialContainer>(material.GetInstanceID()))
                {
                    var c = new MaterialContainer(material);
                    containerTable.Add(c.InstanceId, c);
                }
            }

            for (int i = 0; i < go.transform.childCount; i++)
            {
                VisitToCreateMaterial_r(go.transform.GetChild(i).gameObject);
            }
        }
Esempio n. 15
0
        public MaterialElem(MaterialContainer c)
        {
            this.container = c;
            Transparent    = false;
            Name           = c.Name;

            materialType = PredefinedMaterialTable[0];
            var shadername = c.Material.shader.name;

            foreach (var mtl in PredefinedMaterialTable)
            {
                if (mtl.from == shadername)
                {
                    materialType = mtl;
                    break;
                }
            }
        }
        public void Add(GameObject go)
        {
            // containers
            VisitToCreateLightmap();
            VisitToCreateMesh_r(go);
            VisitToCreateMaterial_r(go);
            VisitToCreateTexture(containerTable.GetEnumerable <MaterialContainer>());

            // game object
            VisitToCreateGameObjectNode_r(go);

            // nodes - for component
            VisitToCreateNode_r <Camera, CameraNode>(go);
            VisitToCreateNode_r <Light, LightNode>(go);
            VisitToCreateRenderNode_r(go);
            VisitToCreateScriptNode_r(go);

            // script variable에서 참조하는 객체

            foreach (var node in graphNodeTable.GetEnumerable <ScriptNode>())
            {
                foreach (var val in node.VariableEnumerable)
                {
                    Material mtl = val.GetMaterial();
                    if (mtl && !containerTable.Contains <MaterialContainer>(mtl.GetInstanceID().ToString()))
                    {
                        var c = new MaterialContainer(mtl);
                        containerTable.Add(c.InstanceId, c);
                    }

                    Texture tex = val.GetTexture();
                    if (tex && !containerTable.Contains <TextureContainer>(tex.GetInstanceID().ToString()))
                    {
                        var c = new TextureContainer(tex);
                        containerTable.Add(c.InstanceId, c);
                    }
                }
            }
            // 새로운 material이 추가되면 연관된 texture가 생겼을지 모른다
            VisitToCreateTexture(containerTable.GetEnumerable <MaterialContainer>());
        }
Esempio n. 17
0
        void RegisterMaterial(MaterialContainer n)
        {
            // 유니티에서는 lightmap 정보가 renderer에 붙지만
            // three.js에서는 material에 들어간다.
            // 그래서 material의 경우는 1:1로 매핑하는게 불가능하다.
            // 그래서 같은 material에 대해서 라이트맵별로 재질을 만들어서 등록했다.
            // (라이트맵이 없는 재질도 등록)

            /*
             * for (int i = -1; i < LightmapSettings.lightmaps.Length; i++) {
             *  // lightmap
             *  if (i >= 0) {
             *      var lightmapNode = new LightmapNode(i, n.Scene);
             *      mtl.LightMapNode = lightmapTextureTable[i];
             *      lightmapMaterialTable[i] = mtl;
             *  }
             * }
             */

            var mtl = new MaterialElem(n);

            root.SharedNodeTable.Add(mtl, n.InstanceId);

            if (n.MainTexture)
            {
                var instanceId = n.MainTexture.GetInstanceID();
                mtl.Map = root.SharedNodeTable.Get <TextureElem>(instanceId);
            }

            if (n.BumpMap)
            {
                var instanceId = n.BumpMap.GetInstanceID();
                mtl.BumpMap = root.SharedNodeTable.Get <TextureElem>(instanceId);
            }

            if (n.DetailNormalMap)
            {
                var uid = n.DetailNormalMap.GetInstanceID();
                mtl.NormalMap = root.SharedNodeTable.Get <TextureElem>(uid);
            }

            if (n.ParallaxMap)
            {
                var uid = n.ParallaxMap.GetInstanceID();
                mtl.DisplacementMap = root.SharedNodeTable.Get <TextureElem>(uid);
            }
            if (n.OcclusionMap)
            {
                var uid = n.OcclusionMap.GetInstanceID();
                mtl.AoMap = root.SharedNodeTable.Get <TextureElem>(uid);
            }
            if (n.EmissionMap)
            {
                var uid = n.EmissionMap.GetInstanceID();
                mtl.EmissiveMap = root.SharedNodeTable.Get <TextureElem>(uid);
            }

            if (n.MetallicGlossMap)
            {
                var uid = n.MetallicGlossMap.GetInstanceID();
                mtl.MetalnessMap = root.SharedNodeTable.Get <TextureElem>(uid);
            }

            if (n.SpecGlossMap)
            {
                var uid = n.SpecGlossMap.GetInstanceID();
                mtl.SpecularMap = root.SharedNodeTable.Get <TextureElem>(uid);
            }
        }
        private void CreateMaterialBlobs()
        {
            ArrayList newMaterialTier = new ArrayList();
            //materialTiers.Add(newMaterialTier);
            materialTiers.Insert(0, newMaterialTier);

            Dictionary<string, int> materialTally = bookshelf.Library.GetMaterialsTally(materialConstraints);
            int maxTallyCount = 0;
            int totalTallyCount = 0;

            // find the maxTallyCount
            foreach (int tally in materialTally.Values)
            {
                if (maxTallyCount < tally)
                {
                    maxTallyCount = tally;
                }
                totalTallyCount += tally;
            }

            float smoothedTallyTotal = 0;
            // compute the total tally after smoothing (sqrt)
            foreach (int i in materialTally.Values)
            {
                smoothedTallyTotal += (float)Math.Sqrt(Math.Sqrt((double)i));
            }

            // create a circle for each material, and scale it's size based on maxTallyCount
            foreach (string materialName in materialTally.Keys)
            {
                float size = (float)(Math.Sqrt(Math.Sqrt((float)((int)materialTally[materialName]))) / smoothedTallyTotal);
                float radius = 0.25f * size;
                //float size = (float)((int)materialTally[materialName]) / (float)totalTallyCount;
                //float radius = 0.04f * (float)Math.Sqrt(Math.Sqrt(size));

                // create a new blob as a circle for the time being
                MaterialContainer newContainer = new MaterialContainer();
                if (materialTextures[materialName] == null)
                {
                    //newContainer.Blob = new SelectableBlob(new Vector2(center.X, center.Y), 0, (Color)materialColors[materialName], null);
                    newContainer.Blob = new SelectableBlob(new Vector2(center.X, center.Y), 0, radius, 0, 0.005f,
                        (Color)materialColors[materialName], XNA.DarkenColor((Color)materialColors[materialName], 0.75f), XNA.DarkenColor((Color)materialColors[materialName], 0.5f), null);
                }
                else
                {
                    //newContainer.Blob = new SelectableBlob(new Vector2(center.X, center.Y), 0, Color.White, (Texture2D)materialTextures[materialName]);
                    newContainer.Blob = new SelectableBlob(new Vector2(center.X, center.Y), 0, 0, 0, 10,
                        Color.White, Color.DarkGray, Color.DarkGray, (Texture2D)materialTextures[materialName]);
                }
                //^ set the edge thickness above
                //newContainer.Blob.SetBorderColors(XNA.DarkenColor(newContainer.Blob.Color, 0.75f), XNA.DarkenColor(newContainer.Blob.Color, 0.25f));
                newContainer.Blob.TouchReleased += new TouchReleaseEventHandler(Blob_TouchReleased);
                newContainer.Name = materialName;
                newContainer.Proportion = size;
                newContainer.Angle = 0;
                newContainer.StartKey = new AnimationParameter();
                newContainer.EndKey = new AnimationParameter();
                // add the blob to the selectable objects list
                bookshelf.SelectableObjects.AddObject(newContainer.Blob);
                //SelectableEllipse newBlob = new SelectableEllipse(Vector2.Zero, radius, 0, Color.Red, Color.Black, null);
                newMaterialTier.Add(newContainer);
            }
        }
Esempio n. 19
0
 public void TestInitialize()
 {
     instance = new MaterialContainer();
 }
Esempio n. 20
0
 void Awake()
 {
     Instance = this;
 }
Esempio n. 21
0
        private void CreateMaterialBlobs()
        {
            Dictionary<Material, int> materialTally = bookshelf.Library.GetMaterialsTally(materialConstraints);
            int maxTallyCount = 0;
            int totalTallyCount = 0;

            // find the maxTallyCount
            foreach (int tally in materialTally.Values)
            {
                if (maxTallyCount < tally)
                {
                    maxTallyCount = tally;
                }
                totalTallyCount += tally;
            }

            float smoothedTallyTotal = 0;
            // compute the total tally after smoothing (sqrt)
            foreach (int i in materialTally.Values)
            {
                smoothedTallyTotal += (float)Math.Sqrt(Math.Sqrt((double)i));
            }

            // create a circle for each material, and scale it's size based on maxTallyCount
            foreach (Material material in materialTally.Keys)
            {
                // sqrt(sqrt(tally)) / sum[i from 0 to n, sqrt(sqrt(i))] (see above)
                // this is the "smoothing function" that we apply to the material tally
                // some materials have only several occurences while others have hundreds
                // this function puts the size of a materials on the same order of magnitude
                float mSize = (float)(Math.Sqrt(Math.Sqrt((float)((int)materialTally[material]))) / smoothedTallyTotal);
                float radius = 0.25f * mSize;

                MaterialContainer newContainer = new MaterialContainer();
                /* we don't use textures, so skip this code
                // create a new blob as a circle for the time being
                if (materialTextures[materialName] == null)
                {
                    //newContainer.Blob = new SelectableBlob(new Vector2(center.X, center.Y), 0, (Color)materialColors[materialName], null);
                    newContainer.Blob = new SelectableBlob(new Vector2(center.X, center.Y), 0, radius, 0, 0.005f,
                        (Color)materialColors[materialName], XNA.DarkenColor((Color)materialColors[materialName], 0.75f), XNA.DarkenColor((Color)materialColors[materialName], 0.5f), null);
                }
                else
                {
                    //newContainer.Blob = new SelectableBlob(new Vector2(center.X, center.Y), 0, Color.White, (Texture2D)materialTextures[materialName]);
                    newContainer.Blob = new SelectableBlob(new Vector2(center.X, center.Y), 0, 0, 0, 10,
                        Color.White, Color.DarkGray, Color.DarkGray, (Texture2D)materialTextures[materialName]);
                }
                //*/

                newContainer.Blob = new SelectableBlob(circleCenter, 0, radius, BORDER_RADIUS + radius, 0.0025f,
                    (Color)materialColors[material], XNA.DarkenColor((Color)materialColors[material], 0.75f), XNA.DarkenColor((Color)materialColors[material], 0.5f), null);

                //^ set the edge thickness above
                //newContainer.Blob.SetBorderColors(XNA.DarkenColor(newContainer.Blob.Color, 0.75f), XNA.DarkenColor(newContainer.Blob.Color, 0.25f));
                newContainer.Blob.TouchReleased += new TouchReleaseEventHandler(Blob_TouchReleased);
                newContainer.Proportion = mSize;
                newContainer.Angle = 0;
                newContainer.Material = material;
                newContainer.StartKey = new AnimationParameter();
                newContainer.EndKey = new AnimationParameter();

                newContainer.TextArray = new SelectableText[2] { new SelectableText(XNA.Font, material.PrimaryArray[Artifact.LANGUAGE_ENGLISH], new Vector3(0, 0, 0), Color.Black, Color.White),
                    new SelectableText(XNA.Font, material.PrimaryArray[Artifact.LANGUAGE_FRENCH], new Vector3(0, 0, 0), Color.Black, Color.White) };
                newContainer.TextArray[Artifact.LANGUAGE_ENGLISH].InverseScale(0.5f, size.X, size.Y);
                newContainer.TextArray[Artifact.LANGUAGE_FRENCH].InverseScale(0.5f, size.X, size.Y);

                // add the blob to the selectable objects list
                bookshelf.SelectableObjects.AddObject(newContainer.Blob);
                //SelectableEllipse newBlob = new SelectableEllipse(Vector2.Zero, radius, 0, Color.Red, Color.Black, null);
                materialList.Add(newContainer);
            }
        }
Esempio n. 22
0
 public void Visit(MaterialContainer n)
 {
     report.Info("## InstanceId: " + n.InstanceId);
     report.Info("Name: " + n.Name);
 }
Esempio n. 23
0
 public PostProcessingStack(MaterialContainer iMaterialContainer)
 {
     mMaterialContainer = iMaterialContainer;
 }
Esempio n. 24
0
    private void Awake()
    {
        instance = this;

        materialList.MaterialGenerator();
    }