public override void Update() { dynamicsWorld.StepSimulation(1 / 60f, 10); if (Ctx2.Input.keyUp(Key.A)) { var ballBody = BulletRigidBodyConstructor.CreateBall(10f, 1f, new TGCVector3(0f, 100f, 0f)); ballBodys.Add(ballBody); dynamicsWorld.AddRigidBody(ballBody); } if (Ctx2.Input.keyUp(Key.S)) { var boxBody = BulletRigidBodyConstructor.CreateBox(new TGCVector3(10, 10, 10), 1f, new TGCVector3(5f, 150f, 5f), MathUtil.SIMD_HALF_PI, MathUtil.SIMD_QUARTER_PI, MathUtil.SIMD_2_PI, 0.3f); boxBodys.Add(boxBody); dynamicsWorld.AddRigidBody(boxBody); } if (Ctx2.Input.keyUp(Key.Space)) { var ballBody = BulletRigidBodyConstructor.CreateBall(10, 1f, new TGCVector3(Ctx2.Camara.Position.X, Ctx2.Camara.Position.Y, Ctx2.Camara.Position.Z)); ballBody.LinearVelocity = new TGCVector3(-Ctx2.Camara.Position.X, -Ctx2.Camara.Position.Y, -Ctx2.Camara.Position.Z).ToBsVector * 0.2f; ballBody.Restitution = 0.9f; ballBodys.Add(ballBody); dynamicsWorld.AddRigidBody(ballBody); } }
public override void Init(BulletExampleWall ctx) { base.Init(ctx); //Creamos shapes y bodies. //El piso es un plano estatico se dice que si tiene masa 0 es estatico. var floorShape = new StaticPlaneShape(TGCVector3.Up.ToBsVector, 0); var floorMotionState = new DefaultMotionState(); var floorInfo = new RigidBodyConstructionInfo(0, floorMotionState, floorShape); floorBody = new RigidBody(floorInfo); floorBody.Friction = 1; floorBody.RollingFriction = 1; // ballBody.SetDamping(0.1f, 0.9f); floorBody.Restitution = 1f; floorBody.UserObject = "floorBody"; dynamicsWorld.AddRigidBody(floorBody); for (var i = -10; i < 10; i++) { for (var j = 0; j < 10; j++) { var boxBody = BulletRigidBodyConstructor.CreateBox(new TGCVector3(10, 10, 10), 1, new TGCVector3(i * 20f + 5f, j * 20f + 5f, 0f), 0, 0, 0, 0.5f); boxBodys.Add(boxBody); dynamicsWorld.AddRigidBody(boxBody); } } //Cargamos objetos de render del framework. var floorTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx.MediaDir + @"Texturas\granito.jpg"); floorMesh = new TgcPlane(new TGCVector3(-2000, 0, -2000), new TGCVector3(4000, 0f, 4000), TgcPlane.Orientations.XZplane, floorTexture); var texture = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx.MediaDir + @"\MeshCreator\Scenes\Deposito\Textures\box1.jpg"); //Es importante crear todos los mesh con centro en el 0,0,0 y que este coincida con el centro de masa definido caso contrario rotaria de otra forma diferente a la dada por el motor de fisica. boxMesh1 = TGCBox.fromSize(new TGCVector3(20, 20, 20), texture); texture = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx.MediaDir + @"\MeshCreator\Scenes\Deposito\Textures\box4.jpg"); boxMesh2 = TGCBox.fromSize(new TGCVector3(20, 20, 20), texture); texture = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx.MediaDir + @"\MeshCreator\Scenes\Deposito\Textures\box3.jpg"); boxMesh3 = TGCBox.fromSize(new TGCVector3(20, 20, 20), texture); texture = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx.MediaDir + @"\MeshCreator\Scenes\Deposito\Textures\box4.jpg"); boxMesh4 = TGCBox.fromSize(new TGCVector3(20, 20, 20), texture); texture = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx.MediaDir + @"\Texturas\pokeball.jpg"); //Se crea una esfera de tamaño 1 para escalarla luego (en render) sphereMesh = new TGCSphere(1, texture, TGCVector3.Empty); //Tgc no crea el vertex buffer hasta invocar a update values. sphereMesh.updateValues(); }
public Tuple <TGCBox, RigidBody> addBox(TGCVector3 pos, TGCVector3 size, TgcTexture text, float mass = 0f, float friction = 0f, float?inertia = null) { var box = TGCBox.fromSize(size, text); var uv = FastMath.Max(size.Y, FastMath.Max(size.X, size.Z)); box.UVTiling = new TGCVector2(FastMath.Ceiling(uv / 80), FastMath.Ceiling(uv / 80)); box.updateValues(); var boxBody = BulletRigidBodyConstructor.CreateBox(box.Size * 0.5f, mass, pos, 0, 0, 0, friction, inertia); dynamicsWorld.AddRigidBody(boxBody); var pair = new Tuple <TGCBox, RigidBody>(box, boxBody); boxes.Add(pair); box.AutoTransform = false; boxBody.Restitution = 0f; return(pair); }
public override void Init(BulletExample3 ctx) { base.Init(ctx); //Creamos shapes y bodies. //El piso es un plano estatico se dice que si tiene masa 0 es estatico. var floorShape = new StaticPlaneShape(TGCVector3.Up.ToBsVector, 0); var floorMotionState = new DefaultMotionState(); var floorInfo = new RigidBodyConstructionInfo(0, floorMotionState, floorShape); floorBody = new RigidBody(floorInfo); dynamicsWorld.AddRigidBody(floorBody); var boxBody = BulletRigidBodyConstructor.CreateBox(new TGCVector3(10, 10, 10), 1f, new TGCVector3(10f, 100f, 10f), MathUtil.SIMD_HALF_PI, MathUtil.SIMD_QUARTER_PI, MathUtil.SIMD_2_PI, 0); boxBodys.Add(boxBody); dynamicsWorld.AddRigidBody(boxBody); var ballBody = BulletRigidBodyConstructor.CreateBall(10f, 1f, new TGCVector3(0f, 50f, 0f)); ballBodys.Add(ballBody); dynamicsWorld.AddRigidBody(ballBody); //Cargamos objetos de render del framework. var floorTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx2.MediaDir + @"Texturas\granito.jpg"); floorMesh = new TgcPlane(new TGCVector3(-2000, 0, -2000), new TGCVector3(4000, 0f, 4000), TgcPlane.Orientations.XZplane, floorTexture); var texture = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx2.MediaDir + @"MeshCreator\Scenes\Deposito\Textures\boxMetal.jpg"); //Es importante crear todos los mesh con centro en el 0,0,0 y que este coincida con el centro de masa definido caso contrario rotaria de otra forma diferente a la dada por el motor de fisica. boxMesh = TGCBox.fromSize(new TGCVector3(20, 20, 20), texture); texture = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx2.MediaDir + @"Texturas\pokeball.jpg"); //Se crea una esfera de tamaño 1 para escalarla luego (en render) sphereMesh = new TGCSphere(1, texture, TGCVector3.Empty); //Tgc no crea el vertex buffer hasta invocar a update values. sphereMesh.updateValues(); }
public void Init(String MediaDir) { #region world configuration // Create a physics world using default config collisionConfiguration = new DefaultCollisionConfiguration(); dispatcher = new CollisionDispatcher(collisionConfiguration); GImpactCollisionAlgorithm.RegisterAlgorithm(dispatcher); constraintSolver = new SequentialImpulseConstraintSolver(); overlappingPairCache = new DbvtBroadphase(); dynamicsWorld = new DiscreteDynamicsWorld(dispatcher, overlappingPairCache, constraintSolver, collisionConfiguration); var gravity = new TGCVector3(0, -60f, 0).ToBsVector; dynamicsWorld.Gravity = gravity; if (UsingHeightmap) { var heightMap = BulletRigidBodyConstructor.CreateSurfaceFromHeighMap(triangleDataVB); heightMap.Restitution = 0; dynamicsWorld.AddRigidBody(heightMap); } #endregion float radius = 30f; float mass = 0.75f; var centerOfMass = new TGCVector3(-50f, 30, -200f); TGCVector3 size = TGCVector3.Empty; #region Stone Sphere ball = BulletRigidBodyConstructor.CreateBall(radius, mass, centerOfMass); ball.SetDamping(0.1f, 0.5f); ball.Restitution = 1f; ball.Friction = 1; dynamicsWorld.AddRigidBody(ball); var ballTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, $"{MediaDir}\\Textures\\rockwall.jpg"); sphereMesh = new TGCSphere(radius, ballTexture, TGCVector3.Empty); sphereMesh.BoundingSphere.setValues(centerOfMass, radius); sphereMesh.updateValues(); director = new TGCVector3(1, 0, 0); #endregion #region BandicootRigidBody //Cuerpo rigido de una caja basica var position = new TGCVector3(0, 1, 0); mass = 1.5f; bandicootRigidBody = BulletRigidBodyConstructor.CreateCapsule(10, 5, position, mass, false); //Valores que podemos modificar a partir del RigidBody base bandicootRigidBody.SetDamping(0.1f, 0f); bandicootRigidBody.Restitution = 0f; bandicootRigidBody.Friction = 0.5f; bandicootRigidBody.InvInertiaDiagLocal = TGCVector3.Empty.ToBsVector; //Agregamos el RidigBody al World dynamicsWorld.AddRigidBody(bandicootRigidBody); #endregion #region Stairs mass = 0; size = new TGCVector3(50, 20, 30); var platformTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, $"{MediaDir}\\textures\\rockwall.jpg"); float angle = 0.75f * FastMath.PI; for (float i = 0, x = size.Z, y = size.Y, z = -size.X; i < 10; i++) { staticPlatform = BulletRigidBodyConstructor.CreateBox(size, mass, centerOfMass, 0, 0, 0, 0.7f); staticPlatform.CenterOfMassTransform = TGCMatrix.RotationY(angle).ToBsMatrix *TGCMatrix.Translation(x, y, z).ToBsMatrix; dynamicsWorld.AddRigidBody(staticPlatform); staticPlatformMesh = TGCBox.fromSize(2 * size, platformTexture); staticPlatformMesh.Transform = new TGCMatrix(staticPlatform.InterpolationWorldTransform); stairsMesh.Add(staticPlatformMesh); x += 35; y += 40; z -= 25; angle -= 0.1f; } #endregion #region Dynamic Platform position = new TGCVector3(0, 0, 0); mass = 1f; size = new TGCVector3(70, 10, 30); dynamicPlatform = BulletRigidBodyConstructor.CreateBox(size, mass, position, 0, 0, 0, 2f); dynamicPlatform.CenterOfMassTransform = TGCMatrix.Translation(-300, 60, -200).ToBsMatrix; dynamicPlatform.AngularFactor = (new Vector3(0, 0, 0)); dynamicsWorld.AddRigidBody(dynamicPlatform); // mesh para visualizar plataforma var platformtexture = TgcTexture.createTexture(D3DDevice.Instance.Device, $"{MediaDir}\\textures\\rockwall.jpg"); dynamicPlatformMesh = TGCBox.fromSize(2 * size, platformtexture); dynamicPlatformMesh.Transform = new TGCMatrix(dynamicPlatform.InterpolationWorldTransform); dynamicPlatformMesh.AutoTransformEnable = false; dynamicPlatformMesh.updateValues(); #endregion }
public void Init(IGameModel ctx) { #region World configuration this.ctx = ctx; // Create a physics world using default config collisionConfiguration = new DefaultCollisionConfiguration(); dispatcher = new CollisionDispatcher(collisionConfiguration); GImpactCollisionAlgorithm.RegisterAlgorithm(dispatcher); constraintSolver = new SequentialImpulseConstraintSolver(); overlappingPairCache = new DbvtBroadphase(); dynamicsWorld = new DiscreteDynamicsWorld(dispatcher, overlappingPairCache, constraintSolver, collisionConfiguration) { Gravity = new TGCVector3(0, -15f, 0).ToBsVector }; var heightMap = BulletRigidBodyConstructor.CreateSurfaceFromHeighMap(ctx.Terrain.getData()); heightMap.Restitution = 0; dynamicsWorld.AddRigidBody(heightMap); #endregion #region BandicootRigidBody var position = new TGCVector3(0, 1, 0); var mass = 1.5f; var radius = 10; var height = 5; BandicootRigidBody = BulletRigidBodyConstructor.CreateCapsule(radius, height, position, mass, false); BandicootRigidBody.SetDamping(0.1f, 0); BandicootRigidBody.Restitution = 0f; BandicootRigidBody.Friction = 0.15f; BandicootRigidBody.InvInertiaDiagLocal = TGCVector3.Empty.ToBsVector; BandicootRigidBody.CenterOfMassTransform = TGCMatrix.Translation(-900, 1000, 900).ToBsMatrix; dynamicsWorld.AddRigidBody(BandicootRigidBody); #endregion #region Rocks var size = new TGCVector3(200, 150, 200); mass = 0; var centerOfMass = TGCVector3.Empty; var rockFriction = 1.5f; var translation = TGCMatrix.Translation(-900, size.Y, 900); // Rock1 Body Rock1Body = BulletRigidBodyConstructor.CreateBox(size, mass, centerOfMass, 0, 0, 0, rockFriction); Rock1Body.CenterOfMassTransform = translation.ToBsMatrix; dynamicsWorld.AddRigidBody(Rock1Body); // Rock1 Mesh var canyonTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, $"{ctx.MediaDir}\\Textures\\canyon-horizontal.png"); Rock1Mesh = TGCBox.fromSize(centerOfMass, 2 * size, canyonTexture); Rock1Mesh.Transform = new TGCMatrix(Rock1Body.InterpolationWorldTransform); // Rock2 Body size = new TGCVector3(100, 150, 100); Rock2Body = BulletRigidBodyConstructor.CreateBox(size, mass, centerOfMass, 0, 0, 0, rockFriction); translation *= TGCMatrix.Translation(400, 1, 1); Rock2Body.CenterOfMassTransform = translation.ToBsMatrix; dynamicsWorld.AddRigidBody(Rock2Body); // Rock2 Mesh Rock2Mesh = TGCBox.fromSize(centerOfMass, 2 * size, canyonTexture); Rock2Mesh.Transform = new TGCMatrix(Rock2Body.InterpolationWorldTransform); // Rock3 Body Rock3Body = BulletRigidBodyConstructor.CreateBox(size, mass, centerOfMass, 0, 0, 0, rockFriction); translation *= TGCMatrix.Translation(800, 1, 1); Rock3Body.CenterOfMassTransform = translation.ToBsMatrix; dynamicsWorld.AddRigidBody(Rock3Body); // Rock3 Mesh Rock3Mesh = TGCBox.fromSize(centerOfMass, 2 * size, canyonTexture); Rock3Mesh.Transform = new TGCMatrix(Rock3Body.InterpolationWorldTransform); // Rock4 Body size = new TGCVector3(100, 200, 100); Rock4Body = BulletRigidBodyConstructor.CreateBox(size, mass, centerOfMass, 0, 0, 0, rockFriction); translation *= TGCMatrix.Translation(0, 1, -700); Rock4Body.CenterOfMassTransform = translation.ToBsMatrix; dynamicsWorld.AddRigidBody(Rock4Body); // Rock4 Mesh Rock4Mesh = TGCBox.fromSize(centerOfMass, 2 * size, canyonTexture); Rock4Mesh.Transform = new TGCMatrix(Rock4Body.InterpolationWorldTransform); // Rock5 Body Rock5Body = BulletRigidBodyConstructor.CreateBox(size, mass, centerOfMass, 0, 0, 0, rockFriction); translation *= TGCMatrix.Translation(1, 1, -900); Rock5Body.CenterOfMassTransform = translation.ToBsMatrix; dynamicsWorld.AddRigidBody(Rock5Body); // Rock5 Mesh Rock5Mesh = TGCBox.fromSize(centerOfMass, 2 * size, canyonTexture); Rock5Mesh.Transform = new TGCMatrix(Rock5Body.InterpolationWorldTransform); #endregion #region Dynamic Platforms mass = 1f; size = new TGCVector3(70, 10, 40); var platformFriction = 2.5f; // DynamicPlatform1 Body DynamicPlatform1Body = BulletRigidBodyConstructor.CreateBox(size, mass, centerOfMass, 0, 0, 0, platformFriction); DynamicPlatform1Body.AngularFactor = new Vector3(0, 0, 0); DynamicPlatform1Body.CenterOfMassTransform = TGCMatrix.RotationY(FastMath.PI_HALF).ToBsMatrix *TGCMatrix.Translation(distance, 300, 900).ToBsMatrix; dynamicsWorld.AddRigidBody(DynamicPlatform1Body); // DynamicPlatform1 Mesh var platformtexture = TgcTexture.createTexture(D3DDevice.Instance.Device, $"{ctx.MediaDir}\\textures\\rockwall.jpg"); DynamicPlatform1Mesh = TGCBox.fromSize(2 * size, platformtexture); DynamicPlatform1Mesh.Transform = new TGCMatrix(DynamicPlatform1Body.InterpolationWorldTransform); // DynamicPlatform2 Body DynamicPlatform2Body = BulletRigidBodyConstructor.CreateBox(size, mass, centerOfMass, 0, 0, 0, platformFriction); DynamicPlatform2Body.AngularFactor = new Vector3(0, 0, 0); DynamicPlatform2Body.CenterOfMassTransform = TGCMatrix.Translation(300, 300, 700).ToBsMatrix; dynamicsWorld.AddRigidBody(DynamicPlatform2Body); // DynamicPlatform2 Mesh var platformtexture2 = TgcTexture.createTexture(D3DDevice.Instance.Device, $"{ctx.MediaDir}\\textures\\rockwall.jpg"); DynamicPlatform2Mesh = TGCBox.fromSize(2 * size, platformtexture); DynamicPlatform2Mesh.Transform = new TGCMatrix(DynamicPlatform2Body.InterpolationWorldTransform); // DynamicPlatform3 Body DynamicPlatform3Body = BulletRigidBodyConstructor.CreateBox(size, mass, centerOfMass, 0, 0, 0, platformFriction); DynamicPlatform3Body.AngularFactor = new Vector3(0, 0, 0); DynamicPlatform3Body.CenterOfMassTransform = TGCMatrix.Translation(300, 350, 0).ToBsMatrix; dynamicsWorld.AddRigidBody(DynamicPlatform3Body); // DynamicPlatform3 Mesh platformtexture2 = TgcTexture.createTexture(D3DDevice.Instance.Device, $"{ctx.MediaDir}\\textures\\rockwall.jpg"); DynamicPlatform3Mesh = TGCBox.fromSize(2 * size, platformtexture); DynamicPlatform3Mesh.Transform = new TGCMatrix(DynamicPlatform3Body.InterpolationWorldTransform); #endregion }
public void Init(String MediaDir) { #region Configuracion Basica de World //Creamos el mundo fisico por defecto. collisionConfiguration = new DefaultCollisionConfiguration(); dispatcher = new CollisionDispatcher(collisionConfiguration); GImpactCollisionAlgorithm.RegisterAlgorithm(dispatcher); constraintSolver = new SequentialImpulseConstraintSolver(); overlappingPairCache = new DbvtBroadphase(); //AxisSweep3(new BsVector3(-5000f, -5000f, -5000f), new BsVector3(5000f, 5000f, 5000f), 8192); dynamicsWorld = new DiscreteDynamicsWorld(dispatcher, overlappingPairCache, constraintSolver, collisionConfiguration); dynamicsWorld.Gravity = new TGCVector3(0, -100f, 0).ToBsVector; #endregion Configuracion Basica de World #region Capsula //Cuerpo rigido de una capsula basica capsuleRigidBody = BulletRigidBodyConstructor.CreateCapsule(10, 50, new TGCVector3(200, 500, 200), 10, false); //Valores que podemos modificar a partir del RigidBody base capsuleRigidBody.SetDamping(0.1f, 0f); capsuleRigidBody.Restitution = 0.1f; capsuleRigidBody.Friction = 1; //Agregamos el RidigBody al World dynamicsWorld.AddRigidBody(capsuleRigidBody); #endregion Capsula #region Terreno //Creamos el RigidBody basico del Terreno var meshRigidBody = BulletRigidBodyConstructor.CreateSurfaceFromHeighMap(triangleDataVB); //Agregamos algo de friccion al RigidBody ya que este va a interactuar con objetos moviles //del World meshRigidBody.Friction = 0.5f; //Agregamos el RigidBody del terreno al World dynamicsWorld.AddRigidBody(meshRigidBody); #endregion Terreno #region Esfera //Creamos una esfera para interactuar pokeball = BulletRigidBodyConstructor.CreateBall(10f, 0.5f, new TGCVector3(100f, 500f, 100f)); pokeball.SetDamping(0.1f, 0.5f); pokeball.Restitution = 1f; //Agregamos la pokebola al World dynamicsWorld.AddRigidBody(pokeball); //Textura de pokebola var texturePokeball = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + @"Texturas\pokeball.jpg"); //Se crea una esfera de tamaño 1 para escalarla luego (en render) sphereMesh = new TGCSphere(1, texturePokeball, TGCVector3.Empty); //Tgc no crea el vertex buffer hasta invocar a update values. sphereMesh.updateValues(); #endregion Esfera #region Personaje //Cargamos personaje var skeletalLoader = new TgcSkeletalLoader(); personaje = skeletalLoader.loadMeshAndAnimationsFromFile( MediaDir + "SkeletalAnimations\\Robot\\Robot-TgcSkeletalMesh.xml", MediaDir + "SkeletalAnimations\\Robot\\", new[] { MediaDir + "SkeletalAnimations\\Robot\\Caminando-TgcSkeletalAnim.xml", MediaDir + "SkeletalAnimations\\Robot\\Parado-TgcSkeletalAnim.xml" }); //Le cambiamos la textura para diferenciarlo un poco personaje.changeDiffuseMaps(new[] { TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "SkeletalAnimations\\Robot\\Textures\\uvwGreen.jpg") }); //Configurar animacion inicial personaje.playAnimation("Parado", true); #endregion Personaje #region Cajas var sizeBox = 20f; //Textura de caja var textureBox = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + @"MeshCreator\Textures\Madera\cajaMadera2.jpg"); box = BulletRigidBodyConstructor.CreateBox(new TGCVector3(sizeBox, sizeBox, sizeBox), 0, new TGCVector3(0, 12, 0), 0, 0, 0, 0.5f); dynamicsWorld.AddRigidBody(box); boxMesh = TGCBox.fromSize(new TGCVector3(40f, 40f, 40f), textureBox); boxMesh.updateValues(); sizeBox = 40f; boxB = BulletRigidBodyConstructor.CreateBox(new TGCVector3(sizeBox, sizeBox, sizeBox), 0, new TGCVector3(100, 40, 0), 0, 0, 0, 0.5f); dynamicsWorld.AddRigidBody(boxB); boxMeshB = TGCBox.fromSize(new TGCVector3(80f, 80f, 80f), textureBox); boxMeshB.updateValues(); box45 = BulletRigidBodyConstructor.CreateBox(new TGCVector3(sizeBox, sizeBox, sizeBox), 0, new TGCVector3(200, 40, 0), BulletSharp.MathUtil.SIMD_QUARTER_PI, 0, 0, 0.5f); dynamicsWorld.AddRigidBody(box45); boxPush = BulletRigidBodyConstructor.CreateBox(new TGCVector3(sizeBox, sizeBox, sizeBox), 0.5f, new TGCVector3(-200, 60, 0), BulletSharp.MathUtil.SIMD_QUARTER_PI, 0, 0, 0.25f); dynamicsWorld.AddRigidBody(boxPush); boxMeshPush = TGCBox.fromSize(new TGCVector3(80f, 80f, 80f), textureBox); boxMeshPush.updateValues(); #endregion Cajas #region Escalera var a = 0; var textureStones = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + @"Texturas\stones.bmp"); //la altura de cualquier cubo que quiera subir una capsula debe ser menor a la mitad del radio var size = new TGCVector3(50, 4, 20); escalon = TGCBox.fromSize(size, textureStones); //Se crean 10 escalonescd d while (a < 10) { escalonRigidBody = BulletRigidBodyConstructor.CreateBox(size, 0, new TGCVector3(200, a * 4 + 10, a * 20 + 100), 0, 0, 0, 0.1f); escalonesRigidBodies.Add(escalonRigidBody); dynamicsWorld.AddRigidBody(escalonRigidBody); a++; } #endregion Escalera #region Plataforma textureStones = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + @"Texturas\cobblestone_quad.jpg"); rigidBodyPlataforma = BulletRigidBodyConstructor.CreateBox(new TGCVector3(50f, 15f, 50f), 0, new TGCVector3(200, 42.5f, 315), 0, 0, 0, 0.5f); dynamicsWorld.AddRigidBody(rigidBodyPlataforma); plataforma = TGCBox.fromSize(new TGCVector3(50f, 15f, 50f), textureStones); plataforma.updateValues(); #endregion Plataforma #region Columna columnaRigidBody = BulletRigidBodyConstructor.CreateCylinder(new TGCVector3(10, 50, 10), new TGCVector3(100, 50, 100), 0); dynamicsWorld.AddRigidBody(columnaRigidBody); var columnaLoader = new TgcSceneLoader(); columnaMesh = columnaLoader.loadSceneFromFile(MediaDir + @"MeshCreator\Meshes\Cimientos\PilarEgipcio\PilarEgipcio-TgcScene.xml", MediaDir + @"MeshCreator\Meshes\Cimientos\PilarEgipcio\").Meshes[0]; columnaMesh.Position = new TGCVector3(100, 7.5f, 100); columnaMesh.UpdateMeshTransform(); #endregion Columna director = new TGCVector3(0, 0, 1); }