Ejemplo n.º 1
0
        private void readLayer(long layers, String name)
        {
            if (layers == 0)
            {
                return;
            }
//        Console.WriteLine(name + ".layers=" + Long.toString(layers, 16));
            BlendChunk raw = findChunkByPtr(layers);

            if (raw == null)
            {
                throw new Exception("GL_BLEND:Unable to find " + name + ".layers for Mesh");
            }
            setData(raw.raw);
//        Console.WriteLine("#layers=" + raw.nr);
            for (int a = 0; a < raw.nr; a++)
            {
                BlendCustomDataLayer layer = new BlendCustomDataLayer(this);
                layer.read();
                String layer_name = layer.name;
                if (layer.data == 0)
                {
//                Console.WriteLine("layer.data == null");
                    continue;
                }
                BlendChunk layer_data = findChunkByPtr(layer.data);
                if (layer_data == null)
                {
                    throw new Exception("GL_BLEND:Unable to find " + name + ".layers.data for Mesh");
                }
                BlendContext ctx = pushData();
                setData(layer_data.raw);
//            Console.WriteLine("layer.data=" + Long.toString(layer.data, 16) + ",type==" + layer.type + ",a=" + a);
                switch (layer.type)
                {
                case CD_MTEXPOLY: {    //15
                    //NOTE:There fis a MTexPoly per face, I only read the first
                    BlendMTexPoly tex = new BlendMTexPoly(this);
                    tex.read();
                    BlendChunk imageChunk = findChunkByPtr(tex.tpage);
                    if (imageChunk == null)
                    {
                        throw new Exception("GL_BLEND:No texture found for UVMap:" + a);
                    }
                    setData(imageChunk.raw);
                    BlendImage image = new BlendImage(this);
                    image.read();
                    OpenGLUVMap map;
                    if (a < obj.GetUVMapCount())
                    {
                        map = obj.GetUVMap(a);
                    }
                    else
                    {
                        map = obj.CreateUVMap();
                    }
                    String tn = image.name;
                    //string texture path for now
                    int tnidx = tn.LastIndexOf('/');
                    if (tnidx != -1)
                    {
                        tn = tn.Substring(tnidx + 1);
                    }
                    tnidx = tn.LastIndexOf('\\');
                    if (tnidx != -1)
                    {
                        tn = tn.Substring(tnidx + 1);
                    }
                    int tidx = model.AddTexture(tn);
                    map.SetTextureIndex(tidx);
                    map.SetName(layer_name);
//                    Console.WriteLine("texpoly=" + map.name);
                    break;
                }

                case CD_MLOOPUV: { //16
                    //There fis a UV per face per vertex
                    if (a >= obj.GetUVMapCount())
                    {
                        obj.CreateUVMap();
                    }
//                    Console.WriteLine("loopuv.nr=" + layer_data.nr);
                    for (int b = 0; b < layer_data.nr; b++)
                    {
                        BlendMLoopUV uv = new BlendMLoopUV(this);
                        uv.read();
                        uv.uv[1] = 1.0f - uv.uv[1];    //invert V(y)
                        obj.AddUV(uv.uv, a);
                    }
                    break;
                }
                }
                popData(ctx);
            }
        }
        /// <summary>
        /// To initialize the custom view cell
        /// </summary>
        void InitializeComponent()
        {
            var layout = new RelativeLayout
            {
                WidthRequest  = 360,
                HeightRequest = 219,

                HorizontalOptions = LayoutOptions.Start,
            };

            layout.Children.Add(
                new Image
            {
                Source = "apps_list_item_bg.png",
                Aspect = Aspect.Fill,
            },
                Constraint.RelativeToParent((parent) =>
            {
                return(0);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(0);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height);
            }));

            var icon = new BlendImage {
            };

            icon.SetBinding(BlendImage.SourceProperty, "IconPath");
            icon.SetBinding(BlendImage.BlendColorProperty, "BlendColor");

            layout.Children.Add(
                icon,
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width * 0.0778);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.2740);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width * 0.2772);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.4475);
            }));

            var label = new Label
            {
                VerticalOptions = LayoutOptions.CenterAndExpand,
            };

            label.SetBinding(Label.TextProperty, "Id");

            layout.Children.Add(
                label,
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width * 0.425);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(0);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width * 0.5);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height);
            }));

            View = layout;
        }
        /// <summary>
        /// To initialize components of the operation item
        /// </summary>
        void InitializeComponent()
        {
            _caption = new Label
            {
                Text = _name,
                HorizontalTextAlignment = TextAlignment.Center,
            };

            _radio = new BlendImage
            {
                Source     = "radio.png",
                BlendColor = Color.FromRgb(231, 214, 25),
            };

            _radioCheck = new BlendImage
            {
                Source     = "radio_check.png",
                BlendColor = Color.FromRgb(231, 214, 25),
                Scale      = 0,
            };

            _radioButton = new RadioButton
            {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.StartAndExpand,

                GroupName  = "Group-Operation",
                IsSelected = false,
            };

            _radioButton.Selected += (s, e) =>
            {
                if (e.Value == false)
                {
                    UpdateUncheckedRadio();
                    return;
                }

                UpdateCheckedRadio();
                Selected?.Invoke(this, EventArgs.Empty);
            };

            Children.Add(
                _caption,
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width * 0.125);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.4612);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width * 0.750);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.4931);
            }));

            Children.Add(
                _radio,
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width * 0.4);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.1507);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width * 0.2);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.2192);
            }));

            Children.Add(
                _radioCheck,
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width * 0.4292);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.1826);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width * 0.1416);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.1553);
            }));

            Children.Add(
                _radioButton,
                Constraint.RelativeToParent((parent) =>
            {
                return(0);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height * 0.1507);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Width);
            }),
                Constraint.RelativeToParent((parent) =>
            {
                return(parent.Height);
            }));
        }