Skip to content
Merged
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
2 changes: 1 addition & 1 deletion app/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ if(DMC_NATIVE_READER_BUILD_TESTS)
enable_testing()
set(DMC_NATIVE_READER_TESTS
black_widow_state composite_builder composite_mod_scene composite_placement core_model_pipeline cxx23_profile dds_ptx_v1
em028_corpus_contract gdata_legacy mod_spatial_adapter module_registry
em028_corpus_contract effect_visualization gdata_legacy mod_spatial_adapter module_registry
png_export_session ptx_model_texture ptx_runtime_compat ptx_transaction render_scene scm_authority
spider_event_execution spider_model_execution uv_gallery session_inspection tm2_legacy workspace_graph
motion_playback pac_assembly player_coat
Expand Down
44 changes: 36 additions & 8 deletions app/src/main/cpp/app_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,34 +300,62 @@ Java_com_dmcrengine_nativeviewer_NativeBridge_imagePreviewWidth(
JNIEnv*, jclass, jlong handle) {
const SessionLock jni_lock{session_mutex()};
const Session* session = from_handle(handle);
if (session == nullptr || !session->image_preview.available() ||
session->image_preview.width > static_cast<std::uint32_t>(
const auto* preview = dmcresource::session_active_preview(session);
if (preview == nullptr || !preview->available() ||
preview->width > static_cast<std::uint32_t>(
std::numeric_limits<jint>::max())) {
return 0;
}
return static_cast<jint>(session->image_preview.width);
return static_cast<jint>(preview->width);
}

extern "C" JNIEXPORT jint JNICALL
Java_com_dmcrengine_nativeviewer_NativeBridge_imagePreviewHeight(
JNIEnv*, jclass, jlong handle) {
const SessionLock jni_lock{session_mutex()};
const Session* session = from_handle(handle);
if (session == nullptr || !session->image_preview.available() ||
session->image_preview.height > static_cast<std::uint32_t>(
const auto* preview = dmcresource::session_active_preview(session);
if (preview == nullptr || !preview->available() ||
preview->height > static_cast<std::uint32_t>(
std::numeric_limits<jint>::max())) {
return 0;
}
return static_cast<jint>(session->image_preview.height);
return static_cast<jint>(preview->height);
}

extern "C" JNIEXPORT jboolean JNICALL
Java_com_dmcrengine_nativeviewer_NativeBridge_imagePreview(
JNIEnv* env, jclass, jlong handle, jobject target) {
const SessionLock jni_lock{session_mutex()};
const Session* session = from_handle(handle);
if (session == nullptr) return JNI_FALSE;
return preview_to_bitmap(env, target, session->image_preview)
const auto* preview = dmcresource::session_active_preview(session);
if (preview == nullptr) return JNI_FALSE;
return preview_to_bitmap(env, target, *preview)
? JNI_TRUE : JNI_FALSE;
}

extern "C" JNIEXPORT jboolean JNICALL
Java_com_dmcrengine_nativeviewer_NativeBridge_hasDualPreview(
JNIEnv*, jclass, jlong handle) {
const SessionLock jni_lock{session_mutex()};
return dmcresource::session_has_dual_preview(from_handle(handle))
? JNI_TRUE : JNI_FALSE;
}

extern "C" JNIEXPORT jboolean JNICALL
Java_com_dmcrengine_nativeviewer_NativeBridge_infoPreviewActive(
JNIEnv*, jclass, jlong handle) {
const SessionLock jni_lock{session_mutex()};
return dmcresource::session_info_preview_active(from_handle(handle))
? JNI_TRUE : JNI_FALSE;
}

extern "C" JNIEXPORT jboolean JNICALL
Java_com_dmcrengine_nativeviewer_NativeBridge_setInfoPreviewActive(
JNIEnv*, jclass, jlong handle, jboolean active) {
const SessionLock jni_lock{session_mutex()};
return dmcresource::session_set_info_preview(
from_handle(handle), active == JNI_TRUE)
? JNI_TRUE : JNI_FALSE;
}

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/cpp/include/dmcresource/child_resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ struct ChildResource {
ResourceCapabilities capabilities{};
InspectionDocument inspection;
RenderScene scene;
// Primary visual representation used by the normal viewer/gallery.
ImagePreview image_preview;
// Optional evidence/diagnostic representation of the same logical child.
// FXBANK records use this for the EXE-backed Info mode while image_preview
// remains the Visual/Playback-facing surface.
ImagePreview info_preview;
std::vector<ChildResource> children;

// Optional bounded source payload for lazy child materialization. Containers
Expand Down
68 changes: 67 additions & 1 deletion app/src/main/cpp/include/dmcresource/effect_bank.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <array>
#include <cstddef>
#include <cstdint>
#include <optional>
Expand Down Expand Up @@ -40,7 +41,8 @@ struct Bank final {

// Registrar address of a kind (0 when the loader ignores it).
[[nodiscard]] std::uint64_t registrar(char kind) noexcept;
// Short description of a kind; tentative except T (texture) and M (model).
// Neutral runtime-kind description. It does not claim an original filename
// or file extension; T/M mention only byte-confirmed payload families.
[[nodiscard]] std::string_view kind_name(char kind) noexcept;

// Structural identity: PNST, slot 0 a manifest whose first token is one
Expand All @@ -67,4 +69,68 @@ struct SpriteAnimation final {
};
[[nodiscard]] std::optional<SpriteAnimation> sprite_animation(const Record& record);

// Runtime-facing views recovered from the canonical dmc3.exe consumers. These
// structs intentionally expose only fields whose access pattern is proven by
// the executable; unknown bytes remain outside the typed view.

// V: fixed 0x2C-byte entries. 0x140324680 builds a local transform from
// translation, degree rotation (converted to radians), and scale, then
// dispatches the referenced child:
// 0=P, 1=E, 2=G, 3=V.
struct VEntry final {
std::uint8_t dispatch{};
std::uint16_t id{};
std::array<float, 3> translation{};
std::array<float, 3> rotation_degrees{};
std::array<float, 3> scale{};
};
struct VRuntimeView final {
std::int16_t count{};
std::vector<VEntry> entries;
};
[[nodiscard]] std::optional<VRuntimeView> v_runtime_view(const Record& record);

// E: 0x1402E3AA0 resolves +0x04 through the T texture manager. When +0x06 is
// one and +0x08 != 0xFFFF, 0x1402E494F binds that id through the A manager.
// Otherwise +0x0C..+0x12 are copied directly into the runtime rectangle.
struct ERuntimeView final {
std::uint8_t mode{};
std::uint16_t texture_id{0xFFFFU};
bool uses_animation{};
std::uint16_t animation_id{0xFFFFU};
SpriteFrame rectangle{};
};
[[nodiscard]] std::optional<ERuntimeView> e_runtime_view(const Record& record);

// G: the generator consumer 0x1402EBC10 reads these offsets directly. Exact
// gameplay labels for several scalar fields are still intentionally withheld;
// the view keeps their source offsets explicit instead of guessing semantics.
struct GRuntimeView final {
std::uint8_t mode{};
std::uint16_t c_id{};
std::int32_t value_18{};
std::int32_t value_20{};
std::uint8_t mode_30{};
float value_38{};
float value_3c{};
std::uint16_t steps_40{};
float value_50{};
float value_54{};
std::uint8_t value_59{};
};
[[nodiscard]] std::optional<GRuntimeView> g_runtime_view(const Record& record);

// P: 0x140312DC0 validates version 2, rebases the relative pointers stored
// from +0x10, and returns the root object. 0x140312840 dispatches on root+1
// with runtime subtype 0..5. The optional child target list is described by
// root+0xC0 and the relative offsets beginning at raw+0x18.
struct PRuntimeView final {
std::uint32_t version{};
std::uint8_t subtype{};
std::uint32_t root_offset{};
std::uint32_t list_offset{};
std::vector<std::uint32_t> target_offsets;
};
[[nodiscard]] std::optional<PRuntimeView> p_runtime_view(const Record& record);

} // namespace dmcresource::effect_bank
28 changes: 28 additions & 0 deletions app/src/main/cpp/include/dmcresource/format_views.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <array>
#include <cstddef>
#include <cstdint>
#include <span>
Expand Down Expand Up @@ -45,6 +46,33 @@ inline constexpr int kViewHeight = 1440;
[[nodiscard]] ImagePreview render_sprite_view(const effect_bank::SpriteAnimation& animation,
std::uint32_t record_id, const ImagePreview* texture);

// FXBANK effect-record views recovered from the runtime consumers. T keeps its
// decoded DDS view, A keeps render_sprite_view, and M uses the ordinary model
// renderer. This view covers the remaining registered effect kinds so a PNST
// gallery never has to represent them as empty black tiles. E may receive its
// resolved T texture and optional A animation from the owning bank.
[[nodiscard]] ImagePreview render_effect_record_view(
const effect_bank::Record& record,
const ImagePreview* texture = nullptr,
const effect_bank::SpriteAnimation* animation = nullptr);

// Cleaner Visual-mode projection. It intentionally uses only confirmed runtime
// links/fields; missing linked previews stay explicit instead of being guessed.
struct EffectLinkedVisual final {
char kind{};
std::uint32_t id{};
std::array<float, 3> translation{};
std::array<float, 3> rotation_degrees{};
std::array<float, 3> scale{1.0F, 1.0F, 1.0F};
const ImagePreview* preview{};
};

[[nodiscard]] ImagePreview render_effect_visual_view(
const effect_bank::Record& record,
const ImagePreview* texture = nullptr,
const effect_bank::SpriteAnimation* animation = nullptr,
std::span<const EffectLinkedVisual> linked = {});

// Attack index: every entry (id, target mask, bone, shape).
[[nodiscard]] ImagePreview render_attack_index_view(const std::vector<collision::AttackEntry>& entries);

Expand Down
11 changes: 11 additions & 0 deletions app/src/main/cpp/include/dmcresource/resource_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ struct Session {
dmcresource::ResourceCapabilities capabilities{};
dmcresource::InspectionDocument inspection;
dmcresource::RenderScene scene;
// Primary visual/playback-facing preview.
dmcresource::ImagePreview image_preview;
// Optional evidence/diagnostic view of the same logical effect/resource.
dmcresource::ImagePreview info_preview;
bool info_preview_active{};
std::vector<dmcresource::ChildResource> children;

dmcresource::Mesh render_mesh;
Expand Down Expand Up @@ -189,6 +193,13 @@ struct Session {
[[nodiscard]] const ImagePreview* session_child_preview(
const Session* session, int index, ImagePreview* scratch);
[[nodiscard]] std::unique_ptr<Session> open_session_child(const Session* session, int index);

// Dual Visual / Info surface. The active preview is the image exposed to
// platform shells; sessions without info_preview behave exactly as before.
[[nodiscard]] bool session_has_dual_preview(const Session* session) noexcept;
[[nodiscard]] bool session_info_preview_active(const Session* session) noexcept;
[[nodiscard]] bool session_set_info_preview(Session* session, bool info) noexcept;
[[nodiscard]] const ImagePreview* session_active_preview(const Session* session) noexcept;
[[nodiscard]] std::string describe_session(const Session* session);
[[nodiscard]] spider::black_widow::StateBits black_widow_state(const Session* session) noexcept;

Expand Down
Loading
Loading