Guest User

Untitled

a guest
Dec 28th, 2014
19
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void d3d_model_floor(int id, gs_scalar x1, gs_scalar y1, gs_scalar z1, gs_scalar x2, gs_scalar y2, gs_scalar z2, gs_scalar hrep, gs_scalar vrep) {
  2.     // Find third point
  3.     gs_scalar x3 = x2;
  4.     gs_scalar y3 = y1;
  5.     gs_scalar z3 = z2;
  6.    
  7.     // Setup U and V vectors
  8.     gs_scalar vX = x2 - x1;
  9.     gs_scalar vY = y2 - y1;
  10.     gs_scalar vZ = z2 - z1;
  11.     gs_scalar wX = x3 - x1;
  12.     gs_scalar wY = y3 - y1;
  13.     gs_scalar wZ = z3 - z1;
  14.  
  15.     // Cross-Product of vectors to create normal vector
  16.     gs_scalar nX = (vY * wZ) - (vZ * wY);
  17.     gs_scalar nY = (vZ * wX) - (vX * wZ);
  18.     gs_scalar nZ = (vX * wY) - (vY * wX);
  19.    
  20.     // Normalize result
  21.     gs_scalar mag = sqrt( (nX*nX) + (nY*nY) + (nZ*nZ) );
  22.     nX /= mag;
  23.     nZ /= mag;
  24.     nX /= mag;
  25.  
  26.     // Create floor
  27.     d3d_model_primitive_begin(id, pr_trianglestrip);
  28.     d3d_model_vertex_normal_texture(id, x1, y1, z1, nX, nY, nZ, 0, 0);
  29.     d3d_model_vertex_normal_texture(id, x1, y2, z1, nX, nY, nZ, 0, vrep);
  30.     d3d_model_vertex_normal_texture(id, x2, y1, z2, nX, nY, nZ, hrep, 0);
  31.     d3d_model_vertex_normal_texture(id, x2, y2, z2, nX, nY, nZ, hrep, vrep);
  32.     d3d_model_primitive_end(id);
  33. }
  34.  
  35. void d3d_model_wall(int id, gs_scalar x1, gs_scalar y1, gs_scalar z1, gs_scalar x2, gs_scalar y2, gs_scalar z2, gs_scalar hrep, gs_scalar vrep) {
  36.     // Find third point
  37.     gs_scalar x3 = x1;
  38.     gs_scalar y3 = y1;
  39.     gs_scalar z3 = z2;
  40.    
  41.     // Setup U and V vectors
  42.     gs_scalar vX = x2 - x1;
  43.     gs_scalar vY = y2 - y1;
  44.     gs_scalar vZ = z2 - z1;
  45.     gs_scalar wX = x3 - x1;
  46.     gs_scalar wY = y3 - y1;
  47.     gs_scalar wZ = z3 - z1;
  48.  
  49.     // Cross-Product of vectors to create normal vector
  50.     gs_scalar nX = (vY * wZ) - (vZ * wY);
  51.     gs_scalar nY = (vZ * wX) - (vX * wZ);
  52.     gs_scalar nZ = (vX * wY) - (vY * wX);
  53.    
  54.     // Normalize result
  55.     gs_scalar mag = sqrt( (nX*nX) + (nY*nY) + (nZ*nZ) );
  56.     nX /= mag;
  57.     nZ /= mag;
  58.     nX /= mag;
  59.  
  60.     // Create wall
  61.     d3d_model_primitive_begin(id, pr_trianglestrip);
  62.     d3d_model_vertex_normal_texture(id, x1, y1, z1, nX, nY, nZ, 0, 0);
  63.     d3d_model_vertex_normal_texture(id, x2, y2, z1, nX, nY, nZ, hrep, 0);
  64.     d3d_model_vertex_normal_texture(id, x1, y1, z2, nX, nY, nZ, 0, vrep);
  65.     d3d_model_vertex_normal_texture(id, x2, y2, z2, nX, nY, nZ, hrep, vrep);
  66.     d3d_model_primitive_end(id);
  67. }
RAW Paste Data