Example #1
0
        public Mdl(mdl_t mdlTStruct,
				   texgroup_struct[] tgs,
				   stvert_t[] vertData,
				   dtriangle_t[] triData,
				   frame_struct[] frame
				   )
        {
            this.header = mdlTStruct;
            this.texGroup = tgs;
            this.vertex = vertData;
            this.triangle = triData;
            this.frame = frame;
        }
Example #2
0
        private frame_struct[] readFrameData(mdl_t mdlTStruct, System.IO.FileStream fstream)
        {
            daliasframetype_t frametype;
            frame_struct[] frame = new frame_struct[mdlTStruct.numframes];

            for(int frame_num = 0; frame_num < mdlTStruct.numframes; frame_num++){
                frametype.type = (aliasframetype_t) readInt(fstream);

                frame[frame_num].type = frametype.type;
                Console.WriteLine("Frame type for frame #{0} is {1}", frame_num, frametype.type);

                if(frametype.type == aliasframetype_t.ALIAS_SINGLE){
                    //no group data for single-frame meshes
                    //we want to use the same data structure, though so set numposes
                    frame[frame_num].numposes = 1;

                    //no interval data for single-frame meshes - set to zero
                    frame[frame_num].interval = new float[1];
                    frame[frame_num].interval[0] = 0.0f;
                }else{
                    //read group data for multi-frame meshes
                    daliasgroup_t groupData = readDAliasGroup(fstream);
                    frame[frame_num].numposes = groupData.numposes;
                    frame[frame_num].interval = new float[groupData.numposes];

                    for(int i = 0; i < groupData.numposes; i++){
                        frame[frame_num].interval[i] = readSingle(fstream);
                    }
                }

                // Read pose data
                frame[frame_num].pose = new pose_struct[frame[frame_num].numposes];

                for(int i = 0; i < frame[frame_num].numposes; i++){
                    daliasframe_t dAliasFrame = readDAliasFrame(fstream);
                    frame[frame_num].pose[i].name   = dAliasFrame.name;
                    Console.WriteLine("Reading pose named {0}", frame[frame_num].pose[i].name);
                    frame[frame_num].pose[i].vertex = new trivertx_t[mdlTStruct.numverts];

                    for(int j = 0; j < mdlTStruct.numverts; j++){
                        frame[frame_num].pose[i].vertex[j] = readTriVertX(fstream);
                    }
                }
            }

            return frame;
        }