private void InitializeModelData() { // Check if this model is an npc, and if so jankload the animation for it. if (this.renderDatums.Length == 1)// && // ArcFileCollection.Instance.ArcFiles[this.renderDatums[0].ArcIndex].FileEntries[this.renderDatums[0].FileIndex].FileName.Contains("npc") == true) { Archive arcFile; ArchiveFileEntry fileEntry; ArchiveCollection.Instance.GetArchiveFileEntryFromDatum(this.renderDatums[0], out arcFile, out fileEntry); string animationFileName = fileEntry.FileName.Replace("rModel", "rMotionList").Replace("model", "motion"); ArchiveCollection.Instance.GetArchiveFileEntryFromFileName(animationFileName, out arcFile, out fileEntry); if (fileEntry != null) { this.modelAnimation = arcFile.GetFileAsResource <rMotionList>(fileEntry.FileName); } } // Loop through all of the datums to render and setup each one for rendering. this.resourcesToRender = new GameResource[this.renderDatums.Length]; for (int i = 0; i < this.renderDatums.Length; i++) { // Create the game resource from the datum. this.resourcesToRender[i] = ArchiveCollection.Instance.GetFileAsResource <GameResource>(this.renderDatums[i]); if (this.resourcesToRender[i] == null) { // Failed to load the required resource. // TODO: Bubble this up to the user. throw new NotImplementedException(); } // Let the object initialize and required directx resources. if (this.resourcesToRender[i].InitializeGraphics(this, this.device) == false) { // Failed to initialize graphics for resource. // TODO: Bubble this up to the user. throw new NotImplementedException(); } } // HACK: For now just cast the first resource to an rModel and use it for reference. rModel firstModel = (rModel)this.resourcesToRender[0]; // Position the camera and make it look at the model. this.camera.Position = new Vector3(firstModel.primitives[0].BoundingBoxMin.X, firstModel.primitives[0].BoundingBoxMin.Y, firstModel.primitives[0].BoundingBoxMin.Z); this.camera.LookAt = (firstModel.header.BoundingBoxMax - firstModel.header.BoundingBoxMin).ToVector3(); //this.camera.Speed = Math.Abs(firstModel.primitives[0].BoundingBoxMin.X / 1000.0f); this.camera.SpeedModifier = Math.Abs(firstModel.primitives[0].BoundingBoxMin.X / 100000.0f); }
protected override void OnGameResourceUpdated() { // Make sure the arc file and game resource are valid. if (this.ArcFile == null || this.GameResource == null) { // Clear the textbox contents and return. this.textBox1.Text = ""; return; } // Cast the resource to an rMotionList object. rMotionList motion = (rMotionList)this.GameResource; // Print all the animation information out to the textbox. string headerInfo = string.Format("*** Header\n{0}\n", StructureToString(motion.header)); string animationDesc = ""; for (int i = 0; i < motion.header.AnimationCount; i++) { animationDesc += string.Format("****************** Animation #{0} ******************\n{1}\n", i, StructureToString(motion.animations[i])); for (int x = 0; x < motion.animations[i].JointCount; x++) { animationDesc += string.Format("\tKey Frame {0}:\tBufferType={1}\tUsage={2}\t\tJointType={3}\tJointIndex={4}\tWeight={5}\t\tDataSize={6}\tDataOffset={7}\n", x, motion.animations[i].KeyFrames[x].Codec, motion.animations[i].KeyFrames[x].Usage, motion.animations[i].KeyFrames[x].JointType, motion.animations[i].KeyFrames[x].JointIndex, motion.animations[i].KeyFrames[x].BlendWeight, motion.animations[i].KeyFrames[x].DataSize, motion.animations[i].KeyFrames[x].DataOffset); //for (int z = 0; z < motion.animations[i].KeyFrames[x].KeyFrameData.Length; z++) //{ // animationDesc += string.Format("\t\tComponent= X={0}\tY={1}\tZ={2}\t\tFlags={3}\n", motion.animations[i].KeyFrames[x].KeyFrameData[z].Component.X, // motion.animations[i].KeyFrames[x].KeyFrameData[z].Component.Y, motion.animations[i].KeyFrames[x].KeyFrameData[z].Component.Z, // motion.animations[i].KeyFrames[x].KeyFrameData[z].Flags); //} } animationDesc += "\n"; } this.textBox1.Text = headerInfo.Replace("\n", "\r\n") + animationDesc.Replace("\n", "\r\n"); }