port 2V2-d.2: Granny runtime on libgr2, main character model animates
Implement the Granny SDK 2.11 API the client uses on top of libgr2 (platform/EterGrnLib/GrannyRuntime.cpp, shim granny.h declared from the SDK header): file sections, type-definition vertex conversion, material textures by Usage, mesh/bone bindings, deformer, control clock/loop/ease and weighted SRT sampling. Port EterGrnLib (LODController, Material, Mesh, Model, ModelInstance*, Motion, Thing, ThingInstance, Util) plus EterLib GrpObjectInstance/GrpCollisionObject/CollisionData verbatim and drop their platform skeletons and pending stand-ins; register the gr2 resource factory; vertex/index buffers are CPU-side until the 2V2-e render adapter. app.UpdateGame/RenderGame now run 40250's bodies, reaching the CPythonApplication members through their singletons (the platform has no app object); CPythonGraphic joins GameSingletons in member order, and GetMousePosition reads the host cursor. port.login_flow asserts the main instance's PART_MAIN model has meshes, its diffuse image loaded and the WAIT motion moves the bones between frames; offline and live pass, port_gate macos PASS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
5266b00c6e
commit
668f48d6ec
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
|
||||
int main() {
|
||||
// ScaleShearCurve uses 9 values per control point. A quadratic span reads
|
||||
@@ -24,5 +25,32 @@ int main() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// BoneTrack::sample fills SRT components and flags; sample_local = compose(sample).
|
||||
gr2::BoneTrack track;
|
||||
track.position.degree = 1;
|
||||
track.position.dim = 3;
|
||||
track.position.knots = {0.0f, 1.0f};
|
||||
track.position.controls = {0.0f, 0.0f, 0.0f, 2.0f, 4.0f, 6.0f};
|
||||
track.orientation.degree = 0;
|
||||
track.orientation.dim = 4;
|
||||
track.orientation.knots = {0.0f};
|
||||
track.orientation.controls = {0.0f, 0.0f, 0.70710678f, 0.70710678f}; // 90 deg about Z
|
||||
gr2::Transform x;
|
||||
track.sample(0.5f, x);
|
||||
if (x.flags != 3 || std::fabs(x.position[0] - 1.0f) > 1e-5f || std::fabs(x.position[2] - 3.0f) > 1e-5f) {
|
||||
std::fprintf(stderr, "BoneTrack::sample flags=%u pos=%f,%f,%f\n", x.flags, x.position[0], x.position[1], x.position[2]);
|
||||
return 1;
|
||||
}
|
||||
gr2::Animation anim;
|
||||
anim.tracks.push_back(track);
|
||||
std::vector<gr2::Mat4> local;
|
||||
anim.sample_local(0.5f, local);
|
||||
const gr2::Mat4 m = gr2::compose(x);
|
||||
// Row-major composite: row 0 is the rotated X axis (0,1,0); translation in 12..14.
|
||||
if (local.size() != 1 || local[0] != m || std::fabs(m[1] - 1.0f) > 1e-5f || std::fabs(m[12] - 1.0f) > 1e-5f) {
|
||||
std::fprintf(stderr, "compose mismatch m[1]=%f m[12]=%f\n", m[1], m[12]);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user