private void InitializePlanes() { var baldosas = TgcTexture.createTexture(MediaDir + "Texturas\\baldosasceramica.jpg"); var lisa = TgcTexture.createTexture(MediaDir + "Texturas\\paredLisa.jpg"); List <TgcPlane> planeCollection = new List <TgcPlane> { new TgcPlane(new TGCVector3(-500.0f, 0f, -500.0f), new TGCVector3(1000f, 1f, 1000f), TgcPlane.Orientations.XZplane, baldosas, 10f, 10f), new TgcPlane(new TGCVector3(500.0f, 0f, -500.0f), new TGCVector3(0f, 400f, 1000f), TgcPlane.Orientations.YZplane, lisa, 23.2f, 16.8f), new TgcPlane(new TGCVector3(500.0f, 0f, -500.0f), new TGCVector3(0f, 400f, 1000f), TgcPlane.Orientations.YZplane, lisa, 23.2f, 16.8f), new TgcPlane(new TGCVector3(-500.0f, 0f, -500.0f), new TGCVector3(1000f, 400f, 0f), TgcPlane.Orientations.XYplane, lisa, 23.2f, 16.8f), new TgcPlane(new TGCVector3(-500.0f, 0f, -500.0f), new TGCVector3(1000f, 400f, 0f), TgcPlane.Orientations.XYplane, lisa, 23.2f, 16.8f), }; planeCollection.ForEach(plane => plane.updateValues()); int index = 0; planes = planeCollection.ConvertAll(plane => { index++; return(plane.toMesh("plane" + index.ToString())); }); // Orient the planes to the center of the scene planes[0].Transform = TGCMatrix.RotationX(FastMath.PI) * planes[0].Transform; planes[1].Transform = TGCMatrix.RotationY(FastMath.PI) * planes[1].Transform; planes[3].Transform = TGCMatrix.RotationY(FastMath.PI) * planes[3].Transform; planes.ForEach(plane => { plane.Effect = effect; plane.Technique = "Wall"; }); planes[0].Technique = "Blinn"; }
public void Render() { // Renderizar la malla del auto, en este caso solo el Chasis Mesh.Transform = TGCMatrix.Translation(new TGCVector3(0, meshAxisRadius.Y - (meshRealHeight / 2f), 0)) * new TGCMatrix(rigidBody.InterpolationWorldTransform); Mesh.Render(); TGCMatrix wheelTransform; // Como las ruedas no son cuerpos rigidos (aún) se procede a realizar las transformaciones de las ruedas para renderizar wheelTransform = TGCMatrix.RotationY(vehicle.GetSteeringValue(0)) * TGCMatrix.RotationTGCQuaternion(new TGCQuaternion(RigidBody.Orientation.X, RigidBody.Orientation.Y, RigidBody.Orientation.Z, RigidBody.Orientation.W)) * TGCMatrix.Translation(new TGCVector3(vehicle.GetWheelInfo(0).WorldTransform.Origin)); wheel.Transform = wheelTransform; wheel.Render(); wheelTransform = TGCMatrix.RotationY(vehicle.GetSteeringValue(1) + FastMath.PI) * TGCMatrix.RotationTGCQuaternion(new TGCQuaternion(RigidBody.Orientation.X, RigidBody.Orientation.Y, RigidBody.Orientation.Z, RigidBody.Orientation.W)) * TGCMatrix.Translation(new TGCVector3(vehicle.GetWheelInfo(1).WorldTransform.Origin)); wheel.Transform = wheelTransform; wheel.Render(); wheelTransform = TGCMatrix.RotationY(-vehicle.GetSteeringValue(2)) * TGCMatrix.RotationTGCQuaternion(new TGCQuaternion(RigidBody.Orientation.X, RigidBody.Orientation.Y, RigidBody.Orientation.Z, RigidBody.Orientation.W)) * TGCMatrix.Translation(new TGCVector3(vehicle.GetWheelInfo(2).WorldTransform.Origin)); wheel.Transform = wheelTransform; wheel.Render(); wheelTransform = TGCMatrix.RotationY(-vehicle.GetSteeringValue(3) + FastMath.PI) * TGCMatrix.RotationTGCQuaternion(new TGCQuaternion(RigidBody.Orientation.X, RigidBody.Orientation.Y, RigidBody.Orientation.Z, RigidBody.Orientation.W)) * TGCMatrix.Translation(new TGCVector3(vehicle.GetWheelInfo(3).WorldTransform.Origin)); wheel.Transform = wheelTransform; wheel.Render(); }
public void rotar(float angulo) { director.TransformCoordinate(TGCMatrix.RotationY(-angulo * 0.01f)); personaje.Transform = TGCMatrix.Translation(TGCVector3.Empty) * TGCMatrix.RotationY(-angulo * 0.01f) * new TGCMatrix(personajeBody.InterpolationWorldTransform); personajeBody.WorldTransform = personaje.Transform.ToBsMatrix; personaje.RotateY(-angulo * 0.01f); }
public void Init(GameModel gameModel) { GModel = gameModel; //Cargar personaje con animaciones var skeletalLoader = new TgcSkeletalLoader(); personaje = skeletalLoader.loadMeshAndAnimationsFromFile( GModel.MediaDir + "SkeletalAnimations\\Robot\\Robot-TgcSkeletalMesh.xml", GModel.MediaDir + "SkeletalAnimations\\Robot\\", new[] { GModel.MediaDir + "SkeletalAnimations\\Robot\\Caminando-TgcSkeletalAnim.xml", GModel.MediaDir + "SkeletalAnimations\\Robot\\Parado-TgcSkeletalAnim.xml" }); //Esto hay que desactivarlo personaje.AutoTransform = false; //Posicion inicial personaje.Position = new TGCVector3(250, 20, 20); matrizPosicionamientoPersonaje = TGCMatrix.Translation(personaje.Position.X, personaje.Position.Y, personaje.Position.Z); checkpoint = personaje.Position; matrizEscalaPersonaje = TGCMatrix.Scaling(0.25f, 0.25f, 0.25f); //La matriz comienza asi porque el personaje comienza dado vuelta matrizRotacionPersonajeY = TGCMatrix.RotationY(FastMath.PI); saltando = false; collider = new TgcBoundingAxisAlignBox(); }
private void InitializeMeshes() { TgcTexture tiles, lava, stones, water; tiles = TgcTexture.createTexture(MediaDir + "Textures/tiles.jpg"); lava = TgcTexture.createTexture(MediaDir + "Textures/lava.jpg"); stones = TgcTexture.createTexture(MediaDir + "Textures/stones.bmp"); water = TgcTexture.createTexture(MediaDir + "Textures/water.bmp"); TGCSphere baseSphere = new TGCSphere(1f, Color.White, TGCVector3.Empty); baseSphere.setTexture(lava); baseSphere.updateValues(); sphereOne = baseSphere.toMesh("sphereOne"); meshes.Add(sphereOne); baseSphere.setTexture(stones); sphereTwo = baseSphere.toMesh("sphereTwo"); meshes.Add(sphereTwo); baseSphere.setTexture(water); sphereThree = baseSphere.toMesh("sphereThree"); meshes.Add(sphereThree); TgcSceneLoader loader = new TgcSceneLoader(); var scene = loader.loadSceneFromFile(MediaDir + "Robot2-TgcScene.xml"); robot = scene.Meshes[0]; robot.Transform = TGCMatrix.Scaling(0.1f, 0.1f, 0.1f) * TGCMatrix.RotationY(FastMath.PI) * TGCMatrix.Translation(TGCVector3.Up * 40f); meshes.Add(robot); TgcPlane tgcPlane = new TgcPlane(TGCVector3.Empty, TGCVector3.One * 100f, TgcPlane.Orientations.XZplane, tiles, 10f, 10f); plane = tgcPlane.toMesh("plane"); meshes.Add(plane); }
public void CalculatePositionTarget(out TGCVector3 pos, out TGCVector3 targetCenter) { targetCenter = TGCVector3.Add(Target, TargetDisplacement); var m = TGCMatrix.Translation(0, OffsetHeight, OffsetForward) * TGCMatrix.RotationY(RotationY) * TGCMatrix.Translation(targetCenter); pos = new TGCVector3(m.M41, m.M42, m.M43); }
public override void UpdateCamera(float elapsedTime) { var moveVector = actualizarMoveVector(); #region actualizarTransformacion //Solo rotar si se esta aprentando el boton izq del mouse if (Input.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT)) { leftrightRot -= -Input.XposRelative * RotationSpeed; updownRot -= Input.YposRelative * RotationSpeed; cameraRotation = TGCMatrix.RotationX(updownRot) * TGCMatrix.RotationY(leftrightRot); // cameraRotation = TGCMatrix.RotationY(leftrightRot); } var cameraRotatedPositionEye = TGCVector3.TransformNormal(moveVector * elapsedTime, cameraRotation); positionEye += cameraRotatedPositionEye; //Calculamos el target de la camara, segun su direccion inicial y las rotaciones en screen space x,y. var cameraRotatedTarget = TGCVector3.TransformNormal(directionView, cameraRotation); var cameraFinalTarget = positionEye + cameraRotatedTarget; //Se calcula el nuevo vector de up producido por el movimiento del update. var cameraOriginalUpVector = DEFAULT_UP_VECTOR; var cameraRotatedUpVector = TGCVector3.TransformNormal(cameraOriginalUpVector, cameraRotation); #endregion base.SetCamera(positionEye, cameraFinalTarget, cameraRotatedUpVector); }
/** * Posicion nave: Posicion inicial del misil * coordenadaEsfericaP: Direccion y sentido del misil * Rotacion nave: Constante con el que misil se rota inicialmente para estar alineado a la trayectoria * pathscene: Path donde esta ubicado el mesh * */ public Misil(TGCVector3 posicionInicial, CoordenadaEsferica coordenadaEsferica, TGCVector3 rotacionInicial, string pathScene, OrigenMisil origenMisil) { this.rotation = rotacionInicial; this.coordenadaEsferica = coordenadaEsferica; this.position = posicionInicial; this.scaleVector = new TGCVector3(.2f, .2f, 4f); velocidadGeneral = 1000; meshs = new TgcMesh[1]; meshs[0] = VariablesGlobales.loader.loadSceneFromFile(VariablesGlobales.mediaDir + pathScene).Meshes[0]; meshs[0].AutoTransformEnable = false; matrizInicialTransformacion = TGCMatrix.RotationY(FastMath.PI_HALF); if (VariablesGlobales.SHADERS) { Effect shader = VariablesGlobales.shaderManager.AskForEffect(ShaderManager.MESH_TYPE.SHADOW); if (shader != null) { meshs[0].Effect = shader; } VariablesGlobales.shaderManager.AddObject(this); } switch (origenMisil) { case OrigenMisil.ENEMIGO: collisionObject = VariablesGlobales.physicsEngine.AgregarMisilEnemigo(meshs[0].BoundingBox.calculateSize()); break; case OrigenMisil.XWING: collisionObject = VariablesGlobales.physicsEngine.AgregarMisilXwing(meshs[0].BoundingBox.calculateSize()); break; } }
private TGCMatrix getSunTransform() { var scale = TGCMatrix.Scaling(SUN_SCALE); var yRot = TGCMatrix.RotationY(axisRotation); return(scale * yRot); }
private void Init() { prevLatitude = Camera.Latitude; Constants.PLANE_DIRECTOR.TransformCoordinate(TGCMatrix.RotationY(FastMath.PI_HALF)); Body = RigidBodyFactory.CreateCapsule(Constants.CAPSULE_RADIUS, Constants.CAPSULE_SIZE, Constants.INDOOR_POSITION, 1f, false); Body.CenterOfMassTransform = TGCMatrix.Translation(Constants.INDOOR_POSITION).ToBulletMatrix(); }
public virtual void Roam() { LookDirection = new TGCVector3(LookDirection.X, 0, LookDirection.Z); // Elimino la componente Y para que roamee al nivel que esta del agua timeSinceLastDirection += GameInstance.ElapsedTime; TGCVector3 rotationVector = TGCVector3.Empty; if (timeSinceLastDirection > timeToChangeDirection) { timeSinceLastDirection = 0f; timeToChangeDirection = MathExtended.GetRandomNumberBetween(2, 5); float randomX = MathExtended.GetRandomNumberBetween(-100, 100); float randomZ = MathExtended.GetRandomNumberBetween(-100, 100); TGCVector3 lastDirection = LookDirection; LookDirection = TGCVector3.Normalize(new TGCVector3(randomX, LookDirection.Y, randomZ)); float angle = MathExtended.AngleBetween(new TGCVector2(lastDirection.X, lastDirection.Z), new TGCVector2(LookDirection.X, LookDirection.Z)); rotationVector.Y = -angle; } rotation += rotationVector; Position += LookDirection * roamingSpeed * GameInstance.ElapsedTime; TGCMatrix rot = TGCMatrix.RotationY(rotation.Y); TGCMatrix trans = TGCMatrix.Translation(Position); TGCMatrix scal = TGCMatrix.Scaling(scale); Transform = scal * rot * trans; }
public Wheel(TgcMesh mesh, TGCVector3 traslado) { this.mesh = mesh; mesh.AutoTransform = false; trasladoInicial = TGCMatrix.Translation(traslado); vectorLimiteIzquierdo.TransformCoordinate(TGCMatrix.RotationY(-FastMath.QUARTER_PI)); vectorLimiteDerecho.TransformCoordinate(TGCMatrix.RotationY(FastMath.QUARTER_PI)); }
private void Rotation() { Latitude -= -Input.XposRelative * Constants.ROTATION_SPEED; Longitude -= Input.YposRelative * Constants.ROTATION_SPEED; Longitude = FastMath.Clamp(Longitude, Constants.LIMIT_MIN, Constants.LIIMIT_MAX); CameraRotation = TGCMatrix.RotationX(Longitude) * TGCMatrix.RotationY(Latitude); }
public void execute() { if (model.Input.keyDown(Key.Left) || model.Input.keyDown(Key.A)) { model.BandicootCamera.rotateY(-1 * model.ElapsedTime); model.DirectorAngle -= (1 * model.ElapsedTime); model.Rotation = TGCMatrix.RotationY(model.DirectorAngle); } }
public TGCMatrix CalculateCameraRotationY() { if (ConsideringInput) { leftrightRot += Input.XposRelative * RotationSpeed; } return(TGCMatrix.RotationY(leftrightRot)); }
private void ChangeFishWay() { TGCMatrix Rotation = TGCMatrix.RotationY(-RotationYSign() * FastMath.PI_HALF); director.TransformCoordinate(Rotation); TotalRotation *= Rotation; Mesh.Mesh.Transform = TGCMatrix.Scaling(Constants.Scale) * TotalRotation * TGCMatrix.Translation(GetMeshPosition()); time = Constants.ScapeFromPlayerCooldown; }
/// <summary> /// Genera la proxima matriz de view, sin actualizar aun los valores internos /// </summary> /// <param name="pos">Futura posicion de camara generada</param> /// <param name="targetCenter">Futuro centro de camara a generada</param> public void CalculatePositionTarget(out TGCVector3 pos, out TGCVector3 targetCenter) { //alejarse, luego rotar y lueg ubicar camara en el centro deseado targetCenter = TGCVector3.Add(Target, TargetDisplacement); var m = TGCMatrix.Translation(0, OffsetHeight, OffsetForward) * TGCMatrix.RotationY(RotationY) * TGCMatrix.Translation(targetCenter); //Extraer la posicion final de la matriz de transformacion pos = new TGCVector3(m.M41, m.M42, m.M43); }
/// <summary> /// Genera la proxima matriz de view, sin actualizar aun los valores internos /// </summary> /// <param name="pos">Futura posicion de camara generada</param> /// <param name="targetCenter">Futuro centro de camara a generada</param> public void CalculatePositionTarget(out TGCVector3 pos, out TGCVector3 targetCenter) { //alejarse, luego rotar y lueg ubicar camara en el centro deseado targetCenter = Target; var m = TGCMatrix.Translation(0, DesplazarAltura, DesplazarAdelante) * TGCMatrix.RotationY(RotationY) * TGCMatrix.Translation(targetCenter); //Extraer la posicion final de la matriz de transformacion pos = new TGCVector3(m.M41, m.M42, m.M43); }
private TGCMatrix getEarthTransform() { var scale = TGCMatrix.Scaling(EARTH_SCALE); var yRot = TGCMatrix.RotationY(earthAxisRotation); var sunOffset = TGCMatrix.Translation(EARTH_ORBIT_OFFSET, 0, 0); var earthOrbit = TGCMatrix.RotationY(earthOrbitRotation); return(scale * yRot * sunOffset * earthOrbit); }
private TGCMatrix getMoonTransform(TGCMatrix earthTransform) { var scale = TGCMatrix.Scaling(MOON_SCALE); var yRot = TGCMatrix.RotationY(axisRotation); var earthOffset = TGCMatrix.Translation(MOON_ORBIT_OFFSET, 0, 0); var moonOrbit = TGCMatrix.RotationY(moonOrbitRotation); return(scale * yRot * earthOffset * moonOrbit * earthTransform); }
public TGCMatrix CalculateCameraRotation() { if (ConsideringInput) { leftrightRot += Input.XposRelative * RotationSpeed; updownRot = FastMath.Clamp(updownRot - Input.YposRelative * RotationSpeed, -FastMath.PI_HALF, FastMath.PI_HALF); } return(TGCMatrix.RotationX(updownRot) * TGCMatrix.RotationY(leftrightRot)); }
/// <summary> /// Crear una nueva camara /// </summary> public MamutCamara(TgcD3dInput input) { this.Input = input; this.directionView = new TGCVector3(0, 0, 75); this.RotationSpeed = 1f; this.leftrightRot = FastMath.PI_HALF; this.updownRot = -FastMath.PI / 10.0f; this.cameraRotation = TGCMatrix.RotationX(updownRot) * TGCMatrix.RotationY(leftrightRot); resetValues(); }
public void Update() { //Intento de hacer que la caja3 se traslade entre dos limites de tiempo if (subir) { traslacionCaja3 += velocidadTraslacionCaja * GModel.ElapsedTime; tiempoDeSubida -= GModel.ElapsedTime; if (tiempoDeSubida <= 0) { subir = false; } } else { traslacionCaja3 -= velocidadTraslacionCaja * GModel.ElapsedTime; tiempoDeSubida += GModel.ElapsedTime; if (tiempoDeSubida >= 5) { subir = true; } } //Movimiento caja4 if (movLateral) { traslacionCaja4 += velocidadTraslacionCaja * GModel.ElapsedTime; tiempoDeMovLateral -= GModel.ElapsedTime; if (tiempoDeMovLateral <= 0) { movLateral = false; } } else { traslacionCaja4 -= velocidadTraslacionCaja * GModel.ElapsedTime; tiempoDeMovLateral += GModel.ElapsedTime; if (tiempoDeMovLateral >= 10) { movLateral = true; } } desplazamientoCaja3 = new TGCVector3(0, traslacionCaja3, 0); desplazamientoCaja4 = new TGCVector3(traslacionCaja4, 0, 0); //El problema de plantearlo asi es que la caja que rota sobre un eje Y no seria facil de calcular... desplazamientoCaja5 = new TGCVector3(0, 1, 0); //En base a la traslacion que quiero se actualiza la matriz de traslación movimientoTraslacionY = TGCMatrix.Translation(desplazamientoCaja3); movimientoTraslacionX = TGCMatrix.Translation(desplazamientoCaja4); //Movimiento caja 5 rotacionTotal += velocidadRotacionCaja * GModel.ElapsedTime; movimientoRotacionY = TGCMatrix.RotationY(rotacionTotal); }
/// <summary> /// Genera la proxima matriz de view, sin actualizar aun los valores internos /// </summary> /// <param name="pos">Futura posicion de camara generada</param> /// <param name="targetCenter">Futuro centro de camara a generada</param> public void CalculatePositionTarget(float rotX, float rotY) { //alejarse, luego rotar y lueg ubicar camara en el centro deseado var m = TGCMatrix.Translation(0, OffsetHeight, OffsetForward) * TGCMatrix.RotationX(rotX) * TGCMatrix.RotationY(rotY) * TGCMatrix.Translation(Target); //Extraer la posicion final de la matriz de transformacion NextPos = new TGCVector3(m.M41, m.M42, m.M43); }
public void Girar(float rotacionReal) { var rotacionRueda = (rotacionReal > 0) ? 1f * this.GetElapsedTime() : -1f * this.GetElapsedTime(); TGCMatrix matrizDeRotacion = TGCMatrix.RotationY(rotacionReal); this.Rotate(rotacionReal); this.vectorAdelante.TransformCoordinate(matrizDeRotacion); this.RotarDelanteras((this.GetVelocidadActual() > 0) ? rotacionRueda : -rotacionRueda); //this.camara.interpolador.Acumulate(rotacionReal); this.RotateOBB(rotacionReal); }
public void deformacion_esfera() { timer += ElapsedTime; var variacionY = FastMath.Max(2f, 6f * FastMath.Abs(FastMath.Cos(timer * 1.5f))); var variacionZ = FastMath.Max(2f, 6f * FastMath.Abs(FastMath.Sin(timer * 1.5f))); var escalado = new TGCVector3(6f, variacionY, variacionZ); sphereOne.Transform = TGCMatrix.RotationY(timer) * TGCMatrix.Scaling(escalado) * TGCMatrix.Translation(spheresCenter); }
/// <summary> /// Realiza un update de la camara a partir del elapsedTime, actualizando Position,LookAt y UpVector. /// Presenta movimientos basicos a partir de input de teclado W, A, S, D, Espacio, Control y rotraciones con el mouse. /// </summary> /// <param name="elapsedTime"></param> public override void UpdateCamera(float elapsedTime) { var moveVector = TGCVector3.Empty; if (Input.keyPressed(Key.Escape)) { LockCam = !lockCam; //habiaSalido = true; } if ((Input.buttonPressed(TgcD3dInput.MouseButtons.BUTTON_LEFT))) { LockCam = !lockCam; //habiaSalido = false; } if (lockCam) { leftrightRot -= -Input.XposRelative * RotationSpeed; updownRot -= Input.YposRelative * RotationSpeed; if (updownRot > 1.5) { updownRot = 1.5f; } if (updownRot < -1.5) { updownRot = -1.5f; } //Se actualiza matrix de rotacion, para no hacer este calculo cada vez y solo cuando en verdad es necesario. cameraRotation = TGCMatrix.RotationX(updownRot) * TGCMatrix.RotationY(leftrightRot); } if (lockCam) { Cursor.Position = mouseCenter; } //Calculamos la nueva posicion del ojo segun la rotacion actual de la camara. var cameraRotatedPositionEye = TGCVector3.TransformNormal(moveVector * elapsedTime, cameraRotation); positionEye += cameraRotatedPositionEye; //Calculamos el target de la camara, segun su direccion inicial y las rotaciones en screen space x,y. var cameraRotatedTarget = TGCVector3.TransformNormal(directionView, cameraRotation); var cameraFinalTarget = positionEye + cameraRotatedTarget; //Se calcula el nuevo vector de up producido por el movimiento del update. var cameraOriginalUpVector = DEFAULT_UP_VECTOR; var cameraRotatedUpVector = TGCVector3.TransformNormal(cameraOriginalUpVector, cameraRotation); base.SetCamera(positionEye, cameraFinalTarget, cameraRotatedUpVector); }
public override void Init() { //Objetos en movimiento. colliderCylinder = new TgcBoundingCylinder(TGCVector3.Empty, 2, 4); colliderCylinder.setRenderColor(Color.LimeGreen); colliderCylinderFixedY = new TgcBoundingCylinderFixedY(TGCVector3.Empty, 2, 4); colliderCylinderFixedY.setRenderColor(Color.LimeGreen); //Cargar personaje con animaciones 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" }); //Configurar animacion inicial personaje.playAnimation("Parado", true); //Escalarlo porque es muy grande personaje.Scale = new TGCVector3(0.04f, 0.04f, 0.04f); //El personaje esta en el 0,0,0 hay que bajarlo var size = personaje.BoundingBox.PMax.Y - personaje.BoundingBox.PMin.Y; personaje.Position = new TGCVector3(0, -3f, 0); //Rotarlo 180° porque esta mirando para el otro lado personaje.Rotation = new TGCVector3(0, FastMath.PI, 0); personaje.Transform = TGCMatrix.RotationY(personaje.Rotation.Y) * TGCMatrix.Translation(personaje.Position); //Objetos estaticos, pueden ser mesh o objetos simplificados. var loader = new TgcSceneLoader(); var scene = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Meshes\\Vehiculos\\Patrullero\\Patrullero-TgcScene.xml"); collisionableMeshAABB = scene.Meshes[0]; collisionableMeshAABB.Scale = new TGCVector3(0.1f, 0.1f, 0.1f); collisionableMeshAABB.Position = new TGCVector3(6, 0, -2); collisionableCylinder = new TgcBoundingCylinderFixedY(new TGCVector3(-6, 0, 0), 2, 2); collisionableSphere = new TgcBoundingSphere(new TGCVector3(-3, 0, 10), 3); fixedYModifier = AddBoolean("fixedY", "use fixed Y", true); //Modifier para ver BoundingBox del personaje showBoundingBoxModifier = AddBoolean("showBoundingBox", "Personaje Bouding Box", false); sizeModifier = AddVertex2f("size", TGCVector2.One, new TGCVector2(5, 10), new TGCVector2(2, 5)); var angle = FastMath.TWO_PI; rotationModifier = AddVertex3f("rotation", new TGCVector3(-angle, -angle, -angle), new TGCVector3(angle, angle, angle), new TGCVector3(FastMath.TWO_PI / 8, 0, FastMath.TWO_PI / 8)); //Configurar camara en Tercer Persona camaraInterna = new TgcThirdPersonCamera(personaje.Position, 25, -45); Camera = camaraInterna; }
private void InitializeTrafficLight() { var sceneLoader = new TgcSceneLoader(); var scene = sceneLoader.loadSceneFromFile(MediaDir + "ModelosTgc//Semaforo//Semaforo-TgcScene.xml", MediaDir + "ModelosTgc//Semaforo//"); trafficLight = scene.Meshes[0]; var size = trafficLight.BoundingBox.calculateSize(); trafficLight.Transform = TGCMatrix.RotationY(FastMath.PI) * TGCMatrix.Translation(0f, size.Y / 2.0f, 0f); trafficLight.Effect = effect; trafficLight.Technique = "Blinn"; }
public void ChangeSharkWay() { var rotation = TGCMatrix.RotationY(FastMath.PI_HALF * -RotationYSign()); director = Constants.DirectorZ; director.TransformCoordinate(rotation); Mesh.Transform = rotation * TGCMatrix.Translation(new TGCVector3(Body.CenterOfMassPosition)); Body.WorldTransform = Mesh.Transform.ToBulletMatrix(); AcumulatedXRotation = 0; AcumulatedYRotation = 0; TotalRotation = rotation; }