• Create Account

## Moving inside an object

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

6 replies to this topic

### #1gnomgrol  Members

699
Like
0Likes
Like

Posted 09 September 2012 - 03:02 AM

Hello guys,
I'd like to know how to make a character moving on or inside other objects.
E.g. If I got the model of a house and I want the character to be able to walk on the roof as well as inside the rooms.

For moving on top of it, I suppose you need to find the triangle the charactermodel is touching, then get the height of the point inside the triangle.
But how can you get the triangle and how can you do it fast enough in big models?

To move inside of a model . . . I have no idea what to do. Could you give me some tips?
(I'm using directx 11 and c++)

Thanks a lot

Edited by gnomgrol, 09 September 2012 - 04:03 AM.

### #2Anddos  Members

582
Like
0Likes
Like

Posted 09 September 2012 - 03:58 AM

I dont understand what you mean by moving on or inside other objects, like you want to test for collison ?

### #3kauna  Members

2918
Like
1Likes
Like

Posted 09 September 2012 - 09:41 AM

Well it is a question collision detection in general, which is rather huge subject and there isn't simple solutions to it.

For example, you could consider your player to cast a vector from it's position downwards and check which triangle is being hit and if it is close enough, get the position from the vector/triangle hit test otherwise the player is falling. For the walls, you can consider the player to be presented by a sphere for example and then scan nearby triangles and move the sphere outside of the triangle plane if there is intersection. This is rather crude and will fail eventually at some cases.

You could look into some existing physics libraries such as ODE and Bullet which will do the collision detection for you. I think that Bullet may even support hit detection with fully polygonal models. This will save you a lot of head ache.

Cheers!

### #4MaxDZ8  Members

4976
Like
0Likes
Like

Posted 10 September 2012 - 01:58 AM

I'd like to know how to make a character moving on or inside other objects.

Let's start from the basics. By default, nothing prevents two simulated objects from fully encroaching each other. This is ideal for ghosts and not so ideal for pretty much everything else.
There's no such thing as "moving on or inside". We want to move it on. Or in. Those are two very different things.
So as others have pointed out, you need some sort of collision detection (library) to first prevent encroaching, then find a way to let it happen selectively... or perhaps not? Let me elaborate.

E.g. If I got the model of a house and I want the character to be able to walk on the roof as well as inside the rooms.

Nobody, nobody serious would model a whole house using a single collision shape (physics model). In general, most maps are made of collections of independent convex hulls. This implies there's no such thing as "in the room" but rather "not in something solid".

To be more explicit, you don't move inside of a model but rather
build your model in such a way it has empty space inside
OR
find a way to make the model non-solid selectively.

For moving on top of it, I suppose you need to find the triangle the charactermodel is touching, then get the height of the point inside the triangle.
But how can you get the triangle and how can you do it fast enough in big models?

In line of principle, what you're trying to do is "contact point generation". I have experienced quite some pain with it and I therefore strongly suggest the use of a library.

What other people have not written is that you're going to take a stroll in the beautifully complicated world of kinematic objects (stuff that moves). This is going to require some hair pulling.

Edited by Krohm, 10 September 2012 - 01:58 AM.

Previously "Krohm"

### #5ankhd  Members

2280
Like
0Likes
Like

Posted 10 September 2012 - 03:33 AM

Hi there.
If it was me and it was my first time at doing this(which it would be) I would use some flat planes layed out on your floor and roof and anywhere else you want to walk on and export them as walkways.meshes keep there wold pos based on the models its for, that way you can use the models world pos to locate it. Make them one sided meshes, also this way you can render just the walkables to test your would when setting up.

### #6MaxDZ8  Members

4976
Like
0Likes
Like

Posted 10 September 2012 - 04:27 AM

This would be very limited, and making it work fast still requires some effort. If this is how you would do it, then just use a physics library.

Previously "Krohm"

### #7gnomgrol  Members

699
Like
0Likes
Like

Posted 10 September 2012 - 08:23 AM

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.