Archived

This topic is now archived and is closed to further replies.

himitsu

collision between character and maps

Recommended Posts

let''s say, for the sake of this example, that i had created a map for one of my towns in an adventure/rpg style game. the whole map is one whole mesh that is loaded in from an .x file. clearly the map is many times larger than the player''s character and of irregular shape. how would one go about performing collision so that the character would walk over hills instead of walking through them?

Share this post


Link to post
Share on other sites
One very rough explanation-

Use the player''s 2D position to figure out which polygon they are standing on top of. Then, use the position/slope of the polygon to figure out where the player should be height-wise.

You may have to be a little bit clever if the landscape has caves, multiple levels, etc.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
himitsu:
i believe there is a ray-mesh intersect detection function that microsoft has implemented (check the SDK docs, i know its there just dont remember exactly what its called)
Also, just out of curiousity (actually i am trying to make an RPG w/ x files in a similar manner) doesn''t ramming an entire .x file at the graphics card and hoping for it to sort through all the polys and only show those that are visible everything slow things down? (this is what people have told me so i got discouraged and stopped working on my game hehe)
Also, have you figured out how to animate .X files?

Share this post


Link to post
Share on other sites
yeah, i agree about the slowing things down part. can you come up with any better way? in an rpg with an open town, you can''t really divide the map into several parts because you don''t have separate rooms like you do in fps games.
no i haven''t really figured out how to animate the .x files. i''ve only been told how easy it is, or to wait for a book to be published, not how to really do it. =P
i''ve been meaning to figure out how to use the SetTime() function that MS used to use for retained mode, at least that made more sense. but i haven''t gotten around to figuring that out.
in the end i signed up for a d3d class at gameinstitute, but now i have to wait for several weeks before they get to that part of the class.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
<>

(from SDK)

D3DXIntersect
Determines if a ray intersects with a mesh.

HRESULT D3DXIntersect(
LPD3DXBASEMESH pMesh,
CONST D3DXVECTOR3* pRayPos,
CONST D3DXVECTOR3* pRayDir,
BOOL* pHit,
DWORD* pFaceIndex,
FLOAT* pU,
FLOAT* pV,
FLOAT* pDist
);


Share this post


Link to post
Share on other sites
About Slowness:
first to te anon poster, dont give up! there are many ways to skin a cow!!! if one doesnt fit you, keep trying!

I havent done any 3d, but this might give you an idea

Ok, Based on the fact that 3d games are 2d games with one more dimention to worry about (I know is more complex than that, what I mean is that the basics are the same) you might want to try the same technic 2d games use, split your world in many pieces, and then handle each separatelly.
You see, the same thing happens when you have a 2d bitmap that is say 10000x10000 pixels, if you render all and let the clipping do its thing it will slow everything up! why? because the clipper will test every pixel to see if it should be drawn or not, and if you have so many pixels, going throw all those if()''s will surely slow down the game, so what you do is that you only draw what is partialy visible or visible.

this is the Idea for 3d, say you have a mesh, and it is 10000x10000 Units big, taking only in consideration X and Y, you could cut it into squares that are 100x100 each, have world coordinates and local coordinates, so you only send to the 3d engine the 9 squares around and under the char, you can have all the files loaded in memory if it is possible, but you ONLY send the ones visible to the 3D pipeline.
you can use a 2 dimentional array to know where every piece of data fits together with the whole.

I dont know if I am making sense or if you will read this, so I will leave it there, and hope it helps.

Share this post


Link to post
Share on other sites
good idea. i was thinking i didn''t want to do specific tile sets. yeah your idea sounds interesting. thanks. =)

Share this post


Link to post
Share on other sites
Now that I think about it again, I remembered the X File (the truth is out there ) like Flash SWF files is composed of chunks of data, like a resource file, were you can store a mesh or many, images, and more, so you dont really need to split the file into many files but internaly arrange your data, so instead of one big mesh you have a bunch of small ones, you can even name em I think so you might be able to get rid of the array I told you before, and name each something representative like 0_0, 0_2, 0_3,1_0 and so on.
the Xfile is a text file (or can be a text file) so you can play with it and turn it into binary when you are done, will work the same.

see ya

Share this post


Link to post
Share on other sites