Download Attachment: [url="http://vbgamer.strategon.com/msgboard/uploaded/cbx/2004317134450_Ani.zip"][img]icon_paperclip.gif[/img]Ani.zip[/url]
68.23 KB">
Need help with simple time conundrum?
cbxOK This is really strange.... I am creating some Animation/Track classes for storing key framed animation. But it only seems to work one way but not the other. I have attached the vb.net code as well as the exe and required dlls. NOTE: That the exe is compiled for the .NET Framework and you will need the framework installed in order for it to run. You will also need DirectX9 installed as well. First run the "Animation Rotation.exe". You should see a box being rotated. That one works just fine. Here comes the strange part. Next run the "Animation Scaling.exe". You should see the same box but it will be scaled instead of rotated. Just let the app run and you will start to see the animation slow down! What the heck is up with that? If you unzip the source code you will see a Animation.vb file. In that file you will see a Animation module with one method called Update. That is where I blend between keys using the Vector3.Lerp function. What is strange is that the roation and scaling BOTH use a vector3 structure to store there roation and scaling. And yet the rotation animation works but not the scale animation. To toggle between scaling animation and rotation animation just go into the Form1.vb file and look for the SetupAnimations method near the bottom of the file. In that method you will see a varible decloration "Dim Onlyscaling As Boolean = True" simply change it to "Dim Onlyscaling As Boolean = False" in order to view the Rotation animation. I believe my problem lies with the Update method in the Animation.vb file. But I can't seem to figure out why. Anybody have any idea as to why this is that case and why the animation slows down only during scaling but not when rotation? Download Attachment: [url="http://vbgamer.strategon.com/msgboard/uploaded/cbx/2004317134450_Ani.zip"][img]icon_paperclip.gif[/img]Ani.zip[/url]
68.23 KB
VBBRHum... have you tried translation as well?
cbx
quote:
Originally posted by VBBR
Hum... have you tried translation as well?
Just tried translation an it did the same thing as scaling, IE: the animation slows down as time progresses. Seems only the rotation works properly. Strange, very strange?
cbxI just did another test to see if maybe it was because there were alot of keys in the scaling animation but not the rotation animation so I added a bunch more keys to the rotation track and rotation still worked fine. So the number of keys in a track is not the problem, and I'm still stumped...
VBBRI will take a closer look at the code as soon as I have my DX9 working with VS 2003... DirectX simply doesn't appear at the References dialog list... I will try reinstalling the SDK.
VBBRI believe the problem is with the ST V3Track... Because I made the rotation routine use the ST and rotation also was becoming slow... Like that: (with "Dim Onlyscaling As Boolean = True") Dim MX As Matrix = Matrix.Identity 'MX.Multiply(Matrix.Scaling(Animation.Update(ST, mobjTimer.LastCapturedTime))) With Animation.Update(ST, mobjTimer.LastCapturedTime) MX.Multiply(Matrix.RotationYawPitchRoll(.X, .Y, .Z)) End With G.Device.SetTransform(Direct3D.TransformType.World, MX) The result is the box rotates in the Y axis slower and slower. Try to take a look at the ST thing.
VBBRGOT IT !!! The problem is in the SetupAnimations Sub. It's actually very simple. In the rotation part of the sub, you put something like that: V.X = DegreeToRadian(45) 'V.Y = V.X 'V.Z = V.X lngValue = mobjTimer.MilliToTicks(100) RT.Add(New DX9Tools.Animation.KeyVector3(lngValue, V)) NOTE the signal after lngValue is "=". Now look at how you defined the keys in the scaling part: lngValue += mobjTimer.MilliToTicks(210) ST.Add(New DX9Tools.Animation.KeyVector3(lngValue, New Vector3(2, 1, 1))) Now, NOTE the signal after lngValue is actually "+=". Then look at the Update sub: If lngCurrentTime - T.BaseTime > T.Item(T.CurrentKeyIndex).Time Then T.BaseTime += T.Item(T.CurrentKeyIndex).Time '- T.BaseTime T.CurrentKeyIndex += 1 End If NOTE the "+=" signal there. That means, there's a "+=" in the SetupAnimations sub AND in the Update sub. Then, all you have to do is replace the "+=" in the scaling part of SetupAnimations with "=". Whew! Hope that will help a little!
cbxOMFG! Dude, seriously, i have to be loosing my mind not to see that! lol Not catching that simple mistake is definatly a new low for me. geeze. After having a good long laugh at my self I still just can't believe I did not see that. Well at least I can continue working on a graphics demo. VBBR if your DX references are not showing up under add references you can copy the dx files ... Microsoft.DirectX.AudioVideoPlayback.dll Microsoft.DirectX.Diagnostics.dll Microsoft.DirectX.Direct3D.dll Microsoft.DirectX.Direct3DX.dll Microsoft.DirectX.DirectDraw.dll Microsoft.DirectX.DirectInput.dll Microsoft.DirectX.DirectPlay.dll Microsoft.DirectX.DirectSound.dll Microsoft.DirectX.dll ... from your c:\windows\assembly\ folder to something like c:\dx9\ That's what I did when I could not get the dx files to show up in the add references dialog. THen you can just reference the libraries from there. Although I'm sure you would prefer to just make a reference from the add references dialog...
VBBRJust reinstalled DX and it is working now, probably wouldn't have found the problem if I couldn't run the program. But thanks anyway.