Traduction d'un code C++ a VB

Résolu
SgtJazz Messages postés 18 Date d'inscription lundi 29 mars 2004 Statut Membre Dernière intervention 20 décembre 2005 - 6 mai 2005 à 23:15
SgtJazz Messages postés 18 Date d'inscription lundi 29 mars 2004 Statut Membre Dernière intervention 20 décembre 2005 - 7 mai 2005 à 07:46
salut je ne connais absolument rien au langage c ou c++ et j'aimerais avoir la traduction en vb de ceci:

BOOL bSphereTest(CObject3D* obj1, CObject3D* obj2 )
{
D3DVECTOR relPos = obj1->prPosition - obj2->prPosition;
float dist = relPos.x * relPos.x + relPos.y * relPos.y + relPos.z * relPos.z;
float minDist = obj1->fRadius + obj2->fRadius;
return dist <= minDist * minDist;
}

http://www.gamedev.net/reference/programming/features/boundingsphere/

un gros Merci,
SgtJazz

un gros Merci,
SgtJazz

1 réponse

SgtJazz Messages postés 18 Date d'inscription lundi 29 mars 2004 Statut Membre Dernière intervention 20 décembre 2005
7 mai 2005 à 07:46
voila la solution
c,est un bouding sphere collision detection
je l,ai fignoler en vb6 pour cela :
cree une form avec un picturebox
ajouter une referance a directX8

copie coller ce code

'nb si vous changez la valeur du z pour 2 valeur differante ne vous fiez pas au dessin dans le picture box, ce test est concu pour la 3d et ca marche a merveil

si vous desirez de laide au sujee de ce test de colision demandez le moi au [mailto:sgtjazzeq@hotmail.com sgtjazzeq@hotmail.com] je vous expliquerez les details

Private Type bsphere
centre As D3DVECTOR
radius As Integer

End Type


Dim c1 As bsphere
Dim c2 As bsphere



Private Sub Form_Load()
With c1
.centre.x = 20
.centre.y = 20
.radius = 20
End With
With c2
.centre.x = 40
.centre.y = 30
.radius = 2
End With

Picture1.Circle (c1.centre.x, c1.centre.y), c1.radius
Picture1.Circle (c2.centre.x, c2.centre.y), c2.radius


Dim a
a = test(c1.centre, c1.radius, c2.centre, c2.radius)
If a = True Then
MsgBox "CE TOUCHE YES YES YES"

Else
MsgBox "ce touche pas"
End If
End Sub


Public Function test(l1 As D3DVECTOR, r1 As Integer, l2 As D3DVECTOR, r2 As Integer) As Boolean
Dim v As D3DVECTOR


v.x = l1.x - l2.x
v.y = l1.y - l2.y
v.z = l1.z - l2.z
Dim dist
dist = (v.x * v.x) + (v.y * v.y) + (v.z * v.z)
Dim mindist
mindist = r1 + r2
If dist < mindist * mindist Then
test = True
Else
test = False
End If


End Function

un gros Merci,
SgtJazz
3
Rejoignez-nous