Example #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;
            }
        }
Example #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;
            }
        }
Example #3
0
 public ColladaLibraryAnimation(ref XmlTextReader reader, ColladaObject parent, ColladaScene scene)
     : base(ref reader, parent, scene, "library_animations")
 {
 }
Example #4
0
            public ColladaNode(ref XmlTextReader reader, ColladaObject parent, ColladaScene scene)
                : base(ref reader, parent, scene, "node")
            {
                scene.nodes.Add(this);

                TreeName = treeName;
            }
Example #5
0
 public ColladaInput(ref XmlTextReader reader,  ColladaObject parent, ColladaScene scene)
     : base(ref reader, parent, scene)
 {
 }
Example #6
0
 public ColladaJoint(ref XmlTextReader reader, ColladaNode parent, ColladaScene scene)
     : base(ref reader, parent, scene)
 {
     //scene.nodes.Add(this);
 }
Example #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);
 }
Example #8
0
 public ColladaControler(ref XmlTextReader reader, ColladaObject parent, ColladaScene scene)
     : base(ref reader, parent, scene, "controller")
 {
 }
Example #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;
            }
Example #10
0
 public Collada(ref XmlTextReader reader, ColladaScene scene)
     : base(ref reader, null, scene, "COLLADA")
 {
 }
Example #11
0
 public ColladaVerts(ref XmlTextReader reader, ColladaObject parent, ColladaScene scene)
     : base(ref reader, parent, scene, "vertices")
 {
 }
Example #12
0
 public ColladaSource(ref XmlTextReader reader, ColladaObject parent, ColladaScene scene)
     : base(ref reader, parent, scene, "source")
 {
 }
Example #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;
            }
Example #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);
                }
            }
Example #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);
                }
            }