Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Macros | Functions | Variables
material.cpp File Reference
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include "SDL_opengl.h"
#include "inexor/engine/glare.hpp"
#include "inexor/engine/glemu.hpp"
#include "inexor/engine/glexts.hpp"
#include "inexor/engine/lightmap.hpp"
#include "inexor/engine/material.hpp"
#include "inexor/engine/octa.hpp"
#include "inexor/engine/octaedit.hpp"
#include "inexor/engine/octarender.hpp"
#include "inexor/engine/octree.hpp"
#include "inexor/engine/rendergl.hpp"
#include "inexor/engine/renderva.hpp"
#include "inexor/engine/shader.hpp"
#include "inexor/engine/water.hpp"
#include "inexor/engine/world.hpp"
#include "inexor/network/legacy/buffer_types.hpp"
#include "inexor/physics/physics.hpp"
#include "inexor/shared/command.hpp"
#include "inexor/shared/cube_formatting.hpp"
#include "inexor/shared/cube_loops.hpp"
#include "inexor/shared/cube_sort.hpp"
#include "inexor/shared/cube_tools.hpp"
#include "inexor/shared/ents.hpp"
#include "inexor/shared/geom.hpp"
#include "inexor/shared/tools.hpp"
#include "inexor/texture/cubemap.hpp"
#include "inexor/texture/slot.hpp"
#include "inexor/texture/texture.hpp"
#include "inexor/util/legacy_time.hpp"

Classes

struct  QuadNode
 
struct  material
 
struct  waterinfo
 
struct  unionfind
 
struct  unionfind::ufval
 

Macros

#define GENFACEORIENT(orient, v0, v1, v2, v3)   case orient: v0 v1 v2 v3 break;
 
#define GENFACEVERTX(orient, vert, mx, my, mz, sx, sy, sz)
 
#define GENFACEVERTY(orient, vert, mx, my, mz, sx, sy, sz)
 
#define GENFACENORMAL   gle::attrib(n);
 
#define GENFACENORMAL
 
#define GENFACEVERTX(o, n, x, y, z, xv, yv, zv)   GENFACEVERT(o,n, x,y,z, xv,yv,zv)
 
#define GENFACEVERTY(o, n, x, y, z, xv, yv, zv)   GENFACEVERT(o,n, x,y,z, xv,yv,zv)
 
#define GENFACEORIENT(orient, v0, v1, v2, v3)   case orient: v0 v1 v2 v3 break;
 
#define GENFACEVERT(orient, vert, mx, my, mz, sx, sy, sz)   gle::attribf(mx sx, my sy, mz sz);
 
#define GLASSVARS(name)
 
#define GENFACEORIENT(orient, v0, v1, v2, v3)   case orient: v0 v1 v2 v3 break;
 
#define GENFACEVERT(orient, vert, mx, my, mz, sx, sy, sz)
 
#define GENFACENORMAL   gle::attrib(n);
 
#define GENFACENORMAL
 

Functions

static void renderwaterfall (const materialsurface &m, float offset, const vec *normal=nullptr)
 
static void drawmaterial (const materialsurface &m, float offset)
 
int findmaterial (const char *name)
 
const char * findmaterialname (int mat)
 
const char * getmaterialdesc (int mat, const char *prefix)
 
int visiblematerial (const cube &c, int orient, const ivec &co, int size, ushort matmask)
 
void genmatsurfs (const cube &c, const ivec &co, int size, vector< materialsurface > &matsurfs)
 
static bool mergematcmp (const materialsurface &x, const materialsurface &y)
 
static int mergematr (materialsurface *m, int sz, materialsurface &n)
 
static int mergematc (materialsurface &m, materialsurface &n)
 
static int mergemat (materialsurface *m, int sz, materialsurface &n)
 
static int mergemats (materialsurface *m, int sz)
 
static bool optmatcmp (const materialsurface &x, const materialsurface &y)
 
 VARF (optmats, 0, 1, 1, allchanged())
 
int optimizematsurfs (materialsurface *matbuf, int matsurfs)
 
void setupmaterials (int start, int len)
 
 VARP (showmat, 0, 1, 1)
 
static bool vismatcmp (const materialsurface *xm, const materialsurface *ym)
 
void sortmaterials (vector< materialsurface * > &vismats)
 
void rendermatgrid (vector< materialsurface * > &vismats)
 
 VARP (glassenv, 0, 1, 1)
 
static void drawglass (const materialsurface &m, float offset, const vec *normal=nullptr)
 
 VARFP (waterfallenv, 0, 1, 1, preloadwatershaders())
 
void rendermaterials ()
 

Variables

static float wfwave
 
static float wfscroll
 
static float wfxscale
 
static float wfyscale
 
const struct material materials []
 
static int sortdim [3]
 
static ivec sortorigin
 
static bool sortedit
 

Class Documentation

struct material
Class Members
ushort id
const char * name
struct waterinfo
Class Members
double area
double depth
materialsurface * m

Macro Definition Documentation

#define GENFACENORMAL   gle::attrib(n);
#define GENFACENORMAL
#define GENFACENORMAL   gle::attrib(n);
#define GENFACENORMAL
#define GENFACEORIENT (   orient,
  v0,
  v1,
  v2,
  v3 
)    case orient: v0 v1 v2 v3 break;
#define GENFACEORIENT (   orient,
  v0,
  v1,
  v2,
  v3 
)    case orient: v0 v1 v2 v3 break;
#define GENFACEORIENT (   orient,
  v0,
  v1,
  v2,
  v3 
)    case orient: v0 v1 v2 v3 break;
#define GENFACEVERT (   orient,
  vert,
  mx,
  my,
  mz,
  sx,
  sy,
  sz 
)    gle::attribf(mx sx, my sy, mz sz);
#define GENFACEVERT (   orient,
  vert,
  mx,
  my,
  mz,
  sx,
  sy,
  sz 
)
Value:
{ \
vec v(mx sx, my sy, mz sz); \
vec reflect = vec(v).sub(camera1->o); \
reflect[dimension(orient)] = -reflect[dimension(orient)]; \
gle::attrib(reflect); \
}
#define dimension(orient)
Definition: octree.hpp:338
vector with 3 floats and some useful methods.
Definition: geom.hpp:110
int mx
Definition: octaedit.cpp:1750
vec & sub(const vec &o)
scalar subtraction
Definition: geom.hpp:177
int orient
Definition: octaedit.cpp:164
physent * camera1
special ent that acts as camera, same object as player1 in FPS mode
Definition: rendergl.cpp:868
vec o
Definition: ents.hpp:130
static void attrib(T x)
Definition: glemu.hpp:106
int mz
Definition: octaedit.cpp:1750
int my
Definition: octaedit.cpp:1750
#define GENFACEVERTX (   orient,
  vert,
  mx,
  my,
  mz,
  sx,
  sy,
  sz 
)
Value:
{ \
vec v(mx sx, my sy, mz sz); \
GENFACENORMAL \
gle::attribf(wfxscale*v.y, wfyscale*(v.z+wfscroll)); \
}
static float wfxscale
Definition: material.cpp:108
static float wfscroll
Definition: material.cpp:108
static float wfyscale
Definition: material.cpp:108
int mx
Definition: octaedit.cpp:1750
static void attrib(T x)
Definition: glemu.hpp:106
int mz
Definition: octaedit.cpp:1750
int my
Definition: octaedit.cpp:1750
#define GENFACEVERTX (   o,
  n,
  x,
  y,
  z,
  xv,
  yv,
  zv 
)    GENFACEVERT(o,n, x,y,z, xv,yv,zv)
#define GENFACEVERTY (   orient,
  vert,
  mx,
  my,
  mz,
  sx,
  sy,
  sz 
)
Value:
{ \
vec v(mx sx, my sy, mz sz); \
GENFACENORMAL \
gle::attribf(wfxscale*v.x, wfyscale*(v.z+wfscroll)); \
}
static float wfxscale
Definition: material.cpp:108
static float wfscroll
Definition: material.cpp:108
static float wfyscale
Definition: material.cpp:108
int mx
Definition: octaedit.cpp:1750
static void attrib(T x)
Definition: glemu.hpp:106
int mz
Definition: octaedit.cpp:1750
int my
Definition: octaedit.cpp:1750
#define GENFACEVERTY (   o,
  n,
  x,
  y,
  z,
  xv,
  yv,
  zv 
)    GENFACEVERT(o,n, x,y,z, xv,yv,zv)
#define GLASSVARS (   name)
Value:
bvec name##color(0x20, 0x80, 0xC0); \
HVARFR(name##colour, 0, 0x2080C0, 0xFFFFFF, \
{ \
if(!name##colour) name##colour = 0x2080C0; \
name##color = bvec((name##colour>>16)&0xFF, (name##colour>>8)&0xFF, name##colour&0xFF); \
});
#define HVARFR(name, min, cur, max, body)
Definition: command.hpp:405
3-dimensional UNSIGNED CHAR vector.
Definition: geom.hpp:1398
if(NOT DEFINED PROJECT_ARCH) message(FATAL_ERROR"You are generating from the wrong folder! \"Where is the Source
Definition: CMakeLists.txt:2
static void color(const bvec &v, uchar alpha=255)
Definition: glemu.hpp:71

Function Documentation

static void drawglass ( const materialsurface m,
float  offset,
const vec normal = nullptr 
)
static
static void drawmaterial ( const materialsurface m,
float  offset 
)
static
int findmaterial ( const char *  name)

References material::id, loopi(), and materials.

Referenced by editmat(), and texture().

const char* findmaterialname ( int  mat)

References loopi(), materials, and material::name.

Referenced by getmaterialdesc().

void genmatsurfs ( const cube c,
const ivec co,
int  size,
vector< materialsurface > &  matsurfs 
)
const char* getmaterialdesc ( int  mat,
const char *  prefix 
)
static int mergemat ( materialsurface m,
int  sz,
materialsurface n 
)
static

References mergematc(), and mergematr().

Referenced by mergemats().

static int mergematc ( materialsurface m,
materialsurface n 
)
static
static bool mergematcmp ( const materialsurface x,
const materialsurface y 
)
inlinestatic
static int mergematr ( materialsurface m,
int  sz,
materialsurface n 
)
static
static int mergemats ( materialsurface m,
int  sz 
)
static

References loopi(), mergemat(), mergematcmp(), and quicksort().

Referenced by optimizematsurfs().

int optimizematsurfs ( materialsurface matbuf,
int  matsurfs 
)
static bool optmatcmp ( const materialsurface x,
const materialsurface y 
)
inlinestatic
void rendermaterials ( )
void rendermatgrid ( vector< materialsurface * > &  vismats)
static void renderwaterfall ( const materialsurface m,
float  offset,
const vec normal = nullptr 
)
static
void setupmaterials ( int  start,
int  len 
)
void sortmaterials ( vector< materialsurface * > &  vismats)
VARF ( optmats  ,
,
,
,
allchanged()   
)
VARFP ( waterfallenv  ,
,
,
,
preloadwatershaders()   
)
VARP ( showmat  ,
,
,
 
)
VARP ( glassenv  ,
,
,
 
)
int visiblematerial ( const cube c,
int  orient,
const ivec co,
int  size,
ushort  matmask 
)
static bool vismatcmp ( const materialsurface xm,
const materialsurface ym 
)
inlinestatic

Variable Documentation

const struct material materials[]
Initial value:
=
{
{"air", MAT_AIR},
{"water", MAT_WATER}, {"water1", MAT_WATER}, {"water2", MAT_WATER+1}, {"water3", MAT_WATER+2}, {"water4", MAT_WATER+3},
{"glass", MAT_GLASS}, {"glass1", MAT_GLASS}, {"glass2", MAT_GLASS+1}, {"glass3", MAT_GLASS+2}, {"glass4", MAT_GLASS+3},
{"lava", MAT_LAVA}, {"lava1", MAT_LAVA}, {"lava2", MAT_LAVA+1}, {"lava3", MAT_LAVA+2}, {"lava4", MAT_LAVA+3},
{"clip", MAT_CLIP},
{"noclip", MAT_NOCLIP},
{"gameclip", MAT_GAMECLIP},
{"death", MAT_DEATH},
{"alpha", MAT_ALPHA}
}
Definition: material.hpp:32
Definition: material.hpp:36
Definition: material.hpp:31
Definition: material.hpp:33
Definition: material.hpp:27
Definition: material.hpp:35
Definition: material.hpp:28
Definition: material.hpp:29
Definition: material.hpp:26

Referenced by findmaterial(), findmaterialname(), and smd::smdmeshgroup::readtriangles().

int sortdim[3]
static
bool sortedit
static

Referenced by vismatcmp().

ivec sortorigin
static
float wfscroll
static

Referenced by rendermaterials().

float wfwave
static

Referenced by rendermaterials(), and renderwaterfall().

float wfxscale
static

Referenced by rendermaterials().

float wfyscale
static

Referenced by rendermaterials().