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(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); }
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 override void Init(GameModel _env) { Env = _env; string compilationErrors; var d3dDevice = D3DDevice.Instance.Device; EfectoRender2D = Microsoft.DirectX.Direct3D.Effect.FromFile(d3dDevice, Env.ShadersDir + "render2D.fx", null, null, ShaderFlags.PreferFlowControl, null, out compilationErrors); shadowEffect = TgcShaders.loadEffect(Env.ShadersDir + "ShadowMap.fx"); skeletalShadowEffect = TgcShaders.loadEffect(Env.ShadersDir + "TgcSkeletalShadowMapMeshShader.fx"); shadowEffect.SetValue("EPSILON", 0.005f); g_LightPos = new TGCVector3(0, 1000, 0); g_LightDir = new TGCVector3(0, -1, 0); g_LightDir.Normalize(); if (EfectoRender2D == null) { throw new Exception("Error al cargar shader. Errores: " + compilationErrors); } EfectoRender2D.SetValue("screen_dx", d3dDevice.PresentationParameters.BackBufferWidth); EfectoRender2D.SetValue("screen_dy", d3dDevice.PresentationParameters.BackBufferHeight); try { texturaVida = TextureLoader.FromFile(d3dDevice, Env.MediaDir + "\\Menu\\heart.png"); } catch { throw new Exception(string.Format("Error at loading texture: {0}", Env.MediaDir + "\\Menu\\heart.png")); } //Crear pisos var AlfombraTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, Env.MediaDir + "carpet.jpg"); var PiedraTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, Env.MediaDir + "piedra.jpg"); base.Init(Env); Env.Personaje.Mesh.updateBoundingBox(); var aabb = Env.Personaje.Mesh.BoundingBox; capsulePJ = BulletRigidBodyConstructor.CreateCapsule((aabb.PMax.X - aabb.PMin.X) / 2, (aabb.PMax.Y - aabb.PMin.Y) / 2, new TGCVector3(0, 0, 0)); capsulePJ.CollisionFlags = CollisionFlags.CharacterObject | capsulePJ.CollisionFlags; dynamicsWorld.AddRigidBody(capsulePJ); boxes = new List <Tuple <TGCBox, RigidBody> >(); Paredes = new List <Tuple <TGCBox, RigidBody> >(); var RoomSize = 500f; var RoomHeight = 500f; //piso Paredes.Add(addBox(new TGCVector3(0f, -1f, 0f), new TGCVector3(RoomSize, 1, RoomSize), AlfombraTexture)); //paredes Paredes.Add(addBox(new TGCVector3(0f, -1f, RoomSize / 2), new TGCVector3(RoomSize, RoomHeight, 1), PiedraTexture)); Paredes.Add(addBox(new TGCVector3(0f, -1f, -RoomSize / 2), new TGCVector3(RoomSize, RoomHeight, 1), PiedraTexture)); Paredes.Add(addBox(new TGCVector3(-RoomSize / 2, -1f, 0f), new TGCVector3(1, RoomHeight, RoomSize), PiedraTexture)); Paredes.Add(addBox(new TGCVector3(RoomSize / 2, -1f, 0f), new TGCVector3(1, RoomHeight, RoomSize), PiedraTexture)); Paredes.Add(addBox(new TGCVector3(0f, RoomHeight, RoomSize / 2), new TGCVector3(RoomSize, RoomHeight, 1), PiedraTexture)); Paredes.Add(addBox(new TGCVector3(0f, RoomHeight, -RoomSize / 2), new TGCVector3(RoomSize, RoomHeight, 1), PiedraTexture)); Paredes.Add(addBox(new TGCVector3(-RoomSize / 2, RoomHeight, 0f), new TGCVector3(1, RoomHeight, RoomSize), PiedraTexture)); Paredes.Add(addBox(new TGCVector3(RoomSize / 2, RoomHeight, 0f), new TGCVector3(1, RoomHeight, RoomSize), PiedraTexture)); // Sobrepisos Paredes.Add(addBox(new TGCVector3(0f, 3f, 75f / 2f + (200 + 25f / 2f) / 2), new TGCVector3(500, 2, 200 + 25f / 2f), AlfombraTexture)); Paredes.Add(addBox(new TGCVector3(0f, 3f, -(75f / 2f) - (200 + 25f / 2f) / 2), new TGCVector3(500, 2, 200 + 25f / 2f), AlfombraTexture)); Paredes.Add(addBox(new TGCVector3(-250f + 75f / 2f, 3f, 0), new TGCVector3(75, 2, 75f), AlfombraTexture)); // Arrastrable/Movible addBox(new TGCVector3(-50f, 75f / 2f, 0f), new TGCVector3(75, 75, 75), PiedraTexture, 100); //Escalones primera pared addBox(new TGCVector3(217f, 130f, 100f), new TGCVector3(75, 75, 75), PiedraTexture); addBox(new TGCVector3(217f, 210f, 180f), new TGCVector3(75, 75, 75), PiedraTexture); // Plataformas Giratorias addSpinningPlatform(new TGCVector3(0f, 225f, 0f), new TGCVector3(100, 50, 100), PiedraTexture, 100000000000f); addSpinningPlatform(new TGCVector3(0f, 610f, 0f), new TGCVector3(60, 30, 60), PiedraTexture, 100000000000f); addSpinningPlatform(new TGCVector3(0f, 660f, 0f), new TGCVector3(50, 25, 50), PiedraTexture, 100000000000f); // Escalones segunda pared addBox(new TGCVector3(-217f, 210f, 180f), new TGCVector3(75, 75, 75), PiedraTexture); addBox(new TGCVector3(-217f, 320f, 80f), new TGCVector3(75, 75, 75), PiedraTexture); addBox(new TGCVector3(-217f, 430f, -20f), new TGCVector3(75, 75, 75), PiedraTexture); addBox(new TGCVector3(-217f, 540f, -110f), new TGCVector3(75, 75, 75), PiedraTexture); Reset(); dynamicsWorld.SetInternalTickCallback((DynamicsWorld world, float timeStep) => { for (int i = 0; i < world.Dispatcher.NumManifolds; i++) { var manifold = world.Dispatcher.GetManifoldByIndexInternal(i); PlataformaGiratoriaBullet giratoria = null; if (manifold.Body0 == capsulePJ) { giratoria = giratorias.Find(g => g.Body == manifold.Body1); } else if (manifold.Body1 == capsulePJ) { giratoria = giratorias.Find(g => g.Body == manifold.Body0); } if (giratoria != null) { Vector3 pmax, pmin, aux; giratoria.Body.CollisionShape.GetAabb(giratoria.Body.WorldTransform, out aux, out pmax); capsulePJ.CollisionShape.GetAabb(capsulePJ.WorldTransform, out pmin, out aux); if (pmin.Y >= pmax.Y - 1) { var t = capsulePJ.CenterOfMassTransform; t.Origin += giratoria.Delta; capsulePJ.CenterOfMassTransform = t; } } } } ); }