Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Marvin commands #404

Merged
merged 6 commits into from
Mar 5, 2023
Merged

More Marvin commands #404

merged 6 commits into from
Mar 5, 2023

Conversation

thokkat
Copy link
Contributor

@thokkat thokkat commented Feb 8, 2023

This PR implements marvin keys F4-F7 and the console command toggle time #215.

F4 - Reset camera to normal mode.
F5 - Freeze camera. Camera stays in place and can't be moved. Character can move freely.
F6 - Free camera. Allows to fly the camera through the world. Character is frozen.
F7 - Like normal play but camera is shifted to a position reached by F6. Camera moves with the character.

F4-F6 are implemented the same as vanilla. There F7 aligns the camera to the players head-to-foot axis. I haven't looked into that and kept the usual y-axis, but can try if it's desirable.

I encountered some hiccups when the camera changes to a different mode. I opted to not stop marvin cam in those cases for now, there's always F4 to reset.

Comparison F7 PR/vanilla

new.mp4
old.mp4

@Try
Copy link
Owner

Try commented Feb 8, 2023

Hi, @thokkat , thanks for PR!

Can you please give more detail explanation on each command? Expected vanilla behavior and implemented one(if differs)

@thokkat
Copy link
Contributor Author

thokkat commented Feb 9, 2023

Edited start post.

Copy link
Owner

@Try Try left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made a quick only look so far, will do testing, once I'm done with npc swimming code, that I'm currently working on.

game/world/worldobjects.cpp Outdated Show resolved Hide resolved
game/mainwindow.cpp Outdated Show resolved Hide resolved
game/camera.h Outdated Show resolved Hide resolved
game/camera.cpp Outdated Show resolved Hide resolved
npc.tick(dtPlayer); else
if(npc.isPlayer()) {
if(Gothic::inst().camera() && Gothic::inst().camera()->isMarvinMode(Camera::M_Free)) {
return;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also why player is not receiving ticks, when in free-cam mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Player can't move, doesn't drop if in air, receives no damage if diving bar is empty, aigoto only starts if free cam mode is left and current animation is frozen. Player can be damaged by monsters and npc though but death animation behaves like aigoto. Maybe it's best to just activate godmode here.

So basically all what's done in player-tick is skipped/ignored.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested vanilla today:
In free cam move playable npc doesn't receive animation ticks for skeletal animation, an no physics ticks. It can receive damage and perceptions(magic damage at least).
Also main menu not working in free-camera O-o

Anyway return; is definitely wrong here.

game/camera.h Outdated Show resolved Hide resolved
game/camera.h Show resolved Hide resolved
game/mainwindow.cpp Show resolved Hide resolved
game/camera.cpp Outdated
if(m==M_Free)
pl->setAnim(AnimationSolver::NoAnim);
if(m==M_Fixed) {
auto offset = dst.target - pl->cameraBone();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This math odd.
Is it another way to write inverse(pl->cameraBone()) * dst.target ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is supposed to calculate the vector from player to camera position. Is there a better way?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a better way?

Matrix seem to be close-most to vanilla. so you storing offset vector in players coordinate system. And then you project it back to world on camera ticks. This should be shorter and titling will be reproduced naturally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it what I'm currently doing? Code below would lead to same offset vector.

   Vec3 offset(0,0,1);
   Matrix4x4 m;
   m.identity();
   m.translate(pl->cameraBone(true));
   m.inverse();
   m.translate(dst.target);
   m.project(offset);  
   cameraOffset = offset;

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean it make sense to change it, and fetch cameraBone from npc as matrix, with tilt and rotation.

Copy link
Contributor Author

@thokkat thokkat Feb 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use pl->transform() to fetch matrix, but still normal tilt. Am I forgetting something or is there anything else needed?

Edit: Ok looks like offsetAng could do the tilt

game/camera.cpp Outdated Show resolved Hide resolved
@ezamelczyk
Copy link

ezamelczyk commented Feb 28, 2023

I can't really pinpoint why it's happening but when I build this branch on m1 mac I have an issue. Menus are working but in the game everything's glitched. I preformed a clean build and it did not help. Main branch does not have this issue. Screenshot attached.

Zrzut ekranu 2023-02-28 o 11 54 07

@thokkat
Copy link
Contributor Author

thokkat commented Feb 28, 2023

@ezamelczyk
Everything this PR does is disabled by default. Once activated only the camera position should change. Maybe it's because this pr was some weeks behind master. But master is now merged in so you could give it another try.

@Try
I addressed the requested changes. I don't know if there's a better way to prevent animation ticks. It seems the animation is reset instead of continued if e.g F6->F7, which leads to problems with mobsi states. As a workaround i prevented the use of F6 in these cases.

Also didn't manage to get tilt in. Everything i did also changed the rotation axis. I'd like to leave that for a follow pr, except you know right away how to do it. Although i like it how it is, just a change of camera perspective.

@ezamelczyk
Copy link

Yup. Seems to be working correctly with updates from main.

@Try
Copy link
Owner

Try commented Mar 5, 2023

Checkout with github no longer working :(
Anyway, code look ok - will merge it as-is now, and fix nitpicks in post

@Try Try merged commit c058d6e into Try:master Mar 5, 2023
Try added a commit that referenced this pull request Mar 7, 2023
@thokkat thokkat deleted the marvin-command branch March 10, 2023 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants