# point_dis for p3dc.dll

2 replies to this topic

### #1 topmarine

topmarine

GMC Member

• New Member
• 122 posts
• Version:GM8.1

Posted 10 November 2011 - 02:03 AM

point_dis script. Hope this helps all those other p3dc.dll users out there.

var vx,vy,vz,dis,zp,zdir;
zdir = argument1
dis = p3dc_ray(level_colid,x,y,z,vx,vy,vz)
zp = z+vz*dis

return dis
• 0

### #2 Zesterer

Zesterer

Professor of Articul

• GMC Member
• 1044 posts
• Version:GM8

Posted 06 February 2012 - 10:51 PM

I think I can guess, but could you explain for others exactly what it does? It is very unclear...
• 0

Fortified - The sword thrusting, castle busting, catapult adjusting new Tower Defense game!

More projects and work coming soon... If you need help on voxels, mesh rendering, physics, perlin noise generation, 3D, mathematics or more just contact me and I'll be happy to help!

Skype: zesterer                Email: barry.of.smith@gmail.com <---- Actually, don't use this address, I never check it.

### #3 Gamer3D

Gamer3D

Human* me = this;

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

Posted 08 February 2012 - 06:04 AM

var vx,vy,vz,dis,zp,zdir;
zdir = argument1
dis = p3dc_ray(level_colid,x,y,z,vx,vy,vz)
zp = z+vz*dis

return dis

I think I can guess, but could you explain for others exactly what it does? It is very unclear...

Well, analyzing it results in:
Calculate a unit-vector from spherical coordinates, in degrees. Use P3DC raycasting to find distance from position <x, y, VARIABLE_UNDEFINED> one unit in that direction, with collisions calculated against VARIABLE_UNDEFINED. It then assigns a value to the useless local variable "zp" and returns whatever p3dc_ray would return.

If you make your game like he does (z for position and level_colid for the P3DC collision model), then it will return the same as
a raycast of distance one in a direction specified by polar coordinates.

Simplifying and replacing his assumptions of variables with arguments, we get:
```var vx, vy, vz, zc;
zc = cos(argument5 * 0.00872664625997164788461845384244);
vx = cos(argument4 * 0.00872664625997164788461845384244) * zc;
vy = -sin(argument4 * 0.00872664625997164788461845384244) * zc;
vz = sin(argument5 * 0.00872664625997164788461845384244);
return p3dc_ray(argument0, argument1, argument2, argument3, vx, vy, vz);
```

The changes: Removed assumed variables "z" and "level_colid" and replaced with arguments. Replaced x and y with arguments to make it more useful. Moved polar coordinate arguments to end of argument array.

P.S. I should have checked the original post date. Not sure why Zesterer revived this topic.
• 0
Fast Priority Queues - Game Maker's priority queues are O(n). Mine do everything that Game Maker's do, but in O(log n) time.
Dual-Quaternion Skinning - Modifying vertexes in GM is slow. This simple vertex shader does the job both quickly and well.