Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How to set up collisions using .XFiles?

Author
Message
abloke
23
Years of Service
User Offline
Joined: 6th Jun 2003
Location:
Posted: 8th Jun 2003 16:23
I'm using a standard .x File for my level.
The level has exported good,i need to know how to set up collisions
for my player character with my level.
It has a 3rd person camera.
I didn't use Cartography shop to model my level,but i have it,if it
will make it easier to set up the collisions.
Thanks.
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 8th Jun 2003 16:33
You need to use the SET OBJECT COLLISION COMMANDS.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 8th Jun 2003 16:38
I find it quite funny that a guy with "abloke" as his forum name has "Gender: Unspecified" in his profile

Do you want Windows menus in your DBP apps? - Get my plugin: http://snow.prohosting.com/~clone99/downloads/tpc_menus_102.zip
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 8th Jun 2003 16:46
Indeed...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Attreid
23
Years of Service
User Offline
Joined: 27th Nov 2002
Location:
Posted: 8th Jun 2003 17:23
abloc, if you have testicles, you can put in your profil that you are a male
you could try to use the command "intersect object" :

Quote: "INTERSECT OBJECT
This command will return the distance to the point of intersection between two coordinates, in reference to the specified object. Use this
command to project a line from your current position to a destination to determine whether a collision will occur with an object. Ideal for bullet
calculations and fast manual polygon collision.

SYNTAX
Return Float=INTERSECT OBJECT(Object Number, X, Y, Z, ToX, ToY, ToZ)"


you make "lines" around your camera, and if there's an object near the camera, you push it

"He will come...the voice from the outer world,
bringing the holy war, the Jihad, which will cleanse the Universe and bring us out of darkness."
abloke
23
Years of Service
User Offline
Joined: 6th Jun 2003
Location:
Posted: 8th Jun 2003 17:26
I dunno...when the 'boys' get together....->
MrTWAToad iv'e tried this:
load object "Level1.x",7
SET OBJECT COLLISION ON 7
SET OBJECT COLLISION TO POLYGONS 2
rem object 2 is my player character

any further help with using the collision commands for a player& a level...2 .x files,would be appreciated gentlemen.

abloke
23
Years of Service
User Offline
Joined: 6th Jun 2003
Location:
Posted: 8th Jun 2003 17:28
thank you Attreid,i'll give it a go,

abloke
23
Years of Service
User Offline
Joined: 6th Jun 2003
Location:
Posted: 8th Jun 2003 17:49
Is there a sample around anywhere for this?
I'm a bit new to 'scripting' in DBPro,in c++ i'm used to this kind of thing:

float cMesh::GetClosestHeight(float XPos, float YPos, float ZPos)
{
float YAbove, YBelow;

YAbove = GetHeightAbove(XPos, YPos, ZPos);
YBelow = GetHeightBelow(XPos, YPos, ZPos);
if(fabs(YAbove-YPos) < fabs(YBelow-YPos))
return YAbove;
return YBelow;
}

float cMesh::GetHeightBelow(float XPos, float YPos, float ZPos)
{
BOOL Hit;
float u, v, Dist;
DWORD FaceIndex;

D3DXIntersect(m_Mesh->m_Mesh,
&D3DXVECTOR3(XPos,YPos,ZPos),
&D3DXVECTOR3(0.0f, -1.0f, 0.0f),
&Hit, &FaceIndex, &u, &v, &Dist, NULL, NULL);
if(Hit == TRUE)
return YPos-Dist;
return YPos;
}

float cMesh::GetHeightAbove(float XPos, float YPos, float ZPos)
{
BOOL Hit;
float u, v, Dist;
DWORD FaceIndex;

D3DXIntersect(m_Mesh->m_Mesh,
&D3DXVECTOR3(XPos,YPos,ZPos),
&D3DXVECTOR3(0.0f, 1.0f, 0.0f),
&Hit, &FaceIndex, &u, &v, &Dist, NULL, NULL);
if(Hit == TRUE)
return YPos+Dist;
return YPos;
}

BOOL cMesh::CheckIntersect(float XStart, float YStart, float ZStart,
float XEnd, float YEnd, float ZEnd,
float *Length)
{
BOOL Hit;
float u, v, Dist;
float XDiff, YDiff, ZDiff, Size;
DWORD FaceIndex;
D3DXVECTOR3 vecDir;

XDiff = XEnd - XStart;
YDiff = YEnd - YStart;
ZDiff = ZEnd - ZStart;

D3DXVec3Normalize(&vecDir, &D3DXVECTOR3(XDiff, YDiff, ZDiff));
D3DXIntersect(m_Mesh->m_Mesh,
&D3DXVECTOR3(XStart,YStart,ZStart), &vecDir,
&Hit, &FaceIndex, &u, &v, &Dist, NULL, NULL);

if(Hit == TRUE) {
Size = (float)sqrt(XDiff*XDiff+YDiff*YDiff+ZDiff*ZDiff);
if(Dist > Size)
Hit = FALSE;
else {
if(Length != NULL)
*Length = Dist;
}
}

return Hit;
}

but i'm sure it will be slighly less code with DBPro
Thanks.

Oliver
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Switzerland
Posted: 8th Jun 2003 17:55
Kensupen did a nice code for .x collision, you can find it in the code snippets forum:
http://www.darkbasicpro.com/apollo/view.php?t=10315&b=6
abloke
23
Years of Service
User Offline
Joined: 6th Jun 2003
Location:
Posted: 8th Jun 2003 18:40
Thanks Oliver.

Login to post a reply

Server time is: 2026-07-11 11:42:16
Your offset time is: 2026-07-11 11:42:16