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

Set default yaw axis Vector3::UNIT_Y (tabletop mode) + Optional X, Z and free rotation #36

Merged
merged 1 commit into from
Apr 20, 2024

Conversation

sercero
Copy link
Contributor

@sercero sercero commented Apr 17, 2024

This solves #18

@sercero
Copy link
Contributor Author

sercero commented Apr 17, 2024

Perhaps it would be better if this was an option... for me this is the most reasonable mode

@paroj
Copy link
Member

paroj commented Apr 17, 2024

I had this on initially. However, this assumes the model actually has y-up. If this is not the case, there is no way to properly orient the model.

An alternative would be to make this configurable:

  • free rotation
  • fixed x-up
  • fixed y-up
  • fixed z-up

@sercero
Copy link
Contributor Author

sercero commented Apr 17, 2024

Is there a way to detect if the model does not have Y-up and rotate everything?

Perhaps that would be faster.

In general one would open models that were exported for OGRE which is Y-up, so it makes sense that the default is this.

I think it would be easier to make this selectable and True by default.

If someone loads a model that is not Y-up (the rare case) then they can choose to disable this.

@paroj
Copy link
Member

paroj commented Apr 17, 2024

In general one would open models that were exported for OGRE which is Y-up, so it makes sense that the default is this.

like I described here OGRECave/blender2ogre#240 it is trivial for user code to change which axis is "up". So I would not assume Y-up.

Also, since assimp is used, you are not even limited to ogre specific files, but maybe just want to inspect how a .obj would look when imported directly in Ogre. There any up assumptions goes out of the window.

Is there a way to detect if the model does not have Y-up and rotate everything?

one could look at the extents, but you need to assume whether the object is a statue or a bench. so generally: no.

@sercero
Copy link
Contributor Author

sercero commented Apr 17, 2024

I had this on initially. However, this assumes the model actually has y-up. If this is not the case, there is no way to properly orient the model.

An alternative would be to make this configurable:

  • free rotation
  • fixed x-up
  • fixed y-up
  • fixed z-up

The issue is that currently you only have the options:

  • free rotation
  • fixed y-up

Otherwise a modification of OGRE Bites CameraMan would be needed.
Unless we can change this with setPivotOffset()

@paroj
Copy link
Member

paroj commented Apr 17, 2024

Otherwise a modification of OGRE Bites CameraMan would be needed.

you should be able to get there without touching CameraMan by just changing the camera node like:

https://github.com/OGRECave/ogre/blob/a98c9ee8a6b93f9cf2d0d1efdaf4e0b7002d3c74/Samples/Simple/include/BSP.h#L78-L79

@sercero
Copy link
Contributor Author

sercero commented Apr 17, 2024

Traceback (most recent call last):
  File "D:\OGRE2\Built\ogre-meshviewer_24.02-win64\ogre_mesh_viewer.py", line 714, in <module>
    app.initApp()
  File "D:\OGRE2\Built\ogre-meshviewer_24.02-win64\ogre_mesh_viewer.py", line 680, in setup
    camnode.setFixedYawAxis(True, Ogre.Vector3.UNIT_Z);
AttributeError: type object 'Ogre.Ogre.Vector3' has no attribute 'UNIT_Z'

Can you help with this?

I can use (0,0,1) but UNIT_Z would be better.

@paroj
Copy link
Member

paroj commented Apr 17, 2024

use (0,0,1).
Maintaining UNIT_Z is a PITA, as Vector3 is a typdef of Vector<N, float> and it only makes sense for N==3

@sercero sercero force-pushed the fixedyaw branch 2 times, most recently from 883b984 to dd5e3d6 Compare April 19, 2024 03:29
@sercero sercero changed the title Fix the yaw axis to be Vector3::UNIT_Y of the parent node (tabletop mode) Set default yaw axis Vector3::UNIT_Y (tabletop mode) + Optional X,Z and free rotation Apr 19, 2024
@sercero sercero changed the title Set default yaw axis Vector3::UNIT_Y (tabletop mode) + Optional X,Z and free rotation Set default yaw axis Vector3::UNIT_Y (tabletop mode) + Optional X, Z and free rotation Apr 19, 2024
ogre_mesh_viewer.py Outdated Show resolved Hide resolved
ogre_mesh_viewer.py Outdated Show resolved Hide resolved
ogre_mesh_viewer.py Outdated Show resolved Hide resolved
ogre_mesh_viewer.py Outdated Show resolved Hide resolved
ogre_mesh_viewer.py Outdated Show resolved Hide resolved
@sercero sercero force-pushed the fixedyaw branch 3 times, most recently from 8f3a7a4 to 816f29f Compare April 20, 2024 03:35
@@ -200,6 +205,23 @@ def draw_loading(self):
ImGui.Text("Loading.. ")
ImGui.End()

def set_orientation(self):
Copy link
Member

@paroj paroj Apr 20, 2024

Choose a reason for hiding this comment

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

this method only modifes self.app therefore it should be moved to app, like probably all related fields

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

ogre_mesh_viewer.py Outdated Show resolved Hide resolved
@paroj paroj merged commit 0125d1c into OGRECave:master Apr 20, 2024
1 check passed
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.

2 participants