protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); currentFont = Content.Load <SpriteFont>("MgGenFont"); defaultTexture = Content.Load <Texture2D>("CheckerBoardTemplateImage"); orientationArrows = Content.Load <Texture2D>("OrientationImage_PartiallyTransparent"); LoadUpDefaultCamera(); LoadEffects(); bigShere = new SpherePNTT(false, 12, 25f, false, true); littleSphere = new SpherePNTT(false, 12, 5f, true); lineToLight = new LinePCT(.1f, Color.White, Vector3.Zero, initialLightPosition); // prep model reader. RiggedModelLoader modelReader = new RiggedModelLoader(Content, riggedEffect); RiggedModelLoader.DefaultTexture = defaultTexture; modelReader.AddAdditionalLoopingTime = true; modelReader.AddedLoopingDuration = .1f; // //model = modelReader.LoadAsset("dude.fbx", 24); //model = modelReader.LoadAsset("new_thin_zombie.fbx", 24); //model = modelReader.LoadAsset("AnimatedCube5.fbx", 24); model = modelReader.LoadAsset("PipeFromCube16VGrpsLCRetexAnimKeyframesMovedUp.fbx", 24); // damn its hard to find models that work. modelVisualNormals = new ModelsVisualNormals(model, orientationArrows, .5f, 1f); primitiveNormalArrows = new NormalArrow(bigShere.vertices, bigShere.indices, orientationArrows, 1f); }
public void SetAnimationFpsCreateFrames(int animationFramesPerSecond, RiggedModel model, bool loopAnimation) { Console.WriteLine("________________________________________________________"); Console.WriteLine("Animation name: " + animationName + " DurationInSeconds: " + DurationInSeconds + " DurationInSecondsLooping: " + DurationInSecondsLooping); fps = animationFramesPerSecond; TotalFrames = (int)(DurationInSeconds * (double)(animationFramesPerSecond)); TicksPerFramePerSecond = TicksPerSecond / (double)(animationFramesPerSecond); SecondsPerFrame = (1d / (animationFramesPerSecond)); CalculateNewInterpolatedAnimationFrames(model, loopAnimation); }
private void CalculateNewInterpolatedAnimationFrames(RiggedModel model, bool loopAnimation) { // Loop nodes. for (int i = 0; i < animatedNodes.Count; i++) { // Make sure we have enough frame orientations alloted for the number of frames. animatedNodes[i].frameOrientations = new Matrix[TotalFrames]; animatedNodes[i].frameOrientationTimes = new double[TotalFrames]; // print name of node as we loop Console.WriteLine("name " + animatedNodes[i].nodeName); // Loop destination frames. for (int j = 0; j < TotalFrames; j++) { // Find and set the interpolated value from the s r t elements based on time. var frameTime = j * SecondsPerFrame; // + .0001d; animatedNodes[i].frameOrientations[j] = Interpolate(frameTime, animatedNodes[i], loopAnimation); animatedNodes[i].frameOrientationTimes[j] = frameTime; } } }