Forge Camera And Input logo

Forge Camera And Input

Community
Nebulavenus
forge-camera-and-input

Set up a first-person camera with quaternion orientation, keyboard/mouse input, and delta time. Use when someone needs to fly through a 3D scene, handle WASD movement, mouse look, or frame-rate-independent motion in SDL3 GPU.

Overview

PublisherNebulavenus
Repositoryforge-gpu
Skill nameforge-camera-and-input
Stars
46
Forks
7
Bundled files
Instructions only
LicenseZlib
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by Nebulavenus on GitHub. Read the source before you install it.

Installation

Install the Forge Camera And Input AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/forge-camera-and-input
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Nebulavenus/forge-gpu.git /tmp/forge-gpu
mkdir -p .claude/skills
cp -r /tmp/forge-gpu/.claude/skills/forge-camera-and-input .claude/skills/forge-camera-and-input
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Forge Camera And Input in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Forge Camera And Input on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Forge Camera And Input is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Camera & Input — First-Person Camera, Keyboard/Mouse, Delta Time

This skill teaches how to add interactive camera controls to a 3D scene. It builds on the depth-and-3d skill (MVP pipeline, depth testing) and uses quaternion math from common/math/forge_math.h.

When to use

  • Adding a first-person camera to a 3D scene
  • Handling keyboard input for smooth movement (WASD)
  • Adding mouse look with relative mouse mode
  • Making movement frame-rate independent with delta time
  • Drawing multiple objects with different model transforms
  • Transitioning from a fixed camera (mat4_look_at) to a player-controlled one

Key API calls (ordered)

  1. SDL_SetWindowRelativeMouseMode — capture mouse for FPS-style look
  2. SDL_GetKeyboardState — poll which keys are currently held
  3. SDL_EVENT_MOUSE_MOTION — read relative mouse deltas (xrel, yrel)
  4. quat_from_euler — convert yaw+pitch to quaternion orientation
  5. quat_forward / quat_right — extract movement directions
  6. mat4_view_from_quat — build view matrix from position + quaternion
  7. SDL_PushGPUVertexUniformData — push per-object MVP matrix
  8. SDL_DrawGPUIndexedPrimitives — draw each object (one call per object)

Code template

Camera state

c
#include "math/forge_math.h"

typedef struct app_state {
    /* ... GPU resources from depth-and-3d skill ... */

    /* Camera */
    vec3  cam_position;   /* world-space position */
    float cam_yaw;        /* radians, rotation around Y */
    float cam_pitch;      /* radians, rotation around X */

    /* Timing */
    Uint64 last_ticks;    /* previous frame timestamp (ms) */

    /* Input */
    bool mouse_captured;
} app_state;

Initialize camera

c
/* In SDL_AppInit: */
state->cam_position = vec3_create(0.0f, 1.6f, 6.0f);
state->cam_yaw      = 0.0f;
state->cam_pitch    = 0.0f;
state->last_ticks   = SDL_GetTicks();

/* Capture mouse for FPS-style look */
if (!SDL_SetWindowRelativeMouseMode(window, true)) {
    SDL_Log("SDL_SetWindowRelativeMouseMode failed: %s", SDL_GetError());
}
state->mouse_captured = true;

Mouse look (in SDL_AppEvent)

c
/* Escape: release mouse first, quit on second press */
if (event->type == SDL_EVENT_KEY_DOWN && event->key.key == SDLK_ESCAPE) {
    if (state->mouse_captured) {
        SDL_SetWindowRelativeMouseMode(state->window, false);
        state->mouse_captured = false;
    } else {
        return SDL_APP_SUCCESS;
    }
}

/* Click to recapture */
if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN && !state->mouse_captured) {
    SDL_SetWindowRelativeMouseMode(state->window, true);
    state->mouse_captured = true;
}

/* Mouse motion -> yaw/pitch */
if (event->type == SDL_EVENT_MOUSE_MOTION && state->mouse_captured) {
    #define MOUSE_SENSITIVITY 0.002f
    state->cam_yaw   -= event->motion.xrel * MOUSE_SENSITIVITY;
    state->cam_pitch -= event->motion.yrel * MOUSE_SENSITIVITY;

    /* Clamp pitch to avoid gimbal lock (see Math Lesson 08) */
    float max_pitch = 89.0f * FORGE_DEG2RAD;
    if (state->cam_pitch >  max_pitch) state->cam_pitch =  max_pitch;
    if (state->cam_pitch < -max_pitch) state->cam_pitch = -max_pitch;
}

Delta time and keyboard movement (in SDL_AppIterate)

c
/* Delta time — frame-rate independent movement */
Uint64 now_ms = SDL_GetTicks();
float dt = (float)(now_ms - state->last_ticks) / 1000.0f;
state->last_ticks = now_ms;
if (dt > 0.1f) dt = 0.1f;  /* clamp to prevent teleportation */

/* Build orientation quaternion from euler angles */
quat cam_orientation = quat_from_euler(
    state->cam_yaw, state->cam_pitch, 0.0f);

/* Extract movement directions from quaternion */
vec3 forward = quat_forward(cam_orientation);
vec3 right   = quat_right(cam_orientation);

/* Poll keyboard for continuous movement */
#define MOVE_SPEED 3.0f
const bool *keys = SDL_GetKeyboardState(NULL);

if (keys[SDL_SCANCODE_W] || keys[SDL_SCANCODE_UP]) {
    state->cam_position = vec3_add(state->cam_position,
        vec3_scale(forward, MOVE_SPEED * dt));
}
if (keys[SDL_SCANCODE_S] || keys[SDL_SCANCODE_DOWN]) {
    state->cam_position = vec3_add(state->cam_position,
        vec3_scale(forward, -MOVE_SPEED * dt));
}
if (keys[SDL_SCANCODE_D] || keys[SDL_SCANCODE_RIGHT]) {
    state->cam_position = vec3_add(state->cam_position,
        vec3_scale(right, MOVE_SPEED * dt));
}
if (keys[SDL_SCANCODE_A] || keys[SDL_SCANCODE_LEFT]) {
    state->cam_position = vec3_add(state->cam_position,
        vec3_scale(right, -MOVE_SPEED * dt));
}
if (keys[SDL_SCANCODE_SPACE]) {
    state->cam_position.y += MOVE_SPEED * dt;
}
if (keys[SDL_SCANCODE_LSHIFT]) {
    state->cam_position.y -= MOVE_SPEED * dt;
}

View matrix (replaces mat4_look_at)

c
/* Build view matrix from camera position + quaternion orientation.
 * This replaces the fixed mat4_look_at from the depth-and-3d skill. */
mat4 view = mat4_view_from_quat(state->cam_position, cam_orientation);

float aspect = (float)window_w / (float)window_h;
mat4 proj = mat4_perspective(60.0f * FORGE_DEG2RAD, aspect, 0.1f, 100.0f);
mat4 vp = mat4_multiply(proj, view);

Drawing multiple objects

c
/* Bind vertex/index buffers once (shared by all objects) */
SDL_BindGPUVertexBuffers(pass, 0, &vertex_binding, 1);
SDL_BindGPUIndexBuffer(pass, &index_binding, SDL_GPU_INDEXELEMENTSIZE_16BIT);

/* Draw each object with its own model matrix */
for (int i = 0; i < num_objects; i++) {
    mat4 model = mat4_multiply(
        mat4_translate(objects[i].position),
        mat4_multiply(
            mat4_rotate_y(elapsed * objects[i].rotation_speed),
            mat4_scale(vec3_create(s, s, s))
        )
    );
    mat4 mvp = mat4_multiply(vp, model);

    Uniforms u = { .mvp = mvp };
    SDL_PushGPUVertexUniformData(cmd, 0, &u, sizeof(u));
    SDL_DrawGPUIndexedPrimitives(pass, INDEX_COUNT, 1, 0, 0, 0);
}

Camera types comparison

Camera typeView matrixInputBest for
Fixedmat4_look_at(eye, target, up)NoneLesson 06, cutscenes
First-personmat4_view_from_quat(pos, quat)WASD + mouseFPS games, editors
Orbitmat4_look_at(eye_from_spherical, target, up)Mouse drag3D viewers, RTS

Math library functions used

FunctionPurpose
quat_from_euler(yaw, pitch, roll)Euler angles to quaternion
quat_forward(q)Camera's look direction (-Z rotated by q)
quat_right(q)Camera's right direction (+X rotated by q)
mat4_view_from_quat(pos, q)View matrix from position + quaternion
mat4_translate(v)Translation matrix for object placement
mat4_rotate_y(angle)Y-axis rotation for spinning objects
mat4_scale(v)Scale matrix for object sizing

Common mistakes

MistakeFix
Camera doesn't respond to mouseCheck SDL_SetWindowRelativeMouseMode(window, true) succeeded
Movement is jittery or too fastUse delta time: speed * dt, not just speed
Camera flips upside downClamp pitch to less than 90 degrees
Movement speed depends on frame rateMultiply by dt (seconds since last frame)
Camera teleports after alt-tabClamp dt to a maximum (e.g., 0.1s)
Objects draw incorrectly with multiple drawsPush uniform BEFORE each draw call
Mouse look reversedCheck sign of xrel/yrel multiplication
Key events instead of key stateUse SDL_GetKeyboardState for smooth continuous movement

Reference

Frequently asked questions

What does the Forge Camera And Input AI skill do?

Set up a first-person camera with quaternion orientation, keyboard/mouse input, and delta time. Use when someone needs to fly through a 3D scene, handle WASD movement, mouse look, or frame-rate-independent motion in SDL3 GPU.

Why use Forge Camera And Input on TypingMind?

Because you install it once and use it with any model. Forge Camera And Input is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Forge Camera And Input in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/forge-camera-and-input. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Forge Camera And Input?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Forge Camera And Input?

As many as you like. As long as a model supports skills, you can use Forge Camera And Input with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Forge Camera And Input AI skill free?

Yes. It is published on GitHub by Nebulavenus under the Zlib license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇