1
0
mirror of https://github.com/rwengine/openrw.git synced 2025-01-31 12:01:38 +01:00

Clump numbering and improved colours

This commit is contained in:
Daniel Evans 2013-07-05 19:50:04 +01:00
parent 572281e4fc
commit bdaf85af75
4 changed files with 30 additions and 5 deletions

View File

@ -44,6 +44,7 @@ const char *fragmentShaderSource = "#version 130\n"
" if(c.a < 0.5) discard;"
" float fogCoord = abs(EyeSpace.z / EyeSpace.w);"
" float fogfac = clamp( (FogEnd-fogCoord)/(FogEnd-FogStart), 0.0, 1.0 );"
" float l = clamp(dot(Normal, SunDirection), 0.0, 1);"
" gl_FragColor = mix(AmbientColour, BaseColour * (vec4(0.5) + Colour * 0.5) * (vec4(0.5) + DynamicColour * 0.5) * c, fogfac);"
// " gl_FragColor = vec4((Normal*0.5)+0.5, 1.0);"
// " gl_FragColor = c * vec4((Normal*0.5)+0.5, 1.0);"
@ -223,7 +224,7 @@ void GTARenderer::renderWorld(GTAEngine* engine)
mix(weather.directLightColor.g, weathernext.directLightColor.g, interpolate) / 255.0,
mix(weather.directLightColor.b, weathernext.directLightColor.b, interpolate) / 255.0,
};
float theta = (hour - 12.f)/24.0 * 2 * 3.14159265;
float theta = (gameTime - 12.f)/24.0 * 2 * 3.14159265;
glm::vec3 sunDirection{
sin(theta),
0.0,
@ -298,7 +299,6 @@ void GTARenderer::renderWorld(GTAEngine* engine)
continue;
}
std::unique_ptr<Model> &model = engine->gameData.models[modelname];
glm::quat rot(-obj.rotW, obj.rotX, obj.rotY, obj.rotZ);
@ -545,6 +545,10 @@ void GTARenderer::renderObject(GTAEngine* engine, const std::unique_ptr<Model>&
else {
rendered++;
}
if( model->geometries[g].clumpNum > 0) {
continue;
}
glm::mat4 matrixModel;
matrixModel = glm::translate(matrixModel, pos);

View File

@ -9,7 +9,7 @@ std::unique_ptr<Model> LoaderDFF::loadFromMemory(char *data)
model->clump = root.readStructure<RW::BSClump>();
size_t dataI = 0;
size_t dataI = 0, clumpID = 0;
while (root.hasMoreData(dataI)) {
auto sec = root.getNextChildSection(dataI);
@ -74,7 +74,7 @@ std::unique_ptr<Model> LoaderDFF::loadFromMemory(char *data)
else {
// To save needing another shader, just insert a white colour for each vertex
for (size_t v = 0; v < geometry.numverts; ++v) {
geometryStruct.colours.push_back(glm::vec4(0.f));
geometryStruct.colours.push_back(glm::vec4(1.f));
}
}
@ -291,10 +291,13 @@ std::unique_ptr<Model> LoaderDFF::loadFromMemory(char *data)
);
}
geometryStruct.clumpNum = clumpID;
// Add it
model->geometries.push_back(geometryStruct);
}
}
clumpID++;
break;
}
case RW::SID_Atomic: {

View File

@ -39,6 +39,8 @@ public:
GLuint VBO, EBO;
RW::BSGeometryBounds geometryBounds;
uint32_t clumpNum;
uint32_t flags;

View File

@ -19,7 +19,7 @@ constexpr int WIDTH = 800,
constexpr double PiOver180 = 3.1415926535897932384626433832795028/180;
sf::Window window;
sf::RenderWindow window;
LoaderDFF dffLoader;
GTAEngine* gta = nullptr;
@ -30,6 +30,8 @@ float moveSpeed = 20.0f;
bool inFocus = false;
bool mouseGrabbed = true;
sf::Font font;
void handleEvent(sf::Event &event)
{
switch (event.type) {
@ -154,6 +156,16 @@ void render()
gta->renderer.renderWorld(gta);
glUseProgram(0);
window.pushGLStates();
window.resetGLStates();
std::stringstream ss;
ss << floor(gta->gameTime) << " (Hour " << fmod(floor(gta->gameTime), 24.f) << ")";
sf::Text t(ss.str(), font, 20);
t.setPosition(10, 10);
window.draw(t);
window.popGLStates();
static size_t fc = 0;
if(fc++ == 60)
{
@ -168,6 +180,10 @@ int main(int argc, char *argv[])
std::cout << "Usage: " << argv[0] << " <path to GTA3 root folder>" << std::endl;
exit(1);
}
if(! font.loadFromFile("DejaVuSansCondensed.ttf")) {
std::cerr << "Failed to load font DejaVuSansCondensed" << std::endl;
}
glewExperimental = GL_TRUE;
glewInit();