Пример #1
0
        private void loadDae(Mesh target)
        {
            gameWindow.log("load Collada: " + target.pointer);

            ColladaScene colladaScene = new ColladaScene(target.pointer);
            colladaScene.saveTo(ref target);

            target.loaded = true;

            if (target.type != Mesh.Type.empty)
            {
                parseFaceList(ref target, false);

                generateVBO(ref target);
            }

            if (target.identifier != -1)
            {
                meshes[target.identifier] = target;
            }
        }
Пример #2
0
        private void loadManagedCollada(Mesh target)
        {
            gameWindow.log("load Managed Collada: " + target.pointer);

            ColladaScene colladaScene = new ColladaScene(gameWindow.modelFolder + target.pointer);
            colladaScene.stepSize = 1.0f / target.animationFps;
            colladaScene.appendAnimations(target.animationData);
            colladaScene.saveTo(ref target);

            target.loaded = true;

            if (target.type != Mesh.Type.empty)
            {
                parseFaceList(ref target, false);

                generateVBO(ref target);
            }

            if (target.identifier != -1)
            {
                meshes[target.identifier] = target;
            }
        }
Пример #3
0
 public ColladaLibraryAnimation(ref XmlTextReader reader, ColladaObject parent, ColladaScene scene)
     : base(ref reader, parent, scene, "library_animations")
 {
 }
Пример #4
0
            public ColladaNode(ref XmlTextReader reader, ColladaObject parent, ColladaScene scene)
                : base(ref reader, parent, scene, "node")
            {
                scene.nodes.Add(this);

                TreeName = treeName;
            }
Пример #5
0
 public ColladaInput(ref XmlTextReader reader,  ColladaObject parent, ColladaScene scene)
     : base(ref reader, parent, scene)
 {
 }
Пример #6
0
 public ColladaJoint(ref XmlTextReader reader, ColladaNode parent, ColladaScene scene)
     : base(ref reader, parent, scene)
 {
     //scene.nodes.Add(this);
 }
Пример #7
0
 public ColladaAnimation(ref XmlTextReader reader, ColladaObject parent, ColladaScene scene)
     : base(ref reader, parent, scene, "animation")
 {
     ColladaLibraryAnimation libPar = (ColladaLibraryAnimation)parent;
     libPar.animations.Add(this);
 }
Пример #8
0
 public ColladaControler(ref XmlTextReader reader, ColladaObject parent, ColladaScene scene)
     : base(ref reader, parent, scene, "controller")
 {
 }
Пример #9
0
            public ColladaVertWeights(ref XmlTextReader reader,  ColladaObject parent, ColladaScene scene)
                : base(ref reader, parent, scene, "vertex_weights")
            {
                int groupCount = 0;
                ColladaInput jointIn = getInput("JOINT");
                ColladaInput weightIn = getInput("WEIGHT");

                float[] weights = weightIn.FloatAry;

                int groupOffset = jointIn.offset;
                int weightOffset = weightIn.offset;

                int vertexCount = vCounts.Length;
                int attributeCount = CalculateAttributeCount();
                int readerPos = 0;

                string[] boneNames = jointIn.NameAry;
                scene.colladaAnimationDataGenerator.boneNames = boneNames;

                groupCount = boneNames.Length;
                if (groupCount > maxAffBones)
                    groupCount = maxAffBones;

                float[][] tmpBoneWeights = new float[groupCount][];
                int[][] tmpBoneIds = new int[groupCount][];

                for (int i = 0; i < groupCount; i++)
                {
                    tmpBoneWeights[i] = new float[vertexCount];
                    tmpBoneIds[i] = new int[vertexCount];
                }

                for (int i = 0; i < vertexCount; i++)
                {
                    int curGroups = vCounts[i];
                    List<WeightJointPair> weightList = new List<WeightJointPair> { };

                    for (int j = 0; j < curGroups; j++)
                    {
                        int id = weightIndices[readerPos + groupOffset];

                        int weightIndex = weightIndices[readerPos + weightOffset];
                        float weight = weights[weightIndex];

                        weightList.Add(new WeightJointPair(id, weight));

                        readerPos += attributeCount;
                    }

                    weightList.Sort(CompareByWeight);

                    float totalWeight = 0;
                    for (int j = 0; j < groupCount && j < curGroups; j++)
                    {
                        totalWeight += weightList[j].weight;
                    }
                    for (int j = 0; j < groupCount && j < curGroups; j++)
                    {

                            tmpBoneWeights[j][i] = weightList[j].weight / totalWeight;
                            tmpBoneIds[j][i] = weightList[j].joint + 1;
                    }
                }

                scene.boneWeights = tmpBoneWeights;
                scene.boneIds = tmpBoneIds;
            }
Пример #10
0
 public Collada(ref XmlTextReader reader, ColladaScene scene)
     : base(ref reader, null, scene, "COLLADA")
 {
 }
Пример #11
0
 public ColladaVerts(ref XmlTextReader reader, ColladaObject parent, ColladaScene scene)
     : base(ref reader, parent, scene, "vertices")
 {
 }
Пример #12
0
 public ColladaSource(ref XmlTextReader reader, ColladaObject parent, ColladaScene scene)
     : base(ref reader, parent, scene, "source")
 {
 }
Пример #13
0
            public ColladaPolys(ref XmlTextReader reader, ColladaObject parent, ColladaScene scene)
                : base(ref reader,parent, scene, "polylist")
            {
                int position = 0;
                foreach (var vCount in vCounts)
                {
                    Polys.Add(new Face(vCount,position));
                    position += vCount;
                }

                int attributeCount = CalculateAttributeCount();

                ColladaInput vertIn = getInput("VERTEX");
                ColladaInput normalIn = getInput("NORMAL");
                ColladaInput texIn = getInput("TEXCOORD");

                scene.positionVboDataList = vertIn.Vector3Data;
                scene.normalVboDataList = normalIn.Vector3Data;
                scene.textureVboDataList = GenericMethods.FlipY(texIn.Vector2Data);

                int offset = vertIn.offset;
                int normaloffset = normalIn.offset;
                int texoffset = texIn.offset;

                foreach (var Poly in Polys)
                {
                    int basepos = Poly.position * attributeCount;
                    foreach (var vert in Poly.Vertice)
                    {
                        vert.Vi = rawIndices[basepos + offset];
                        vert.Ni = rawIndices[basepos + normaloffset];
                        vert.Ti = rawIndices[basepos + texoffset];
                        basepos += attributeCount;
                    }
                }

                scene.FaceList = Polys;
            }
Пример #14
0
            public ColladaObject(ref XmlTextReader reader, ColladaObject parent, ColladaScene scene)
            {
                this.parent = parent;
                parent.childs.Add(this);

                this.scene = scene;
                scene.colladaObjects.Add(this);

                while (reader.MoveToNextAttribute())
                {
                    specialHeaderAttributes(ref reader);
                    genericHeaderAttributes(ref reader);
                }
            }
Пример #15
0
            public ColladaObject(ref XmlTextReader reader,  ColladaObject parent, ColladaScene scene, string nodename)
            {
                this.parent = parent;
                if(parent != null)
                    parent.childs.Add(this);

                this.scene = scene;
                scene.colladaObjects.Add(this);

                this.nodename = nodename;

                while (reader.MoveToNextAttribute())
                {
                    specialHeaderAttributes(ref reader);
                    genericHeaderAttributes(ref reader);
                }
                while (reader.Read() && !(reader.Name == nodename && reader.NodeType == XmlNodeType.EndElement) )
                {
                    specialAttributes(ref reader);
                    genericAttributes(ref reader);
                }
            }