mirror of
https://github.com/rwengine/openrw.git
synced 2024-09-18 16:32:32 +02:00
TOBJ slightly functional
This commit is contained in:
parent
d3d2165947
commit
7e418f1b6b
@ -16,6 +16,9 @@ struct ObjectData
|
|||||||
int32_t flags;
|
int32_t flags;
|
||||||
bool LOD;
|
bool LOD;
|
||||||
|
|
||||||
|
short timeOn;
|
||||||
|
short timeOff;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
WET = 1, /// Render with a wet effect
|
WET = 1, /// Render with a wet effect
|
||||||
NIGHTONLY = 1 << 1, /// Render only during the night
|
NIGHTONLY = 1 << 1, /// Render only during the night
|
||||||
|
@ -125,7 +125,7 @@ bool GameWorld::placeItems(const std::string& name)
|
|||||||
for( size_t i = 0; i < ipll.m_instances.size(); ++i) {
|
for( size_t i = 0; i < ipll.m_instances.size(); ++i) {
|
||||||
std::shared_ptr<InstanceData> inst = ipll.m_instances[i];
|
std::shared_ptr<InstanceData> inst = ipll.m_instances[i];
|
||||||
if(! createInstance(inst->id, inst->pos, inst->rot)) {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,8 @@ bool LoaderIDE::load(const std::string &filename)
|
|||||||
std::stringstream strstream(line);
|
std::stringstream strstream(line);
|
||||||
|
|
||||||
switch (section) {
|
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::shared_ptr<ObjectData> objs(new ObjectData);
|
||||||
|
|
||||||
std::string id, numClumps, flags,
|
std::string id, numClumps, flags,
|
||||||
@ -67,6 +68,18 @@ bool LoaderIDE::load(const std::string &filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
getline(strstream, flags, ',');
|
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
|
// Put stuff in our struct
|
||||||
objs->ID = atoi(id.c_str());
|
objs->ID = atoi(id.c_str());
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <objects/GTAInstance.hpp>
|
#include <objects/GTAInstance.hpp>
|
||||||
#include <objects/GTAVehicle.hpp>
|
#include <objects/GTAVehicle.hpp>
|
||||||
#include <ai/GTAAIController.hpp>
|
#include <ai/GTAAIController.hpp>
|
||||||
|
#include <data/ObjectData.hpp>
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
@ -288,8 +289,12 @@ void GTARenderer::renderWorld()
|
|||||||
for(size_t i = 0; i < engine->objectInstances.size(); ++i) {
|
for(size_t i = 0; i < engine->objectInstances.size(); ++i) {
|
||||||
GTAInstance& inst = *engine->objectInstances[i];
|
GTAInstance& inst = *engine->objectInstances[i];
|
||||||
|
|
||||||
if(((inst.object->flags & ObjectData::NIGHTONLY) | (inst.object->flags & ObjectData::DAYONLY)) != 0) {
|
if(inst.object->timeOn != inst.object->timeOff) {
|
||||||
//continue;
|
// Update rendering flags.
|
||||||
|
if(engine->getHour() < inst.object->timeOn
|
||||||
|
&& engine->getHour() > inst.object->timeOff) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!inst.model)
|
if(!inst.model)
|
||||||
|
@ -384,6 +384,12 @@ void handleCommandEvent(sf::Event &event)
|
|||||||
case sf::Keyboard::F9:
|
case sf::Keyboard::F9:
|
||||||
command("object-info");
|
command("object-info");
|
||||||
break;
|
break;
|
||||||
|
case sf::Keyboard::LBracket:
|
||||||
|
gta->gameTime -= 60.f;
|
||||||
|
break;
|
||||||
|
case sf::Keyboard::RBracket:
|
||||||
|
gta->gameTime += 60.f;
|
||||||
|
break;
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user