Example #1
0
        /// <summary>
        /// Creates native height field object given current Unity Terrain
        /// object - if present (in component level or in parents).
        /// </summary>
        /// <returns>Native height field shape object.</returns>
        protected override agxCollide.Shape CreateNative()
        {
            TerrainData terrainData = GetTerrainData();

            if (terrainData == null)
            {
                return(null);
            }

            Vector3 scale = terrainData.heightmapScale;

            int[] res = new int[] { terrainData.heightmapWidth, terrainData.heightmapHeight };
            float[,] heights = terrainData.GetHeights(0, 0, res[0], res[1]);

            int resX = res[0];
            int resY = res[1];

            agx.RealVector agxHeights = new agx.RealVector(resX * resY);
            for (int x = resX - 1; x >= 0; --x)
            {
                for (int y = resY - 1; y >= 0; --y)
                {
                    agxHeights.Add(heights[x, y] * scale.y);
                }
            }

            agxCollide.HeightField hf = new agxCollide.HeightField((uint)res[0], (uint)res[1], GetWidth(), GetHeight(), agxHeights, false, 150.0);
            return(hf);
        }
Example #2
0
        private void initializeGearBox(agxDriveTrain.GearBox gearBox)
        {
            agx.RealVector gears = new agx.RealVector();

            foreach (var g in m_gears)
            {
                gears.Add(g);
            }

            gearBox.setGearRatios(gears);
            gearBox.setGear(1);
        }