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:
Bálint Hodossy
2023-12-11 14:56:19 +00:00
41 changed files with 864 additions and 1091 deletions
@@ -6,6 +6,6 @@ MonoImporter:
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
userData:
assetBundleName:
assetBundleVariant:
+9 -4
View File
@@ -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}"));
}
}
}