Shadowrun: Awakened 29 September 2011 - Build 871
Functions
texture.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

color checker_texture (vector *, texture *, ray *)
color cyl_checker_texture (vector *, texture *, ray *)
color gnoise_texture (vector *, texture *, ray *)
color grit_texture (vector *, texture *, ray *)
color image_cyl_texture (vector *, texture *, ray *)
color image_plane_texture (vector *, texture *, ray *)
color image_sphere_texture (vector *, texture *, ray *)
void InitTextures (void)
color marble_texture (vector *, texture *, ray *)
int Noise (flt, flt, flt)
color standard_texture (vector *, texture *, ray *)
color wood_texture (vector *, texture *, ray *)

Function Documentation

color checker_texture ( vector ,
texture ,
ray  
)

Definition at line 172 of file texture.cpp.

References color::b, texture::ctr, color::g, color::r, vector::x, vector::y, and vector::z.

Referenced by apitextotex().

                                                             {
  long x,y,z;
  flt xh,yh,zh;
  color col;

  xh=hit->x - tex->ctr.x; 
  x=(long) ((fabs(xh) * 3) + 0.5);
  x=x % 2;
  yh=hit->y - tex->ctr.y;
  y=(long) ((fabs(yh) * 3) + 0.5);
  y=y % 2;
  zh=hit->z - tex->ctr.z;
  z=(long) ((fabs(zh) * 3) + 0.5);
  z=z % 2;

  if (((x + y + z) % 2)==1) {
    col.r=1.0;
    col.g=0.2;
    col.b=0.0;
  }
  else {
    col.r=0.0;
    col.g=0.2;
    col.b=1.0;
  }

  return col;
}
color cyl_checker_texture ( vector ,
texture ,
ray  
)

Definition at line 201 of file texture.cpp.

References color::b, texture::ctr, color::g, color::r, vector::x, xyztocyl(), vector::y, and vector::z.

Referenced by apitextotex().

                                                                 {
  long x,y;
  vector rh;
  flt u,v;
  color col;
 
  rh.x=hit->x - tex->ctr.x;
  rh.y=hit->y - tex->ctr.y;
  rh.z=hit->z - tex->ctr.z;

  xyztocyl(rh, 1.0, &u, &v); 

  x=(long) (fabs(u) * 18.0);
  x=x % 2;
  y=(long) (fabs(v) * 10.0);
  y=y % 2;
 
  if (((x + y) % 2)==1) {
    col.r=1.0;
    col.g=0.2;
    col.b=0.0;
  }
  else {
    col.r=0.0;
    col.g=0.2;
    col.b=1.0;
  }
 
  return col;
}
color gnoise_texture ( vector ,
texture ,
ray  
)

Definition at line 373 of file texture.cpp.

References color::b, texture::col, texture::ctr, color::g, Noise(), color::r, vector::x, vector::y, and vector::z.

Referenced by apitextotex().

                                                            {
  color col;
  flt f;

  f=Noise((hit->x - tex->ctr.x), 
          (hit->y - tex->ctr.y), 
      (hit->z - tex->ctr.z));

  if (f < 0.01) f=0.01;
  if (f > 1.0) f=1.0;

  col.r=tex->col.r * f;
  col.g=tex->col.g * f;
  col.b=tex->col.b * f;

  return col;
}
color grit_texture ( vector ,
texture ,
ray  
)

Definition at line 157 of file texture.cpp.

References color::b, texture::col, color::g, and color::r.

Referenced by apitextotex().

                                                          {
  int rnum;
  flt fnum;
  color col;

  rnum=rand() % 4096;
  fnum=(rnum / 4096.0 * 0.2) + 0.8;

  col.r=tex->col.r * fnum;
  col.g=tex->col.g * fnum;
  col.b=tex->col.b * fnum;

  return col;
}
color image_cyl_texture ( vector ,
texture ,
ray  
)

Definition at line 79 of file texture.cpp.

References texture::ctr, ImageMap(), texture::img, texture::rot, texture::scale, vector::x, xyztocyl(), vector::y, and vector::z.

Referenced by apitextotex().

                                                               {
  vector rh;
  flt u,v;
 
  rh.x=hit->x - tex->ctr.x;
  rh.z=hit->y - tex->ctr.y;
  rh.y=hit->z - tex->ctr.z;
 
  xyztocyl(rh, 1.0, &u, &v);

  u = u * tex->scale.x;  
  u = u + tex->rot.x;
  u=fmod(u, 1.0);
  if (u < 0.0) u+=1.0; 

  v = v * tex->scale.y; 
  v = v + tex->rot.y;
  v=fmod(v, 1.0);
  if (v < 0.0) v+=1.0; 

  return ImageMap((rawimage *)tex->img, u, v); 
}  
color image_plane_texture ( vector ,
texture ,
ray  
)

Definition at line 127 of file texture.cpp.

References texture::ctr, ImageMap(), texture::img, texture::rot, texture::scale, texture::uaxs, texture::vaxs, VDOT, vector::x, vector::y, and vector::z.

Referenced by apitextotex().

                                                                 {
  vector pnt;
  flt u,v;
 
  pnt.x=hit->x - tex->ctr.x;
  pnt.y=hit->y - tex->ctr.y;
  pnt.z=hit->z - tex->ctr.z;

  VDOT(u, tex->uaxs, pnt);
/*  VDOT(len, tex->uaxs, tex->uaxs);
  u = u / sqrt(len); */

  VDOT(v, tex->vaxs, pnt); 
/*  VDOT(len, tex->vaxs, tex->vaxs);
  v = v / sqrt(len); */
    

  u = u * tex->scale.x;
  u = u + tex->rot.x;
  u = fmod(u, 1.0);
  if (u < 0.0) u += 1.0;

  v = v * tex->scale.y;
  v = v + tex->rot.y;
  v = fmod(v, 1.0);
  if (v < 0.0) v += 1.0;

  return ImageMap((rawimage *)tex->img, u, v);
}
color image_sphere_texture ( vector ,
texture ,
ray  
)

Definition at line 103 of file texture.cpp.

References texture::ctr, ImageMap(), texture::img, texture::rot, texture::scale, vector::x, xyztospr(), vector::y, and vector::z.

Referenced by apitextotex().

                                                                  {
  vector rh;
  flt u,v;
 
  rh.x=hit->x - tex->ctr.x;
  rh.y=hit->y - tex->ctr.y;
  rh.z=hit->z - tex->ctr.z;
 
  xyztospr(rh, &u, &v);

  u = u * tex->scale.x;
  u = u + tex->rot.x;
  u=fmod(u, 1.0);
  if (u < 0.0) u+=1.0;
 
  v = v * tex->scale.y;
  v = v + tex->rot.y;
  v=fmod(v, 1.0);
  if (v < 0.0) v+=1.0;
 
  return ImageMap((rawimage *)tex->img, u, v);
}
void InitTextures ( void  )

Definition at line 391 of file texture.cpp.

References InitNoise(), and ResetImages().

Referenced by rt_initialize().

color marble_texture ( vector ,
texture ,
ray  
)

Definition at line 342 of file texture.cpp.

References color::b, color::g, Noise(), color::r, vector::x, vector::y, and vector::z.

Referenced by apitextotex().

                                                            {
  flt i,d;
  flt x,y,z;
  color col;
 
  x=hit->x;
  y=hit->y; 
  z=hit->z;

  x=x * 1.0;

  d=x + 0.0006 * Noise(x, (y * 1.0), (z * 1.0));
  d=d*(((int) d) % 25);
  i=0.0 + 0.10 * fabs(d - 10.0 - 20.0 * ((int) d * 0.05));
  if (i > 1.0) i=1.0;
  if (i < 0.0) i=0.0;  

/*
  col.r=i * tex->col.r;
  col.g=i * tex->col.g;
  col.b=i * tex->col.b;
*/

  col.r = (1.0 + sin(i * 6.28)) / 2.0;
  col.g = (1.0 + sin(i * 16.28)) / 2.0;
  col.b = (1.0 + cos(i * 30.28)) / 2.0;

  return col;      
}
int Noise ( flt  ,
flt  ,
flt   
)

Definition at line 293 of file texture.cpp.

References NMAX, and NoiseMatrix.

Referenced by gnoise_texture(), and marble_texture().

                               {
  byte ix, iy, iz;
  flt ox, oy, oz;
  int p000, p001, p010, p011;
  int p100, p101, p110, p111;
  int p00, p01, p10, p11;
  int p0, p1;
  int d00, d01, d10, d11;
  int d0, d1, d;

  x=fabs(x);
  y=fabs(y);
  z=fabs(z);

  ix=((int) x) % (NMAX-1);
  iy=((int) y) % (NMAX-1);
  iz=((int) z) % (NMAX-1);

  ox=(x - ((int) x));
  oy=(y - ((int) y));
  oz=(z - ((int) z));

  p000=NoiseMatrix[ix][iy][iz];
  p001=NoiseMatrix[ix][iy][iz+1];
  p010=NoiseMatrix[ix][iy+1][iz];
  p011=NoiseMatrix[ix][iy+1][iz+1];
  p100=NoiseMatrix[ix+1][iy][iz];
  p101=NoiseMatrix[ix+1][iy][iz+1];
  p110=NoiseMatrix[ix+1][iy+1][iz];
  p111=NoiseMatrix[ix+1][iy+1][iz+1];

  d00=p100-p000;
  d01=p101-p001;
  d10=p110-p010;
  d11=p111-p011;

  p00=(int) ((int) d00*ox) + p000;
  p01=(int) ((int) d01*ox) + p001;
  p10=(int) ((int) d10*ox) + p010;
  p11=(int) ((int) d11*ox) + p011;
  d0=p10-p00;
  d1=p11-p01;
  p0=(int) ((int) d0*oy) + p00;
  p1=(int) ((int) d1*oy) + p01;
  d=p1-p0;

  return (int) ((int) d*oz) + p0;
}
color standard_texture ( vector ,
texture ,
ray  
)

Definition at line 74 of file texture.cpp.

References texture::col.

Referenced by apitextotex().

                                                              {
  return tex->col;
}
color wood_texture ( vector ,
texture ,
ray  
)

Definition at line 233 of file texture.cpp.

References color::b, texture::ctr, color::g, color::r, vector::x, vector::y, and vector::z.

Referenced by apitextotex().

                                                          {
  flt radius, angle;
  int grain;
  color col;
  flt x,y,z;

  x=(hit->x - tex->ctr.x) * 1000;
  y=(hit->y - tex->ctr.y) * 1000;
  z=(hit->z - tex->ctr.z) * 1000;

  radius=sqrt(x*x + z*z);
  if (z == 0.0) 
    angle=3.1415926/2.0;
  else 
    angle=atan(x / z);

  radius=radius + 3.0 * sin(20 * angle + y / 150.0);
  grain=((int) (radius + 0.5)) % 60;
  if (grain < 40) {
    col.r=0.8;
    col.g=1.0;
    col.b=0.2;
  }
  else {
    col.r=0.0;
    col.g=0.0;
    col.b=0.0;
  }     

  return col;
} 

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net