Example #1
0
        public void AddNewUserAndOrder()
        {
            Console.WriteLine("Name of product: ");
            string productName = Console.ReadLine();

            Console.WriteLine("Customer: ");
            string customerName = Console.ReadLine();

            Console.WriteLine("Batch size: ");
            string batchSizeString = Console.ReadLine();
            int    orderBatchSize  = int.Parse(batchSizeString);

            Console.WriteLine("What type is this product?\n" +
                              "1. Bread\n" +
                              "2. Cake\n" +
                              "3. Pastery\n" +
                              "4. Pies\n");
            string   typeAsString = Console.ReadLine();
            int      typeAsInt    = int.Parse(typeAsString);
            BakeType type         = (BakeType)typeAsInt;

            decimal orderCost = OrderCostMethod(type, orderBatchSize);

            ProductContent product = new ProductContent(productName, customerName, orderBatchSize, orderCost, type);

            _productRepo.AddToList(product);
        }
Example #2
0
 public Product(string productname, string customername, int orderbatchsize, BakeType type, decimal ordercost)
 {
     ProductName    = productname;
     CustomerName   = customername;
     OrderBatchSize = orderbatchsize;
     OrderCost      = ordercost;
 }
        public decimal CalculateProductOrder(BakeType type)
        {
            decimal orderTotal = 100m;

            switch (type)
            {
            case BakeType.Bread:
                orderTotal += 500.01m;
                break;

            case 2:
                type = BakeType.Cake;
                break;

            case 3:
                type = BakeType.Pastery;
                break;

            case 4:
                type = BakeType.Pie;
                break;
            }


            return(orderTotal);
        }
Example #4
0
    void Bake(Mesh m, int blendShapeID, BakeType type, int dest)
    {
        List <Vector3> normals = new List <Vector3>();

        m.GetNormals(normals);
        List <Vector4> tangents = new List <Vector4>();

        m.GetTangents(tangents);
        Vector3[] deltaPositions = new Vector3[m.vertexCount];
        Vector3[] deltaNormals   = new Vector3[m.vertexCount];
        Vector3[] deltaTangents  = new Vector3[m.vertexCount];
        m.GetBlendShapeFrameVertices(blendShapeID, 0, deltaPositions, deltaNormals, deltaTangents);
        List <Vector3> uv = new List <Vector3>();

        switch (type)
        {
        case BakeType.DeltaPosition:
            for (int i = 0; i < m.vertexCount; i++)       // We bake positions using the normals and tangents as an orthogonal basis.
            {
                Vector3 XYZ = ToTangentSpace(deltaPositions[i], normals[i], tangents[i]);
                uv.Add(XYZ);
            }
            break;
        }

        m.SetUVs(dest, uv);
    }
Example #5
0
        private Dictionary <BakeType, Primitive.TextureEntryFace> GetBakedTextureFaces(ScenePresence sp)
        {
            if (sp.IsChildAgent)
            {
                return(new Dictionary <BakeType, Primitive.TextureEntryFace>());
            }

            Dictionary <BakeType, Primitive.TextureEntryFace> bakedTextures
                = new Dictionary <BakeType, Primitive.TextureEntryFace>();

            AvatarAppearance appearance = sp.Appearance;

            Primitive.TextureEntryFace[] faceTextures = appearance.Texture.FaceTextures;

            foreach (int i in Enum.GetValues(typeof(BakeType)))
            {
                BakeType bakeType = (BakeType)i;

                if (bakeType == BakeType.Unknown)
                {
                    continue;
                }

//                m_log.DebugFormat(
//                    "[AVFACTORY]: NPC avatar {0} has texture id {1} : {2}",
//                    acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]);

                int ftIndex = (int)AppearanceManager.BakeTypeToAgentTextureIndex(bakeType);
                Primitive.TextureEntryFace texture = faceTextures[ftIndex];    // this will be null if there's no such baked texture
                bakedTextures[bakeType] = texture;
            }

            return(bakedTextures);
        }
Example #6
0
        public void UpdateOrder(string userInput, ProductContent product)
        {
            List <ProductContent> contentList = _productRepo.GetProductList();

            switch (userInput)
            {
            case "Y":

                Console.WriteLine("Here are your options: \n" +
                                  "1. Change product name.\n" +
                                  "2. Change customer name.\n" +
                                  "3. Change batch size.\n" +
                                  "4. Change order cost\n" +
                                  "5. Change bake type.\n");
                string userResponse       = Console.ReadLine();
                int    userNumberResponse = int.Parse(userResponse);
                switch (userNumberResponse)
                {
                case 1:
                    Console.WriteLine("Enter product new name: ");
                    product.ProductName = Console.ReadLine();
                    break;

                case 2:
                    Console.WriteLine("Enter customer new name: ");
                    product.CustomerName = Console.ReadLine();
                    break;

                case 3:
                    Console.WriteLine("Enter new batch size: ");
                    string batchSize    = Console.ReadLine();
                    int    batchSizeInt = int.Parse(batchSize);
                    product.OrderBatchSize = batchSizeInt;
                    break;

                case 4:
                    Console.WriteLine("Enter new order cost: ");
                    string orderCost      = Console.ReadLine();
                    int    orderCostAsInt = int.Parse(orderCost);
                    product.OrderCost = orderCostAsInt;
                    break;

                case 5:
                    Console.WriteLine("What would you like to change the type to?\n" +
                                      "1. Bread\n" +
                                      "2. Cake\n" +
                                      "3. Pastery\n" +
                                      "4. Pies\n");
                    string   typeAsString = Console.ReadLine();
                    int      typeAsInt    = int.Parse(typeAsString);
                    BakeType type         = (BakeType)typeAsInt;
                    product.Type = type;
                    break;
                }
                break;

            case "N":
                break;
            }
        }
Example #7
0
        public decimal OrderCostMethod(BakeType type, int orderBatchSize)
        {
            decimal initialCharge = 100m;

            switch (type)
            {
            case BakeType.Bread:
                decimal total = 500.01m * orderBatchSize;
                initialCharge += total;
                break;

            case BakeType.Cake:
                decimal total2 = 2000m * orderBatchSize;
                initialCharge += total2;
                break;

            case BakeType.Pastery:
                decimal total3 = 200.10m * orderBatchSize;
                initialCharge += total3;
                break;

            case BakeType.Pies:
                decimal total4 = 851.5m * orderBatchSize;
                initialCharge += total4;
                break;
            }
            return(initialCharge);
        }
Example #8
0
 public ProductContent(string productName, string customerName, int orderBatchSize, BakeType type)
 {
     ProductName    = productName;
     CustomerName   = customerName;
     OrderBatchSize = orderBatchSize;
     Type           = type;
 }
Example #9
0
 public Product(string productName, BakeType bakeType, int batchOrder, string RiskName, decimal orderCost)
 {
     ProductName    = productName;
     BakeType       = bakeType;
     OrderBatchSize = batchOrder;
     RiskName       = RiskName;
     OrderCost      = orderCost;
 }
Example #10
0
 public Product(string productName, BakeType bakeType, int batchOrder, string customerName, decimal orderCost)
 {
     ProductName    = productName;
     BakeType       = bakeType;
     OrderBatchSize = batchOrder;
     CustomerName   = customerName;
     OrderCost      = orderCost;
 }
 public Product(BakeType type, string productName, string customerName, int orderBatchSize, decimal orderCost)
 {
     Type           = type;
     ProductName    = productName;
     CustomerName   = customerName;
     OrderBatchSize = orderBatchSize;
     OrderCost      = orderCost;
 }
        private BakeType GetBakeType()
        {
            Console.WriteLine("Bake Type: 1. Bread\n\t" +
                              "2. Cake\n\t" +
                              "3. Pastery\n\t" +
                              "4. Pie\n\t");
            BakeType bakeType = (BakeType)int.Parse(Console.ReadLine());

            return(bakeType);
        }
Example #13
0
 public Product(int orderNumber, string firstName, string lastName, string productName, BakeType bakeType, int batchSize)
 {
     OrderNumber      = orderNumber;
     FirstName        = firstName;
     LastName         = lastName;
     ProductName      = productName;
     BakeType         = bakeType;
     BatchSize        = batchSize;
     CustomerFullName = $"{firstName} {lastName}";
     OrderCost        = SetOrderCost();
 }
Example #14
0
        public void ValueFromSwitchCorrect()
        {
            ProductRepository repo      = new ProductRepository();
            Product           bakedGood = new Product();
            BakeType          product   = BakeType.Bread;

            decimal actualCost   = repo.CostOfCart(product);
            decimal expectedCost = 600.01m;

            Assert.AreEqual(actualCost, expectedCost);
        }
Example #15
0
        public void ProductRepository_CalculateCost_ShouldBeCorrectDecimal()
        {
            //Arrange
            ProductRepository _productRepo = new ProductRepository();
            BakeType          product      = BakeType.Pastery;

            //Act
            decimal actual   = _productRepo.CalculateCost(product);
            decimal expected = 300.10m;

            //Assert
            Assert.AreEqual(expected, actual);
        }
        public List <Product> GetProducts(BakeType bakeType)
        {
            List <Product> products = new List <Product>();

            foreach (Product product in _products)
            {
                if (bakeType == product.BakeType)
                {
                    products.Add(product);
                }
            }
            return(products);
        }
        public decimal Costs(BakeType type)
        {
            decimal bakingCosts = 100m;

            switch (type)
            {
            case BakeType.Bread:
                bakingCosts += 500.01m;
                break;

            case BakeType.Cake:
                bakingCosts += 2000m;
                break;

            case BakeType.Pastry:
                bakingCosts += 200.10m;
                break;

            case BakeType.Pies:
                bakingCosts += 851.50m;
                break;
            }
            return(bakingCosts);


            //if (type == BakeType.Bread)
            //{
            //    decimal actualBakingCosts = bakingCosts + 500.01m;
            //    return actualBakingCosts;
            //}
            //else if (type == BakeType.Cake)
            //{
            //    decimal actualBakingCosts = bakingCosts + 2000m;
            //    return actualBakingCosts;
            //}
            //else if (type == BakeType.Pastry)
            //{
            //    decimal actualBakingCosts = bakingCosts + 200.10m;
            //    return actualBakingCosts;
            //}
            //else if (type == BakeType.Pies)
            //{
            //    decimal actualBakingCosts = bakingCosts + 851.50m;
            //    return actualBakingCosts;
            //}
            //else
            //{
            //    decimal actualBakingCosts = bakingCosts;
            //    return actualBakingCosts;
            //}
        }
Example #18
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="bakeType">Bake type</param>
        public Baker(BakeType bakeType)
        {
            this.bakeType = bakeType;

            if (bakeType == BakeType.Eyes)
            {
                bakeWidth = 128;
                bakeHeight = 128;
            }
            else
            {
                bakeWidth = 512;
                bakeHeight = 512;
            }
        }
Example #19
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="bakeType">Bake type</param>
        public Baker(BakeType bakeType)
        {
            this.bakeType = bakeType;

            if (bakeType == BakeType.Eyes)
            {
                bakeWidth  = 128;
                bakeHeight = 128;
            }
            else
            {
                bakeWidth  = 512;
                bakeHeight = 512;
            }
        }
Example #20
0
        private void AddOrderList()
        {
            Console.WriteLine("What would you like to order?\n" +
                              "1. Bread\n" +
                              "2. Cake\n" +
                              "3. Pastry" +
                              "4. Pie");

            string inputAsString = Console.ReadLine();
            int    input         = int.Parse(inputAsString);

            BakeType type = BakeType.Bread;

            switch (input)
            {
            case 1:
                type = BakeType.Bread;
                break;

            case 2:
                type = BakeType.Cake;
                break;

            case 3:
                type = BakeType.Pastery;
                break;

            case 4:
                type = BakeType.Pie;
                break;
            }
            decimal cost = _productRepo.CalculateProductOrder(type);

            Console.WriteLine("Enter amount of order here:");
            string breadAsString = Console.ReadLine();
            int    bread         = int.Parse(breadAsString);

            Product newProduct = new Product(productName, customerName, type, cost);

            _productRepo.AddProductToList(newProduct);
        }
        private void AddNewOrder()
        {
            int orderNumber = ParseIntegerInput("Order Number: ");

            string firstName = GetUserInputAsString("First Name: ");

            string lastName = GetUserInputAsString("Last Name: ");

            BakeType bakeType = GetBakeType();

            string productName = GetUserInputAsString("Product Name: ");

            int batchSize = ParseIntegerInput("Order Amount: ");

            Product product = new Product(orderNumber, firstName, lastName, productName, bakeType, batchSize);

            _productRepo.AddProductToList(product);

            Console.WriteLine($"Order was successful! \n\t {product.ToString()}");

            Pause();
        }
Example #22
0
    void Bake(Mesh m, int blendShapeID, BakeType type, int dest, int packID, BakeAttribute bakeAttribute)
    {
        List <Vector3> normals = new List <Vector3>();

        m.GetNormals(normals);
        List <Vector4> tangents = new List <Vector4>();

        m.GetTangents(tangents);
        Vector3[] deltaPositions = new Vector3[m.vertexCount];
        Vector3[] deltaNormals   = new Vector3[m.vertexCount];
        Vector3[] deltaTangents  = new Vector3[m.vertexCount];
        m.GetBlendShapeFrameVertices(blendShapeID, 0, deltaPositions, deltaNormals, deltaTangents);

        Vector3[] pdeltaPositions = new Vector3[m.vertexCount];
        Vector3[] pdeltaNormals   = new Vector3[m.vertexCount];
        Vector3[] pdeltaTangents  = new Vector3[m.vertexCount];
        m.GetBlendShapeFrameVertices(packID, 0, pdeltaPositions, pdeltaNormals, pdeltaTangents);
        List <Vector4> uv = new List <Vector4>();

        switch (type)
        {
        case BakeType.DeltaPosition:
            for (int i = 0; i < m.vertexCount; i++)       // We bake positions using the normals and tangents as an orthogonal basis.
            {
                Vector3 XYZ     = ToTangentSpace(deltaPositions[i], normals[i], tangents[i]);
                Vector3 packrat = ToTangentSpace(pdeltaPositions[i], normals[i], tangents[i]);
                switch (bakeAttribute)
                {
                case BakeAttribute.X: uv.Add(new Vector4(XYZ.x, XYZ.y, XYZ.z, packrat.x)); break;

                case BakeAttribute.Y: uv.Add(new Vector4(XYZ.x, XYZ.y, XYZ.z, packrat.y)); break;

                case BakeAttribute.Z: uv.Add(new Vector4(XYZ.x, XYZ.y, XYZ.z, packrat.z)); break;
                }
            }
            break;
        }
        m.SetUVs(dest, uv);
    }
        public void ProductContentObject()
        {
            ProductContent content = new ProductContent();

            content.CustomerName = "Ben";
            string expected = "Ben";

            Assert.AreEqual(expected, content.CustomerName);

            ProductContent contentTwo = new ProductContent("Blue Bread", "Ben", 16, 20.0m, BakeType.Bread);

            string   expectedProduct   = "Blue Bread";
            string   expectedName      = "Ben";
            int      expectedOrderSize = 16;
            decimal  expectedCost      = 20.0m;
            BakeType expectedType      = BakeType.Bread;

            Assert.AreEqual(expectedProduct, contentTwo.ProductName);
            Assert.AreEqual(expectedName, contentTwo.CustomerName);
            Assert.AreEqual(expectedOrderSize, contentTwo.OrderBatchSize);
            Assert.AreEqual(expectedCost, contentTwo.OrderCost);
            Assert.AreEqual(expectedType, contentTwo.Type);
        }
        public decimal CalculateCost(BakeType type)
        {
            decimal totalCost = 100m;

            switch (type)
            {
            case BakeType.Bread:
                totalCost += 500.01m;
                break;

            case BakeType.Cake:
                totalCost += 2000m;
                break;

            case BakeType.Pastery:
                totalCost += 200.10m;
                break;

            case BakeType.Pie:
                totalCost += 851.50m;
                break;
            }
            return(totalCost);
        }
        public bool RemoveProductBySpecifications(string RiskName, string productName, BakeType type)
        {
            bool successful = false;

            foreach (Product product in _products)
            {
                if (product.RiskName == RiskName && product.ProductName == productName && product.BakeType == type)
                {
                    RemoveOrderedProduct(product);
                    successful = true;
                    break;
                }
            }
            return(successful);
        }
 /// <summary>
 /// Gives the layer number that is used for morph mask
 /// </summary>
 /// <param name="bakeType">>A BakeType</param>
 /// <returns>Which layer number as defined in BakeTypeToTextures is used for morph mask</returns>
 public static AvatarTextureIndex MorphLayerForBakeType(BakeType bakeType)
 {
     // Indexes return here correspond to those returned
     // in BakeTypeToTextures(), those two need to be in sync.
     // Which wearable layer is used for morph is defined in avatar_lad.xml
     // by looking for <layer> that has <morph_mask> defined in it, and
     // looking up which wearable is defined in that layer. Morph mask
     // is never combined, it's always a straight copy of one single clothing
     // item's alpha channel per bake.
     switch (bakeType)
     {
         case BakeType.Head:
             return AvatarTextureIndex.Hair; // hair
         case BakeType.UpperBody:
             return AvatarTextureIndex.UpperShirt; // shirt
         case BakeType.LowerBody:
             return AvatarTextureIndex.LowerPants; // lower pants
         case BakeType.Skirt:
             return AvatarTextureIndex.Skirt; // skirt
         case BakeType.Hair:
             return AvatarTextureIndex.Hair; // hair
         default:
             return AvatarTextureIndex.Unknown;
     }
 }
        /// <summary>
        /// Converts a BakeType to a list of the texture slots that make up that bake
        /// </summary>
        /// <param name="bakeType">A BakeType</param>
        /// <returns>A list of texture slots that are inputs for the given bake</returns>
        public static List<AvatarTextureIndex> BakeTypeToTextures(BakeType bakeType)
        {
            List<AvatarTextureIndex> textures = new List<AvatarTextureIndex>();

            switch (bakeType)
            {
                case BakeType.Head:
                    textures.Add(AvatarTextureIndex.HeadBodypaint);
                    textures.Add(AvatarTextureIndex.HeadTattoo);
                    textures.Add(AvatarTextureIndex.Hair);
                    textures.Add(AvatarTextureIndex.HeadAlpha);
                    break;
                case BakeType.UpperBody:
                    textures.Add(AvatarTextureIndex.UpperBodypaint);
                    textures.Add(AvatarTextureIndex.UpperTattoo);
                    textures.Add(AvatarTextureIndex.UpperGloves);
                    textures.Add(AvatarTextureIndex.UpperUndershirt);
                    textures.Add(AvatarTextureIndex.UpperShirt);
                    textures.Add(AvatarTextureIndex.UpperJacket);
                    textures.Add(AvatarTextureIndex.UpperAlpha);
                    break;
                case BakeType.LowerBody:
                    textures.Add(AvatarTextureIndex.LowerBodypaint);
                    textures.Add(AvatarTextureIndex.LowerTattoo);
                    textures.Add(AvatarTextureIndex.LowerUnderpants);
                    textures.Add(AvatarTextureIndex.LowerSocks);
                    textures.Add(AvatarTextureIndex.LowerShoes);
                    textures.Add(AvatarTextureIndex.LowerPants);
                    textures.Add(AvatarTextureIndex.LowerJacket);
                    textures.Add(AvatarTextureIndex.LowerAlpha);
                    break;
                case BakeType.Eyes:
                    textures.Add(AvatarTextureIndex.EyesIris);
                    textures.Add(AvatarTextureIndex.EyesAlpha);
                    break;
                case BakeType.Skirt:
                    textures.Add(AvatarTextureIndex.Skirt);
                    break;
                case BakeType.Hair:
                    textures.Add(AvatarTextureIndex.Hair);
                    textures.Add(AvatarTextureIndex.HairAlpha);
                    break;
            }

            return textures;
        }
 /// <summary>
 /// Converts a BakeType to the corresponding baked texture slot in AvatarTextureIndex
 /// </summary>
 /// <param name="index">A BakeType</param>
 /// <returns>The AvatarTextureIndex slot that holds the given BakeType</returns>
 public static AvatarTextureIndex BakeTypeToAgentTextureIndex(BakeType index)
 {
     switch (index)
     {
         case BakeType.Head:
             return AvatarTextureIndex.HeadBaked;
         case BakeType.UpperBody:
             return AvatarTextureIndex.UpperBaked;
         case BakeType.LowerBody:
             return AvatarTextureIndex.LowerBaked;
         case BakeType.Eyes:
             return AvatarTextureIndex.EyesBaked;
         case BakeType.Skirt:
             return AvatarTextureIndex.SkirtBaked;
         case BakeType.Hair:
             return AvatarTextureIndex.HairBaked;
         default:
             return AvatarTextureIndex.Unknown;
     }
 }
        /// <summary>
        /// Get a list of all of the textures that need to be downloaded for a
        /// single bake layer
        /// </summary>
        /// <param name="bakeType">Bake layer to get texture AssetIDs for</param>
        /// <returns>A list of texture AssetIDs to download</returns>
        private List<UUID> GetTextureDownloadList(BakeType bakeType)
        {
            List<AvatarTextureIndex> indices = BakeTypeToTextures(bakeType);
            List<UUID> textures = new List<UUID>();

            for (int i = 0; i < indices.Count; i++)
            {
                AvatarTextureIndex index = indices[i];

                if (index == AvatarTextureIndex.Skirt && !Wearables.ContainsKey(WearableType.Skirt))
                    continue;

                AddTextureDownload(index, textures);
            }

            return textures;
        }
        /// <summary>
        /// Blocking method to create and upload a baked texture for a single 
        /// bake layer
        /// </summary>
        /// <param name="bakeType">Layer to bake</param>
        /// <returns>True on success, otherwise false</returns>
        private bool CreateBake(BakeType bakeType)
        {
            List<AvatarTextureIndex> textureIndices = BakeTypeToTextures(bakeType);
            Baker oven = new Baker(bakeType);

            for (int i = 0; i < textureIndices.Count; i++)
            {
                AvatarTextureIndex textureIndex = textureIndices[i];
                TextureData texture = Textures[(int)textureIndex];
                texture.TextureIndex = textureIndex;

                oven.AddTexture(texture);
            }

            int start = Environment.TickCount;
            oven.Bake();
            Logger.DebugLog("Baking " + bakeType + " took " + (Environment.TickCount - start) + "ms");

            UUID newAssetID = UUID.Zero;
            int retries = UPLOAD_RETRIES;

            while (newAssetID == UUID.Zero && retries > 0)
            {
                newAssetID = UploadBake(oven.BakedTexture.AssetData);
                --retries;
            }

            Textures[(int)BakeTypeToAgentTextureIndex(bakeType)].TextureID = newAssetID;

            if (newAssetID == UUID.Zero)
            {
                Logger.Log("Failed uploading bake " + bakeType, Helpers.LogLevel.Warning);
                return false;
            }

            return true;
        }
Example #31
0
    void Bake(int blendShapeID, BakeType type, int dest)
    {
        Mesh m = mesh.sharedMesh;

        if (!m)
        {
            throw new UnityException("Bad mesh.");
        }
        List <Vector3> normals = new List <Vector3> ();

        m.GetNormals(normals);
        List <Vector4> tangents = new List <Vector4> ();

        m.GetTangents(tangents);
        Vector3[] deltaPositions = new Vector3[m.vertexCount];
        Vector3[] deltaNormals   = new Vector3[m.vertexCount];
        Vector3[] deltaTangents  = new Vector3[m.vertexCount];
        m.GetBlendShapeFrameVertices(blendShapeID, 0, deltaPositions, deltaNormals, deltaTangents);
        List <Vector3> uv = new List <Vector3> ();

        switch (type)
        {
        case BakeType.DeltaPosition:
            for (int i = 0; i < m.vertexCount; i++)               // We bake positions using the normals and tangents as an orthogonal basis.
            {
                Vector3 DP = deltaPositions [i];
                Vector3 X  = normals [i];
                Vector3 Y  = new Vector3(tangents [i].x, tangents [i].y, tangents [i].z);
                Vector3 Z  = Vector3.Cross(X, Y);
                Vector3.OrthoNormalize(ref X, ref Y, ref Z);
                Matrix4x4 toNewSpace = new Matrix4x4();
                toNewSpace.SetRow(0, X);
                toNewSpace.SetRow(1, Y);
                toNewSpace.SetRow(2, Z);
                toNewSpace [3, 3] = 1.0F;
                Vector3 XYZ = toNewSpace.MultiplyPoint(DP);
                uv.Add(XYZ);
            }
            break;

        case BakeType.DeltaNormal:
            for (int i = 0; i < m.vertexCount; i++)
            {
                uv.Add(deltaNormals [i]);
            }
            break;

        case BakeType.DeltaTangent:
            for (int i = 0; i < m.vertexCount; i++)
            {
                uv.Add(deltaTangents [i]);
            }
            break;
        }
        if (dest <= 3)
        {
            m.SetUVs(dest, uv);
        }
        else if (dest == 4)             // There is no uv destination higher than 3! But we can sneak a vec3 into uv1.w, uv2.w, and uv3.w....
        {
            List <Vector4> uv1 = new List <Vector4>();
            List <Vector4> uv2 = new List <Vector4>();
            List <Vector4> uv3 = new List <Vector4>();
            m.GetUVs(1, uv1);
            m.GetUVs(2, uv2);
            m.GetUVs(3, uv3);
            for (int i = 0; i < uv.Count; i++)
            {
                uv1 [i] = new Vector4(uv1[i].x, uv1[i].y, uv1[i].z, uv[i].x);
                uv2 [i] = new Vector4(uv2[i].x, uv2[i].y, uv2[i].z, uv[i].y);
                uv3 [i] = new Vector4(uv3[i].x, uv3[i].y, uv3[i].z, uv[i].z);
            }
            m.SetUVs(1, uv1);
            m.SetUVs(2, uv2);
            m.SetUVs(3, uv3);
        }
        else
        {
            throw new UnityException("Yeah, there's no uv destination that high, bud.");
        }
    }
Example #32
0
    private IEnumerator BakeObject(GameObject _bakeable, BakeType type) //hier zit HET PROBLEEM
    {
        if (!(_bakeable != null))
        {
            StartCoroutine(BakePreparedScene());
            yield break;
        }

        List <Node> ret = new List <Node>();
        //get size collider
        Collider c = _bakeable.GetComponent <Collider>();

        if (!(c != null))
        {
            if (type == BakeType.Object)
            {
                bakePrepare = StartCoroutine(BakePreparedScene());
            }
            if (type != BakeType.Object)
            {
                EndRealtimeBakeFrame(_bakeable, ret);
            }
            yield break;
        }

        Vector3 size = c.bounds.size;

        //get mid size bakeable
        Node midNode = GetNodeFromVector(c.bounds.center);

        int _x    = (int)(size.x / widthSizeNode);
        int _y    = (int)(size.y / heightSizeNode);
        int _z    = (int)(size.z / widthSizeNode);
        int halfX = _x / 2;
        int halfY = _y / 2;
        int halfZ = _z / 2;

        Collider[] hits;
        //RaycastHit hit;
        Node node;

        if (!(midNode != null))
        {
            //Debug.Log(bakeable.name + " not scanned, the center has to be in the bakeable area.");
            if (type == BakeType.Object)
            {
                bakePrepare = StartCoroutine(BakePreparedScene());
            }
            if (type != BakeType.Object)
            {
                EndRealtimeBakeFrame(_bakeable, ret);
            }
            yield break;
        }

        for (int x = midNode.x - halfX; x <= halfX + midNode.x; x++)
        {
            for (int y = midNode.y - halfY; y <= halfY + midNode.y + 1; y++)
            {
                for (int z = midNode.z - halfZ; z <= halfZ + midNode.z; z++)
                {
                    calc++;
                    if (calc > calculationsPerFrame)
                    {
                        calc = 0;
                        yield return(null);
                    }

                    //check if in bounds
                    if (x < 0 || x >= grid.GetLength(0))
                    {
                        continue;
                    }
                    if (y < 0 || y >= grid.GetLength(1))
                    {
                        continue;
                    }
                    if (z < 0 || z >= grid.GetLength(2))
                    {
                        continue;
                    }

                    node = grid[x, y, z];
                    if (node.filled && node.bakeType == BakeType.Object)
                    {
                        continue;
                    }

                    Vector3 midPos = GetVectorFromNode(grid[x, y, z]);

                    hits = Physics.OverlapSphere(midPos, heightSizeNode / 2); //in het midden schieten, niet in de hoek
                    if (visualizeRaycasts)
                    {
                        Color v = hits.Length > 0 ? Color.red : Color.grey;
                        Debug.DrawRay(midPos, Vector3.down, v, 1);
                    }

                    calc += heavyCalcCost;
                    if (calc > calculationsPerFrame)
                    {
                        calc = 0;
                        yield return(null);
                    }

                    foreach (Collider hit in hits)
                    {
                        if (_bakeable != hit.transform.gameObject)
                        {
                            continue;
                        }
                        node.bakeType = type;
                        node.filled   = true;
                        ret.Add(node);
                        break;
                    }
                }
            }
        }

        if (type == BakeType.Object)
        {
            bakePrepare = StartCoroutine(BakePreparedScene());
        }
        if (type != BakeType.Object)
        {
            EndRealtimeBakeFrame(_bakeable, ret);
        }
    }
Example #33
0
    private List <Node> BakeObject(GameObject bakeable, BakeType type) //hier zit HET PROBLEEM
    {
        List <Node> ret = new List <Node>();
        //get size collider
        Collider c    = bakeable.GetComponent <Collider>();
        Vector3  size = c.bounds.size;

        //get mid size bakeable
        Node midNode = GetNodeFromVector(bakeable.transform.position);

        int _x    = (int)(size.x / widthSizeNode);
        int _y    = (int)(size.y / heightSizeNode);
        int _z    = (int)(size.z / widthSizeNode);
        int halfX = _x / 2;
        int halfY = _y / 2;
        int halfZ = _z / 2;

        Collider[] hits;
        Node       node;

        if (!(midNode != null))
        {
            Debug.Log(bakeable.name + " not scanned, the center has to be in the bakeable area.");
            return(null);
        }


        #region Old Code
        for (int x = midNode.x - halfX; x <= halfX + midNode.x; x++)         //dit is dus verkeerd, somehow
        {
            for (int y = midNode.y - halfY; y <= halfY + midNode.y + 1; y++) //eentje hoger erbij doen
            {
                for (int z = midNode.z - halfZ; z <= halfZ + midNode.z; z++)
                {
                    //check if in bounds
                    if (x < 0 || x >= grid.GetLength(0))
                    {
                        continue;
                    }
                    if (y < 0 || y >= grid.GetLength(1))
                    {
                        continue;
                    }
                    if (z < 0 || z >= grid.GetLength(2))
                    {
                        continue;
                    }

                    node = grid[x, y, z];
                    if (node.filled)
                    {
                        continue;
                    }

                    Vector3 midPos = GetVectorFromNode(grid[x, y, z]);
                    hits = Physics.OverlapSphere(midPos, heightSizeNode / 4);
                    if (visualizeRaycasts)
                    {
                        Color v = hits.Length > 0 ? Color.red : Color.grey;
                        Debug.DrawRay(midPos, Vector3.down, v, 1);
                    }
                    foreach (Collider hit in hits)
                    {
                        if (bakeable != hit.transform.gameObject)
                        {
                            continue;
                        }
                        node.bakeType = type;
                        node.filled   = true;
                        ret.Add(node);
                        break;
                    }
                }
            }
        }

        #endregion

        return(ret);
    }
Example #34
0
        private int AddImagesToDownload(BakeType bakeType)
        {
            int imageCount = 0;

            // Download all of the images in this layer
            switch (bakeType)
            {
                case BakeType.Head:
                    lock (ImageDownloads)
                    {
                        imageCount += AddImageDownload(TextureIndex.HeadBodypaint);
                        //imageCount += AddImageDownload(TextureIndex.Hair);
                    }
                    break;
                case BakeType.UpperBody:
                    lock (ImageDownloads)
                    {
                        imageCount += AddImageDownload(TextureIndex.UpperBodypaint);
                        imageCount += AddImageDownload(TextureIndex.UpperGloves);
                        imageCount += AddImageDownload(TextureIndex.UpperUndershirt);
                        imageCount += AddImageDownload(TextureIndex.UpperShirt);
                        imageCount += AddImageDownload(TextureIndex.UpperJacket);
                    }
                    break;
                case BakeType.LowerBody:
                    lock (ImageDownloads)
                    {
                       imageCount += AddImageDownload(TextureIndex.LowerBodypaint);
                       imageCount += AddImageDownload(TextureIndex.LowerUnderpants);
                       imageCount += AddImageDownload(TextureIndex.LowerSocks);
                       imageCount += AddImageDownload(TextureIndex.LowerShoes);
                       imageCount += AddImageDownload(TextureIndex.LowerPants);
                       imageCount += AddImageDownload(TextureIndex.LowerJacket);
                    }
                    break;
                case BakeType.Eyes:
                    lock (ImageDownloads)
                    {
                        imageCount += AddImageDownload(TextureIndex.EyesIris);
                    }
                    break;
                case BakeType.Skirt:
                    if (Wearables.ContainsKey(WearableType.Skirt))
                    {
                        lock (ImageDownloads)
                        {
                            imageCount += AddImageDownload(TextureIndex.Skirt);
                        }
                    }
                    break;
                case BakeType.Hair:
                    lock (ImageDownloads)
                    {
                        imageCount += AddImageDownload(TextureIndex.Hair);
                    }
                    break;
                default:
                    Log.Log("Unknown BakeType :" + bakeType.ToString(), Helpers.LogLevel.Warning);
                    break;
            }
            
            return imageCount;
        }
Example #35
0
        private void RebakeLayer(BakeType bakeType)
        {
            Dictionary<int, float> paramValues;

            // Build a dictionary of appearance parameter indices and values from the wearables
            paramValues=MakeParamValues();    

            Baker bake = new Baker(Log, bakeType, 0, paramValues);
                
            for (int ii = 0; ii < AVATAR_TEXTURE_COUNT; ii++)
            { 
                if(bakeType==Baker.BakeTypeFor((TextureIndex)ii) && AgentAssets[ii]!=null)
                {
                    Log.Log("Adding asset "+AgentAssets[ii].AssetID.ToString()+" to baker",Helpers.LogLevel.Debug);
                    bake.AddTexture((TextureIndex)ii,(AssetTexture)AgentAssets[ii],true);
                }
            }
        
            UploadBake(bake);
        }
Example #36
0
 private TextureIndex BakeTypeToAgentTextureIndex(BakeType index)
 {
     switch (index)
     {
         case BakeType.Head:
             return TextureIndex.HeadBaked;
         case BakeType.UpperBody:
             return TextureIndex.UpperBaked;
         case BakeType.LowerBody:
             return TextureIndex.LowerBaked;
         case BakeType.Eyes:
             return TextureIndex.EyesBaked;
         case BakeType.Skirt:
             return TextureIndex.SkirtBaked;
         default:
             return TextureIndex.Unknown;
     }
 }