help for the collison

Irrlicht.Net is no longer developed or supported, Irrlicht.Net Cross Platform is a much more complete wrapper. Please ask your C# related questions on their forums first.
Locked
karim1a2004
Posts: 41
Joined: Sat Jan 15, 2005 8:03 pm
Contact:

help for the collison

Post by karim1a2004 »

I desire of the assistance for the collision enters the ball and the racket thank you

Imports Irrlicht
Imports Irrlicht.Core
Imports Irrlicht.GUI
Imports Irrlicht.IO
Imports Irrlicht.Scene
Imports Irrlicht.Video
Module Module1
Public device As New IrrlichtDevice(DriverType.OPENGL, New Dimension2D(640, 480), 16, False, True, False)
Public cam As Scene.ICameraSceneNode = device.SceneManager.AddCameraSceneNode(Nothing, New Vector3D(-50, 150, -200), New Vector3D(0, -55, 200), -1)
Public Text As GUI.IGUIEnvironment
Public Xc, Yc, Zc As Single
Public Xb, Yb, Zb, Dbx, Dbz As Single

Sub Main()
device.EventReceiver = New MyEventReceiver
Dim MeshBar As IAnimatedMesh = device.SceneManager.GetMesh("..\..\..\media\bar.x")


Dim Mesh As IAnimatedMesh = device.SceneManager.GetMesh("..\..\..\media\land.3ds")
Dim MeshBall As IAnimatedMesh = device.SceneManager.GetMesh("..\..\..\media\ball.x")
Dim AnodeB As ISceneNode = device.SceneManager.AddOctTreeSceneNode(Mesh, Nothing, -1)
Dim Ball As ISceneNode = device.SceneManager.AddAnimatedMeshSceneNode(MeshBall, Nothing, -1)
Dim Bar As ISceneNode = device.SceneManager.AddAnimatedMeshSceneNode(MeshBar, Nothing, -1)

Dim tex As ITexture = device.VideoDriver.GetTexture("C:\zip\irrlicht\vb\IrrTUTORIAL\hiiplane\wall.bmp")
Dim tex2 As ITexture = device.VideoDriver.GetTexture("..\..\..\media\t351sml.jpg")

Dim Selector As ITriangleSelector
Dim Meta As IMetaTriangleSelector

Dim Bal As Core.Line3D
Dim v3dCollision As Core.Vector3D
Dim test As Core.Triangle3D

Xc = -50 : Yc = 10 : Zc = -350
Xb = 100 : Yb = 30 : Zb = -100 : Dbx = 2 : Dbz = 2
cam.Position = New Vector3D(-50, 300, -605)

Bar.Position = New Core.Vector3D(Xc, Yc, Zc)
Bar.SetMaterialTexture(0, tex2)
Bar.SetMaterialFlag(MaterialFlag.LIGHTING, False)
'Bar.Scale = New Vector3D(1, 1, 1)

Ball.Position = New Core.Vector3D(Xb, Yb, Zb)
Ball.SetMaterialTexture(0, tex2)
Ball.SetMaterialFlag(MaterialFlag.LIGHTING, False)
Ball.Scale = New Vector3D(1, 1, 1)

AnodeB.Position = New Core.Vector3D(0, 7, 0)
AnodeB.SetMaterialTexture(0, tex)
AnodeB.SetMaterialFlag(MaterialFlag.LIGHTING, False)

Dim Colid As New Collision
' Selector = device.SceneManager.CreateOctTreeTriangleSelector(MeshBar.GetMesh(0), Bar, 128)
Selector = device.SceneManager.CreateTriangleSelectorFromBoundingBox(Bar)

'Meta.AddTriangleSelector(Selector)
Dim anim As ISceneNodeAnimator = device.SceneManager.CreateCollisionResponseAnimator(Selector, Ball, New Vector3D(30, 50, 30), New Vector3D(0, 0, 0), New Vector3D(0, 50, 0), 0.0005F)
Ball.AddAnimator(anim)
Dim intersection As Vector3D = New Vector3D
Dim tri As Triangle3D = New Triangle3D
Dim line As Line3D = New Line3D

While device.Run() = True
If device.WindowActive Then

device.VideoDriver.BeginScene(True, True, New Color(0, 100, 100, 100))
Bar.Position = New Core.Vector3D(Xc, Yc, Zc)

If Xb > 400 Or Xb < -450 Then Dbx = -Dbx
If Zb > 300 Or Zb < -400 Then Dbz = -Dbz
Xb = Xb + Dbx : Zb = Zb + Dbz

Ball.Position = New Core.Vector3D(Xb, Yb, Zb)
line.start = New Core.Vector3D(Ball.Position.X, Ball.Position.Y, Ball.Position.Z)
line.end = line.start
device.WindowCaption = Bar.BoundingBox.MaxEdge.Z
If (device.SceneManager.SceneCollisionManager.GetCollisionPoint(line, Selector, intersection, tri)) Then
End

End If
' If Colid.TestCollision(Ball, Bar) Then End

End If


device.SceneManager.DrawAll()

device.VideoDriver.EndScene()



End While
End Sub

End Module
Public Class MyEventReceiver
Implements IEventReceiver

Public Function OnEvent(ByVal e As [Event]) As Boolean Implements IEventReceiver.OnEvent
If e.Type = EventType.KeyInput Then
'37=leftkey,38=upkey,39=rightkey,40=downkey,
If e.Key = 27 Then End
' If e.Key = 38 Then Yc -= 10
' If e.Key = 40 Then Yc += 10
If e.Key = 37 Then Xc -= 10
If e.Key = 39 Then Xc += 10

Return True
End If

Return False
End Function


End Class
karim1a2004
Posts: 41
Joined: Sat Jan 15, 2005 8:03 pm
Contact:

Post by karim1a2004 »

If (device.SceneManager.SceneCollisionManager.GetCollisionPoint(line, Selector, intersection, tri)) Then
End

End If
this function dont'work
help me juste for that
thanks
Guest

Post by Guest »

karim1a2004 wrote:If (device.SceneManager.SceneCollisionManager.GetCollisionPoint(line, Selector, intersection, tri)) Then
End

End If
this function dont'work
help me juste for that
thanks
I think that .NET wrapper for GetCollisionPoint is not fully/correctly implemented. In this forum you should find a temporary unofficial fix. Else, you need to wait for another official release by Niko.
Guest

Post by Guest »

I think that .NET wrapper for GetCollisionPoint is not fully/correctly implemented. In this forum you should find a temporary unofficial fix. Else, you need to wait for another official release by Niko.
Yes, I have the same problem. But I can't find a fix for this.
Thorben Linneweber

Post by Thorben Linneweber »

I think that .NET wrapper for GetCollisionPoint is not fully/correctly implemented. In this forum you should find a temporary unofficial fix. Else, you need to wait for another official release by Niko.
Yes, I have the same problem. But I can't find a fix for this.
karim1a2004
Posts: 41
Joined: Sat Jan 15, 2005 8:03 pm
Contact:

Post by karim1a2004 »

hello
i do this function colidebox in vb.net
that work perfectli
:lol:

Imports Irrlicht.Core
Imports Irrlicht.Scene

Public Class Collision
Public Function TestCollision(ByVal NodeA As ISceneNode, ByVal Tpoint As Vector3D) As Boolean
Dim Cx, Cy, Cz As Boolean
Dim OBJbox As Box3D = NodeA.BoundingBox
Dim Pos As Vector3D = NodeA.Position


If (Tpoint.X > (Pos.X + OBJbox.MinEdge.X) And Tpoint.X < (Pos.X + OBJbox.MaxEdge.X)) Then Cx = True


If (Tpoint.Y > (Pos.Y + OBJbox.MinEdge.Y) And Tpoint.Y < (Pos.Y + OBJbox.MaxEdge.Y)) Then Cy = True

If (Tpoint.Z > (Pos.Z + OBJbox.MinEdge.Z) And Tpoint.Z < (Pos.Z + OBJbox.MaxEdge.Z)) Then Cz = True


If (Cx And Cy And Cz) Then Return True



End Function
End Class
Locked