1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 03:12:36 +01:00

TOBJ slightly functional

This commit is contained in:
Daniel Evans 2013-12-28 00:51:15 +00:00
parent d3d2165947
commit 7e418f1b6b
5 changed files with 31 additions and 4 deletions

View File

@ -16,6 +16,9 @@ struct ObjectData
int32_t flags;
bool LOD;
short timeOn;
short timeOff;
enum {
WET = 1, /// Render with a wet effect
NIGHTONLY = 1 << 1, /// Render only during the night

View File

@ -125,7 +125,7 @@ bool GameWorld::placeItems(const std::string& name)
for( size_t i = 0; i < ipll.m_instances.size(); ++i) {
std::shared_ptr<InstanceData> inst = ipll.m_instances[i];
if(! createInstance(inst->id, inst->pos, inst->rot)) {
std::cerr << "No object for instance " << inst->id << " (" << path << ")" << std::endl;
std::cerr << "No object for instance " << inst->id << " Model: " << inst->model << " (" << path << ")" << std::endl;
}
}

View File

@ -47,7 +47,8 @@ bool LoaderIDE::load(const std::string &filename)
std::stringstream strstream(line);
switch (section) {
case OBJS: { // Supports Type 1, 2 and 3
case OBJS:
case TOBJ: { // Supports Type 1, 2 and 3
std::shared_ptr<ObjectData> objs(new ObjectData);
std::string id, numClumps, flags,
@ -68,6 +69,18 @@ bool LoaderIDE::load(const std::string &filename)
getline(strstream, flags, ',');
// Keep reading TOBJ data
if(section == LoaderIDE::TOBJ) {
std::string buff;
getline(strstream, buff, ',');
objs->timeOn = atoi(buff.c_str());
getline(strstream, buff, ',');
objs->timeOff = atoi(buff.c_str());
}
else {
objs->timeOff = objs->timeOn = 0;
}
// Put stuff in our struct
objs->ID = atoi(id.c_str());
objs->flags = atoi(flags.c_str());

View File

@ -8,6 +8,7 @@
#include <objects/GTAInstance.hpp>
#include <objects/GTAVehicle.hpp>
#include <ai/GTAAIController.hpp>
#include <data/ObjectData.hpp>
#include <deque>
#include <cmath>
@ -288,8 +289,12 @@ void GTARenderer::renderWorld()
for(size_t i = 0; i < engine->objectInstances.size(); ++i) {
GTAInstance& inst = *engine->objectInstances[i];
if(((inst.object->flags & ObjectData::NIGHTONLY) | (inst.object->flags & ObjectData::DAYONLY)) != 0) {
//continue;
if(inst.object->timeOn != inst.object->timeOff) {
// Update rendering flags.
if(engine->getHour() < inst.object->timeOn
&& engine->getHour() > inst.object->timeOff) {
continue;
}
}
if(!inst.model)

View File

@ -384,6 +384,12 @@ void handleCommandEvent(sf::Event &event)
case sf::Keyboard::F9:
command("object-info");
break;
case sf::Keyboard::LBracket:
gta->gameTime -= 60.f;
break;
case sf::Keyboard::RBracket:
gta->gameTime += 60.f;
break;
break;
default: break;
}