Command Palette

Search for a command to run...

Назад к скиллам
скилл № 13444

forge-scene-model-loading

Load and render pipeline-processed 3D models (.fscene + .fmesh + .fmat) through forge_scene.h with per-primitive materials, mesh instancing, and scene…

БесплатноБез исполняемых скриптов
Nebulavenusот Nebulavenus★ 51 звезда на GitHub

Установить forge-scene-model-loading в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

forge-scene-model-loading

Load pipeline-processed 3D models through forge_scene.h. One forge_scene_load_model() call handles file loading, GPU buffer upload, and per-material texture loading. The draw functions traverse the scene node hierarchy and bind materials per-submesh.

Prerequisites

Models must be processed through the asset pipeline tools first:

# Process mesh (produces .fmesh + .fmat)
./build/tools/mesh/forge_mesh_tool input.gltf output.fmesh --verbose

# Process scene hierarchy (produces .fscene)
./build/tools/scene/forge_scene_tool input.gltf output.fscene --verbose

# Copy textures alongside the .fmat file
cp source_textures/*.png output_dir/

Usage pattern

#define SDL_MAIN_USE_CALLBACKS 1
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include "math/forge_math.h"

#define FORGE_PIPELINE_IMPLEMENTATION
#include "pipeline/forge_pipeline.h"

#define FORGE_SCENE_MODEL_SUPPORT
#define FORGE_SCENE_IMPLEMENTATION
#include "scene/forge_scene.h"

typedef struct {
    ForgeScene      scene;
    ForgeSceneModel model;
} app_state;

SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv)
{
    app_state *state = (app_state *)SDL_calloc(1, sizeof(*state));
    if (!state) return SDL_APP_FAILURE;
    *appstate = state;

    ForgeSceneConfig cfg = forge_scene_default_config("Model Viewer");
    cfg.cam_start_pos = vec3_create(0.0f, 2.0f, 5.0f);
    cfg.font_path = "assets/fonts/liberation_mono/LiberationMono-Regular.ttf";

    if (!forge_scene_init(&state->scene, &cfg, argc, argv))
        return SDL_APP_FAILURE;

    /* Load a pipeline-processed model.
     * base_dir is where textures are found (same dir as .fmat). */
    if (!forge_scene_load_model(&state->scene, &state->model,
                                "assets/MyModel/MyModel.fscene",
                                "assets/MyModel/MyModel.fmesh",
                                "assets/MyModel/MyModel.fmat",
                                "assets/MyModel")) {
        SDL_Log("Failed to load model");
        return SDL_APP_FAILURE;
    }

    return SDL_APP_CONTINUE;
}

SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
{
    app_state *state = (app_state *)appstate;
    return forge_scene_handle_event(&state->scene, event);
}

SDL_AppResult SDL_AppIterate(void *appstate)
{
    app_state *state = (app_state *)appstate;
    ForgeScene *s = &state->scene;

    if (!forge_scene_begin_frame(s)) return SDL_APP_CONTINUE;

    mat4 placement = mat4_translate(vec3_create(0.0f, 0.0f, 0.0f));

    /* Shadow pass */
    forge_scene_begin_shadow_pass(s);
    forge_scene_draw_model_shadows(s, &state->model, placement);
    forge_scene_end_shadow_pass(s);

    /* Main pass */
    forge_scene_begin_main_pass(s);
    forge_scene_draw_model(s, &state->model, placement);
    forge_scene_draw_grid(s);
    forge_scene_end_main_pass(s);

    return forge_scene_end_frame(s);
}

void SDL_AppQuit(void *appstate, SDL_AppResult result)
{
    (void)result;
    app_state *state = (app_state *)appstate;
    if (!state) return;
    if (forge_scene_device(&state->scene)) {
        if (!SDL_WaitForGPUIdle(forge_scene_device(&state->scene))) {
            SDL_Log("SDL_WaitForGPUIdle failed: %s", SDL_GetError());
        }
        forge_scene_free_model(&state->scene, &state->model);
    }
    forge_scene_destroy(&state->scene);
    SDL_free(state);
}

Key defines

Both defines must appear before including forge_scene.h:

Define Purpose
FORGE_SCENE_MODEL_SUPPORT Enables model types and functions (pulls in forge_pipeline.h)
FORGE_SCENE_IMPLEMENTATION Compiles the implementation (one .c file only)
FORGE_PIPELINE_IMPLEMENTATION Compiles the pipeline library (one .c file only)

ForgeSceneModelVertex layout

The model pipeline uses a 48-byte vertex with tangent data for normal mapping:

Field Type Size Offset HLSL
position float3 12 B 0 TEXCOORD0
normal float3 12 B 12 TEXCOORD1
uv float2 8 B 24 TEXCOORD2
tangent float4 16 B 32 TEXCOORD3

ForgeSceneModel struct

After forge_scene_load_model, the struct contains:

Field Type Description
scene_data ForgePipelineScene Node hierarchy with world transforms
mesh ForgePipelineMesh Vertex/index data, submeshes, LODs
materials ForgePipelineMaterialSet PBR material descriptions
vertex_buffer SDL_GPUBuffer * Uploaded 48-byte vertices
index_buffer SDL_GPUBuffer * Uploaded uint32 indices
mat_textures[] ForgeSceneModelTextures Per-material GPU textures
draw_calls uint32_t Updated each draw_model call

Pipeline variants

The renderer selects a pipeline per-submesh based on material properties:

| Variant | Condition | Behavior | |---------|---------

Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл forge-scene-model-loading?

Load and render pipeline-processed 3D models (.fscene + .fmesh + .fmat) through forge_scene.h with per-primitive materials, mesh instancing, and scene hierarchy traversal.

Как установить скилл forge-scene-model-loading?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл forge-scene-model-loading запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить forge-scene-model-loading с