mirror of https://github.com/bjornbytes/lovr.git
lovr.graphics.plane takes regular transform;
This commit is contained in:
parent
d8500e456c
commit
41210b1bd0
|
@ -515,14 +515,9 @@ int l_lovrGraphicsPlane(lua_State* L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
float x = luaL_optnumber(L, 2, 0.f);
|
float transform[16];
|
||||||
float y = luaL_optnumber(L, 3, 0.f);
|
luax_readtransform(L, 2, transform, 1);
|
||||||
float z = luaL_optnumber(L, 4, 0.f);
|
lovrGraphicsPlane(drawMode, texture, transform);
|
||||||
float s = luaL_optnumber(L, 5, 1.f);
|
|
||||||
float nx = luaL_optnumber(L, 6, 0.f);
|
|
||||||
float ny = luaL_optnumber(L, 7, 1.f);
|
|
||||||
float nz = luaL_optnumber(L, 8, 0.f);
|
|
||||||
lovrGraphicsPlane(drawMode, texture, x, y, z, s, nx, ny, nz);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -603,28 +603,7 @@ void lovrGraphicsTriangle(DrawMode mode, float* points) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void lovrGraphicsPlane(DrawMode mode, Texture* texture, float x, float y, float z, float size, float nx, float ny, float nz) {
|
void lovrGraphicsPlane(DrawMode mode, Texture* texture, mat4 transform) {
|
||||||
|
|
||||||
// Normalize the normal vector
|
|
||||||
float len = sqrt(nx * nx + ny * ny + nz + nz);
|
|
||||||
if (len != 0) {
|
|
||||||
len = 1 / len;
|
|
||||||
nx *= len;
|
|
||||||
ny *= len;
|
|
||||||
nz *= len;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Vector perpendicular to the normal vector and the vector of the default geometry (cross product)
|
|
||||||
float cx = -ny;
|
|
||||||
float cy = nx;
|
|
||||||
float cz = 0.f;
|
|
||||||
|
|
||||||
// Angle between normal vector and the normal vector of the default geometry (dot product)
|
|
||||||
float theta = acos(nz);
|
|
||||||
|
|
||||||
float transform[16];
|
|
||||||
mat4_setTransform(transform, x, y, z, size, size, size, theta, cx, cy, cz);
|
|
||||||
|
|
||||||
lovrGraphicsPush();
|
lovrGraphicsPush();
|
||||||
lovrGraphicsMatrixTransform(transform);
|
lovrGraphicsMatrixTransform(transform);
|
||||||
|
|
||||||
|
|
|
@ -171,7 +171,7 @@ void lovrGraphicsDrawPrimitive(GLenum mode, int hasNormals, int hasTexCoords, in
|
||||||
void lovrGraphicsPoints(float* points, int count);
|
void lovrGraphicsPoints(float* points, int count);
|
||||||
void lovrGraphicsLine(float* points, int count);
|
void lovrGraphicsLine(float* points, int count);
|
||||||
void lovrGraphicsTriangle(DrawMode mode, float* points);
|
void lovrGraphicsTriangle(DrawMode mode, float* points);
|
||||||
void lovrGraphicsPlane(DrawMode mode, Texture* texture, float x, float y, float z, float size, float nx, float ny, float nz);
|
void lovrGraphicsPlane(DrawMode mode, Texture* texture, mat4 transform);
|
||||||
void lovrGraphicsPlaneFullscreen(Texture* texture);
|
void lovrGraphicsPlaneFullscreen(Texture* texture);
|
||||||
void lovrGraphicsBox(DrawMode mode, Texture* texture, mat4 transform);
|
void lovrGraphicsBox(DrawMode mode, Texture* texture, mat4 transform);
|
||||||
void lovrGraphicsCylinder(float x1, float y1, float z1, float x2, float y2, float z2, float r1, float r2, int capped, int segments);
|
void lovrGraphicsCylinder(float x1, float y1, float z1, float x2, float y2, float z2, float r1, float r2, int capped, int segments);
|
||||||
|
|
Loading…
Reference in New Issue