mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-03 09:23:37 +00:00
STARK: Read path resources
This commit is contained in:
parent
1ff3a2888c
commit
50d882f9f4
@ -45,6 +45,7 @@
|
||||
#include "engines/stark/resources/light.h"
|
||||
#include "engines/stark/resources/lipsync.h"
|
||||
#include "engines/stark/resources/location.h"
|
||||
#include "engines/stark/resources/path.h"
|
||||
#include "engines/stark/resources/pattable.h"
|
||||
#include "engines/stark/resources/root.h"
|
||||
#include "engines/stark/resources/script.h"
|
||||
@ -228,6 +229,9 @@ Resources::Object *XRCReader::createResource(XRCReadStream *stream, Resources::O
|
||||
case Resources::Type::kSoundItem:
|
||||
resource = new Resources::Sound(parent, subType, index, name);
|
||||
break;
|
||||
case Resources::Type::kPath:
|
||||
resource = Resources::Path::construct(parent, subType, index, name);
|
||||
break;
|
||||
case Resources::Type::kFloorField:
|
||||
resource = new Resources::FloorField(parent, subType, index, name);
|
||||
break;
|
||||
|
@ -49,6 +49,7 @@ MODULE_OBJS := \
|
||||
resources/lipsync.o \
|
||||
resources/location.o \
|
||||
resources/object.o \
|
||||
resources/path.o \
|
||||
resources/pattable.o \
|
||||
resources/root.o \
|
||||
resources/script.o \
|
||||
|
@ -62,6 +62,7 @@ const char *Type::getName() const {
|
||||
{ Type::kAnimScript, "AnimScript" },
|
||||
{ Type::kAnimScriptItem, "AnimScriptItem" },
|
||||
{ Type::kSoundItem, "SoundItem" },
|
||||
{ Type::kPath, "Path" },
|
||||
{ Type::kFloorField, "FloorField" },
|
||||
{ Type::kBookmark, "Bookmark" },
|
||||
{ Type::kKnowledgeSet, "KnowledgeSet" },
|
||||
|
@ -55,6 +55,7 @@ public:
|
||||
kAnimScript = 14,
|
||||
kAnimScriptItem = 15,
|
||||
kSoundItem = 16,
|
||||
kPath = 17,
|
||||
kFloorField = 18,
|
||||
kBookmark = 19,
|
||||
kKnowledgeSet = 20,
|
||||
|
123
engines/stark/resources/path.cpp
Normal file
123
engines/stark/resources/path.cpp
Normal file
@ -0,0 +1,123 @@
|
||||
/* ResidualVM - A 3D game interpreter
|
||||
*
|
||||
* ResidualVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the AUTHORS
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "engines/stark/resources/path.h"
|
||||
|
||||
#include "engines/stark/formats/xrc.h"
|
||||
|
||||
namespace Stark {
|
||||
namespace Resources {
|
||||
|
||||
Object *Path::construct(Object *parent, byte subType, uint16 index, const Common::String &name) {
|
||||
switch (subType) {
|
||||
case kPath2D:
|
||||
return new Path2D(parent, subType, index, name);
|
||||
case kPath3D:
|
||||
return new Path3D(parent, subType, index, name);
|
||||
default:
|
||||
error("Unknown path subtype %d", subType);
|
||||
}
|
||||
}
|
||||
|
||||
Path::~Path() {
|
||||
}
|
||||
|
||||
Path::Path(Object *parent, byte subType, uint16 index, const Common::String &name) :
|
||||
Object(parent, subType, index, name) {
|
||||
_type = TYPE;
|
||||
}
|
||||
|
||||
void Path::readData(Formats::XRCReadStream *stream) {
|
||||
_field_30 = stream->readUint32LE();
|
||||
}
|
||||
|
||||
void Path::printData() {
|
||||
debug("field_30: %d", _field_30);
|
||||
}
|
||||
|
||||
Path2D::Path2D(Object *parent, byte subType, uint16 index, const Common::String &name) :
|
||||
Path(parent, subType, index, name) {
|
||||
}
|
||||
|
||||
void Path2D::readData(Formats::XRCReadStream *stream) {
|
||||
Path::readData(stream);
|
||||
|
||||
uint32 stepCount = stream->readUint32LE();
|
||||
for (uint i = 0; i < stepCount; i++) {
|
||||
Step step;
|
||||
step.weight = stream->readFloat();
|
||||
step.position = stream->readPoint();
|
||||
|
||||
_steps.push_back(step);
|
||||
}
|
||||
|
||||
stream->readUint32LE(); // Unused in the original
|
||||
}
|
||||
|
||||
void Path2D::printData() {
|
||||
Path::printData();
|
||||
|
||||
for (uint i = 0; i < _steps.size(); i++) {
|
||||
debug("step[%d]: (x %d, y %d), weight: %f", i,
|
||||
_steps[i].position.x, _steps[i].position.y, _steps[i].weight);
|
||||
}
|
||||
}
|
||||
|
||||
Path2D::~Path2D() {
|
||||
}
|
||||
|
||||
Path3D::Path3D(Object *parent, byte subType, uint16 index, const Common::String &name) :
|
||||
Path(parent, subType, index, name),
|
||||
_sortKey(0) {
|
||||
}
|
||||
|
||||
void Path3D::readData(Formats::XRCReadStream *stream) {
|
||||
Path::readData(stream);
|
||||
|
||||
uint32 stepCount = stream->readUint32LE();
|
||||
for (uint i = 0; i < stepCount; i++) {
|
||||
Step step;
|
||||
step.weight = stream->readFloat();
|
||||
step.position = stream->readVector3();
|
||||
|
||||
_steps.push_back(step);
|
||||
}
|
||||
|
||||
_sortKey = stream->readFloat();
|
||||
}
|
||||
|
||||
void Path3D::printData() {
|
||||
Path::printData();
|
||||
|
||||
for (uint i = 0; i < _steps.size(); i++) {
|
||||
debug("step[%d]: (x %f, y %f, z %f), weight: %f", i,
|
||||
_steps[i].position.x(), _steps[i].position.y(), _steps[i].position.z(), _steps[i].weight);
|
||||
}
|
||||
|
||||
debug("sortKey: %f", _sortKey);
|
||||
}
|
||||
|
||||
Path3D::~Path3D() {
|
||||
}
|
||||
|
||||
} // End of namespace Resources
|
||||
} // End of namespace Stark
|
108
engines/stark/resources/path.h
Normal file
108
engines/stark/resources/path.h
Normal file
@ -0,0 +1,108 @@
|
||||
/* ResidualVM - A 3D game interpreter
|
||||
*
|
||||
* ResidualVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the AUTHORS
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef STARK_RESOURCES_PATH_H
|
||||
#define STARK_RESOURCES_PATH_H
|
||||
|
||||
#include <common/rect.h>
|
||||
#include <math/vector3d.h>
|
||||
#include "common/str.h"
|
||||
|
||||
#include "engines/stark/resources/object.h"
|
||||
|
||||
namespace Stark {
|
||||
|
||||
namespace Formats {
|
||||
class XRCReadStream;
|
||||
}
|
||||
|
||||
namespace Resources {
|
||||
|
||||
class Path : public Object {
|
||||
public:
|
||||
static const Type::ResourceType TYPE = Type::kPath;
|
||||
|
||||
enum SubType {
|
||||
kPath2D = 1,
|
||||
kPath3D = 2
|
||||
};
|
||||
|
||||
/** Path factory */
|
||||
static Object *construct(Object *parent, byte subType, uint16 index, const Common::String &name);
|
||||
|
||||
Path(Object *parent, byte subType, uint16 index, const Common::String &name);
|
||||
virtual ~Path();
|
||||
|
||||
// Resource API
|
||||
virtual void readData(Formats::XRCReadStream *stream) override;
|
||||
|
||||
protected:
|
||||
void printData() override;
|
||||
|
||||
uint32 _field_30;
|
||||
};
|
||||
|
||||
class Path2D : public Path {
|
||||
public:
|
||||
Path2D(Object *parent, byte subType, uint16 index, const Common::String &name);
|
||||
virtual ~Path2D();
|
||||
|
||||
struct Step {
|
||||
float weight;
|
||||
Common::Point position;
|
||||
};
|
||||
|
||||
// Resource API
|
||||
virtual void readData(Formats::XRCReadStream *stream) override;
|
||||
|
||||
private:
|
||||
// Resource API
|
||||
void printData();
|
||||
|
||||
Common::Array<Step> _steps;
|
||||
};
|
||||
|
||||
class Path3D : public Path {
|
||||
public:
|
||||
Path3D(Object *parent, byte subType, uint16 index, const Common::String &name);
|
||||
virtual ~Path3D();
|
||||
|
||||
struct Step {
|
||||
float weight;
|
||||
Math::Vector3d position;
|
||||
};
|
||||
|
||||
// Resource API
|
||||
virtual void readData(Formats::XRCReadStream *stream) override;
|
||||
|
||||
private:
|
||||
// Resource API
|
||||
void printData();
|
||||
|
||||
Common::Array<Step> _steps;
|
||||
float _sortKey;
|
||||
};
|
||||
|
||||
} // End of namespace Resources
|
||||
} // End of namespace Stark
|
||||
|
||||
#endif // STARK_RESOURCES_PATH_H
|
Loading…
x
Reference in New Issue
Block a user