int mouse_get_quad3d_intersect(Vec3D *contact,Quad3D quad) { Text text; Vec3D position,vector; mouse_get_3d_ray(&position,&vector); vec3d_scale(vector,vector,10000); print_quad3d(text,quad); return ray_in_quad3d( position, vector, quad, contact); }
static void space_body_update(Space *space,Body *body) { GList *it; Cube a,b; Body *other; Vec3D stepVector; Vec3D stepOffVector; if ((!body) || (body->_done))return; vec3d_scale(stepVector,body->velocity,space->stepFactor); vec3d_negate(stepOffVector,stepVector); vec3d_add(body->position,body->position,stepVector); a.x = body->position.x + body->bounds.x; a.y = body->position.y + body->bounds.y; a.z = body->position.z + body->bounds.z; a.w = body->bounds.w; a.h = body->bounds.h; a.d = body->bounds.d; for (it = space->bodylist;it != NULL;it = g_list_next(it)) { if (!it->data)continue; if (it->data == body)continue; /*check for collision*/ other = (Body *)it->data; vec3d_cpy(b,other->position); b.w = other->bounds.w; b.h = other->bounds.h; b.d = other->bounds.d; vec3d_add(b,b,other->bounds); if (cube_cube_intersection(a,b)) { /*call touch functions*/ /*back the f**k off*/ //vec3d_cpy(body->_stepOffVector,stepOffVector); //body->_done = 1; // body->_needsBackoff = 1; if (body->touch.function) { body->touch.function(body->touch.data,other); } } } }
void mouse_draw_3d_ray() { Vec3D position,vector, position2; mouse_get_3d_ray(&position,&vector); vec3d_scale(vector,vector,100); vec3d_add(position2,position,vector); draw_dot_3D(position, 4, vec3d(1,0,0), 1); draw_line_3D(position, position2, 2, vec3d(0,1,0), 1); draw_dot_3D(position2, 7, vec3d(0,0,1), 1); }