CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Oct 2009

    [RESOLVED] Real-time vehicle animation in .NET

    I work for a company that produces accident reconstruction software. We have a vehicle dynamics program that realistically simulates the motion of a vehicle (position and rotation of car and steer angle of individual wheels, etc).

    All the positions of the car are stored into an array called AMTN. The vehicle dynamics program can calculate positions at time steps finer than .005 secs (200 FPS).

    I need to represent this data in real time, and so far I have not been able to accomplish this. I have tried doing this in Excel/VBA, VB6, and am currently trying to do it in VB.NET.

    I have used a whole plethora of timers and counters as well as different methods of drawing lines on graphics linked to images linked to picture boxes, etc. My animation program writes/clears the screen correctly, but there is clearly some sort of lag in either the timer or writing method. I have scaled it down to 25 FPS and there is still a lag.

    Here is an example of what I am trying to do with each tick of the timer:

        Sub Timer1_Tick1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            If Actr < STOctr + 1 Then
                'Display vehicle
                MyGraphic.DrawLine(Mypen, AMTN(Actr, 11), AMTN(Actr, 12),   AMTN(Actr, 13), AMTN(Actr, 14))
                MyGraphic.DrawLine(Mypen, AMTN(Actr, 13), AMTN(Actr, 14), AMTN(Actr, 15), AMTN(Actr, 16))
                MyGraphic.DrawLine(Redpen, AMTN(Actr, 15), AMTN(Actr, 16), AMTN(Actr, 17), AMTN(Actr, 18))
                MyGraphic.DrawLine(Mypen, AMTN(Actr, 17), AMTN(Actr, 18), AMTN(Actr, 11), AMTN(Actr, 12))
                Awindow.Image = MyImage
                Actr = Actr + 1
                Timer1.Enabled = False
                Playing = False
                Animation_start.Text = "Start"
            End If

    With each tick of the timer, the graphic is cleared, lines representing each side of the car are drawn onto the graphic, and the picturebox is then assigned to the image, which is linked to the graphic. This is just like how your asteroids program works.

    Do I need to change my method? Should I use sprites? Or would it be better for me to create images/bitmaps of the animation beforehand and simply flip through them with a timer?

    I'm thinking that creating the images beforehand might work because I do not have to calculate the vehicle's position as it is predetermined by my AMTN matrix.

    Please let me know if there is a more efficient way of displaying my vehicle on the screen that would allow for greater FPS, etc.

    Your expertise is much appreciated!

    Last edited by HanneSThEGreaT; October 14th, 2009 at 11:46 AM. Reason: Code Tags!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.