public static Model Load(string file, Device device) { XmlDocument document = new XmlDocument(); document.Load(file); XmlNamespaceManager ns = new XmlNamespaceManager(document.NameTable); ns.AddNamespace("c", "http://www.collada.org/2005/11/COLLADASchema"); // Read vertex positions var positionsNode = document.SelectSingleNode("/c:COLLADA/c:library_geometries/c:geometry[@id='geom-Torus001']/c:mesh/c:source[@id='geom-Torus001-positions']/c:float_array[@id='geom-Torus001-positions-array']", ns); var indicesNode = document.SelectSingleNode("/c:COLLADA/c:library_geometries/c:geometry[@id='geom-Torus001']/c:mesh/c:triangles/c:p", ns); var positions = ParseVector3s(positionsNode.InnerText).ToArray(); var indices = ParseInts(indicesNode.InnerText).ToArray(); // Mixing concerns here, but oh well var positionsBuffer = new DataStream(positions, true, false); var indicesBuffer = new DataStream(indices, true, false); var model = new Model() { VertexBuffer = new Buffer(device, positionsBuffer, positions.Length * Vector3.SizeInBytes, ResourceUsage.Default, BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None), IndexBuffer = new Buffer(device, indicesBuffer, indices.Length * sizeof(int), ResourceUsage.Default, BindFlags.IndexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None), IndexCount = indices.Length, VertexPositions = positions }; return model; }
/// <summary>Simple examples of all the PhysX bits running together.</summary> protected override void LoadPhysics(Scene scene) { // The ground plane (if created) sould be the first actor var groundActor = scene.Actors.First(); groundActor.Name = "Default Ground Plane"; // // Create most of the PhysX objects available RigidBodySample.SimpleBoxes(scene); ClothSample.FlagOfCloth(scene); JointSample.RevoluteJoint(scene); JointSample.PrismaticJointWithLimit(scene); FluidSample.FluidWithEmitterAndDrain(scene); ForceFieldSample.CreateForceField(scene); HeightfieldSample.HeightfieldGrid(scene); _torusModel = ConvexSample.ActorWithConvexShape(scene, Engine.GraphicsDevice); ControllerSample.CapsuleController(scene); // Enable to view soft bodies, they run slowly if (false) SoftBodySample.TeapotSoftBody(scene); _basicVehicle = new VehicleSample(Engine.Scene); }