Fix examples
This commit is contained in:
parent
01869ab291
commit
9d9daa7127
2 changed files with 7 additions and 10 deletions
|
|
@ -38,7 +38,7 @@ pub fn main() anyerror!void {
|
||||||
|
|
||||||
// Load gltf model animations
|
// Load gltf model animations
|
||||||
var animIndex: usize = 0;
|
var animIndex: usize = 0;
|
||||||
var animCurrentFrame: i32 = 0;
|
var animCurrentFrame: f32 = 0;
|
||||||
const modelAnimations = try rl.loadModelAnimations("examples/models/resources/models/gltf/greenman.glb");
|
const modelAnimations = try rl.loadModelAnimations("examples/models/resources/models/gltf/greenman.glb");
|
||||||
const animsCount = modelAnimations.len;
|
const animsCount = modelAnimations.len;
|
||||||
defer rl.unloadModelAnimations(modelAnimations);
|
defer rl.unloadModelAnimations(modelAnimations);
|
||||||
|
|
@ -47,8 +47,8 @@ pub fn main() anyerror!void {
|
||||||
var boneSocketIndex: [BONE_SOCKETS]usize = undefined;
|
var boneSocketIndex: [BONE_SOCKETS]usize = undefined;
|
||||||
|
|
||||||
// search bones for sockets
|
// search bones for sockets
|
||||||
for (0..@as(usize, @intCast(characterModel.boneCount))) |i| {
|
for (0..@as(usize, @intCast(characterModel.skeleton.boneCount))) |i| {
|
||||||
const boneName: [:0]const u8 = @ptrCast(&characterModel.bones[i].name);
|
const boneName: [:0]const u8 = @ptrCast(&characterModel.skeleton.bones[i].name);
|
||||||
if (rl.textIsEqual(boneName, "socket_hat")) {
|
if (rl.textIsEqual(boneName, "socket_hat")) {
|
||||||
boneSocketIndex[BONE_SOCKET_HAT] = i;
|
boneSocketIndex[BONE_SOCKET_HAT] = i;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -96,7 +96,7 @@ pub fn main() anyerror!void {
|
||||||
|
|
||||||
// Update model animation
|
// Update model animation
|
||||||
const anim = modelAnimations[animIndex];
|
const anim = modelAnimations[animIndex];
|
||||||
animCurrentFrame = @mod(animCurrentFrame + 1, anim.frameCount);
|
animCurrentFrame = @mod(animCurrentFrame + 1, @as(f32, @floatFromInt(anim.keyframeCount)));
|
||||||
rl.updateModelAnimation(characterModel, anim, animCurrentFrame);
|
rl.updateModelAnimation(characterModel, anim, animCurrentFrame);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -120,8 +120,8 @@ pub fn main() anyerror!void {
|
||||||
for (0..BONE_SOCKETS) |i| {
|
for (0..BONE_SOCKETS) |i| {
|
||||||
if (!showEquip[i]) continue;
|
if (!showEquip[i]) continue;
|
||||||
|
|
||||||
const transform = &anim.framePoses[@intCast(animCurrentFrame)][boneSocketIndex[i]];
|
const transform = &anim.keyframePoses[@as(usize, @intFromFloat(animCurrentFrame))][boneSocketIndex[i]];
|
||||||
const inRotation = characterModel.bindPose[boneSocketIndex[i]].rotation;
|
const inRotation = characterModel.skeleton.bindPose[boneSocketIndex[i]].rotation;
|
||||||
const outRotation = transform.rotation;
|
const outRotation = transform.rotation;
|
||||||
|
|
||||||
// Calculate socket rotation (angle between bone in initial pose and same bone in current animation frame)
|
// Calculate socket rotation (angle between bone in initial pose and same bone in current animation frame)
|
||||||
|
|
|
||||||
|
|
@ -41,10 +41,7 @@ const Light = extern struct {
|
||||||
type: Type = .directional,
|
type: Type = .directional,
|
||||||
enabled: bool = false,
|
enabled: bool = false,
|
||||||
_enabled_pad1: u8 = 0,
|
_enabled_pad1: u8 = 0,
|
||||||
_enabled_pad2: @Type(.{.int = .{
|
_enabled_pad2: @Int(.unsigned, @bitSizeOf(c_uint) - 16) = 0,
|
||||||
.signedness = .unsigned,
|
|
||||||
.bits = @bitSizeOf(c_uint) - 16,
|
|
||||||
}}) = 0,
|
|
||||||
position: rl.Vector3 = .init(0, 0, 0),
|
position: rl.Vector3 = .init(0, 0, 0),
|
||||||
target: rl.Vector3 = .init(0, 0, 0),
|
target: rl.Vector3 = .init(0, 0, 0),
|
||||||
color: [4]f32 = .{ 0, 0, 0, 0 },
|
color: [4]f32 = .{ 0, 0, 0, 0 },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue