Beispiel #1
0
        public static geometry FindGeoemertyFromController(controller controller, library_geometries geometries)
        {
            skin   skin    = controller.Item as skin;
            string mesh_id = skin.source1.Trim('#');

            return(Array.Find(geometries.geometry, x => x.id == mesh_id));
        }
        //设置皮肤
        void SetSkin(skin newSkin)
        {
            if (currSkin == newSkin)
            {
                return;
            }

            currSkin = newSkin;

            switch (currSkin)
            {
            case skin.Starry:

                ApplySkin(StarrySkin);
                BorderMain.Background = new ImageBrush(ChangeBitmapToImageSource(Properties.Resources.tableback2));
                textColor             = Colors.White;

                break;

            case skin.ColorBox:

                ApplySkin(ColorBoxSkin);
                BorderMain.Background = new ImageBrush(ChangeBitmapToImageSource(Properties.Resources.Color3));
                textColor             = Colors.Black;
                break;
            }

            TextBlockChosenDate.Foreground = new SolidColorBrush(textColor);
            TextBoxCId.Foreground          = new SolidColorBrush(textColor);

            RefreshSchedule();
        }
Beispiel #3
0
        public void sua(string skin)
        {
            skin sk = (from d in db.skins select d).Single(t => t.tenskin == skin);

            sk.tenskin = skin;
            db.SubmitChanges();
        }
Beispiel #4
0
        public void sua(string skin)
        {
            skin sk = (from a in db.skins select a).Single(t => t.trangthai == true);

            sk.tenskin = skin;
            db.SubmitChanges();
        }
Beispiel #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            skin skin = db.skins.Find(id);

            db.skins.Remove(skin);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #6
0
 public ActionResult Edit([Bind(Include = "id,name,fk_skinsInGiveaway")] skin skin)
 {
     if (ModelState.IsValid)
     {
         db.Entry(skin).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(skin));
 }
Beispiel #7
0
        public ActionResult Create([Bind(Include = "id,name,fk_skinsInGiveaway")] skin skin)
        {
            if (ModelState.IsValid)
            {
                db.skins.Add(skin);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(skin));
        }
Beispiel #8
0
        private static List <BoneWeight[]> ParseWeightController(controller controller, ColladaScene scene)
        {
            if (controller == null)
            {
                return(new List <BoneWeight[]>());
            }

            List <BoneWeight[]> boneWeights = new List <BoneWeight[]>();
            skin skin = controller.Item as skin;

            string[] skinningCounts = skin.vertex_weights.vcount.Trim(' ').Split(' ');
            string[] indices        = skin.vertex_weights.v.Trim(' ').Split(' ');

            int maxSkinning = (int)scene.Settings.MaxSkinningCount;
            int stride      = skin.vertex_weights.input.Length;

            int indexOffset = 0;

            for (int v = 0; v < skinningCounts.Length; v++)
            {
                int numSkinning = Convert.ToInt32(skinningCounts[v]);

                BoneWeight[] boneWeightsArr = new BoneWeight[Math.Min(maxSkinning, numSkinning)];
                for (int j = 0; j < numSkinning; j++)
                {
                    if (j < scene.Settings.MaxSkinningCount)
                    {
                        boneWeightsArr[j] = new BoneWeight();
                        foreach (var input in skin.vertex_weights.input)
                        {
                            int offset = (int)input.offset;
                            var source = DaeUtility.FindSourceFromInput(input, skin.source);
                            int index  = Convert.ToInt32(indices[indexOffset + offset]);
                            if (input.semantic == "WEIGHT")
                            {
                                var weights = source.Item as float_array;
                                boneWeightsArr[j].Weight = (float)weights.Values[index];
                            }
                            if (input.semantic == "JOINT")
                            {
                                var bones = source.Item as Name_array;
                                boneWeightsArr[j].Bone = bones.Values[index];
                            }
                        }
                    }
                    indexOffset += stride;
                }

                boneWeightsArr = RemoveZeroWeights(boneWeightsArr);
                boneWeights.Add(boneWeightsArr);
            }

            return(boneWeights);
        }
Beispiel #9
0
        public ActionResult AddConfirmed(int id)
        {
            skin              skin              = db.skins.Find(id);
            giveaway          giveaway          = db.giveaways.Find(Session["GiveawayID"]);
            skins_in_giveaway skins_in_giveaway = new skins_in_giveaway();

            skins_in_giveaway.fk_giveaway = giveaway.id;
            skins_in_giveaway.fk_skin     = skin.id;
            db.skins_in_giveaway.Add(skins_in_giveaway);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        private void ExportMeshBinding(Model model, string skelRef, MeshBinding meshBinding, List <geometry> geometries, List <controller> controllers, List <node> geomNodes)
        {
            var exporter = new ColladaMeshExporter(meshBinding.Mesh, Options);
            var mesh     = exporter.Export();
            var geom     = new geometry();

            geom.id   = meshBinding.Mesh.Name + "-geom";
            geom.name = meshBinding.Mesh.Name;
            geom.Item = mesh;
            geometries.Add(geom);

            bool       hasSkin = skelRef != null && meshBinding.Mesh.IsSkinned();
            skin       skin    = null;
            controller ctrl    = null;

            if (hasSkin)
            {
                var boneNames = new Dictionary <string, Bone>();
                foreach (var bone in model.Skeleton.Bones)
                {
                    boneNames.Add(bone.Name, bone);
                }

                skin      = ExportSkin(meshBinding.Mesh, model.Skeleton.Bones, boneNames, geom.id);
                ctrl      = new controller();
                ctrl.id   = meshBinding.Mesh.Name + "-skin";
                ctrl.name = meshBinding.Mesh.Name + "_Skin";
                ctrl.Item = skin;
                controllers.Add(ctrl);
            }

            var geomNode = new node();

            geomNode.id   = geom.name + "-node";
            geomNode.name = geom.name;
            geomNode.type = NodeType.NODE;

            if (hasSkin)
            {
                var controllerInstance = new instance_controller();
                controllerInstance.url       = "#" + ctrl.id;
                controllerInstance.skeleton  = new string[] { "#" + skelRef };
                geomNode.instance_controller = new instance_controller[] { controllerInstance };
            }
            else
            {
                var geomInstance = new instance_geometry();
                geomInstance.url           = "#" + geom.id;
                geomNode.instance_geometry = new instance_geometry[] { geomInstance };
            }

            geomNodes.Add(geomNode);
        }
Beispiel #11
0
        // GET: Skins/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            skin skin = db.skins.Find(id);

            if (skin == null)
            {
                return(HttpNotFound());
            }
            return(View(skin));
        }
Beispiel #12
0
    public SkinData(SkinUI skinUI)
    {
        W.Clear();
        for (int i = 0; i < skinUI.cotsume.Length; i++)
        {
            skin test = new skin();
            test.id       = skinUI.cotsume[i].id;
            test.HP       = skinUI.cotsume[i].HP;
            test.checkBuy = skinUI.cotsume[i].checkBuy;
            test.checkUse = skinUI.cotsume[i].checkUse;

            W.Add(test);
        }
    }
Beispiel #13
0
        private void mouseClick()
        {
            if (mouseSystem.Clicked(new Vector2(500, 110), new Vector2(16, 16)))
            {
                var _playerReadyButtom = playerReadyButtom.Get <AnimatedSprite>();
                if (!ready)
                {
                    _playerReadyButtom.Play("Ready");
                    ProtoHelper.WriteToChat("!Ready");

                    var _ReadyText = readyText.Get <Text>();
                    _ReadyText.text = "Ready";
                }
                else
                {
                    _playerReadyButtom.Play("NotReady");
                    ProtoHelper.WriteToChat("!NotReady");

                    var _ReadyText = readyText.Get <Text>();
                    _ReadyText.text = "Not ready";
                }
                ready = !ready;
            }
            if (mouseSystem.Clicked(new Vector2(690, 80), new Vector2(16, 16)))
            {
                var s = playerSkin + 1;
                playerSkin   = s <= (skin)Enum.GetValues(typeof(skin)).Length - 1 ? s : 0;
                playerSprite = new Sprite(_sceneHandler._content.Load <Texture2D>(playerSkin.ToString()));
                ProtoHelper.WriteToChat($"!SkinChange,{(int)playerSkin}");
            }
            if (mouseSystem.Clicked(new Vector2(690, 120), new Vector2(16, 16)))
            {
                var s = playerSkin - 1;
                playerSkin   = s < 0 ? (skin)Enum.GetValues(typeof(skin)).Length - 1 : s;
                playerSprite = new Sprite(_sceneHandler._content.Load <Texture2D>(playerSkin.ToString()));
                ProtoHelper.WriteToChat($"!SkinChange,{(int)playerSkin}");
            }
        }
Beispiel #14
0
        private void ImportSkin(Root root, skin skin)
        {
            if (skin.source1[0] != '#')
            {
                throw new ParsingException("Only ID references are supported for skin geometries");
            }

            Mesh mesh = null;

            if (!ColladaGeometries.TryGetValue(skin.source1.Substring(1), out mesh))
            {
                throw new ParsingException("Skin references nonexistent mesh: " + skin.source1);
            }

            if (!mesh.VertexFormat.HasBoneWeights)
            {
                var msg = String.Format("Tried to apply skin to mesh ({0}) with non-skinned vertices",
                                        mesh.Name);
                throw new ParsingException(msg);
            }

            var sources = new Dictionary <String, ColladaSource>();

            foreach (var source in skin.source)
            {
                var src = ColladaSource.FromCollada(source);
                sources.Add(src.id, src);
            }

            List <Bone>    joints          = null;
            List <Matrix4> invBindMatrices = null;

            foreach (var input in skin.joints.input)
            {
                if (input.source[0] != '#')
                {
                    throw new ParsingException("Only ID references are supported for joint input sources");
                }

                ColladaSource inputSource = null;
                if (!sources.TryGetValue(input.source.Substring(1), out inputSource))
                {
                    throw new ParsingException("Joint input source does not exist: " + input.source);
                }

                if (input.semantic == "JOINT")
                {
                    List <string> jointNames = inputSource.NameParams.Values.SingleOrDefault();
                    if (jointNames == null)
                    {
                        throw new ParsingException("Joint input source 'JOINT' must contain array of names.");
                    }

                    var skeleton = root.Skeletons[0];
                    joints = new List <Bone>();
                    foreach (var name in jointNames)
                    {
                        Bone bone       = null;
                        var  lookupName = name.Replace("_x0020_", " ");
                        if (!skeleton.BonesBySID.TryGetValue(lookupName, out bone))
                        {
                            throw new ParsingException("Joint name list references nonexistent bone: " + lookupName);
                        }

                        joints.Add(bone);
                    }
                }
                else if (input.semantic == "INV_BIND_MATRIX")
                {
                    invBindMatrices = inputSource.MatrixParams.Values.SingleOrDefault();
                    if (invBindMatrices == null)
                    {
                        throw new ParsingException("Joint input source 'INV_BIND_MATRIX' must contain a single array of matrices.");
                    }
                }
                else
                {
                    throw new ParsingException("Unsupported joint semantic: " + input.semantic);
                }
            }

            if (joints == null)
            {
                throw new ParsingException("Required joint input semantic missing: JOINT");
            }

            if (invBindMatrices == null)
            {
                throw new ParsingException("Required joint input semantic missing: INV_BIND_MATRIX");
            }

            var influenceCounts = ColladaHelpers.StringsToIntegers(skin.vertex_weights.vcount);
            var influences      = ColladaHelpers.StringsToIntegers(skin.vertex_weights.v);

            foreach (var count in influenceCounts)
            {
                if (count > 4)
                {
                    throw new ParsingException("GR2 only supports at most 4 vertex influences");
                }
            }

            // TODO
            if (influenceCounts.Count != mesh.OriginalToConsolidatedVertexIndexMap.Count)
            {
                Utils.Warn(String.Format("Vertex influence count ({0}) differs from vertex count ({1})", influenceCounts.Count, mesh.OriginalToConsolidatedVertexIndexMap.Count));
            }

            List <Single> weights = null;

            int jointInputIndex = -1, weightInputIndex = -1;

            foreach (var input in skin.vertex_weights.input)
            {
                if (input.semantic == "JOINT")
                {
                    jointInputIndex = (int)input.offset;
                }
                else if (input.semantic == "WEIGHT")
                {
                    weightInputIndex = (int)input.offset;

                    if (input.source[0] != '#')
                    {
                        throw new ParsingException("Only ID references are supported for weight input sources");
                    }

                    ColladaSource inputSource = null;
                    if (!sources.TryGetValue(input.source.Substring(1), out inputSource))
                    {
                        throw new ParsingException("Weight input source does not exist: " + input.source);
                    }

                    if (!inputSource.FloatParams.TryGetValue("WEIGHT", out weights))
                    {
                        weights = inputSource.FloatParams.Values.SingleOrDefault();
                    }

                    if (weights == null)
                    {
                        throw new ParsingException("Weight input source " + input.source + " must have WEIGHT float attribute");
                    }
                }
                else
                {
                    throw new ParsingException("Unsupported skin input semantic: " + input.semantic);
                }
            }

            if (jointInputIndex == -1)
            {
                throw new ParsingException("Required vertex weight input semantic missing: JOINT");
            }

            if (weightInputIndex == -1)
            {
                throw new ParsingException("Required vertex weight input semantic missing: WEIGHT");
            }

            // Remove bones that are not actually influenced from the binding list
            var boundBones = new HashSet <Bone>();
            int offset     = 0;
            int stride     = skin.vertex_weights.input.Length;

            while (offset < influences.Count)
            {
                var jointIndex  = influences[offset + jointInputIndex];
                var weightIndex = influences[offset + weightInputIndex];
                var joint       = joints[jointIndex];
                var weight      = weights[weightIndex];
                if (!boundBones.Contains(joint))
                {
                    boundBones.Add(joint);
                }

                offset += stride;
            }

            if (boundBones.Count > 127)
            {
                throw new ParsingException("D:OS supports at most 127 bound bones per mesh.");
            }

            mesh.BoneBindings = new List <BoneBinding>();
            var boneToIndexMaps = new Dictionary <Bone, int>();

            for (var i = 0; i < joints.Count; i++)
            {
                if (boundBones.Contains(joints[i]))
                {
                    // Collada allows one inverse bind matrix for each skin, however Granny
                    // only has one matrix for one bone, even if said bone is used from multiple meshes.
                    // Hopefully the Collada ones are all equal ...
                    var iwt = invBindMatrices[i];
                    // iwt.Transpose();
                    joints[i].InverseWorldTransform = new float[] {
                        iwt[0, 0], iwt[1, 0], iwt[2, 0], iwt[3, 0],
                        iwt[0, 1], iwt[1, 1], iwt[2, 1], iwt[3, 1],
                        iwt[0, 2], iwt[1, 2], iwt[2, 2], iwt[3, 2],
                        iwt[0, 3], iwt[1, 3], iwt[2, 3], iwt[3, 3]
                    };

                    // Bind all bones that affect vertices to the mesh, so we can reference them
                    // later from the vertexes BoneIndices.
                    var binding = new BoneBinding();
                    binding.BoneName = joints[i].Name;
                    // TODO
                    // Use small bounding box values, as it interferes with object placement
                    // in D:OS 2 (after the Gift Bag 2 update)
                    binding.OBBMin = new float[] { -0.1f, -0.1f, -0.1f };
                    binding.OBBMax = new float[] { 0.1f, 0.1f, 0.1f };
                    mesh.BoneBindings.Add(binding);
                    boneToIndexMaps.Add(joints[i], boneToIndexMaps.Count);
                }
            }

            offset = 0;
            for (var vertexIndex = 0; vertexIndex < influenceCounts.Count; vertexIndex++)
            {
                var   influenceCount = influenceCounts[vertexIndex];
                float influenceSum   = 0.0f;
                for (var i = 0; i < influenceCount; i++)
                {
                    var weightIndex = influences[offset + i * stride + weightInputIndex];
                    influenceSum += weights[weightIndex];
                }

                for (var i = 0; i < influenceCount; i++)
                {
                    var jointIndex  = influences[offset + jointInputIndex];
                    var weightIndex = influences[offset + weightInputIndex];
                    var joint       = joints[jointIndex];
                    var weight      = weights[weightIndex] / influenceSum;
                    // Not all vertices are actually used in triangles, we may have unused verts in the
                    // source list (though this is rare) which won't show up in the consolidated vertex map.
                    if (mesh.OriginalToConsolidatedVertexIndexMap.TryGetValue(vertexIndex, out List <int> consolidatedIndices))
                    {
                        foreach (var consolidatedIndex in consolidatedIndices)
                        {
                            var vertex = mesh.PrimaryVertexData.Vertices[consolidatedIndex];
                            vertex.AddInfluence((byte)boneToIndexMaps[joint], weight);
                        }
                    }

                    offset += stride;
                }
            }

            foreach (var vertex in mesh.PrimaryVertexData.Vertices)
            {
                vertex.FinalizeInfluences();
            }

            // Warn if we have vertices that are not influenced by any bone
            int notInfluenced = 0;

            foreach (var vertex in mesh.PrimaryVertexData.Vertices)
            {
                if (vertex.BoneWeights[0] == 0)
                {
                    notInfluenced++;
                }
            }

            if (notInfluenced > 0)
            {
                Utils.Warn(String.Format("{0} vertices are not influenced by any bone", notInfluenced));
            }

            if (skin.bind_shape_matrix != null)
            {
                var bindShapeFloats = skin.bind_shape_matrix.Trim().Split(new char[] { ' ' }).Select(s => Single.Parse(s)).ToArray();
                var bindShapeMat    = ColladaHelpers.FloatsToMatrix(bindShapeFloats);
                bindShapeMat.Transpose();

                // Deform geometries that were affected by our bind shape matrix
                mesh.PrimaryVertexData.Transform(bindShapeMat);
            }

            if (Options.RecalculateOBBs)
            {
                UpdateOBBs(root.Skeletons.Single(), mesh);
            }
        }
        //设置皮肤
        void SetSkin(skin newSkin)
        {
            if (currSkin == newSkin) return;

            currSkin = newSkin;

            switch (currSkin)
            {
                case skin.Starry:

                    ApplySkin(StarrySkin);
                    BorderMain.Background = new ImageBrush(ChangeBitmapToImageSource(Properties.Resources.tableback2));
                    textColor = Colors.White;

                    break;
                case skin.ColorBox:

                    ApplySkin(ColorBoxSkin);
                    BorderMain.Background = new ImageBrush(ChangeBitmapToImageSource(Properties.Resources.Color3));
                    textColor = Colors.Black;
                    break;
            }

            TextBlockChosenDate.Foreground = new SolidColorBrush(textColor);
            TextBoxCId.Foreground = new SolidColorBrush(textColor);

            RefreshSchedule();
        }
Beispiel #16
0
        public static void ExportIOModelAsDAE(string FileName, IOModel m)
        {
            COLLADA colladaFile = new COLLADA();

            List <geometry> list_geometries = new List <geometry>(m.Meshes.Count);

            if (m.HasMeshes)
            {
                foreach (IOMesh iomesh in m.Meshes)
                {
                    geometry g = new geometry();
                    g.name = iomesh.Name;
                    g.id   = iomesh.Name + $"_{m.Meshes.IndexOf(iomesh)}";

                    List <double> list_positions = new List <double>();
                    List <double> list_normals   = new List <double>();
                    List <double> list_uvs       = new List <double>();
                    List <double> list_colors    = new List <double>();
                    foreach (IOVertex v in iomesh.Vertices)
                    {
                        list_positions.Add(v.Position.X);
                        list_positions.Add(v.Position.Y);
                        list_positions.Add(v.Position.Z);
                        list_normals.Add(v.Normal.X);
                        list_normals.Add(v.Normal.Y);
                        list_normals.Add(v.Normal.Z);
                        list_uvs.Add(v.UV0.X);
                        list_uvs.Add(v.UV0.Y);
                    }

                    // Position
                    source source_position = new source();
                    {
                        float_array floats = new float_array();
                        floats.count  = (ulong)list_positions.Count;
                        floats.id     = g.id + "_pos_arr";
                        floats.Values = list_positions.ToArray();

                        source_position = CreateSource(list_positions.Count, 3, floats.id, floats, new param[] {
                            new param()
                            {
                                name = "X", type = "float"
                            },
                            new param()
                            {
                                name = "Y", type = "float"
                            },
                            new param()
                            {
                                name = "Z", type = "float"
                            }
                        });
                    }

                    // Normal
                    source source_normal = new source();
                    {
                        float_array floats = new float_array();
                        floats.count  = (ulong)list_normals.Count;
                        floats.id     = g.id + "_nrm_arr";
                        floats.Values = list_normals.ToArray();

                        source_normal = CreateSource(list_normals.Count, 3, floats.id, floats, new param[] {
                            new param()
                            {
                                name = "X", type = "float"
                            },
                            new param()
                            {
                                name = "Y", type = "float"
                            },
                            new param()
                            {
                                name = "Z", type = "float"
                            }
                        });
                    }

                    // UV0
                    source source_uv0 = new source();
                    {
                        float_array floats = new float_array();
                        floats.count  = (ulong)list_uvs.Count;
                        floats.id     = g.id + "_uv0_arr";
                        floats.Values = list_uvs.ToArray();

                        source_uv0 = CreateSource(list_uvs.Count, 2, floats.id, floats, new param[] {
                            new param()
                            {
                                name = "S", type = "float"
                            },
                            new param()
                            {
                                name = "T", type = "float"
                            }
                        });
                    }

                    // vertices

                    vertices vertices = new vertices();
                    vertices.id    = g.id + "_verts";
                    vertices.input = new InputLocal[]
                    {
                        new InputLocal()
                        {
                            source = "#" + source_position.id, semantic = "POSITION"
                        },
                        new InputLocal()
                        {
                            source = "#" + source_normal.id, semantic = "NORMAL"
                        },
                        new InputLocal()
                        {
                            source = "#" + source_uv0.id, semantic = "TEXCOORD"
                        }
                    };

                    // triangles
                    triangles triangles = new triangles();
                    triangles.count = (ulong)iomesh.Indices.Count;
                    triangles.input = new InputLocalOffset[] {
                        new InputLocalOffset()
                        {
                            offset = 0, semantic = "VERTEX", source = "#" + vertices.id
                        }
                    };
                    triangles.p = string.Join(" ", iomesh.Indices);

                    // creating mesh
                    mesh geomesh = new mesh();
                    geomesh.source   = new source[] { source_position, source_normal, source_uv0 };
                    geomesh.Items    = new object[] { triangles };
                    geomesh.vertices = vertices;

                    g.Item = geomesh;

                    list_geometries.Add(g);
                }
            }
            library_geometries lib_geometry = new library_geometries();

            lib_geometry.geometry = list_geometries.ToArray();


            // controllers

            List <controller> list_controller = new List <controller>();

            if (m.HasMeshes && m.HasSkeleton)
            {
                // create lists
                List <source> skinSources  = new List <source>();
                List <string> boneNames    = new List <string>();
                List <double> InverseBinds = new List <double>();
                foreach (RBone b in m.Skeleton.Bones)
                {
                    boneNames.Add(b.Name);
                    InverseBinds.AddRange(new double[] { b.InvWorldTransform.M11, b.InvWorldTransform.M21, b.InvWorldTransform.M31, b.InvWorldTransform.M41,
                                                         b.InvWorldTransform.M12, b.InvWorldTransform.M22, b.InvWorldTransform.M32, b.InvWorldTransform.M42,
                                                         b.InvWorldTransform.M13, b.InvWorldTransform.M23, b.InvWorldTransform.M33, b.InvWorldTransform.M43,
                                                         b.InvWorldTransform.M14, b.InvWorldTransform.M24, b.InvWorldTransform.M34, b.InvWorldTransform.M44, });
                }



                // setup controllers
                foreach (IOMesh iomesh in m.Meshes)
                {
                    controller controller = new controller()
                    {
                        id = iomesh.Name + "_" + m.Meshes.IndexOf(iomesh) + "_controller"
                    };
                    list_controller.Add(controller);

                    // create source for weights
                    List <double> weights   = new List <double>();
                    List <int>    bones     = new List <int>();
                    List <int>    boneCount = new List <int>();
                    StringBuilder build_v   = new StringBuilder();
                    foreach (IOVertex v in iomesh.Vertices)
                    {
                        int bcount = 0;
                        if (v.BoneWeights.X > 0)
                        {
                            if (!weights.Contains(v.BoneWeights.X))
                            {
                                weights.Add(v.BoneWeights.X);
                            }
                            build_v.Append($"{(int)v.BoneIndices.X} {weights.IndexOf(v.BoneWeights.X)} ");
                            bcount++;
                        }
                        if (v.BoneWeights.Y > 0)
                        {
                            if (!weights.Contains(v.BoneWeights.Y))
                            {
                                weights.Add(v.BoneWeights.Y);
                            }
                            build_v.Append($"{(int)v.BoneIndices.Y} {weights.IndexOf(v.BoneWeights.Y)} ");
                            bcount++;
                        }
                        if (v.BoneWeights.Z > 0)
                        {
                            if (!weights.Contains(v.BoneWeights.Z))
                            {
                                weights.Add(v.BoneWeights.Z);
                            }
                            build_v.Append($"{(int)v.BoneIndices.Z} {weights.IndexOf(v.BoneWeights.Z)} ");
                            bcount++;
                        }
                        if (v.BoneWeights.W > 0)
                        {
                            if (!weights.Contains(v.BoneWeights.W))
                            {
                                weights.Add(v.BoneWeights.W);
                            }
                            build_v.Append($"{(int)v.BoneIndices.W} {weights.IndexOf(v.BoneWeights.W)} ");
                            bcount++;
                        }
                        boneCount.Add(bcount);
                    }


                    // skin

                    Name_array arr_name = new Name_array();
                    arr_name.count  = (ulong)boneNames.Count;
                    arr_name.id     = controller.id + "joints";
                    arr_name.Values = boneNames.ToArray();

                    source source_skin = CreateSource(boneNames.Count, 1, arr_name.id, arr_name, new param[] {
                        new param()
                        {
                            name = "JOINT", type = "name"
                        }
                    });

                    // bind

                    float_array arr_bind = new float_array();
                    arr_bind.count  = (ulong)InverseBinds.Count;
                    arr_bind.id     = controller.id + "binds";
                    arr_bind.Values = InverseBinds.ToArray();

                    source source_binds = CreateSource(InverseBinds.Count, 16, arr_bind.id, arr_bind, new param[] {
                        new param()
                        {
                            name = "TRANSFORM", type = "float4x4"
                        }
                    });

                    // weight

                    source source_weight = new source();
                    {
                        float_array floats = new float_array();
                        floats.count  = (ulong)weights.Count;
                        floats.id     = controller.id + "_weights";
                        floats.Values = weights.ToArray();

                        source_weight = CreateSource(weights.Count, 1, floats.id, floats, new param[] {
                            new param()
                            {
                                name = "WEIGHT", type = "float"
                            },
                        });
                    }

                    skin skin = new skin();
                    skin.source1 = "#" + iomesh.Name + $"_{m.Meshes.IndexOf(iomesh)}";
                    skin.source  = new source[] { source_skin, source_binds, source_weight };

                    skin.joints = new skinJoints()
                    {
                        input = new InputLocal[]
                        {
                            new InputLocal()
                            {
                                semantic = "JOINT",
                                source   = "#" + source_skin.id
                            },
                            new InputLocal()
                            {
                                semantic = "INV_BIND_MATRIX",
                                source   = "#" + source_binds.id
                            }
                        }
                    };


                    //skin weights
                    skin.vertex_weights       = new skinVertex_weights();
                    skin.vertex_weights.count = (ulong)iomesh.Vertices.Count;
                    skin.vertex_weights.input = new InputLocalOffset[]
                    {
                        new InputLocalOffset()
                        {
                            semantic = "JOINT",
                            source   = "#" + source_skin.id,
                            offset   = 0
                        },
                        new InputLocalOffset()
                        {
                            semantic = "WEIGHT",
                            source   = "#" + source_weight.id,
                            offset   = 1
                        }
                    };
                    skin.vertex_weights.vcount = string.Join(" ", boneCount);
                    skin.vertex_weights.v      = build_v.ToString();

                    controller.Item = skin;
                }
            }
            library_controllers lib_controllers = new library_controllers();

            lib_controllers.controller = list_controller.ToArray();


            // scene nodes

            List <node> scene_nodes  = new List <node>();
            int         visual_index = 0;

            if (m.HasSkeleton)
            {
                Dictionary <RBone, node> boneToNode = new Dictionary <RBone, node>();
                foreach (RBone b in m.Skeleton.Bones)
                {
                    // create bone node
                    node node = new node();
                    node.name = b.Name;
                    node.id   = "bone" + visual_index++;
                    node.sid  = b.Name;
                    node.type = NodeType.JOINT;

                    // add transform
                    matrix mat = new matrix()
                    {
                        Values = new double[] { b.Transform.M11, b.Transform.M21, b.Transform.M31, b.Transform.M41,
                                                b.Transform.M12, b.Transform.M22, b.Transform.M32, b.Transform.M42,
                                                b.Transform.M13, b.Transform.M23, b.Transform.M33, b.Transform.M43,
                                                b.Transform.M14, b.Transform.M24, b.Transform.M34, b.Transform.M44, }
                    };
                    node.ItemsElementName = new ItemsChoiceType2[] { ItemsChoiceType2.matrix };
                    node.Items            = new object[] { mat };

                    // deal with parenting
                    boneToNode.Add(b, node);
                    if (b.ParentID == -1)
                    {
                        scene_nodes.Add(node);
                    }
                    else
                    {
                        if (boneToNode[m.Skeleton.Bones[b.ParentID]].node1 == null)
                        {
                            boneToNode[m.Skeleton.Bones[b.ParentID]].node1 = new node[0];
                        }
                        node[] parentnode = boneToNode[m.Skeleton.Bones[b.ParentID]].node1;
                        Array.Resize <node>(ref parentnode, parentnode.Length + 1);
                        parentnode[parentnode.Length - 1] = node;
                        boneToNode[m.Skeleton.Bones[b.ParentID]].node1 = parentnode;
                    }
                }
            }
            if (m.HasMeshes)
            {
                foreach (IOMesh iomesh in m.Meshes)
                {
                    node node = new node()
                    {
                        id   = "mesh" + visual_index++,
                        name = iomesh.Name,
                        type = NodeType.NODE
                    };

                    if (m.HasSkeleton)
                    {
                        instance_controller controller = new instance_controller()
                        {
                            url = iomesh.Name + "_" + m.Meshes.IndexOf(iomesh) + "_controller"
                        };
                        controller.skeleton      = new string[] { "#bone0" };
                        node.instance_controller = new instance_controller[] { controller };
                    }
                    scene_nodes.Add(node);
                }
            }

            // visual scene root
            library_visual_scenes scenes = new library_visual_scenes();

            scenes.visual_scene = new visual_scene[] {
                new visual_scene()
                {
                    id   = "visualscene0",
                    name = "rdmscene"
                }
            };
            scenes.visual_scene[0].node = scene_nodes.ToArray();


            // scene
            COLLADAScene scene = new COLLADAScene();

            scene.instance_visual_scene = new InstanceWithExtra()
            {
                url = "#visualscene0"
            };

            // putting it all together
            colladaFile.Items = new object[] { lib_geometry, lib_controllers, scenes };
            colladaFile.scene = scene;

            colladaFile.Save(FileName);
        }
Beispiel #17
0
        public skin ExportSkin(List <Bone> bones, Dictionary <string, Bone> nameMaps, string geometryId)
        {
            var sources = new List <source>();
            var joints  = new List <string>();
            var poses   = new List <float>();

            var boundBones   = new HashSet <string>();
            var orderedBones = new List <Bone>();

            foreach (var boneBinding in BoneBindings)
            {
                boundBones.Add(boneBinding.BoneName);
                orderedBones.Add(nameMaps[boneBinding.BoneName]);
            }

            /*
             * Append all bones to the end of the bone list, even if they're not influencing the mesh.
             * We need this because some tools (eg. Blender) expect all bones to be present, otherwise their
             * inverse world transform would reset to identity.
             */
            foreach (var bone in bones)
            {
                if (!boundBones.Contains(bone.Name))
                {
                    orderedBones.Add(bone);
                }
            }

            foreach (var bone in orderedBones)
            {
                boundBones.Add(bone.Name);
                joints.Add(bone.Name);

                var invWorldTransform = FloatsToMatrix(bone.InverseWorldTransform);
                invWorldTransform.Transpose();

                poses.AddRange(new float[] {
                    invWorldTransform.M11, invWorldTransform.M12, invWorldTransform.M13, invWorldTransform.M14,
                    invWorldTransform.M21, invWorldTransform.M22, invWorldTransform.M23, invWorldTransform.M24,
                    invWorldTransform.M31, invWorldTransform.M32, invWorldTransform.M33, invWorldTransform.M34,
                    invWorldTransform.M41, invWorldTransform.M42, invWorldTransform.M43, invWorldTransform.M44
                });
            }

            var jointSource   = ColladaUtils.MakeNameSource(Name, "joints", new string[] { "JOINT" }, joints.ToArray());
            var poseSource    = ColladaUtils.MakeFloatSource(Name, "poses", new string[] { "TRANSFORM" }, poses.ToArray(), 16, "float4x4");
            var weightsSource = PrimaryVertexData.MakeBoneWeights(Name);

            var vertices = PrimaryVertexData.Deduplicator.DeduplicatedPositions;
            var vertexInfluenceCounts = new List <int>(vertices.Count);
            var vertexInfluences      = new List <int>(vertices.Count);
            int weightIdx             = 0;

            foreach (var vertex in vertices)
            {
                int influences = 0;
                var indices    = vertex.BoneIndices;
                var weights    = vertex.BoneWeights;
                for (int i = 0; i < 4; i++)
                {
                    if (weights[i] > 0)
                    {
                        influences++;
                        vertexInfluences.Add(indices[i]);
                        vertexInfluences.Add(weightIdx++);
                    }
                }

                vertexInfluenceCounts.Add(influences);
            }

            var jointOffsets = new InputLocalOffset();

            jointOffsets.semantic = "JOINT";
            jointOffsets.source   = "#" + jointSource.id;
            jointOffsets.offset   = 0;

            var weightOffsets = new InputLocalOffset();

            weightOffsets.semantic = "WEIGHT";
            weightOffsets.source   = "#" + weightsSource.id;
            weightOffsets.offset   = 1;

            var vertWeights = new skinVertex_weights();

            vertWeights.count  = (ulong)vertices.Count;
            vertWeights.input  = new InputLocalOffset[] { jointOffsets, weightOffsets };
            vertWeights.v      = string.Join(" ", vertexInfluences.Select(x => x.ToString()).ToArray());
            vertWeights.vcount = string.Join(" ", vertexInfluenceCounts.Select(x => x.ToString()).ToArray());

            var skin = new skin();

            skin.source1           = "#" + geometryId;
            skin.bind_shape_matrix = "1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1";

            var skinJoints     = new skinJoints();
            var skinJointInput = new InputLocal();

            skinJointInput.semantic = "JOINT";
            skinJointInput.source   = "#" + jointSource.id;
            var skinInvBindInput = new InputLocal();

            skinInvBindInput.semantic = "INV_BIND_MATRIX";
            skinInvBindInput.source   = "#" + poseSource.id;
            skinJoints.input          = new InputLocal[] { skinJointInput, skinInvBindInput };

            skin.joints         = skinJoints;
            skin.source         = new source[] { jointSource, poseSource, weightsSource };
            skin.vertex_weights = vertWeights;

            return(skin);
        }
Beispiel #18
0
 private Skin(skin skinData)
     : base()
 {
     MapProperties(this, skinData);
 }
Beispiel #19
0
        private static List <STGenericMesh> LoadMeshData(ColladaScene scene, Node node,
                                                         geometry geom, library_materials materials, controller controller = null)
        {
            List <STGenericMesh> meshes = new List <STGenericMesh>();

            mesh daeMesh = geom.Item as mesh;

            STGenericMesh mesh = new STGenericMesh();

            mesh.Vertices = new List <STVertex>();
            mesh.Name     = geom.name;
            meshes.Add(mesh);

            var boneWeights = ParseWeightController(controller, scene);

            foreach (var item in daeMesh.Items)
            {
                //Poly lists can control specific amounts of indices for primitive types like quads
                if (item is polylist)
                {
                    var poly = item as polylist;
                    ConvertPolygon(scene, mesh, daeMesh, poly.input,
                                   boneWeights, materials, poly.material, poly.p, (int)poly.count, poly.vcount);
                }
                else if (item is triangles)
                {
                    var triangle = item as triangles;
                    ConvertPolygon(scene, mesh, daeMesh, triangle.input,
                                   boneWeights, materials, triangle.material, triangle.p, (int)triangle.count);
                }
            }

            for (int v = 0; v < mesh.Vertices.Count; v++)
            {
                if (scene.Settings.FlipUVsVertical)
                {
                    for (int i = 0; i < mesh.Vertices[v].TexCoords.Length; i++)
                    {
                        mesh.Vertices[v].TexCoords[i] = new Vector2(mesh.Vertices[v].TexCoords[i].X, 1 - mesh.Vertices[v].TexCoords[i].Y);
                    }
                }

                mesh.Vertices[v].Position = Vector3.TransformPosition(mesh.Vertices[v].Position, node.Transform);
                mesh.Vertices[v].Normal   = Vector3.TransformNormal(mesh.Vertices[v].Normal, node.Transform);
            }

            if (controller != null)
            {
                skin skin       = controller.Item as skin;
                var  bindMatrix = CreateBindMatrix(skin.bind_shape_matrix);
                Console.WriteLine($"bindMatrix {bindMatrix.ExtractScale()}");
                bindMatrix = bindMatrix.ClearScale();
                for (int v = 0; v < mesh.Vertices.Count; v++)
                {
                    mesh.Vertices[v].Position = Vector3.TransformPosition(mesh.Vertices[v].Position, bindMatrix);
                    mesh.Vertices[v].Normal   = Vector3.TransformNormal(mesh.Vertices[v].Normal, bindMatrix);
                }
            }

            //  meshes = STGenericMesh.SeperatePolygonGroups<STGenericMesh>(mesh);

            if (scene.Settings.RemoveDuplicateVerts)
            {
                // mesh.RemoveDuplicateVertices();
            }

            return(meshes);
        }
        public static void AddSkinnedModelWithAnimations(ref Skin SkinChunk, ref SkeletonCTTR SkeletonChunk, ref Shader[] ShaderChunks)//, ref Animation[] AnimChunks)
        {
            List <uint> IndexList = new List <uint>();

            cachedGeoms.geometry = new geometry[SkinChunk.NumPrimGroups];
            for (int primgroups = 0; primgroups < SkinChunk.NumPrimGroups; primgroups++)
            {
                cachedGeoms.geometry[primgroups]      = new geometry();
                cachedGeoms.geometry[primgroups].id   = "geometry" + primgroups;
                cachedGeoms.geometry[primgroups].name = "geometry" + primgroups;
                mesh newMesh = new Collada141.mesh();

                newMesh.vertices                   = new vertices();
                newMesh.vertices.id                = "geometry" + primgroups + "-vertices";
                newMesh.vertices.name              = "geometry" + primgroups + "-vertices";
                newMesh.vertices.input             = new InputLocal[1];
                newMesh.vertices.input[0]          = new InputLocal();
                newMesh.vertices.input[0].semantic = "POSITION";
                newMesh.vertices.input[0].source   = "#geometry" + primgroups + "-positions";
                //newMesh.vertices.input[1] = new InputLocal();
                //newMesh.vertices.input[1].semantic = "TEXCOORD";
                //newMesh.vertices.input[1].source = "#geometry" + primgroups + "-texcoords";
                //newMesh.vertices.input[2].semantic = "COLOR";
                //newMesh.vertices.input[2].source = "#geometry0-colors";

                newMesh.source = new source[3];

                newMesh.source[0]    = new source();
                newMesh.source[0].id = "geometry" + primgroups + "-positions";
                float_array geom_positions = new float_array();
                geom_positions.id = "geometry" + primgroups + "-positions-array";
                PositionList posList = SkinChunk.GetChildren <PrimitiveGroupCTTR>()[primgroups].GetChildren <PositionList>()[0];
                geom_positions.count  = (ulong)posList.Positions.Length * 3;
                geom_positions.Values = new double[geom_positions.count];
                for (ulong i = 0; i < geom_positions.count / 3; i++)
                {
                    if (i % 3 == 0)
                    {
                        geom_positions.Values[i] = posList.Positions[i / 3].X;
                    }
                    else if (i % 3 == 1)
                    {
                        geom_positions.Values[i] = posList.Positions[i / 3].Y;
                    }
                    else
                    {
                        geom_positions.Values[i] = posList.Positions[i / 3].Z;
                    }
                }

                newMesh.source[0].Item                             = geom_positions;
                newMesh.source[0].technique_common                 = new sourceTechnique_common();
                newMesh.source[0].technique_common.accessor        = new accessor();
                newMesh.source[0].technique_common.accessor.source = "#" + geom_positions.id;
                newMesh.source[0].technique_common.accessor.count  = geom_positions.count / 3;
                newMesh.source[0].technique_common.accessor.stride = 3;
                newMesh.source[0].technique_common.accessor.param  = new param[3] {
                    new param(), new param(), new param(),
                };
                newMesh.source[0].technique_common.accessor.param[0].name = "X";
                newMesh.source[0].technique_common.accessor.param[0].type = "float";
                newMesh.source[0].technique_common.accessor.param[1].name = "Y";
                newMesh.source[0].technique_common.accessor.param[1].type = "float";
                newMesh.source[0].technique_common.accessor.param[2].name = "Z";
                newMesh.source[0].technique_common.accessor.param[2].type = "float";

                newMesh.source[1]    = new source();
                newMesh.source[1].id = "geometry" + primgroups + "-mesh-normals";
                float_array geom_normals = new float_array();
                geom_normals.id = "geometry" + primgroups + "-mesh-map-array";
                NormalList normals = SkinChunk.GetChildren <PrimitiveGroupCTTR>()[primgroups].GetChildren <NormalList>()[0];
                geom_normals.count  = (ulong)normals.Normals.Length * 3;
                geom_normals.Values = new double[geom_normals.count];
                for (ulong i = 0; i < geom_normals.count; i++)
                {
                    if (i % 3 == 0)
                    {
                        geom_normals.Values[i] = normals.Normals[i / 3].X;
                    }
                    else if (i % 3 == 1)
                    {
                        geom_normals.Values[i] = normals.Normals[i / 3].Y;
                    }
                    else
                    {
                        geom_normals.Values[i] = normals.Normals[i / 3].Z;
                    }
                }

                newMesh.source[1].Item                             = geom_normals;
                newMesh.source[1].technique_common                 = new sourceTechnique_common();
                newMesh.source[1].technique_common.accessor        = new accessor();
                newMesh.source[1].technique_common.accessor.source = "#" + geom_normals.id;
                newMesh.source[1].technique_common.accessor.count  = geom_positions.count / 3;
                newMesh.source[1].technique_common.accessor.stride = 3;
                newMesh.source[1].technique_common.accessor.param  = new param[3] {
                    new param(), new param(), new param(),
                };
                newMesh.source[1].technique_common.accessor.param[0].name = "X";
                newMesh.source[1].technique_common.accessor.param[0].type = "float";
                newMesh.source[1].technique_common.accessor.param[1].name = "Y";
                newMesh.source[1].technique_common.accessor.param[1].type = "float";
                newMesh.source[1].technique_common.accessor.param[2].name = "Z";
                newMesh.source[1].technique_common.accessor.param[2].type = "float";

                newMesh.source[2]    = new source();
                newMesh.source[2].id = "geometry" + primgroups + "-mesh-map-0";
                float_array geom_texcoords = new float_array();
                geom_texcoords.id = "geometry" + primgroups + "-mesh-map-array";
                UVList UV = SkinChunk.GetChildren <PrimitiveGroupCTTR>()[primgroups].GetChildren <UVList>()[0];
                geom_texcoords.count  = (ulong)UV.UVs.Length * 2;
                geom_texcoords.Values = new double[geom_texcoords.count];
                for (ulong i = 0; i < geom_texcoords.count; i++)
                {
                    ulong pos = i / 2;
                    geom_texcoords.Values[i] = UV.UVs[pos].X;
                    i++;
                    geom_texcoords.Values[i] = UV.UVs[pos].Y;
                }

                newMesh.source[2].Item                             = geom_texcoords;
                newMesh.source[2].technique_common                 = new sourceTechnique_common();
                newMesh.source[2].technique_common.accessor        = new accessor();
                newMesh.source[2].technique_common.accessor.source = "#" + geom_texcoords.id;
                newMesh.source[2].technique_common.accessor.count  = geom_texcoords.count / 2;
                newMesh.source[2].technique_common.accessor.stride = 2;
                newMesh.source[2].technique_common.accessor.param  = new param[2] {
                    new param(), new param(),
                };
                newMesh.source[2].technique_common.accessor.param[0].name = "S";
                newMesh.source[2].technique_common.accessor.param[0].type = "float";
                newMesh.source[2].technique_common.accessor.param[1].name = "T";
                newMesh.source[2].technique_common.accessor.param[1].type = "float";

                /*
                 * newMesh.source[3].id = "geometry" + primgroups + "-colors-Col";
                 * float_array geom_colors = new float_array();
                 * geom_colors.id = "geometry" + primgroups + "-colors-Col-array";
                 * ColourList colors = SkinChunk.GetChildren<PrimitiveGroupCTTR>()[primgroups].GetChildren<ColourList>()[0];
                 * geom_colors.count = (ulong)colors.Colours.Length * 3;
                 * geom_colors.Values = new double[geom_colors.count];
                 * for (ulong i = 0; i < geom_colors.count / 3; i++)
                 * {
                 *  if (i % 3 == 0)
                 *  {
                 *      geom_colors.Values[i] = colors.Colours[i];
                 *  }
                 *  else if (i % 3 == 1)
                 *  {
                 *      geom_colors.Values[i] = colors.Colours[i / 3];
                 *  }
                 *  else
                 *  {
                 *      geom_colors.Values[i] = colors.Colours[i / 3];
                 *  }
                 * }
                 *
                 * newMesh.source[3].Item = geom_colors;
                 * newMesh.source[3].technique_common = new sourceTechnique_common();
                 * newMesh.source[3].technique_common.accessor = new accessor();
                 * newMesh.source[3].technique_common.accessor.source = geom_colors.id;
                 * newMesh.source[3].technique_common.accessor.count = geom_colors.count / 3;
                 * newMesh.source[3].technique_common.accessor.stride = 3;
                 * newMesh.source[3].technique_common.accessor.param = new param[3];
                 * newMesh.source[3].technique_common.accessor.param[0].name = "R";
                 * newMesh.source[3].technique_common.accessor.param[0].type = "float";
                 * newMesh.source[3].technique_common.accessor.param[1].name = "G";
                 * newMesh.source[3].technique_common.accessor.param[1].type = "float";
                 * newMesh.source[3].technique_common.accessor.param[2].name = "B";
                 * newMesh.source[3].technique_common.accessor.param[2].type = "float";
                 */

                polylist meshTriangles = new polylist();
                meshTriangles.material          = "";
                meshTriangles.count             = (ulong)SkinChunk.GetChildren <PrimitiveGroupCTTR>()[primgroups].GetChildren <IndexList>()[0].Indices.Length / 4;
                meshTriangles.input             = new InputLocalOffset[3];
                meshTriangles.input[0]          = new InputLocalOffset();
                meshTriangles.input[0].semantic = "VERTEX";
                meshTriangles.input[0].source   = "#" + newMesh.vertices.id;
                meshTriangles.input[0].offset   = 0;
                meshTriangles.input[1]          = new InputLocalOffset();
                meshTriangles.input[1].semantic = "NORMAL";
                meshTriangles.input[1].source   = "#" + "geometry" + primgroups + "-mesh-normals";
                meshTriangles.input[1].offset   = 1;
                meshTriangles.input[2]          = new InputLocalOffset();
                meshTriangles.input[2].semantic = "TEXCOORD";
                meshTriangles.input[2].source   = "#" + "geometry" + primgroups + "-mesh-map-0";
                meshTriangles.input[2].offset   = 2;
                meshTriangles.input[2].set      = 0;
                string packed_primitives = "";
                for (int i = 0; i < SkinChunk.GetChildren <PrimitiveGroupCTTR>()[primgroups].GetChildren <IndexList>()[0].Indices.Length; i++)
                {
                    packed_primitives += SkinChunk.GetChildren <PrimitiveGroupCTTR>()[primgroups].GetChildren <IndexList>()[0].Indices[i];
                    packed_primitives += " ";
                }
                string packed_vcount = "";
                for (int i = 0; i < SkinChunk.GetChildren <PrimitiveGroupCTTR>()[primgroups].GetChildren <IndexList>()[0].Indices.Length / 3; i++)
                {
                    packed_vcount += "3 ";
                }
                meshTriangles.vcount = packed_vcount;

                meshTriangles.p = packed_primitives;

                newMesh.Items    = new object[1];
                newMesh.Items[0] = meshTriangles;

                cachedGeoms.geometry[primgroups].Item = newMesh;

                for (int i = 0; i < SkinChunk.GetChildren <PrimitiveGroupCTTR>()[primgroups].GetChildren <IndexList>()[0].Indices.Length; i++)
                {
                    IndexList.Add(SkinChunk.GetChildren <PrimitiveGroupCTTR>()[primgroups].GetChildren <IndexList>()[0].Indices[i]);
                }
            }

            cachedMats.material = new material[ShaderChunks.Length];
            List <string> shader_tex = new List <string>();

            for (int mat = 0; mat < ShaderChunks.Length; mat++)
            {
                cachedMats.material[mat]                     = new material();
                cachedMats.material[mat].id                  = "mat" + ShaderChunks[mat].Name;
                cachedMats.material[mat].name                = ShaderChunks[mat].Name;
                cachedMats.material[mat].instance_effect     = new instance_effect();
                cachedMats.material[mat].instance_effect.url = "#" + ShaderChunks[mat].Name; //effect name
                if (ShaderChunks[mat].GetChildren <ShaderTextureParam>().Length > 0)
                {
                    if (!shader_tex.Contains(ShaderChunks[mat].GetChildren <ShaderTextureParam>()[0].Value))
                    {
                        shader_tex.Add(ShaderChunks[mat].GetChildren <ShaderTextureParam>()[0].Value);
                    }
                }
            }

            cachedImages.image = new image[shader_tex.Count];
            for (int i = 0; i < cachedImages.image.Length; i++)
            {
                cachedImages.image[i]    = new image();
                cachedImages.image[i].id = "image" + shader_tex[i];
                //fx_surface_init_from_common init_from = new fx_surface_init_from_common();
                //init_from.Value = shader_tex[i];
                //cachedImages.image[i].Item = init_from;
            }

            cachedEffects.effect = new effect[ShaderChunks.Length];
            for (int mat = 0; mat < ShaderChunks.Length; mat++)
            {
                cachedEffects.effect[mat]                                        = new effect();
                cachedEffects.effect[mat].id                                     = ShaderChunks[mat].Name;
                cachedEffects.effect[mat].name                                   = ShaderChunks[mat].Name;
                cachedEffects.effect[mat].newparam                               = new fx_newparam_common[2];
                cachedEffects.effect[mat].newparam[0]                            = new fx_newparam_common();
                cachedEffects.effect[mat].newparam[0].sid                        = "Image-surface";
                cachedEffects.effect[mat].newparam[0].surface                    = new fx_surface_common();
                cachedEffects.effect[mat].newparam[0].surface.type               = fx_surface_type_enum.Item2D;
                cachedEffects.effect[mat].newparam[0].surface.init_from          = new fx_surface_init_from_common[1];
                cachedEffects.effect[mat].newparam[0].surface.init_from[0]       = new fx_surface_init_from_common();
                cachedEffects.effect[mat].newparam[0].surface.init_from[0].Value = ShaderChunks[mat].Name;
                cachedEffects.effect[mat].newparam[0].surface.format             = "A8R8G8B8";

                cachedEffects.effect[mat].newparam[1]                     = new fx_newparam_common();
                cachedEffects.effect[mat].newparam[1].sid                 = "Image-sampler";
                cachedEffects.effect[mat].newparam[1].sampler2D           = new fx_sampler2D_common();
                cachedEffects.effect[mat].newparam[1].sampler2D.source    = "Image-surface";
                cachedEffects.effect[mat].newparam[1].sampler2D.wrap_s    = fx_sampler_wrap_common.CLAMP;
                cachedEffects.effect[mat].newparam[1].sampler2D.wrap_t    = fx_sampler_wrap_common.CLAMP;
                cachedEffects.effect[mat].newparam[1].sampler2D.minfilter = fx_sampler_filter_common.NEAREST;
                cachedEffects.effect[mat].newparam[1].sampler2D.magfilter = fx_sampler_filter_common.NEAREST;
                cachedEffects.effect[mat].newparam[1].sampler2D.mipfilter = fx_sampler_filter_common.NEAREST;

                cachedEffects.effect[mat].Items                  = new effectFx_profile_abstractProfile_COMMON[1];
                cachedEffects.effect[mat].Items[0]               = new effectFx_profile_abstractProfile_COMMON();
                cachedEffects.effect[mat].Items[0].technique     = new effectFx_profile_abstractProfile_COMMONTechnique();
                cachedEffects.effect[mat].Items[0].technique.sid = "common";
                effectFx_profile_abstractProfile_COMMONTechniquePhong common_phong = new effectFx_profile_abstractProfile_COMMONTechniquePhong();
                common_color_or_texture_typeTexture textureType = new common_color_or_texture_typeTexture();
                textureType.texture           = "Image-sampler";
                textureType.texcoord          = "tc";
                common_phong.diffuse          = new common_color_or_texture_type();
                common_phong.diffuse.Item     = textureType;
                common_phong.transparent      = new common_transparent_type();
                common_phong.transparent.Item = textureType;

                cachedEffects.effect[mat].Items[0].technique.Item = common_phong;
            }

            cachedControllers.controller = new controller[SkinChunk.NumPrimGroups];

            for (int a = 0; a < SkinChunk.NumPrimGroups; a++)
            {
                cachedControllers.controller[a]      = new controller();
                cachedControllers.controller[a].id   = SkinChunk.Name + a;
                cachedControllers.controller[a].name = SkinChunk.Name + a;

                skin ControllerSkin = new skin();

                ControllerSkin.source1 = "#geometry" + a;
                ControllerSkin.source  = new source[3];

                ControllerSkin.source[0]    = new source();
                ControllerSkin.source[0].id = "controller" + a + "-joints";
                Name_array Joints_Names = new Name_array();
                Joints_Names.id     = "controller" + a + "-joints-array";
                Joints_Names.count  = (ulong)SkeletonChunk.GetChildren <SkeletonJointCTTR>().Length;
                Joints_Names.Values = new string[Joints_Names.count];
                for (ulong i = 0; i < Joints_Names.count; i++)
                {
                    Joints_Names.Values[i] = SkeletonChunk.GetChildren <SkeletonJointCTTR>()[i].Name;
                }

                ControllerSkin.source[0].Item                             = Joints_Names;
                ControllerSkin.source[0].technique_common                 = new sourceTechnique_common();
                ControllerSkin.source[0].technique_common.accessor        = new accessor();
                ControllerSkin.source[0].technique_common.accessor.source = "#" + Joints_Names.id;
                ControllerSkin.source[0].technique_common.accessor.count  = Joints_Names.count;
                ControllerSkin.source[0].technique_common.accessor.param  = new param[1] {
                    new param()
                };
                ControllerSkin.source[0].technique_common.accessor.param[0].name = "JOINT";
                ControllerSkin.source[0].technique_common.accessor.param[0].type = "Name";

                ControllerSkin.source[1]    = new source();
                ControllerSkin.source[1].id = "controller" + a + "-bind_poses";
                float_array Bind_Poses = new float_array();
                Bind_Poses.id     = "controller" + a + "-bind_poses-array";
                Bind_Poses.count  = (ulong)SkeletonChunk.GetChildren <SkeletonJointCTTR>().Length * 16;
                Bind_Poses.Values = new double[Bind_Poses.count];
                int bind_pose_pos = 0;
                for (ulong i = 0; i < Joints_Names.count; i++)
                {
                    Bind_Poses.Values[bind_pose_pos] = SkeletonChunk.GetChildren <SkeletonJointCTTR>()[i].RestPose.M11;
                    bind_pose_pos++;
                    Bind_Poses.Values[bind_pose_pos] = SkeletonChunk.GetChildren <SkeletonJointCTTR>()[i].RestPose.M12;
                    bind_pose_pos++;
                    Bind_Poses.Values[bind_pose_pos] = SkeletonChunk.GetChildren <SkeletonJointCTTR>()[i].RestPose.M13;
                    bind_pose_pos++;
                    Bind_Poses.Values[bind_pose_pos] = SkeletonChunk.GetChildren <SkeletonJointCTTR>()[i].RestPose.M14;
                    bind_pose_pos++;
                    Bind_Poses.Values[bind_pose_pos] = SkeletonChunk.GetChildren <SkeletonJointCTTR>()[i].RestPose.M21;
                    bind_pose_pos++;
                    Bind_Poses.Values[bind_pose_pos] = SkeletonChunk.GetChildren <SkeletonJointCTTR>()[i].RestPose.M22;
                    bind_pose_pos++;
                    Bind_Poses.Values[bind_pose_pos] = SkeletonChunk.GetChildren <SkeletonJointCTTR>()[i].RestPose.M23;
                    bind_pose_pos++;
                    Bind_Poses.Values[bind_pose_pos] = SkeletonChunk.GetChildren <SkeletonJointCTTR>()[i].RestPose.M24;
                    bind_pose_pos++;
                    Bind_Poses.Values[bind_pose_pos] = SkeletonChunk.GetChildren <SkeletonJointCTTR>()[i].RestPose.M31;
                    bind_pose_pos++;
                    Bind_Poses.Values[bind_pose_pos] = SkeletonChunk.GetChildren <SkeletonJointCTTR>()[i].RestPose.M32;
                    bind_pose_pos++;
                    Bind_Poses.Values[bind_pose_pos] = SkeletonChunk.GetChildren <SkeletonJointCTTR>()[i].RestPose.M33;
                    bind_pose_pos++;
                    Bind_Poses.Values[bind_pose_pos] = SkeletonChunk.GetChildren <SkeletonJointCTTR>()[i].RestPose.M34;
                    bind_pose_pos++;
                    Bind_Poses.Values[bind_pose_pos] = SkeletonChunk.GetChildren <SkeletonJointCTTR>()[i].RestPose.M41;
                    bind_pose_pos++;
                    Bind_Poses.Values[bind_pose_pos] = SkeletonChunk.GetChildren <SkeletonJointCTTR>()[i].RestPose.M42;
                    bind_pose_pos++;
                    Bind_Poses.Values[bind_pose_pos] = SkeletonChunk.GetChildren <SkeletonJointCTTR>()[i].RestPose.M43;
                    bind_pose_pos++;
                    Bind_Poses.Values[bind_pose_pos] = SkeletonChunk.GetChildren <SkeletonJointCTTR>()[i].RestPose.M44;
                    bind_pose_pos++;
                }

                ControllerSkin.source[1].Item                             = Bind_Poses;
                ControllerSkin.source[1].technique_common                 = new sourceTechnique_common();
                ControllerSkin.source[1].technique_common.accessor        = new accessor();
                ControllerSkin.source[1].technique_common.accessor.source = "#" + Bind_Poses.id;
                ControllerSkin.source[1].technique_common.accessor.count  = Bind_Poses.count;
                ControllerSkin.source[1].technique_common.accessor.param  = new param[1] {
                    new param()
                };
                ControllerSkin.source[1].technique_common.accessor.param[0].name = "TRANSFORM";
                ControllerSkin.source[1].technique_common.accessor.param[0].type = "float4x4";

                ControllerSkin.source[2]    = new source();
                ControllerSkin.source[2].id = "controller" + a + "-weights";
                float_array Weights_Array = new float_array();
                Weights_Array.id     = "controller" + a + "-weights-array";
                Weights_Array.count  = Joints_Names.count;
                Weights_Array.Values = new double[Joints_Names.count];
                for (int i = 0; i < Weights_Array.Values.Length; i++)
                {
                    Weights_Array.Values[i] = 1;
                }

                ControllerSkin.source[2].Item                             = Weights_Array;
                ControllerSkin.source[2].technique_common                 = new sourceTechnique_common();
                ControllerSkin.source[2].technique_common.accessor        = new accessor();
                ControllerSkin.source[2].technique_common.accessor.source = "#" + Weights_Array.id;
                ControllerSkin.source[2].technique_common.accessor.count  = Weights_Array.count;
                ControllerSkin.source[2].technique_common.accessor.param  = new param[1] {
                    new param()
                };
                ControllerSkin.source[2].technique_common.accessor.param[0].name = "WEIGHT";
                ControllerSkin.source[2].technique_common.accessor.param[0].type = "float";

                ControllerSkin.joints       = new skinJoints();
                ControllerSkin.joints.input = new InputLocal[2] {
                    new InputLocal(), new InputLocal()
                };
                ControllerSkin.joints.input[0].semantic = "JOINT";
                ControllerSkin.joints.input[0].source   = "#" + ControllerSkin.source[0].id;
                ControllerSkin.joints.input[1].semantic = "INV_BIND_MATRIX";
                ControllerSkin.joints.input[1].source   = "#" + ControllerSkin.source[1].id;

                ControllerSkin.vertex_weights       = new skinVertex_weights();
                ControllerSkin.vertex_weights.count = (ulong)IndexList.Count;
                ControllerSkin.vertex_weights.input = new InputLocalOffset[2] {
                    new InputLocalOffset(), new InputLocalOffset()
                };
                ControllerSkin.vertex_weights.input[0].semantic = "JOINT";
                ControllerSkin.vertex_weights.input[0].source   = "#" + ControllerSkin.source[0].id;
                ControllerSkin.vertex_weights.input[0].offset   = 0;
                ControllerSkin.vertex_weights.input[1].semantic = "WEIGHT";
                ControllerSkin.vertex_weights.input[1].source   = "#" + ControllerSkin.source[2].id;
                ControllerSkin.vertex_weights.input[1].offset   = 1;
                string vertex_vcount = "";
                for (int i = 0; i < IndexList.Count; i++)
                {
                    vertex_vcount += "1 ";
                }
                ControllerSkin.vertex_weights.vcount = vertex_vcount;

                string index_list_str = "";
                for (int i = 0; i < IndexList.Count; i++)
                {
                    index_list_str += IndexList[i] + " ";
                }

                ControllerSkin.vertex_weights.v = index_list_str;

                cachedControllers.controller[a].Item = ControllerSkin;
            }

            cachedVscenes.visual_scene = new visual_scene[1] {
                new visual_scene()
            };
            cachedVscenes.visual_scene[0].id      = "Scene0";
            cachedVscenes.visual_scene[0].name    = "Scene0";
            cachedVscenes.visual_scene[0].node    = new node[SkinChunk.NumPrimGroups + 1];
            cachedVscenes.visual_scene[0].node[0] = new node();
            //cachedVscenes.visual_scene[0].node[0].Items = new object[1];
            //cachedVscenes.visual_scene[0].node[0].Items[0] = new matrix();

            for (int i = 0; i < SkeletonChunk.Children.Count; i++)
            {
                SkeletonJointCTTR joint = (SkeletonJointCTTR)SkeletonChunk.Children[i];
                if (joint.SkeletonParent == 0)
                {
                    //cachedVscenes.visual_scene[0].node[0].node1 = new node[10];
                }
            }

            cachedVscenes.visual_scene[0].node[0].id   = SkeletonChunk.Name;
            cachedVscenes.visual_scene[0].node[0].type = NodeType.JOINT;

            //todo: joints node tree
            // SkeletonParent - 0 means root, the rest is chunk child index
            // SkeletonJointCTTR.BindPose matrix as transform matrix?

            for (int i = 1; i < SkinChunk.NumPrimGroups + 1; i++)
            {
                cachedVscenes.visual_scene[0].node[i] = new node();

                cachedVscenes.visual_scene[0].node[i].id   = "node" + i;
                cachedVscenes.visual_scene[0].node[i].name = "polygon" + i;
                cachedVscenes.visual_scene[0].node[i].type = NodeType.NODE;
                cachedVscenes.visual_scene[0].node[i].instance_controller = new instance_controller[1] {
                    new instance_controller()
                };
                cachedVscenes.visual_scene[0].node[i].instance_controller[0].url      = "#" + cachedControllers.controller[i - 1].id;
                cachedVscenes.visual_scene[0].node[i].instance_controller[0].skeleton = new string[1] {
                    "#" + cachedVscenes.visual_scene[0].node[0].id
                };
                cachedVscenes.visual_scene[0].node[i].instance_controller[0].bind_material = new bind_material();
                cachedVscenes.visual_scene[0].node[i].instance_controller[0].bind_material.technique_common = new instance_material[1] {
                    new instance_material()
                };
                cachedVscenes.visual_scene[0].node[i].instance_controller[0].bind_material.technique_common[0].symbol            = "#" + cachedMats.material[0].id;
                cachedVscenes.visual_scene[0].node[i].instance_controller[0].bind_material.technique_common[0].target            = "#" + cachedMats.material[0].id;
                cachedVscenes.visual_scene[0].node[i].instance_controller[0].bind_material.technique_common[0].bind_vertex_input = new instance_materialBind_vertex_input[1] {
                    new instance_materialBind_vertex_input()
                };
                cachedVscenes.visual_scene[0].node[i].instance_controller[0].bind_material.technique_common[0].bind_vertex_input[0].semantic       = "tc";
                cachedVscenes.visual_scene[0].node[i].instance_controller[0].bind_material.technique_common[0].bind_vertex_input[0].input_semantic = "TEXCOORD";
            }



            //not working:
            // - vertex weights error out
            // - mesh comes out wrong

            //animclips
            //anims
        }
Beispiel #21
0
        public void InitializeBase(IWebDriver objDriver)
        {
            //LoginPage = new MdnHomePage(driver);
            //LoginPage1 = new MdnLoginPage1(driver);
            //HomePage = new MdnHomePage(driver);
            //CommonPage = new MdnCommonPage(driver);

            #region initialize old
            driver                = objDriver;
            CheckOutobj           = new CheckOut(driver);
            takeScreenhsot        = new ScreenShot(driver);
            approvalrequest       = new Approvalrequestobject(driver);
            instructors           = new Instructor(driver);
            approvalrequest       = new Approvalrequestobject(driver);
            DomainConsoleobj      = new DomainConsole(driver);
            ManageGradebookobj    = new ManageGradebook();
            Instructorsobj        = new Instructorspof();
            MyResponsibilitiesobj = new My_Responsibilities(driver);
            manageuserobj         = new ManageUsers(driver);
            objTrainingHome       = new TrainingHomes(driver);
            objCurriculum         = new CreateCurriculum(driver);
            classroomcourse       = new ClassroomCourse(driver);
            ContentSearchobj      = new ContentSearch(driver);
            objCreate             = new Create(driver);
            detailspage           = new Details(driver);


            TrainingHomeobj         = new TrainingHomes(driver);
            AdminstrationConsoleobj = new AdminstrationConsole(driver);
            Testsobj             = new Tests(driver);
            Detailsobj           = new Details(driver);
            EditSummaryobj       = new EditSummary(driver);
            Scorm1_2obj          = new Scorm1_2(driver);
            EditQuestionobj      = new EditQuestion(driver);
            EditQuestionGroupobj = new EditQuestionGroup(driver);

            AddUsrObj = new AddUsers(driver);

            generalcourseobj           = new GeneralCourse(driver);
            myteachingscheduleobj      = new MyTeachingSchedule();
            professionaldevelopmentobj = new ProfessionalDevelopments(driver);
            documentobj                = new Document(driver);
            CreateNewAccountobj        = new CreateNewAccount(driver);
            ManageUsersobj             = new ManageUsers(driver);
            Createobj                  = new Create(driver);
            summaryobj                 = new Summary(driver);
            reauiredtrainingconsoleobj = new RequiredTrainingConsoles(driver);
            requiredtrainingobj        = new RequiredTraining(driver);
            Trainingobj                = new Training(driver);
            Loginobj      = new Login(driver);
            Contentobj    = new Content(driver);
            Creditsobj    = new Credits(driver);
            AddContentobj = new AddContent(driver);
            Summaryobj    = new Summary(driver);
            ScheduleAndManageSectionobj = new ScheduleAndManageSection(driver);
            SearchResultsobj            = new SearchResults(driver);
            CourseSectionobj            = new CreateNewCourseSectionAndEventPage(driver);
            Transcriptsobj              = new Transcripts(driver);
            Productsobj                 = new Products(driver);
            BrowseTrainingCatalogobj    = new BrowseTrainingCatalog(driver);
            ShoppingCartsobj            = new ShoppingCarts(driver);
            ProfessionalDevelopmentsobj = new ProfessionalDevelopments(driver);
            Createnewproficencyscaleobj = new Createnewproficencyscale(driver);
            Createnewcompetencyobj      = new Createnewcompetency(driver);
            CreateNewSucessProfileobj   = new CreateNewSucessProfile(driver);
            SucessProfileobj            = new SucessProfile(driver);
            Searchobj             = new Search(driver);
            TrainingActivitiesobj = new TrainingActivities(driver);
            ProfessionalDevelopments_learnerobj = new ProfessionalDevelopments_learner(driver);
            Organizationobj             = new Organization(driver);
            DevelopmentPlansobj         = new DevelopmentPlans(driver);
            AddDevelopmentActivitiesobj = new AddDevelopmentActivities(driver);
            MyAccountobj            = new MyAccount(driver);
            UsersUtilobj            = new UsersUtil(driver);
            MyCalendersobj          = new MyCalenders(driver);
            MyReportsobj            = new MyReports(driver);
            Config_Reportsobj       = new Config_Reports(driver);
            ConfigurationConsoleobj = new ConfigurationConsole(driver);
            ApprovalPathobj         = new ApprovalPath(driver);
            MyMessageobj            = new MyMessages(driver);
            MessageUtilobj          = new MessageUtil(driver);
            MyRequestsobj           = new MyRequests(driver);
            Blogsobj = new Blogs(driver);
            CollabarationSpacesobj = new CollabarationSpaces(driver);
            Faqsobj                     = new Faqs(driver);
            HomePageFeedobj             = new HomePageFeed(driver);
            ProductTypesobj             = new ProductTypes(driver);
            Surveysobj                  = new Surveys(driver);
            SurveyScalesobj             = new SurveyScales(driver);
            AuditingConsolesobj         = new AuditingConsoles(driver);
            Categoryobj                 = new Category(driver);
            Trainingsobj                = new Trainings(driver);
            VirtualMeetingsobj          = new VirtualMeetings(driver);
            CreditTypeobj               = new CreditType(driver);
            AssignedUserobj             = new AssignedUser(driver);
            AddUsersobj                 = new AddUsers(driver);
            CustomFieldobj              = new CustomField(driver);
            CreateNewCustomFieldobj     = new CreateNewCustomField(driver);
            EditFieldobj                = new EditField(driver);
            EducationLevelobj           = new EducationLevel(driver);
            EditOrganizationobj         = new EditOrganization(driver);
            SelectManagerobj            = new SelectManager(driver);
            Roleobj                     = new Role(driver);
            SelectTrainingPOCobj        = new SelectTrainingPOC(driver);
            Complexobj                  = new Complex(driver);
            AccountCodesobj             = new AccountCodes(driver);
            AccountCodeTypesobj         = new AccountCodeTypes(driver);
            DiscountCodesobj            = new DiscountCodes(driver);
            ManageTaxRatesobj           = new ManageTaxRates(driver);
            TaxItemCategoriesobj        = new TaxItemCategories(driver);
            Certificatesobj             = new Certificates(driver);
            CourseProvidersobj          = new CourseProviders(driver);
            ExternalLearningsobj        = new ExternalLearnings(driver);
            ExternalLearningConsolesobj = new ExternalLearningConsoles(driver);
            ExternalLearningtypesobj    = new ExternalLearningtypes(driver);
            RequiredTrainingConsolesobj = new RequiredTrainingConsoles(driver);
            SelectProfileobj            = new SelectProfile(driver);
            TrainingProfilesobj         = new TrainingProfiles(driver);
            EditTrainingProfileobj      = new EditTrainingProfile(driver);
            MergeUsersobj               = new MergeUsers(driver);
            UserGroupobj                = new UserGroup(driver);
            SelectCertificateobj        = new SelectCertificate(driver);
            ManageProficencyScaleobj    = new ManageProficencyScale(driver);
            ArchivedProficencyScaleobj  = new ArchivedProficencyScale(driver);
            MappedContentobj            = new MappedContent(driver);
            MappedCompetencyobj         = new MappedCompetency(driver);
            ManageSuccessProfileobj     = new ManageSuccessProfile(driver);
            FAQ_lobj                    = new FAQ_l(driver);
            Announcements_lobj          = new Announcements_l(driver);
            JobTitlesobj                = new JobTitles(driver);
            ManageJobTitleobj           = new ManageJobTitle(driver);
            ManagePricingScheduleobj    = new ManagePricingSchedule(driver);
            ExternalLearningSearchobj   = new ExternalLearningSearch(driver);
            urlobj              = new url(driver);
            skinobj             = new skin(driver);
            MyOwnLearningobj    = new MyOwnLearningUtils(driver);
            CurrentTrainingsobj = new CurrentTrainings(driver);
            scormobj            = new Scorm12(driver);
            aicccourse          = new AICC(driver);
            ojtcourse           = new OJT(driver);
            TrainingCatalogobj  = new TrainingCatalogUtil(driver);
            accesskeys          = new AccessKeys(driver);
            #endregion
        }