Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ option(SOURCEPP_USE_MDLPP "Build mdlpp library" ${SOURC
option(SOURCEPP_USE_SNDPP "Build sndpp library" ${SOURCEPP_LIBS_START_ENABLED})
option(SOURCEPP_USE_STEAMPP "Build steampp library" ${SOURCEPP_LIBS_START_ENABLED})
option(SOURCEPP_USE_TOOLPP "Build toolpp library" ${SOURCEPP_LIBS_START_ENABLED})
option(SOURCEPP_USE_VCDPP "Build vcdpp library" ${SOURCEPP_LIBS_START_ENABLED})
option(SOURCEPP_USE_VCRYPTPP "Build vcryptpp library" ${SOURCEPP_LIBS_START_ENABLED})
option(SOURCEPP_USE_VPKPP "Build vpkpp library" ${SOURCEPP_LIBS_START_ENABLED})
option(SOURCEPP_USE_VTFPP "Build vtfpp library" ${SOURCEPP_LIBS_START_ENABLED})
Expand Down Expand Up @@ -74,6 +75,9 @@ endif()
if(SOURCEPP_USE_TOOLPP)
set(SOURCEPP_USE_KVPP ON CACHE INTERNAL "" FORCE)
endif()
if(SOURCEPP_USE_VCDPP)
set(SOURCEPP_USE_VPKPP ON CACHE INTERNAL "" FORCE)
endif()
if(SOURCEPP_USE_VPKPP)
set(SOURCEPP_USE_KVPP ON CACHE INTERNAL "" FORCE)
endif()
Expand Down Expand Up @@ -164,6 +168,7 @@ add_sourcepp_library(mdlpp TEST ) # sourcepp::mdlpp
add_sourcepp_library(sndpp TEST ) # sourcepp::sndpp
add_sourcepp_library(steampp C CSHARP PYTHON TEST ) # sourcepp::steampp
add_sourcepp_library(toolpp PYTHON TEST ) # sourcepp::toolpp
add_sourcepp_library(vcdpp TEST ) # sourcepp::vcdpp
add_sourcepp_library(vcryptpp C CSHARP PYTHON TEST ) # sourcepp::vcryptpp
add_sourcepp_library(vpkpp C CSHARP PYTHON TEST ) # sourcepp::vpkpp
add_sourcepp_library(vtfpp C CSHARP PYTHON TEST BENCH) # sourcepp::vtfpp
Expand All @@ -179,7 +184,7 @@ sourcepp_test_setup_post()

# Print options
print_options(OPTIONS
USE_BSPPP USE_DMXPP USE_FSPP USE_GAMEPP USE_KVPP USE_MDLPP USE_SNDPP USE_STEAMPP USE_TOOLPP USE_VCRYPTPP USE_VPKPP USE_VTFPP "\n"
USE_BSPPP USE_DMXPP USE_FSPP USE_GAMEPP USE_KVPP USE_MDLPP USE_SNDPP USE_STEAMPP USE_TOOLPP USE_VCDPP USE_VCRYPTPP USE_VPKPP USE_VTFPP "\n"
BUILD_C_WRAPPERS BUILD_CSHARP_WRAPPERS BUILD_PYTHON_WRAPPERS BUILD_WASM_WRAPPERS "\n"
BUILD_BENCHMARKS BUILD_WITH_TBB BUILD_WITH_THREADS BUILD_TESTS BUILD_TESTS_EXTRA BUILD_WIN7_COMPAT LINK_STATIC_MSVC_RUNTIME "\n")

Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,25 @@ The Python wrappers can be found on PyPI in the [sourcepp](https://pypi.org/proj
<td align="center">✅</td>
</tr>
<tr><!-- empty row to disable GitHub striped bg color --></tr>
<tr>
<td rowspan="3"><code>vcdpp</code><sup>*</sup></td>
<td><a href="https://developer.valvesoftware.com/wiki/Scenes.image" target="_blank" rel="noreferrer">IMAGE</a> (Scenes)</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td rowspan="3" align="center"></td>
</tr>
<tr><!-- empty row to disable GitHub striped bg color --></tr>
<tr>
<td>
<a href="https://developer.valvesoftware.com/wiki/VCD" target="_blank" rel="noreferrer">VCD</a> v1
<br> &bull; BVCD v1-4
<br> &bull; VCE v1
<br> &bull; XCD v??TODO?? (Xbox, Half-Life 2)
</td>
<td align="center">✅</td>
<td align="center">✅</td>
</tr>
<tr><!-- empty row to disable GitHub striped bg color --></tr>
<tr>
<td rowspan="3"><code>vcryptpp</code></td>
<td><a href="https://developer.valvesoftware.com/wiki/VICE" target="_blank" rel="noreferrer">VICE</a> encrypted files</td>
Expand Down
18 changes: 18 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,24 @@ <h2>Supported Formats</h2>
<td>✅</td>
<td>✅</td>
</tr>
<tr class="support-table-no-offset">
<td rowspan="2">vcdpp<sup><a href="#support-footnote-1">*</a></sup></td>
<td><a href="https://developer.valvesoftware.com/wiki/Scenes.image" target="_blank" rel="noreferrer">IMAGE</a> (Scenes)</td>
<td>✅</td>
<td>✅</td>
</tr>
<tr>
<td>
<a href="https://developer.valvesoftware.com/wiki/VCD" target="_blank" rel="noreferrer">VCD</a> v1
<ul>
<li>BVCD v1-4</li>
<li>VCE v1</li>
<li>XCD v??TODO?? (Xbox, Half-Life 2)</li>
</ul>
</td>
<td>✅</td>
<td>✅</td>
</tr>
<tr class="support-table-no-offset">
<td rowspan="2">
vcryptpp
Expand Down
1 change: 1 addition & 0 deletions include/vcdpp/IMAGE.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#pragma once
266 changes: 266 additions & 0 deletions include/vcdpp/VCD.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
#pragma once

#include <optional>
#include <string>
#include <string_view>
#include <tuple>
#include <vector>

#include <sourcepp/parser/Binary.h>

namespace vcdpp {

struct Event {
enum class Type : uint8_t {
UNSPECIFIED = 0,
SECTION = 1,
EXPRESSION = 2,
LOOK_AT = 3,
MOVE_TO = 4,
SPEAK = 5,
GESTURE = 6,
SEQUENCE = 7,
FACE = 8,
FIRE_TRIGGER = 9,
FLEX_ANIMATION = 10,
SUBSCENE = 11,
LOOP = 12,
INTERRUPT = 13,
STOP_POINT = 14,
PERMIT_RESPONSES = 15,
GENERIC = 16,
CAMERA = 17,
SCRIPT = 18,
} type;
std::string name;
float startTime = 0.f;
float endTime = 0.f;
std::string param;
std::string param2;
std::string param3;

float pitch = 0.f;
float yaw = 0.f;

enum class Interpolate : uint8_t {
DEFAULT = 0,
CATMULLROM_NORMALIZE_X,
EASEIN,
EASEOUT,
EASEINOUT,
BSPLINE,
LINEAR_INTERP,
KOCHANEK,
KOCHANEK_EARLY,
KOCHANEK_LATE,
SIMPLE_CUBIC,
CATMULLROM,
CATMULLROM_NORMALIZE,
CATMULLROM_TANGENT,
EXPONENTIAL_DECAY,
HOLD,
COUNT,
};

struct Curve {
Interpolate from = Interpolate::DEFAULT;
Interpolate to = Interpolate::DEFAULT;
};

struct Edge {
Curve curve;
float time = 0.f;
};

struct Sample {
float time = 0.f;
float value = 0.f;
std::optional<Curve> curve;
};

struct RampLegacy {
float attack = 1.f;
float sustain = 1.f;
float decay = 1.f;
};
std::optional<RampLegacy> eventRampLegacy;

struct Ramp {
std::optional<Curve> curve;
std::optional<Edge> leftEdge;
std::optional<Edge> rightEdge;
std::vector<Sample> samples;
};
std::optional<Ramp> eventRamp;

bool resumeCondition = false;
bool lockBodyFacing = false;
float distanceToTarget = 0.f;
bool fixedLength = false;
bool forceShortMovement = false;
bool syncToFollowingGesture = false;
bool playOverScript = false;

struct RelativeTagLegacy {
std::string name;
std::string filename;
};

std::optional<RelativeTagLegacy> relativeTagLegacy;

struct Tag {
std::string name;
float value = 0.f;
};

std::vector<Tag> relativeTags;
std::vector<Tag> absoluteTagsPlaybackTimes;
std::vector<Tag> absoluteTagsShiftedTimes;

struct FlexTimingTag {
Tag tag;
bool locked = false;
};

std::vector<FlexTimingTag> flexTimingTags;

struct FlexAnimation {
bool samplesUseTime = false;
std::optional<Curve> curve;

struct Track {
std::string name;
bool disabled = false;
float minRange = 0.f;
float maxRange = 1.f;
std::optional<Edge> leftEdge;
std::optional<Edge> rightEdge;
std::vector<Sample> primary;
std::optional<std::vector<Sample>> secondary;
};

std::vector<Track> tracks;
};

std::vector<FlexAnimation> flexAnimations;

float sequenceDuration = -1.f;

struct SpeechData {
enum class CCType : uint8_t {
CC_MASTER = 0,
CC_SLAVE = 1,
CC_DISABLED = 2, // unused
} ccType = CCType::CC_MASTER;
std::string ccToken;
enum class CCFlags : uint8_t {
NONE = 0,
USING_COMBINED_FILE = 1 << 0, // unused
COMBINED_USING_GENDER_TOKEN = 1 << 1, // unused
NO_ATTENUATE = 1 << 2,
} ccFlags = CCFlags::NONE;
} speechData;

int8_t loopCount = 0;

bool active = true;
};
SOURCEPP_BITFLAGS_ENUM(Event::SpeechData::CCFlags);

struct Actor {
struct Channel {
std::string name;
std::vector<Event> events;
bool active = true;
};

std::string name;
std::string faceposerModel;
std::vector<Channel> channels;
bool active = true;
};

struct FaceposerSettings {
struct ScaleSettings {
int choreoView = 100;
int expressionTool = 100;
int gestureTool = 100;
int rampTool = 100;
int sceneRampTool = 100;
};
std::optional<ScaleSettings> scaleSettings;
std::optional<std::string> mapName;
std::optional<uint8_t> fps = 60;
std::optional<bool> snap = false;
std::optional<bool> ignorePhonemes = false;
};

class VCD {
public:
enum class Platform {
UNKNOWN = 0,
VCD = 1,
VCE = 2,
BVCD = sourcepp::parser::binary::makeFourCC("bvcd"),
XVCD = sourcepp::parser::binary::makeFourCC("xvcd"),
};

enum class ParseError {
OK = 0,
EXPECTED_OPENING_BRACE,
UNKNOWN_EVENT_TYPE,
UNKNOWN_ABSOLUTETAGS_TYPE,
UNKNOWN_CC_TYPE,
INVALID_CURVE_TOKEN,
UNKNOWN_CURVE_TYPE,
UNKNOWN_EVENT_KEY,
UNKNOWN_CHANNEL_KEY,
UNKNOWN_ACTOR_KEY,
UNKNOWN_SCENE_SETTINGS_KEY,
UNKNOWN_TOP_LEVEL_KEY,
};

[[nodiscard]] static std::string getMessageForParseErrorCode(ParseError error, std::string_view token);

class SyntaxError : public std::runtime_error {
public:
explicit SyntaxError(ParseError error, std::string_view token) : std::runtime_error{getMessageForParseErrorCode(error, token)} {};
};

VCD() = default;

explicit VCD(std::string_view vcdData);

[[nodiscard]] Platform getPlatform() const;

[[nodiscard]] uint8_t getVersion() const;

[[nodiscard]] uint32_t getChecksum() const;

[[nodiscard]] const std::vector<Event>& getGlobalEvents() const;

[[nodiscard]] const std::vector<Actor>& getActors() const;

[[nodiscard]] const std::optional<Event::Ramp>& getSceneRamp() const;

[[nodiscard]] const FaceposerSettings& getFaceposerSettings() const;

protected:
Platform platform = Platform::UNKNOWN;
uint8_t version = 1;
uint32_t checksum = 0;
std::vector<Event> globalEvents;
std::vector<Actor> actors;
std::optional<Event::Ramp> sceneRamp;
FaceposerSettings faceposerSettings;
};

namespace literals {

inline VCD operator""_vcd(const char* str, const std::size_t len) {
return VCD{std::string_view{str, len}};
}

} // namespace literals

} // namespace vcdpp
9 changes: 9 additions & 0 deletions include/vcdpp/vcdpp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

/*
* This header is just included so consumers of this library can
* include it the same way as any of the other SourcePP libraries.
*/

#include "IMAGE.h"
#include "VCD.h"
1 change: 1 addition & 0 deletions src/vcdpp/IMAGE.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <vcdpp/IMAGE.h>
Loading
Loading