# point_dis for p3dc.dll

### #1

Posted 10 November 2011 - 01:49 AM

var vx,vy,vz,dis,zp,zdir;

zdir = argument1

vx = cos(degtorad(argument0))*cos(degtorad(zdir))

vy = -sin(degtorad(argument0))*cos(degtorad(zdir))

vz = sin(degtorad(zdir))

dis = p3dc_ray(level_colid,x,y,z,vx,vy,vz)

zp = z+vz*dis

return dis

### #2

Posted 06 February 2012 - 10:37 PM

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

Posted 08 February 2012 - 05:50 AM

var vx,vy,vz,dis,zp,zdir;

zdir = argument1

vx = cos(degtorad(argument0))*cos(degtorad(zdir))

vy = -sin(degtorad(argument0))*cos(degtorad(zdir))

vz = sin(degtorad(zdir))

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.

Dual-Quaternion Skinning - Modifying vertexes in GM is slow. This simple vertex shader does the job both quickly and well.

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users