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
Tiled output for obj #122
Open
kiselev-dv
wants to merge
8
commits into
tordanik:master
Choose a base branch
from
kiselev-dv:tiled_out
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Tiled output for obj #122
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bcb8daf
Tiled output for obj
kiselev-dv ad217a2
Add json lib to build.xml
kiselev-dv 6807f5e
Refactor meta writing
kiselev-dv bbd68ad
Switch to gson
kiselev-dv a519ec8
WGS 84 geometry math cleanup
kiselev-dv 74b62ec
Get name for material file from dummy .obj filename for tiled output
kiselev-dv cff585e
Subtiles generation
kiselev-dv 9dcc078
Add Cesium License
kiselev-dv File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package org.osm2world.core.math; | ||
|
||
import org.osm2world.core.map_data.creation.LatLon; | ||
|
||
public class WGS84Util { | ||
|
||
private static final double WGS84_A = 6378137.0; | ||
private static final double WGS84_B = 6356752.3142451793; | ||
|
||
private static final VectorXYZ oneOverRadiiSquared = new VectorXYZ( | ||
1.0 / (WGS84_A * WGS84_A), | ||
1.0 / (WGS84_A * WGS84_A), | ||
1.0 / (WGS84_B * WGS84_B)); | ||
|
||
private static final VectorXYZ wgs84RadiiSquared = | ||
new VectorXYZ(WGS84_A * WGS84_A, WGS84_A * WGS84_A, WGS84_B * WGS84_B); | ||
|
||
public static VectorXYZ cartesianFromLatLon(LatLon origin, double height) { | ||
double latitude = Math.toRadians(origin.lat); | ||
double longitude = Math.toRadians(origin.lon); | ||
VectorXYZ radiiSquared = wgs84RadiiSquared; | ||
|
||
double cosLatitude = Math.cos(latitude); | ||
VectorXYZ scratchN = new VectorXYZ( | ||
cosLatitude * Math.cos(longitude), | ||
cosLatitude * Math.sin(longitude), | ||
Math.sin(latitude)); | ||
|
||
scratchN = scratchN.normalize(); | ||
|
||
VectorXYZ scratchK = mulByComponents(radiiSquared, scratchN); | ||
double gamma = Math.sqrt(scratchN.dot(scratchK)); | ||
scratchK = scratchK.mult(1.0 / gamma); | ||
scratchN = scratchN.mult(height); | ||
|
||
return scratchK.add(scratchN); | ||
} | ||
|
||
public static double[] eastNorthUpToFixedFrame(VectorXYZ cartesian) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was taken from Cesium |
||
|
||
VectorXYZ normal = geodeticSurfaceNormal(cartesian); | ||
VectorXYZ tangent = new VectorXYZ(-cartesian.y, cartesian.x, 0.0).normalize(); | ||
VectorXYZ bitangent = normal.cross(tangent); | ||
|
||
// Matrix 4x4 by columns | ||
return new double[] { | ||
tangent.x, | ||
tangent.y, | ||
tangent.z, | ||
0.0, | ||
bitangent.x, | ||
bitangent.y, | ||
bitangent.z, | ||
0.0, | ||
normal.x, | ||
normal.y, | ||
normal.z, | ||
0.0, | ||
cartesian.x, | ||
cartesian.y, | ||
cartesian.z, | ||
1.0 | ||
}; | ||
} | ||
|
||
public static VectorXYZ geodeticSurfaceNormal(VectorXYZ cartesian) { | ||
VectorXYZ mulByComponents = mulByComponents(cartesian, oneOverRadiiSquared); | ||
return mulByComponents.normalize(); | ||
} | ||
|
||
public static VectorXYZ mulByComponents(VectorXYZ a, VectorXYZ b) { | ||
return new VectorXYZ(a.x * b.x, a.y * b.y, a.z * b.z); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
src/org/osm2world/core/target/BuildingsByHeightComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.osm2world.core.target; | ||
|
||
import java.util.Comparator; | ||
|
||
import org.osm2world.core.map_data.data.MapArea; | ||
import org.osm2world.core.world.data.WorldObject; | ||
import org.osm2world.core.world.modules.BuildingModule.Building; | ||
import org.osm2world.core.world.modules.BuildingModule.BuildingPart; | ||
import org.osm2world.core.world.modules.BuildingModule.BuildingPart.Roof; | ||
|
||
final class BuildingsByHeightComparator implements Comparator<MapArea> { | ||
|
||
public double getMaxEle(Building b) { | ||
double maxEle = 0.0; | ||
if (b != null) { | ||
for (BuildingPart part : b.getParts()) { | ||
Roof roof = part.getRoof(); | ||
if (roof != null) { | ||
maxEle = Math.max(maxEle, roof.getMaxRoofEle()); | ||
} | ||
} | ||
double areaAsEle = b.getArea().getOuterPolygon().getArea() / 200.0 * 4.0; | ||
maxEle += areaAsEle; | ||
} | ||
return maxEle; | ||
} | ||
|
||
@Override | ||
public int compare(MapArea o1, MapArea o2) { | ||
Building b1 = null; | ||
Building b2 = null; | ||
|
||
for(WorldObject wo1 : o1.getRepresentations()) { | ||
if (wo1 instanceof Building) { | ||
b1 = (Building) wo1; | ||
} | ||
} | ||
|
||
for(WorldObject wo2 : o2.getRepresentations()) { | ||
if (wo2 instanceof Building) { | ||
b2 = (Building) wo2; | ||
} | ||
} | ||
|
||
// From max to min | ||
return Double.compare(getMaxEle(b2), getMaxEle(b1)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.osm2world.core.target; | ||
|
||
import org.osm2world.core.map_data.data.MapElement; | ||
import org.osm2world.core.target.common.RenderableToPrimitiveTarget; | ||
|
||
public interface TargetProvider<R extends RenderableToPrimitiveTarget> { | ||
|
||
public Target<R> getTarget(MapElement e); | ||
|
||
public void close(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This was taken from Cesium