-
Notifications
You must be signed in to change notification settings - Fork 22
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
Fix world positions on rotated or scaled terrain #153
Fix world positions on rotated or scaled terrain #153
Conversation
…methods for rotated and scaled terrain
So this bug affected my Mundus integration into ode4j. I am not blocked, but I am glad you are fixing. adding this code so that I am reminded/remember where to fix it once fixed in this PR. private double heightfield_callback( Object pUserData, int x, int z ) {
float fx = x/2f; // because we have 40 samples on a 20x20 mesh, we divide by 2
float fz = z/2f; // because we have 40 samples on a 20x20 mesh, we divide by 2
double h = ((TerrainComponent) scene.sceneGraph.getGameObjects().get(0).findComponentByType(Component.Type.TERRAIN)).
getHeightAtWorldCoord(fx, fz);
return h*3f + 0.2f; // x3 because I scaled the Y terrain x3 in the Mundus editor (issue#153), +0.2f to increase thickness of mesh
//Mundus PR >>> https://github.com/JamesTKhan/Mundus/pull/153 remove *3f once fixed
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you.
I got the latest code because I see: public float getHeightAtWorldCoord(float worldX, float worldZ, Matrix4 terrainTransform) {
// Translates world coordinates to local coordinates
tmp.set(worldX, 0f, worldZ).mul(tmpMatrix.set(terrainTransform).inv()); But the height is still calculated without the Y Scale = 3 |
Ohh, I think I know why. I will check it and fix it today. |
@Dgzt @JamesTKhan Sorry for the stupid question but is it possible to point to a specific forked branch in your
|
@antzGames I normally just check out the Mundus PR, then build it if I need to using Maven Publish to my local. But you may be able to use jitpack to point straight to Dgzt's branches, however the branch for this PR was deleted already from what I can tell |
@antzGames I usually check out the PR with this git command: git fetch origin pull/ID/head:BRANCH_NAME
git checkout BRANCH_NAME and build the project and copy common and runtime jars into my project's
|
Thanks guys. This is exactly what I was looking for. Now I can test people PRs from a runtime perspective as testing the editor is easy. |
Currently the
isOnTerrain
,getNormalAtWordCoordinate
andgetHeightAtWorldCoord
methods onTerrain
are only check translation and don't check rotation and scaling.You can test them with these temporary codes in
FreeCamController
in editor:isOnTerrain:
getNormalAtWordCoordinate:
getHeightAtWorldCoord:
Just you need add
currentProject
constructor parameter and add this parameter inMundus.kt
.