Merge branch 'feature/unity-hmap-dyn' of https://github.com/Balint-H/mujoco into feature/unity-hmap-dyn
Merge in format from GitHub
This commit is contained in:
@@ -6,6 +6,6 @@ MonoImporter:
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -51,7 +51,7 @@ public class MjcfGenerationContext {
|
||||
}
|
||||
return _meshAssets[mesh];
|
||||
}
|
||||
|
||||
|
||||
// Adds a mesh to the list of assets that will be added to the generated MJCF.
|
||||
// Returns the unique name that identifies this new asset.
|
||||
public string AddHeightFieldAsset(MjHeightFieldShape hField) {
|
||||
@@ -115,15 +115,20 @@ public class MjcfGenerationContext {
|
||||
mjcf.SetAttribute("vertex", vertexPositionsStr.ToString());
|
||||
}
|
||||
|
||||
private static void GenerateHeightFieldMjcf(MjHeightFieldShape hFieldComponent, XmlElement mjcf) {
|
||||
private static void GenerateHeightFieldMjcf(MjHeightFieldShape hFieldComponent, XmlElement mjcf) {
|
||||
mjcf.SetAttribute("nrow", "0");
|
||||
mjcf.SetAttribute("ncol", "0");
|
||||
mjcf.SetAttribute("content_type", "image/png");
|
||||
mjcf.SetAttribute("file", hFieldComponent.FullHeightMapPath);
|
||||
var baseHeight = hFieldComponent.terrain.transform.localPosition.y + hFieldComponent.MinimumHeight;
|
||||
var heightRange = Mathf.Clamp(hFieldComponent.MaximumHeight - hFieldComponent.MinimumHeight, 0.00001f, Mathf.Infinity);
|
||||
mjcf.SetAttribute("size", MjEngineTool.MakeLocaleInvariant($"{hFieldComponent.HeightMapScale.x*hFieldComponent.HeightMapLength/2} {hFieldComponent.HeightMapScale.z * hFieldComponent.HeightMapWidth/2} {heightRange} {baseHeight}"));
|
||||
|
||||
mjcf.SetAttribute(
|
||||
"size",
|
||||
MjEngineTool.MakeLocaleInvariant(
|
||||
$@"{hFieldComponent.HeightMapScale.x*hFieldComponent.HeightMapLength/2}
|
||||
{hFieldComponent.HeightMapScale.z * hFieldComponent.HeightMapWidth/2}
|
||||
{heightRange}
|
||||
{baseHeight}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user