Exemple #1
0
        /*--------------------------------------------------Creating terrain--------------------------------------------------*/
        //public void Create_Terrain(Guid guid, string heightmap, Vector3 position, string materialName, double restitution, double friction, double height)
        public AgX_Scene(Guid guid, List <Vector3> vertices, List <int> triangles, Vector3 position, string materialName)
        {
            this.guid = guid;

            //AgX:
            agx.Vec3Vector   agx_vertices = new agx.Vec3Vector();
            agx.UInt32Vector agx_indices  = new agx.UInt32Vector();
            for (int i = 0; i < vertices.Count; i++)
            {
                agx_vertices.Add(Operations.ToAgxVec3(vertices[i]));
            }
            for (int i = 0; i < triangles.Count; i++)
            {
                agx_indices.Add((uint)triangles[i]);
            }
            terrain = new agx.RigidBody();

            //uint optionsMask = (uint)agxCollide.Trimesh.TrimeshOptionsFlags.TERRAIN;
            var terrain_trimesh = new agxCollide.Trimesh(agx_vertices, agx_indices, "handmade terrain");//, optionsMask, height);

            var geometry = new agxCollide.Geometry();

            geometry.add(terrain_trimesh);
            geometry.setMaterial(new agx.Material(materialName));

            terrain.add(geometry);
            terrain.setMotionControl(agx.RigidBody.MotionControl.STATIC);

            //position.y -= height;
            terrain.setLocalPosition(Operations.ToAgxVec3(position));//move right and -height for global 0

            ///Adds terrain to simulation
            //simulation.add(terrain);
            Agx_Simulation.sim_Instance.add(terrain);
        }
Exemple #2
0
        public static agx.Vec3Vector ToAgxVec3Vector(Vector3[] vector3)
        {
            agx.Vec3Vector vec3 = vector3.Count() > 0 ? new agx.Vec3Vector(vector3.Count()) : new agx.Vec3Vector();

            for (int i = 0; i < vector3.Count(); i++)
            {
                vec3.Add(new agx.Vec3(vector3[i].x, vector3[i].y, vector3[i].z));
            }
            return(vec3);
        }
Exemple #3
0
        private void Add(Vector3 v)
        {
            int index;

            if (!m_vertexToIndexTable.TryGetValue(v, out index))
            {
                index = m_vertices.Count;
                m_vertexToIndexTable.Add(v, index);

                if (m_transform != null)
                {
                    m_vertices.Add(m_transform.InverseTransformDirection(m_toWorld * v).ToHandedVec3());
                }
                else
                {
                    m_vertices.Add(v.ToHandedVec3());
                }
            }

            m_indices.Add(Convert.ToUInt32(index));
        }