Jump to content


Photo

Precise 3D Collisions Dll (P3Dc.Dll)


  • Please log in to reply
415 replies to this topic

#201 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 15 March 2011 - 07:41 AM

I'm not accusing you're modeling program, I'm accusing the converter that you used to turn it into a .d3d format. Many others, and I - have not encountered a problem if the model is created correctly. I've had you and 1 other person encounter errors (since the newest version), nonetheless I'll look into it... again. May also just look into returning a -1 on an error, but that wouldn't really fix the problem its just another way to notify you I guess.


[EDIT]
Better idea. Over the next few days I'll develop a simple program that will "fix" common errors in the model files that these converters often leave behind in the model files. This will ensure that they will always work with p3dc as well.
[/EDIT]

Edited by brett14, 15 March 2011 - 07:49 AM.

  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#202 johnjoe

johnjoe

    GMC Member

  • New Member
  • 299 posts
  • Version:Unknown

Posted 15 March 2011 - 08:27 AM

awesome!
  • 0

#203 Jepie0

Jepie0

    GMC Member

  • GMC Member
  • 213 posts

Posted 17 March 2011 - 09:32 AM

Hey Brett14 nice to see your still working on this. Just wondering about the current issue thats been brought up with .d3d models causing p3dc to crash, I also encountered the same issue but not from a conversion program i would make simple model shapes in gm and then save them via the in built commands. Instead of a separate program to fix the models would it be possible for p3dc to check if the model will fail and then correct it automatically before loading?

Also its been a few weeks but i hopefully will be able to provide that example i talked about awhile back to showcase the normals issues i was having with simple collision
meshes made with the p3dc model scripts.

Cheers, Jepie0
  • 0

#204 regular

regular

    GMC Member

  • New Member
  • 399 posts

Posted 17 March 2011 - 06:39 PM

Does your dll under whatever circumstance end the game? Im using it at without even one single game_end(); in my game, the game stops with no obvious reason. How do you handle exceptions?
  • 0

suno li walo
ale li pona


#205 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 17 March 2011 - 07:17 PM

@jepie0: the default shapes were removed back in 5.0, due to some internal changes to the dll. They will be back in 5.02.
@regular: if there is an error in the model the game will crash. Other than that, not that I know of. What are you doing that is causing the game to crash.

[Edit]
Going to update to V5.02 later today (tonight). It fixes the bug/incompatibility to jepie0 was talking about. Also still working on the model fixer, and am possibly going to implement it directly into p3dc's model loading system so that it will detect errors in the model.
[/Edit]

Edited by brett14, 17 March 2011 - 07:35 PM.

  • 1

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#206 regular

regular

    GMC Member

  • New Member
  • 399 posts

Posted 17 March 2011 - 07:31 PM

I wouldnt call it crash, more like ending the game as if it was game_end();
I'm using the following functions only:
p3dc_begin_model
p3dc_set_trianglemask
p3dc_add_wall
p3dc_add_floor
p3dc_add_block
p3dc_begin_replace
p3dc_end_replace
p3dc_ray_stil
p3dc_get_lastmask

if there is an error in the model

What kind of error is this? Can using many long masks and a lot of blocks be the reason of that error?
  • 0

suno li walo
ale li pona


#207 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 17 March 2011 - 07:42 PM

When does it crash, like what exactly are you doing? There has been minimal testing done with trianglemasks, so that could very possibly be the cause of the error. Also, what is the rays direction (/Vector?)


if there is an error in the model

I'm referring to external models, sometimes converters leave off the last vertex or give 1 too many lines etc. If you're not using external models, then there won't be an error in it. Don't worry about it.

[Edit]
I notice that you're not using p3dc_end_model, not sure if you left it off of the list by accident, or don't actually use it. It is needed after all the triangle data is added to the model. Also, note that all triangle data has to be added to the model BEFORE you do any collision checking to it, so that if you are using p3dc_begin_replace(<SNIP>) then checking against the model before you have called p3dc_end_replace(<SNIP>); it will cause a crash. Also, is it possible that I could see the .gmk to check for any errors on your side (if it is not mentioned above)?
[/Edit]

[Edit2]
Also, using the split model functions will throw an exception before a model is split, or if the X,Y origin are outside of the area defined when splitting the level model.
[/Edit2]

Edited by brett14, 17 March 2011 - 08:00 PM.

  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#208 regular

regular

    GMC Member

  • New Member
  • 399 posts

Posted 17 March 2011 - 08:07 PM

I do use p3dc_end_model(); I dont use external models though. The code which contains p3dc_* functions is quite small, really, here's all of it:
//create event of control object
sblsk=p3dc_begin_model();

with(strana)
for(i=-1;i<2;i+=1)for(j=-1;j<2;j+=1)
   {
   p3dc_set_trianglemask(kv4e[i+1,j+1]);
   switch(ravn)
   {
   case "x":p3dc_add_wall(st*kb*1.5,-kv/2+kb*i,-kv/2+kb*j,st*kb*1.5,kv/2+kb*i,kv/2+kb*j);break;
   case "y":p3dc_add_wall(-kv/2+kb*i,st*kb*1.5,-kv/2+kb*j,kv/2+kb*i,st*kb*1.5,kv/2+kb*j);break;
   case "z":p3dc_add_floor(-kv/2+kb*i,-kv/2+kb*j,st*kb*1.5,kv/2+kb*i,kv/2+kb*j,st*kb*1.5);break;
   }
   }
   p3dc_set_trianglemask(1);p3dc_add_block(kb*1.5-k,kb*1.5-k,kb*1.5-k,k-kb*1.5,k-kb*1.5,k-kb*1.5);
p3dc_end_model();

pionki=p3dc_begin_model();
p3dc_end_model();
//draw event of control object
var dir,zdir;zdir=(mouse_y/room_height-0.5)*180;dir=540*(mouse_x-room_width/4)/(room_width);
zdir=min(89.9,max(-89.9,zdir));
dir=min(450,max(-90,dir));
var xf,yf,zf;
xf=lengthdir_x(lengthdir_x(rast,zdir),dir);
yf=lengthdir_y(lengthdir_x(rast,zdir),dir);
zf=lengthdir_y(rast,zdir);
d3d_set_projection_ext(xf,yf,zf,0,0,0, 0,0,1,45,640/480,1,10000);


if sl4wl4
{
sl4wl4=0;
p3dc_begin_replace(pionki);var q;q=3;
p3dc_set_trianglemask(1);
p3dc_add_block(kb*1.5-q,kb*1.5-q,kb*1.5-q,q-kb*1.5,q-kb*1.5,q-kb*1.5);
with(strana)
for(i=-1;i<2;i+=1)for(j=-1;j<2;j+=1)
if pnk[i+1,j+1]!=0
   {
   p3dc_set_trianglemask(pnk[i+1,j+1]);
   pnk[i+1,j+1].i=i+1;pnk[i+1,j+1].j=j+1;
   pnk[i+1,j+1].ravn=id;
   var k;k=0.5
   switch(ravn)
   {
   case "x":p3dc_add_block(st*kb*1.5,-k*kv/2+kb*i,-k*kv/2+kb*j,st*kb*1.5+12*st,k*kv/2+kb*i,k*kv/2+kb*j);break;
   case "y":p3dc_add_block(-k*kv/2+kb*i,st*kb*1.5,-k*kv/2+kb*j,k*kv/2+kb*i,st*kb*1.5+12*st,k*kv/2+kb*j);break;
   case "z":p3dc_add_block(-k*kv/2+kb*i,-k*kv/2+kb*j,st*kb*1.5,k*kv/2+kb*i,k*kv/2+kb*j,st*kb*1.5+12*st);break;
   }
   }
p3dc_end_replace();
}
//this updates the collision model


var mm;
dX = 0 - lengthdir_x(lengthdir_x(rast,zdir),dir);
dY = 0 - lengthdir_y(lengthdir_x(rast,zdir),dir);
dZ = 0 - lengthdir_y(rast,zdir);
mm = sqrt(dX*dX + dY*dY + dZ*dZ);dX /= mm;dY /= mm;dZ /= mm;
uX = 0;uY = 0;uZ = 1;
mm = uX*dX + uY*dY + uZ*dZ;uX -= mm*dX;uY -= mm*dY;uZ -= mm*dZ;mm = sqrt(uX*uX + uY*uY + uZ*uZ);uX /= mm;uY /= mm;uZ /= mm;
tFOV = tan(45*pi/360);uX *= tFOV;uY *= tFOV;uZ *= tFOV;vX = uY*dZ - dY*uZ;vY = uZ*dX - dZ*uX;vZ = uX*dY - dX*uY;
vX *= 640/480;vY *= 640/480;vZ *= 640/480;
screenx = 2*mouse_x/640-1;
screeny = 1-2*mouse_y/480;
mX = dX + uX*screeny + vX*screenx;
mY = dY + uY*screeny + vY*screenx;
mZ = dZ + uZ*screeny + vZ*screenx;

dis=p3dc_ray_still(pionki,lengthdir_x(lengthdir_x(rast,
zdir),dir),lengthdir_y(lengthdir_x(rast,zdir),dir),lengthdir_y(rast,
zdir),mX,mY,mZ);
var wxxnv;wxxnv=1;
if dis!=10000000&&!x1.vs&&!y1.vs&&!z1.vs&&!x2.vs&&!y2.vs&&!z2.vs&&!instance_exists(ef)&&!instance_exists(ef2)&&!sound_isplaying(sound4)
var ind;ind=p3dc_get_lastmask();
//...
dis=p3dc_ray_still(sblsk,lengthdir_x(lengthdir_x(rast,
zdir),dir),lengthdir_y(lengthdir_x(rast,zdir),dir),lengthdir_y(rast,
zdir),mX,mY,mZ);
if dis!=10000000&&!x1.vs&&!y1.vs&&!z1.vs&&!x2.vs&&!y2.vs&&!z2.vs&&!instance_exists(ef)&&!instance_exists(ef2)&&!sound_isplaying(sound4)
var ind;ind=p3dc_get_lastmask();
//...
That's all of it.
All the code is correct, i.e. it's behaving like it's intended to be.
ps: but now that I think of it, I dont trust Scripts>search in scripts that much, so I'll search for game_end(); for third time.
  • 0

suno li walo
ale li pona


#209 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 17 March 2011 - 08:17 PM

There doesn't appear to be an error in that code, and as far as I know it shouldn't crash the game... Put breaks/exits in the code to see where it crashes at.
  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#210 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 19 March 2011 - 07:05 AM

@jepie0: the default shapes are now fixed, and will load in external models (tested briefly, should work but may be errors. Please report any - Except that the ellipsoid is not supported.)

@regular: Did you find out if the error was P3DC related?

@johnjoe: The "fixer" is still being worked on. Been quite busy lately, and it is a relatively big project. Also got a lot going on, and most of my free time is being tunneled into a c++ app I'm developing.

Edited by brett14, 19 March 2011 - 07:06 AM.

  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#211 Jepie0

Jepie0

    GMC Member

  • GMC Member
  • 213 posts

Posted 19 March 2011 - 10:48 AM

Hey Brett14, I finally got around to making that example to showcase the problems i am having with normals and p3dc. I tested p3dc v5.02 and used it to make this example i also loaded the resource file to make sure the p3dc scripts are the latest. All the basic models i created within GM and saved load perfectly now with no crashing. When using the loaded GM models as collision meshes or using p3dc's in built basic model functions i still get incorrect normals on nearly all the basic shapes.

Block: Perfect normals
Cone: outer normals correct but base is inverted
Cylinder: outer normals half correct and half inverted, one base is correct the other inverted
Floor: half correct half inverted
Wall: half correct half inverted

Example download link

Hopefully this better helps to explain the issue.

Cheers, Jepie0
  • 0

#212 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 19 March 2011 - 06:59 PM

Yeah, never did fix those... I'll get around to it sometime. Thanks for the link though as it will really help me to find the problems.

Edited by brett14, 19 March 2011 - 07:00 PM.

  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#213 redfeild

redfeild

    GMC Member

  • New Member
  • 470 posts

Posted 20 March 2011 - 04:40 PM

Better idea. Over the next few days I'll develop a simple program that will "fix" common errors in the model files that these converters often leave behind in the model files. This will ensure that they will always work with p3dc as well.

Yes, please get on this. I don't know where the errors lie in the .mod I'm using (I exported it from Marzipan, which usually works) but it crashes my game every single time I try to load it.
  • 0
Posted Image Legalize it Posted Image

#214 _176368

_176368

    GMC Member

  • New Member
  • 13 posts

Posted 25 March 2011 - 08:32 AM

Just tried to run Example 1 and Avast popped up with "DROPPER BLOCKED!" The description is: Win32:Dropper-EHP [Drp]. I think I've opened it before though... Is Avast BS'n me or did it somehow acquire a virus?
  • 0

#215 _176368

_176368

    GMC Member

  • New Member
  • 13 posts

Posted 25 March 2011 - 08:34 AM

I tried to edit my last post, but it seems to have made another.

I just tried to run it again, and it worked fine. Either Avast is having a spaz or I now have a virus.

Edited by _176368, 25 March 2011 - 08:35 AM.

  • 0

#216 redfeild

redfeild

    GMC Member

  • New Member
  • 470 posts

Posted 25 March 2011 - 06:50 PM

I think it's just Avast's bull****.
  • 0
Posted Image Legalize it Posted Image

#217 whiteshadow

whiteshadow

    GMC Member

  • New Member
  • 29 posts
  • Version:GM8

Posted 27 March 2011 - 08:27 AM

ok so i tried this again. the game loads and i can see the model load and draw but the hourglass on the mouse spins then the error comes up. all i did was write
show_info();

//Init variables for moving
z=50;
zdir=0;
zspeed=0;
zprevious=50;
accelerate=0;

//Init 3D
d3d_start();
d3d_set_hidden(1);
draw_set_color(c_white);

//Create a player collision model
player_colid=p3dc_begin_model();
p3dc_add_block(-1.4,-1.4,0,1.4,1.4,5);
p3dc_end_model();

tex_wall=background_get_texture(bck_wall);//get the id of the background, for drawing the level

//Load the 3d model into p3dc (the collisions)
level_colid=p3dc_begin_model();
p3dc_add_model("Media\facility_passage_test.gmmod",0,0,0,0,0,0);
p3dc_end_model();

p3dc_sort_model(level_colid,false);
p3dc_split_model(level_colid,1000,1000,50,50,5);

//Load the 3d model into GM (for drawing
mod_level=d3d_model_create();
d3d_model_load(mod_level,"Media\facility_passage_test.gmmod");
instead of
show_info();

//Init variables for moving
z=50;
zdir=0;
zspeed=0;
zprevious=50;
accelerate=0;

//Init 3D
d3d_start();
d3d_set_hidden(1);
draw_set_color(c_white);

//Create a player collision model
player_colid=p3dc_begin_model();
p3dc_add_block(-1.4,-1.4,0,1.4,1.4,5);
p3dc_end_model();

tex_wall=background_get_texture(bck_wall);//get the id of the background, for drawing the level

//Load the 3d model into p3dc (the collisions)
level_colid=p3dc_begin_model();
p3dc_add_model("Media\map_model.d3d",0,0,0,0,0,0);
p3dc_end_model();

p3dc_sort_model(level_colid,false);
p3dc_split_model(level_colid,1000,1000,50,50,5);

//Load the 3d model into GM (for drawing
mod_level=d3d_model_create();
d3d_model_load(mod_level,"Media\map_model.d3d");
by the way its the script for controller in the create event for example 3. i kinda need to know why this is happening because i realy want to finish my game soon.
  • 0
Error 43
It's Coming

#218 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 27 March 2011 - 09:16 AM

Try running it without p3dc_split_model(<SNIP>);. That function will cause the game to crash (with the hourglass) if you're outside of the area defined inside of the function. The level collisions will run quite a bit slower though.
  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#219 whiteshadow

whiteshadow

    GMC Member

  • New Member
  • 29 posts
  • Version:GM8

Posted 27 March 2011 - 09:38 AM

i took that part out and now it just automaticly ends the game as soon as it starts but theres no error
  • 0
Error 43
It's Coming

#220 redfeild

redfeild

    GMC Member

  • New Member
  • 470 posts

Posted 27 March 2011 - 04:07 PM

I just found an easy fix for P3DC's crashes. The level model I was using crashed the game whenever I tried to load it, so I went back to my model editor and triangulated all the faces. Then I exported a new .mod from Marzipan and now it works fine!
  • 0
Posted Image Legalize it Posted Image

#221 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 27 March 2011 - 08:00 PM

...

Edited by brett14, 27 March 2011 - 08:02 PM.

  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#222 Legojak

Legojak

    GMC Member

  • GMC Member
  • 48 posts
  • Version:GM8

Posted 16 April 2011 - 06:48 PM

The external_define constant keeps having error messages:


___________________________________________
ERROR in
action number 1
of Create Event
for object <undefined>:

Error defining an external function.

Also, I'm using Game Maker 8.1, which just came out today or yesterday.

Is there supposed to be a different way to open it now?

:GM8_new: .1
  • 0

An ominously empty signature...


#223 redfeild

redfeild

    GMC Member

  • New Member
  • 470 posts

Posted 16 April 2011 - 07:00 PM

The external_define constant keeps having error messages:


___________________________________________
ERROR in
action number 1
of Create Event
for object <undefined>:

Error defining an external function.

Also, I'm using Game Maker 8.1, which just came out today or yesterday.

Is there supposed to be a different way to open it now?

:GM8_new: .1

Are your game and the DLL in the same folder?
  • 0
Posted Image Legalize it Posted Image

#224 Legojak

Legojak

    GMC Member

  • GMC Member
  • 48 posts
  • Version:GM8

Posted 16 April 2011 - 07:09 PM

The error message was copied off from the examples. <_<

So does anybody have ideas?

Edited by Legojak, 16 April 2011 - 11:26 PM.

  • 0

An ominously empty signature...


#225 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 17 April 2011 - 05:52 AM

GMAPI does not support GM 8.1, therefore P3DC does not support 8.1. You'll have to wait until Snake_PL, or somebody else either upgrades it or creates an alternative. I have updated the first post to notify everybody of this.
Sorry, but there's not much I can do until those updates come out.
~~Brett14;

Edited by brett14, 17 April 2011 - 07:14 AM.

  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#226 Legojak

Legojak

    GMC Member

  • GMC Member
  • 48 posts
  • Version:GM8

Posted 17 April 2011 - 02:42 PM

Ok... :mellow:

For now I'll just have to export everything to GM 8............

Edited by Legojak, 17 April 2011 - 02:42 PM.

  • 0

An ominously empty signature...


#227 lostdarkwolf

lostdarkwolf

    GMC Member

  • GMC Member
  • 413 posts
  • Version:GM8.1

Posted 05 May 2011 - 05:35 AM

i have an idea! =D
how bout we have a gm8 application work with the dll and have it tell a gm8.1 application all the aruments and such.
  • 0

Colorado finally did it! they legalized the recreational!


#228 lostdarkwolf

lostdarkwolf

    GMC Member

  • GMC Member
  • 413 posts
  • Version:GM8.1

Posted 05 May 2011 - 05:45 AM

i have an idea! =D
how bout we have a gm8 application tell a gm8.1 application the answer to all the functions. perhapps through the registry or exteranl files?

EDIT: oops... GMC told me that the previous post was unsuccessful.

Edited by lostdarkwolf, 05 May 2011 - 05:46 AM.

  • 0

Colorado finally did it! they legalized the recreational!


#229 orange451

orange451

    GMC Member

  • GMC Member
  • 1411 posts
  • Version:GM8.1

Posted 10 May 2011 - 01:17 PM

Can this support rotations in floors or blocks?
That'd be really useful :P
  • 0

bC14QqN.pngNrTFeil.png


#230 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 10 May 2011 - 11:30 PM

Yes, look at example 5.
  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#231 orange451

orange451

    GMC Member

  • GMC Member
  • 1411 posts
  • Version:GM8.1

Posted 11 May 2011 - 01:35 AM

:) Thank you for that.

I am currently using the collisions from your example 4, but I have run into a problem.
When I walk like for 3 seconds in a straight direction, I'll fall out of my map that I've made.
Is this because of:
p3dc_sort_model(level_colid,false);
p3dc_split_model(level_colid,2000,2000,50,50,10);

Also, why do some of my walls' collisions not register?
  • 0

bC14QqN.pngNrTFeil.png


#232 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 11 May 2011 - 03:29 AM

p3dc_sort_model() is for optimizing only. Simply put it splits the level up into 50x50 smaller regions (based on your arguments) and then collision checking will only be done on the region you're standing in. This can massively increase speed (assuming you have the same # of triangles in each region it has to do 2500x less checks), but it is easy to encounter errors. My guess is that you walked outside of the 2000x2000 set area, or are using the wrong type of collision.

The 10 at the end, should be equal to, or slightly greater than the object with the largest radius. It gives that much padding to each region so if you're player is 20 wide and your only checking with 10 padding then the collisions on the outskirts of each region will not register.


The top argument, sorting is only *recommended* if you're using p3dc_ray_first. You can remove it unless you are using ray_first. It is a very slow function to call.

Edited by brett14, 11 May 2011 - 03:35 AM.

  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#233 orange451

orange451

    GMC Member

  • GMC Member
  • 1411 posts
  • Version:GM8.1

Posted 12 May 2011 - 01:01 AM

I've hit another snag :P

if(zref<=8){
    if(zspeed<=0){
        zref=zprevious-7;
        zspeed=0;
        z = zprevious-1;
    }else{
        z=8+z-zref;
        zspeed=0;
    }
}else{
    zspeed+=gravitation;
}

zprevious=z;

That's your code from your examples, and I think this will help me to achieve what I need.

What I am trying to do, is make it so if a player collides with a wall and there is a floor 8 pixels above the floor the player is currently on, he'll increment his Z value by 1. This will help for stair like movement without having to go back and edit all my maps to add in an invisible slope.

I am assuming that zref is a variable to states where the next floor is, but how can I modify the code to do what I need?
  • 1

bC14QqN.pngNrTFeil.png


#234 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 12 May 2011 - 03:33 AM

Zref is the distance to the floor below the player. Z is the players current z value. zprevious was the previous z.

There are a couple ways to do what you want. I assume you want to have a method of getting to 1 floor to the other. Below are how I suggest doing it.
Try an elevator? Uses p3dc.
Add stairs to the level. If the distance between the steps is too big then you'll have to jump up them. Make small steps! (or an invisible slope)
Create a ladder, and add it to the model with a trianglemask of C_LADDER. Check if your trying to run forward and if the trianglemask is c_ladder then keep increasing the z.


But if your really keen on doing whatever it is you want, then you can do a raycast directly upwards and find its distance. If it's less than 8 increase then set your zvalue accordingly.


If I didn't answer the question how you would like, or if I misunderstood you just say so.
Cheers
~~Brett14;


[EDIT]
For a ladder, add a wall with a trianglemask. Do a raycast directly forward in the direction that the player is facing. Check if he is holding forward, and if he is and the distance to the wall is (<ANY VALUE) then start climbing the ladder. When the next update comes I'll include examples with ladders and elevators.
[/EDIT]

Edited by brett14, 12 May 2011 - 03:40 AM.

  • 1

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#235 orange451

orange451

    GMC Member

  • GMC Member
  • 1411 posts
  • Version:GM8.1

Posted 12 May 2011 - 10:53 AM

This is what I came up with:

xd=cos(degtorad(dir))
            yd=-sin(degtorad(dir))
            zd=sin(degtorad(0));
            dis1=p3dc_ray_still(global.level_collision,x,y,z+1,xd,yd,zd);
            dis2=p3dc_ray_still(global.level_collision,x,y,z+10,xd,yd,zd);
            
            xp1=dis1*xd;
            yp1=dis1*yd;
            
            if (point_distance(x, y, xp1, yp1) <= 4 ) {
                if abs(dis2-dis1) > 4 {
                    z+=2;
                }
            }


without the xp1 and yp1 stuff, it works... (sort of). I can't figure out how to get the distance between the rays made and the player. Can you help?



[EDIT]

if (speed!=0){
        
            xd=cos(degtorad(direction));
            yd=-sin(degtorad(direction));
        
            dis1=p3dc_ray_still(global.level_collision,x,y,z+1,xd,yd,0);
            dis2=p3dc_ray_still(global.level_collision,x,y,z+10,xd,yd,0);
            room_caption = string(dis1) + string(" || ") + string(dis2)
            
            if (dis1 <= 6 ) {
                if dis2 >8.5 {
                    z+=8;
                }
            }
        }


Got it working! Thanks for the help, brett :)

Edited by orange451, 12 May 2011 - 06:59 PM.

  • 0

bC14QqN.pngNrTFeil.png


#236 Legojak

Legojak

    GMC Member

  • GMC Member
  • 48 posts
  • Version:GM8

Posted 12 May 2011 - 09:26 PM

There are a couple ways to do what you want. I assume you want to have a method of getting to 1 floor to the other. Below are how I suggest doing it.
Try an elevator? Uses p3dc.


Please give credit if you use my elevator. ^_^

Edited by Legojak, 12 May 2011 - 09:29 PM.

  • 0

An ominously empty signature...


#237 sneaky666

sneaky666

    536e65616b79

  • GMC Member
  • 1047 posts
  • Version:GM:Studio

Posted 20 May 2011 - 01:21 AM

when will this be updated to work with gm 8.1, i need some good 3d collision checking and i cant find anything that works with 8.1...
  • 1

Mountain Adventure 3D Highscore: 44 [◊ TheUltimate ◊]
Shoot Them Up Challenge Edition Winner: [◊ TheUltimate ◊]
Cursor Catch Current Winners: mr magnus || ◊ TheUltimate ◊
Tron Challenge Current Winners: ◊ TheUltimate ◊ [Legendary] || thegame [Easy] || FoxInABox [Easy]

>>>>>Click Here To See My List Of Games<<<<<


#238 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 20 May 2011 - 11:17 PM

Im waiting for GMAPI. If it does not get updated anytime soon then I may modify it (make it slower) and remove the gmapi dependancy.
  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#239 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 20 May 2011 - 11:18 PM

If you really need a 3d collision engine badly (right this second), use the modmod source (like I did) and create one. It shouldnt take too long.
  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#240 sneaky666

sneaky666

    536e65616b79

  • GMC Member
  • 1047 posts
  • Version:GM:Studio

Posted 22 May 2011 - 07:52 PM

I'm actually a noob when it comes to writing code for collision checking in 3d. I don't know where to begin. I am mainly looking for code to check if a (my player) rectangular prism is in collision with my floating platform (which is a rectangular prism).

The thing is the player shape, can be rotated and transformed (moved in any axis) so the collision checking has to take this into consideration.

Edited by sneaky666, 22 May 2011 - 07:54 PM.

  • 0

Mountain Adventure 3D Highscore: 44 [◊ TheUltimate ◊]
Shoot Them Up Challenge Edition Winner: [◊ TheUltimate ◊]
Cursor Catch Current Winners: mr magnus || ◊ TheUltimate ◊
Tron Challenge Current Winners: ◊ TheUltimate ◊ [Legendary] || thegame [Easy] || FoxInABox [Easy]

>>>>>Click Here To See My List Of Games<<<<<


#241 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 25 May 2011 - 11:17 PM

As I said, can't really update without GMAPI or a simular alternative without rewriting quite a bit of it. I'll wait a bit longer (couple weeks?), then if nothing has come out by then I'll change it.
  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#242 orange451

orange451

    GMC Member

  • GMC Member
  • 1411 posts
  • Version:GM8.1

Posted 26 May 2011 - 02:01 AM

Didn't this dll use to work without gmapi?
Would that dll still work, and be easier to use than modmod for gm8.1?
  • 0

bC14QqN.pngNrTFeil.png


#243 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 26 May 2011 - 02:50 AM

Yes, it used to work without gmapi before V3. I added the dependency to increase the speed and make it easier for me to use gmapi. I will probably have to end up removing the dependancy and making a work around for what is used, but that would require me to restructure most of the dll (work!) which I'll wait for gmapi to update or remove it. Snake said he'd try to implement a feature to detect the version and find the memory locations of the functions etc. from that.


As for answering you're question, it should work with gm 8.1, but no guarantees. Its also quite a bit slower and missing a few functions but it should do for now. I don't have it anymore though, somebody might or it might even be on my host-a-net profile/64-digits profile.
  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#244 Alvare

Alvare

    Not an administrator

  • GMC Member
  • 1812 posts
  • Version:None

Posted 26 May 2011 - 03:36 PM

Whyyyyyyyyyyyyyyyyyyyyyyy! :angry:

I'll wait.. :(
  • 0

#245 orange451

orange451

    GMC Member

  • GMC Member
  • 1411 posts
  • Version:GM8.1

Posted 26 May 2011 - 08:09 PM

http://www.host-a.ne...4/P3DC V300.zip

Thanks brett!
  • 0

bC14QqN.pngNrTFeil.png


#246 orange451

orange451

    GMC Member

  • GMC Member
  • 1411 posts
  • Version:GM8.1

Posted 26 May 2011 - 08:10 PM

[EDIT]
double post... sorry

Edited by orange451, 26 May 2011 - 08:11 PM.

  • 0

bC14QqN.pngNrTFeil.png


#247 iampure675

iampure675

    GMC Member

  • New Member
  • 35 posts

Posted 26 May 2011 - 09:27 PM

I have game maker version 8 pro...
I have checked everything over like a million times and I can't find what's wrong, so everytime i start my game an error appears saying...
PLEASE HELP. this looks really cool to use and i can't wait for it to work :)

___________________________________________
ERROR in
action number 1
of Create Event
for object obj_player:

Error defining an external function.
  • 0

#248 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 27 May 2011 - 12:26 AM

Did you extract everything? Do the examples run for you? What version of gamemaker 8?


Whyyyyyyyyyyyyyyyyyyyyyyy

I didn't expect gm 8.1 to come out with an auto-updater, and I expected snake to be able to update gmapi to go along with the newer versions. Also it made the dll faster and did a couple other things, nonetheless it went in...

Edited by brett14, 27 May 2011 - 12:29 AM.

  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#249 iampure675

iampure675

    GMC Member

  • New Member
  • 35 posts

Posted 27 May 2011 - 06:14 PM

Did you extract everything? Do the examples run for you? What version of gamemaker 8?


Whyyyyyyyyyyyyyyyyyyyyyyy

I didn't expect gm 8.1 to come out with an auto-updater, and I expected snake to be able to update gmapi to go along with the newer versions. Also it made the dll faster and did a couple other things, nonetheless it went in...


Yes I extracted everything, tried all the examples, and I have version 8.0
  • 0

#250 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 27 May 2011 - 11:24 PM

Interesting. Try restarting the comp? Do you have a LEGAL version of gm?
  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012