Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Move a mesh  (Read 1446 times)
Canning
Community Member
*
Posts: 592


« on: April 04, 2009, 01:12:09 AM »

OK

I am after some code that will move a mesh from a source vector to a destination vector.

I have modified some code from the 'A14 - Give a destination to a mesh.' The code is as follows:

Public Sub Check_Projectile_Movement()
    Dim x As Integer
   
    For x = 1 To numProjectile
        If GetDistance3D(ProjectilePosition(x).x, 0, ProjectilePosition(x).z, ProjectileDestination(x).x, 0, ProjectileDestination(x).z) > 2 Then
           
            ProjectileDirection(x) = VNormalize(VSubtract(ProjectileDestination(x), ProjectilePosition(x)))
            ProjectileAngleY(x) = Direction2Ang(ProjectileDirection(x).x, ProjectileDirection(x).z)
           
            ProjectilePosition(x) = VAdd(ProjectilePosition(x), VScale(ProjectileDirection(x), TV3D.TimeElapsed * 0.1))
            ProjectilePosition(x).y = Land.GetHeight(ProjectilePosition(x).x, ProjectilePosition(x).z) + 10
            Projectile(x).SetPosition ProjectilePosition(x).x, ProjectilePosition(x).y, ProjectilePosition(x).z
        End If
    Next
End Sub

The problem with this is that the mesh slows down when it nearly reaches its destination. I would like some help to modify this code so that the mesh moves at the same speed from source to destination...

Is there any sample code out there that does this?

thanks in advance

Canning
Logged

I am using 2010 VB.NET and TV 6.5 with Windows 7
SylvainTV
Administrator
Community Member
*****
Posts: 4946


WWW
« Reply #1 on: April 04, 2009, 08:02:03 AM »

Hmm I think that actually you're already using a normalized direction, so it should already use the same linear speed.
Logged

Regards

Sylvain Dupont
TrueVision3D Developer
sylvain@truevision3d.com

TV3D IRC at http://chat.truevision3d.com or on server irc.truevision3d.com #Truevision3D. Come talk with us !
Canning
Community Member
*
Posts: 592


« Reply #2 on: April 04, 2009, 07:29:12 PM »

When i get close to the destination vector... it slows down.Why is this?
Logged

I am using 2010 VB.NET and TV 6.5 with Windows 7
jviper
Community Member
*
Posts: 2130

Discipline in training


« Reply #3 on: April 04, 2009, 08:02:51 PM »

hmm,  TV3D.TimeElapsed should only be called once in the beginning of the render.
and just another guess:
 GetDistance3D(ProjectilePosition(x).x, 0, ProjectilePosition(x).z, ProjectileDestination(x).x, 0, ProjectileDestination(x).z) > 2 Then

this could cause the tank to never reach it's destination.
« Last Edit: April 04, 2009, 08:13:58 PM by jviper » Logged

JAbstract.....Don't just imagine, make it happen!
Canning
Community Member
*
Posts: 592


« Reply #4 on: April 05, 2009, 12:42:22 AM »

jviper: It still reaches its destination (or very close to it).

Is there another sub (from someone) that moves a mesh that i could use instead of my one?
Logged

I am using 2010 VB.NET and TV 6.5 with Windows 7
jviper
Community Member
*
Posts: 2130

Discipline in training


« Reply #5 on: April 05, 2009, 10:31:34 AM »

Try changing
GetDistance3D(ProjectilePosition(x).x, 0, ProjectilePosition(x).z, ProjectileDestination(x).x, 0, ProjectileDestination(x).z) > 2

to
GetDistance3D(ProjectilePosition(x).x, 0, ProjectilePosition(x).z, ProjectileDestination(x).x, 0, ProjectileDestination(x).z) > 0

EDIT: I just lookd at the sample that came with the SDK. The code seems to match yours, but there does not seem to be any slow down when it get's to the end of it's path. Ofcourse, this is still the 6.2 SDk, so I don't know how different that is from the 6.3 SDK. Either way, I think that code is poorly implemented, and you should come up with your own code.
« Last Edit: April 05, 2009, 11:11:54 AM by jviper » Logged

JAbstract.....Don't just imagine, make it happen!
Canning
Community Member
*
Posts: 592


« Reply #6 on: April 13, 2009, 07:49:40 PM »

OK, thanks guys.
Logged

I am using 2010 VB.NET and TV 6.5 with Windows 7
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks