DirectX wrong collision

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 4140 Views - Last Post: 04 January 2013 - 12:38 PM Rate Topic: -----

#1 frostraver  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 93
  • Joined: 11-September 12

DirectX wrong collision

Posted 25 December 2012 - 07:36 AM

Hi everyone. I have a quick question.
What could be the problem if you see the included screenshot?
I really don't know how this can happen. The lines in the screen shot are from a Debug Renderer.

Thanks in advance

Posted Image
Is This A Good Question/Topic? 0
  • +

Replies To: DirectX wrong collision

#2 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 614
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

Re: DirectX wrong collision

Posted 25 December 2012 - 08:41 AM

Is this C++ related? Can you show us the specific problem you're having with the code?
Was This Post Helpful? 0
  • +
  • -

#3 frostraver  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 93
  • Joined: 11-September 12

Re: DirectX wrong collision

Posted 25 December 2012 - 09:04 AM

Well... It's written in C++. There isn't a specific piece of code I'm having trouble with. I just don't know what could've caused this problem.
Was This Post Helpful? 0
  • +
  • -

#4 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: DirectX wrong collision

Posted 25 December 2012 - 10:02 AM

The image doesn't tell you anything without code. Also a more specific description of the problem would help.
Was This Post Helpful? 0
  • +
  • -

#5 frostraver  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 93
  • Joined: 11-September 12

Re: DirectX wrong collision

Posted 25 December 2012 - 11:27 AM

The problem is that the ball (which falls from above the orange object) falls onto the orange thing but it gets stuck in it. What it should do is to just collide with each other (like when you let a ball fall on the floor irl). And obviously it isn't doing that. You can see in the screen shot that the ball sinks into the orange object (which is actually the level)
Was This Post Helpful? 0
  • +
  • -

#6 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: DirectX wrong collision

Posted 25 December 2012 - 11:43 AM

No, it isn't obvious because you know what is supposed to occur and people on the forum don't. If you bothered to explain initially you could have had your answer earlier.

Anyway, this is a common problem with novice developers. What is missing here is a 'collision resolver'. What they do is in game physics is that they simulate what happens with objects after they collide, for instance do they rebound or 'stick' as I think is what you are trying to achieve.

To avoid something overly complicated you can ensure that the sphere object is always radius distance from its center to the surface it collided with.
Was This Post Helpful? 0
  • +
  • -

#7 frostraver  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 93
  • Joined: 11-September 12

Re: DirectX wrong collision

Posted 25 December 2012 - 11:51 AM

Yeah. That should solve the problem. The thing is I don't actually know where I should implement this. I'm giving a link to my project here. Can you give me some guidance on where I could implement this?

Download project
Was This Post Helpful? 0
  • +
  • -

#8 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: DirectX wrong collision

Posted 25 December 2012 - 12:05 PM

Just call your collision resolver function when a collision is detected.
Was This Post Helpful? 0
  • +
  • -

#9 frostraver  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 93
  • Joined: 11-September 12

Re: DirectX wrong collision

Posted 03 January 2013 - 04:50 AM

Hi,

can someone please give me some help on how to build this Collision Resolver? I don't seem to have one and I don't know how to build one.
Something else that might be the problem: could it be that if your normals are flipped, the collision doesn't work right? If so, how do I flip the normals of my mesh?

Thanks.
Was This Post Helpful? 0
  • +
  • -

#10 jimblumberg  Icon User is offline

  • member icon


Reputation: 4003
  • View blog
  • Posts: 12,354
  • Joined: 25-December 09

Re: DirectX wrong collision

Posted 03 January 2013 - 08:19 AM

Please post your current code, inside code tags.

Jim
Was This Post Helpful? 0
  • +
  • -

#11 frostraver  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 93
  • Joined: 11-September 12

Re: DirectX wrong collision

Posted 03 January 2013 - 08:23 AM

Download Project

You can download my project with the link above. Thing is I don't know where or how I should write this Collision Resolver.

If you've downloaded the project
- SpherePNT is the class used to make the sphere (and which resembles the player)
- TestGameApp is the main class of the project.
- DirectX 10 and PhysX are used.

Thanks.
Was This Post Helpful? 0
  • +
  • -

#12 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 768
  • View blog
  • Posts: 2,234
  • Joined: 20-March 10

Re: DirectX wrong collision

Posted 03 January 2013 - 11:01 AM

Collision detection is discussed in great detail in this book


Game Physics Book Link

You really need something like this book if you are serious about game

development.

You cant just dump your Direct X code. Which is always quite complex.
onto a forum and expect us to fix it for you. Its not how it works.

Get a good game physics book and try take it from there.


Regards

Snoopy.
Was This Post Helpful? 1
  • +
  • -

#13 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: DirectX wrong collision

Posted 03 January 2013 - 11:49 AM

This very book is excellent! :)
Was This Post Helpful? 0
  • +
  • -

#14 frostraver  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 93
  • Joined: 11-September 12

Re: DirectX wrong collision

Posted 04 January 2013 - 08:18 AM

Thanks for the link. I've taken a look at this book and I found some interesting things I might take a look at.
I've been testing my app today and I've noticed that when I move my ball to the mesh it gets stuck inside it. When the ball is inside this mesh it seems that the collision is done right. Could it be that my Cooking is done wrong? My first thought is that my normals are flipped (since I had problems with this before and I solved it by setting my fx file (in hlsl) to CullMode = NONE.

Thanks for having so much patience :)/>

This post has been edited by ButchDean: 04 January 2013 - 12:23 PM
Reason for edit:: Fixed your duplicate text.

Was This Post Helpful? 0
  • +
  • -

#15 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: DirectX wrong collision

Posted 04 January 2013 - 12:25 PM

Yes, I mentioned how to fix problems like this here. The collision resolver will react accordingly to the collision getting you out of that problem. The book linked to above will explain.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2