public override void Init() { //Cargar 25 cajas formando una matriz var loader = new TgcSceneLoader(); boxes = new List <TGCBox>(); var texture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\granito.jpg"); var boxSize = new TGCVector3(30, 30, 30); for (var i = 0; i < 5; i++) { for (var j = 0; j < 5; j++) { var center = new TGCVector3((boxSize.X + boxSize.X / 2) * i, (boxSize.Y + boxSize.Y / 2) * j, 0); var box = TGCBox.fromSize(center, boxSize, texture); box.Transform = TGCMatrix.Translation(box.Position); boxes.Add(box); } } //Iniciarlizar PickingRay pickingRay = new TgcPickingRay(Input); Camara.SetCamera(new TGCVector3(100f, 100f, -500f), new TGCVector3(100f, 100f, -250f)); //Crear caja para marcar en que lugar hubo colision collisionPointMesh = TGCBox.fromSize(new TGCVector3(3, 3, 3), Color.Red); selected = false; //UserVars para mostrar en que punto hubo colision UserVars.addVar("CollP-X:"); UserVars.addVar("CollP-Y:"); UserVars.addVar("CollP-Z:"); }
public override void Init() { //Path de Heightmap default del terreno y Modifier para cambiarla currentHeightmap = MediaDir + "Heighmaps\\" + "Heightmap3.jpg"; heightmapModifier = AddTexture("heightmap", currentHeightmap); //Modifiers para variar escala del mapa currentScaleXZ = 50f; scaleXZModifier = AddFloat("scaleXZ", 0.1f, 100f, currentScaleXZ); currentScaleY = 1.5f; scaleYModifier = AddFloat("scaleY", 0.1f, 10f, currentScaleY); createHeightMapMesh(D3DDevice.Instance.Device, currentHeightmap, currentScaleXZ, currentScaleY); //Path de Textura default del terreno y Modifier para cambiarla currentTexture = MediaDir + "Heighmaps\\" + "TerrainTexture3.jpg"; textureModifier = AddTexture("texture", currentTexture); loadTerrainTexture(D3DDevice.Instance.Device, currentTexture); //Configurar FPS Camara Camara = new TgcFpsCamera(new TGCVector3(3200f, 450f, 1500f), Input); //UserVars para cantidad de vertices UserVars.addVar("Vertices", totalVertices); UserVars.addVar("Triangles", totalVertices / 3); }
public override void Init() { //Malla default var initialMeshFile = MediaDir + "MeshCreator\\Meshes\\Vehiculos\\CamionDeAgua\\CamionDeAgua-TgcScene.xml"; //Modifiers currentScene = null; currentPath = null; Modifiers.addFile("Mesh", initialMeshFile, "-TgcScene.xml |*-TgcScene.xml"); Modifiers.addButton("Reload", "Reload", Reload_ButtonClick); currentColor = Color.White; Modifiers.addColor("Color", currentColor); Modifiers.addBoolean("BoundingBox", "BoundingBox", false); currentAlphaBlending = false; Modifiers.addBoolean("AlphaBlending", "AlphaBlending", currentAlphaBlending); //UserVars UserVars.addVar("Name"); UserVars.addVar("Meshes"); UserVars.addVar("Textures"); UserVars.addVar("Triangles"); UserVars.addVar("Vertices"); UserVars.addVar("SizeX"); UserVars.addVar("SizeY"); UserVars.addVar("SizeZ"); }
public override void Init() { //Crear esfera sphere = new TgcSphere(); currentTexture = null; //Modifiers para vararis sus parametros Modifiers.addEnum("base", typeof(TgcSphere.eBasePoly), TgcSphere.eBasePoly.ICOSAHEDRON); Modifiers.addBoolean("inflate", "yes", true); Modifiers.addInterval("level of detail", new object[] { 0, 1, 2, 3, 4 }, 2); Modifiers.addBoolean("edges", "show", false); Modifiers.addFloat("radius", 0, 100, 10); Modifiers.addVertex3f("position", new Vector3(-100, -100, -100), new Vector3(100, 100, 100), new Vector3(0, 0, 0)); Modifiers.addVertex3f("rotation", new Vector3(-180, -180, -180), new Vector3(180, 180, 180), new Vector3(0, 0, 0)); Modifiers.addBoolean("Use texture", "yes", true); Modifiers.addTexture("texture", MediaDir + "\\Texturas\\madera.jpg"); Modifiers.addVertex2f("offset", new Vector2(-0.5f, -0.5f), new Vector2(0.9f, 0.9f), new Vector2(0, 0)); Modifiers.addVertex2f("tiling", new Vector2(0.1f, 0.1f), new Vector2(4, 4), new Vector2(1, 1)); Modifiers.addColor("color", Color.White); Modifiers.addBoolean("boundingsphere", "show", false); UserVars.addVar("Vertices"); UserVars.addVar("Triangulos"); Camara = new TgcRotationalCamera(new Vector3(), 50f); }
public override void Render() { PreRender(); //Ver si cambio el modelo elegido por el usuario var selectedPath = (string)Modifiers["Mesh"]; if (selectedPath != currentMeshFile) { //cargar nuevo modelo currentMeshFile = selectedPath; loadMesh(currentMeshFile); //Actualizar contadores de triangulos y vertices UserVars.setValue("Vertices", mesh.NumberVertices); UserVars.setValue("Triangles", mesh.NumberFaces); } //Renderizar la malla. //Hay que renderizar cada subset por separado for (var i = 0; i < meshMaterials.Length; i++) { D3DDevice.Instance.Device.Material = meshMaterials[i]; D3DDevice.Instance.Device.SetTexture(0, meshTextures[i]); mesh.DrawSubset(i); } PostRender(); }
public override void Init() { //Crear esfera sphere = new TGCSphere(); //No recomendamos utilizar AutoTransformEnable, con juegos complejos se pierde el control. sphere.AutoTransform = true; currentTexture = null; //Modifiers para vararis sus parametros baseModifier = AddEnum("base", typeof(TGCSphere.eBasePoly), TGCSphere.eBasePoly.ICOSAHEDRON); inflateModifier = AddBoolean("inflate", "yes", true); levelOfDetailModifier = AddInterval("level of detail", new object[] { 0, 1, 2, 3, 4 }, 2); edgesModifier = AddBoolean("edges", "show", false); radiusModifier = AddFloat("radius", 0, 100, 10); positionModifier = AddVertex3f("position", new TGCVector3(-100, -100, -100), new TGCVector3(100, 100, 100), TGCVector3.Empty); rotationModifier = AddVertex3f("rotation", new TGCVector3(-180, -180, -180), new TGCVector3(180, 180, 180), TGCVector3.Empty); useTextureModifier = AddBoolean("Use texture", "yes", true); textureModifier = AddTexture("texture", MediaDir + "\\Texturas\\madera.jpg"); offsetModifier = AddVertex2f("offset", new TGCVector2(-0.5f, -0.5f), new TGCVector2(0.9f, 0.9f), TGCVector2.Zero); tilingModifier = AddVertex2f("tiling", new TGCVector2(0.1f, 0.1f), new TGCVector2(4, 4), TGCVector2.One); colorModifier = AddColor("color", Color.White); boundingsphereModifier = AddBoolean("boundingsphere", "show", false); UserVars.addVar("Vertices"); UserVars.addVar("Triangulos"); Camara = new TgcRotationalCamera(TGCVector3.Empty, 50f, Input); }
//mansion spencer 2.0.xml public override void Init() { var loader = new TgcSceneLoader(); scene = loader.loadSceneFromFile(MediaDir + "Desktop\\mansion spencer 2.0.xml"); //Descactivar inicialmente a todos los modelos scene.setMeshesEnabled(false); //Camara = new TgcFpsCamera(new Vector3(0, 0, 0), 800f, 600f, Input); // Camara = new TgcCamera(); var cameraPosition = new Vector3(0, 0, 125); var lookAt = Vector3.Empty; Camara.SetCamera(cameraPosition, lookAt); //Modifiers Modifiers.addBoolean("portalRendering", "PortalRendering", true); Modifiers.addBoolean("WireFrame", "WireFrame", false); Modifiers.addBoolean("showPortals", "Show Portals", false); //throw new NotImplementedException(); UserVars.addVar("MeshCount"); }
public override void Update() { PreUpdate(); physicsExample.Update(Input); UserVars.setValue("Tgccito_Position", physicsExample.GetCharacterPosition()); PostUpdate(); }
public override void Init() { //Path de Heightmap default del terreno y Modifier para cambiarla currentHeightmap = MediaDir + "Heighmaps\\" + "Heightmap1.jpg"; Modifiers.addTexture("heightmap", currentHeightmap); //Modifiers para variar escala del mapa currentScaleXZ = 20f; Modifiers.addFloat("scaleXZ", 0.1f, 100f, currentScaleXZ); currentScaleY = 1.3f; Modifiers.addFloat("scaleY", 0.1f, 10f, currentScaleY); createHeightMapMesh(D3DDevice.Instance.Device, currentHeightmap, currentScaleXZ, currentScaleY); //Path de Textura default del terreno y Modifier para cambiarla currentTexture = MediaDir + "Heighmaps\\" + "TerrainTexture1-256x256.jpg"; Modifiers.addTexture("texture", currentTexture); loadTerrainTexture(D3DDevice.Instance.Device, currentTexture); //Configurar FPS Camara Camara = new TgcFpsCamera(new Vector3(-24.9069f, 386.3114f, 673.7542f), 100f, 100f); //UserVars para cantidad de vertices UserVars.addVar("Vertices", totalVertices); UserVars.addVar("Triangles", totalVertices / 3); }
public override void Init() { //FPS Camara Camara = new TgcFpsCamera(new Vector3(-140f, 40f, -50f), 200f, 200f); //Cargar escena desde archivo ZIP var loader = new TgcSceneLoader(); tgcScene = loader.loadSceneFromZipFile("4toPiso-TgcScene.xml", MediaDir + "4toPiso\\4toPiso.zip", MediaDir + "4toPiso\\Extract\\"); /* * //Version para cargar escena desde carpeta descomprimida * TgcSceneLoader loader = new TgcSceneLoader(); * tgcScene = loader.loadSceneFromFile( * this.MediaDir + "4toPiso\\Extract\\4toPiso-TgcScene.xml", * this.MediaDir + "4toPiso\\Extract\\"); */ //Modifier para habilitar o deshabilitar FrustumCulling Modifiers.addBoolean("culling", "Frustum culling", true); //UserVar para contar la cantidad de meshes que se renderizan UserVars.addVar("Meshes renderizadas"); }
public override void Init() { //Cargar 25 cajas formando una matriz var loader = new TgcSceneLoader(); boxes = new List <TgcBox>(); var texture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\granito.jpg"); var boxSize = new Vector3(30, 30, 30); for (var i = 0; i < 5; i++) { for (var j = 0; j < 5; j++) { var center = new Vector3((boxSize.X + boxSize.X / 2) * i, (boxSize.Y + boxSize.Y / 2) * j, 0); var box = TgcBox.fromSize(center, boxSize, texture); boxes.Add(box); } } //Iniciarlizar PickingRay pickingRay = new TgcPickingRay(); Camara = new TgcRotationalCamera(new Vector3(100f, 100f, -250f), 600f); //FIXME esta camara deberi ser estatica y no rotacional, ya que sino trae problemas con el picking. //Crear caja para marcar en que lugar hubo colision collisionPointMesh = TgcBox.fromSize(new Vector3(3, 3, 3), Color.Red); selected = false; //UserVars para mostrar en que punto hubo colision UserVars.addVar("CollP-X:"); UserVars.addVar("CollP-Y:"); UserVars.addVar("CollP-Z:"); }
/// <summary> /// Vuelve la configuracion de Render y otras cosas a la configuracion inicial /// </summary> public void ResetDefaultConfig() { D3DDevice.Instance.DefaultValues(); D3DDevice.Instance.Device.Transform.World = Matrix.Identity; UserVars.ClearVars(); Modifiers.Clear(); ElapsedTime = -1; }
public override void Init() { physicsExample = new HelloWorldBullet2(); physicsExample.Init(this); UserVars.addVar("MeshCount"); Camara = new TgcRotationalCamera(new TGCVector3(0, 20, 0), 100, Input); }
public override void Update() { PreUpdate(); physicsExample.Update(); UserVars.setValue("MeshCount", physicsExample.GetElements()); PostUpdate(); }
public override void Render() { PreRender(); //Si hacen clic con el mouse, ver si hay colision RayAABB if (Input.buttonPressed(TgcD3dInput.MouseButtons.BUTTON_LEFT)) { //Actualizar Ray de colision en base a posicion del mouse pickingRay.updateRay(); //Testear Ray contra el AABB de todos los meshes foreach (var box in boxes) { var aabb = box.BoundingBox; //Ejecutar test, si devuelve true se carga el punto de colision collisionPoint selected = TgcCollisionUtils.intersectRayAABB(pickingRay.Ray, aabb, out collisionPoint); if (selected) { selectedMesh = box; break; } } } //Renderizar modelos foreach (var box in boxes) { box.Render(); } //Renderizar BoundingBox del mesh seleccionado if (selected) { //Render de AABB selectedMesh.BoundingBox.Render(); //Cargar punto de colision UserVars.setValue("CollP-X:", collisionPoint.X); UserVars.setValue("CollP-Y:", collisionPoint.Y); UserVars.setValue("CollP-Z:", collisionPoint.Z); //Dibujar caja que representa el punto de colision collisionPointMesh.Position = collisionPoint; collisionPointMesh.Transform = TGCMatrix.Translation(collisionPointMesh.Position); collisionPointMesh.Render(); } else { //Reset de valores UserVars.setValue("CollP-X:", 0); UserVars.setValue("CollP-Y:", 0); UserVars.setValue("CollP-Z:", 0); } PostRender(); }
public override void Init() { //Triangulo 1. //Definir array de vertices para el triangulo, del tipo Coordendas (X,Y,Z) + Color simpleTriangleData = new CustomVertex.PositionColored[3]; //Cargar informacion de vertices. Nesitamos 3 vertices para crear un triangulo simpleTriangleData[0] = new CustomVertex.PositionColored(-1, 0, 0, Color.Red.ToArgb()); simpleTriangleData[1] = new CustomVertex.PositionColored(1, 0, 0, Color.Green.ToArgb()); simpleTriangleData[2] = new CustomVertex.PositionColored(0, 1, 0, Color.Blue.ToArgb()); //Cargar variables de usuario con alguna informacion util para ver en pantalla UserVars.addVar("Triangle 1 vertices", simpleTriangleData.Length); //Triangulo 2. //Current texture currentTexurePah = MediaDir + "Texturas\\baldosaFacultad.jpg"; texture = TextureLoader.FromFile(D3DDevice.Instance.Device, currentTexurePah); //Modifiers vertex1Modifier = AddVertex3f("vertex1", new TGCVector3(-3, -3, -3), new TGCVector3(3, 3, 3), new TGCVector3(-1, 0, 0)); texCoord1Modifier = AddVertex2f("texCoord1", TGCVector2.Zero, TGCVector2.One, new TGCVector2(1, 0)); color1Modifier = AddColor("color1", Color.White); vertex2Modifier = AddVertex3f("vertex2", new TGCVector3(-3, -3, -3), new TGCVector3(3, 3, 3), new TGCVector3(1, 0, 0)); texCoord2Modifier = AddVertex2f("texCoord2", TGCVector2.Zero, TGCVector2.One, new TGCVector2(0, 1)); color2Modifier = AddColor("color2", Color.White); vertex3Modifier = AddVertex3f("vertex3", new TGCVector3(-3, -3, -3), new TGCVector3(3, 3, 3), TGCVector3.Up); texCoord3Modifier = AddVertex2f("texCoord3", TGCVector2.Zero, TGCVector2.One, TGCVector2.One); color3Modifier = AddColor("color3", Color.White); rotationModifier = AddFloat("rotation", -2, 2f, 0f); textureEnableModifier = AddBoolean("TextureEnable", "Con textura", true); textureImageModifier = AddTexture("Texture image", currentTexurePah); //Triangulo 3. //Crear vertexBuffer vertexBuffer = new VertexBuffer(typeof(CustomVertex.PositionColored), 3, D3DDevice.Instance.Device, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Default); //Cargar informacion de vertices: (X,Y,Z) + Color var data = new CustomVertex.PositionColored[3]; data[0] = new CustomVertex.PositionColored(-1, 0, 0, Color.Red.ToArgb()); data[1] = new CustomVertex.PositionColored(1, 0, 0, Color.Green.ToArgb()); data[2] = new CustomVertex.PositionColored(0, 1, 0, Color.Blue.ToArgb()); //Almacenar informacion en VertexBuffer vertexBuffer.SetData(data, 0, LockFlags.None); //User Vars UserVars.addVar("Triangle 3 vertices"); UserVars.setValue("Triangle 3 vertices", data.Length); //Configurar camara en rotacion Camara = new TgcRotationalCamera(new TGCVector3(0, 0.5f, 0), 7.5f, Input); }
public override void Update() { physicsExample.Update(Input, ElapsedTime, TimeBetweenUpdates); UserVars.setValue("HummerPositionX", physicsExample.getHummer().Position.X); UserVars.setValue("HummerPositionY", physicsExample.getHummer().Position.Y); UserVars.setValue("HummerPositionZ", physicsExample.getHummer().Position.Z); UserVars.setValue("HummerBodyPositionX", physicsExample.getBodyPos().X); UserVars.setValue("HummerBodyPositionY", physicsExample.getBodyPos().Y); UserVars.setValue("HummerBodyPositionZ", physicsExample.getBodyPos().Z); camaraInterna.Target = physicsExample.getHummer().Position; }
public override void Init() { currentMeshFile = MediaDir + "ModelosX" + "\\" + "shampoo.x"; //cargar mesh loadMesh(currentMeshFile); //User Vars UserVars.addVar("Vertices", mesh.NumberVertices); UserVars.addVar("Triangles", mesh.NumberFaces); //Modifiers Modifiers.addFile("Mesh", currentMeshFile, ".X files|*.x"); }
public override void Init() { //Definir array de vertices para el triangulo, del tipo Coordendas (X,Y,Z) + Color data = new CustomVertex.PositionColored[3]; //Cargar información de vertices. Nesitamos 3 vertices para crear un triángulo data[0] = new CustomVertex.PositionColored(-1, 0, 0, Color.Red.ToArgb()); data[1] = new CustomVertex.PositionColored(1, 0, 0, Color.Green.ToArgb()); data[2] = new CustomVertex.PositionColored(0, 1, 0, Color.Blue.ToArgb()); //Configurar camara en rotacion Camara = new TgcRotationalCamera(new Vector3(0, 0.5f, 0), 3f); //Cargar variables de usuario con alguna informacion util para ver en pantalla UserVars.addVar("Cantida de Vertices", data.Length); }
public override void Update() { PreUpdate(); physicsExample.Update(Input); UserVars.setValue("HummerPositionX", physicsExample.getHummer().Position.X); UserVars.setValue("HummerPositionY", physicsExample.getHummer().Position.Y); UserVars.setValue("HummerPositionZ", physicsExample.getHummer().Position.Z); UserVars.setValue("HummerBodyPositionX", physicsExample.getBodyPos().X); UserVars.setValue("HummerBodyPositionY", physicsExample.getBodyPos().Y); UserVars.setValue("HummerBodyPositionZ", physicsExample.getBodyPos().Z); camaraInterna.Target = physicsExample.getHummer().Position; PostUpdate(); }
/// <summary> /// Carga una malla estatica de formato TGC /// </summary> private void loadMesh(string path) { currentPath = path; //Dispose de escena anterior if (currentScene != null) { currentScene.disposeAll(); } //Cargar escena con herramienta TgcSceneLoader var loader = new TgcSceneLoader(); currentScene = loader.loadSceneFromFile(path); //Ajustar camara en base al tamano del objeto Camara = new TgcRotationalCamera(currentScene.BoundingBox.calculateBoxCenter(), currentScene.BoundingBox.calculateBoxRadius() * 2, Input); //Calcular cantidad de triangulos y texturas var triangleCount = 0; var verticesCount = 0; var texturesCount = 0; foreach (var mesh in currentScene.Meshes) { triangleCount += mesh.NumberTriangles; verticesCount += mesh.NumberVertices; texturesCount += mesh.RenderType == TgcMesh.MeshRenderType.VERTEX_COLOR ? 0 : mesh.DiffuseMaps.Length; } //UserVars UserVars.setValue("Name", currentScene.SceneName); UserVars.setValue("Meshes", currentScene.Meshes.Count); UserVars.setValue("Textures", texturesCount); UserVars.setValue("Triangles", triangleCount); UserVars.setValue("Vertices", verticesCount); var size = currentScene.BoundingBox.calculateSize(); UserVars.setValue("SizeX", TgcParserUtils.printFloat(size.X)); UserVars.setValue("SizeY", TgcParserUtils.printFloat(size.Y)); UserVars.setValue("SizeZ", TgcParserUtils.printFloat(size.Z)); }
public override void Init() { //En este ejemplo primero cargamos una escena 3D entera. var loader = new TgcSceneLoader(); scene = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Ciudad\\Ciudad-TgcScene.xml"); //scene = loader.loadSceneFromFile(MediaDir + "4toPiso\\Extract\\4toPiso-TgcScene.xml"); /* C:\Users\llain2\Documents\TGC\Viewer\Media\4toPiso\Extract * //Luego cargamos otro modelo aparte que va a hacer el objeto que controlamos con el teclado * var scene2 = * loader.loadSceneFromFile(MediaDir + "MeshCreator\\Meshes\\Vehiculos\\Hummer\\Hummer-TgcScene.xml"); * * //Solo nos interesa el primer modelo de esta escena (tiene solo uno) * mainMesh = scene2.Meshes[0]; * <<<<<<< HEAD * ======= * mainMesh.AutoTransformEnable = true; * >>>>>>> master * //Movemos el mesh un poco para arriba. Porque sino choca con el piso todo el tiempo y no se puede mover. * mainMesh.Position = new TGCVector3(0, 50, 0); * mainMesh.UpdateMeshTransform();*/ physicsExample = new CubePhysic(); //physicsExample.setHummer(mainMesh); scene.Meshes[0].Position = TGCVector3.Empty; physicsExample.setBuildings(scene.Meshes); physicsExample.Init(MediaDir); //Vamos a utilizar la camara en 3ra persona para que siga al objeto principal a medida que se mueve camaraInterna = new TgcThirdPersonCamera(physicsExample.getPositionHummer(), 250, 375); Camara = camaraInterna; UserVars.addVar("HummerPositionX"); UserVars.addVar("HummerPositionY"); UserVars.addVar("HummerPositionZ"); UserVars.addVar("HummerBodyPositionX"); UserVars.addVar("HummerBodyPositionY"); UserVars.addVar("HummerBodyPositionZ"); }
public override void Render() { PreRender(); //Actualizar parametros de la caja updateSphere(); UserVars.setValue("Vertices", sphere.VertexCount); UserVars.setValue("Triangulos", sphere.TriangleCount); //Renderizar caja sphere.render(); //Mostrar Boundingsphere de la caja var boundingsphere = (bool)Modifiers["boundingsphere"]; if (boundingsphere) { sphere.BoundingSphere.render(); } PostRender(); }
public override void Render() { PreRender(); var frustumCullingEnabled = (bool)Modifiers["culling"]; //Renderizar sin ninguna optimizacion if (!frustumCullingEnabled) { tgcScene.renderAll(); UserVars.setValue("Meshes renderizadas", tgcScene.Meshes.Count); } //Renderizar con Frustum Culling else { //Analizar cada malla contra el Frustum - con fuerza bruta var totalMeshes = 0; foreach (var mesh in tgcScene.Meshes) { //Nos ocupamos solo de las mallas habilitadas if (mesh.Enabled) { //Solo mostrar la malla si colisiona contra el Frustum var r = TgcCollisionUtils.classifyFrustumAABB(TgcFrustum.Instance, mesh.BoundingBox); if (r != TgcCollisionUtils.FrustumResult.OUTSIDE) { mesh.render(); totalMeshes++; } } } //Actualizar cantidad de meshes dibujadas UserVars.setValue("Meshes renderizadas", totalMeshes); } PostRender(); }
public override void Init() { //Crear vertexBuffer vertexBuffer = new VertexBuffer(typeof(CustomVertex.PositionColored), 3, D3DDevice.Instance.Device, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Default); //Cargar informacion de vertices: (X,Y,Z) + Color var data = new CustomVertex.PositionColored[3]; data[0] = new CustomVertex.PositionColored(-1, 0, 0, Color.Red.ToArgb()); data[1] = new CustomVertex.PositionColored(1, 0, 0, Color.Green.ToArgb()); data[2] = new CustomVertex.PositionColored(0, 1, 0, Color.Blue.ToArgb()); //Almacenar información en VertexBuffer vertexBuffer.SetData(data, 0, LockFlags.None); //Configurar camara en rotacion Camara = new TgcRotationalCamera(new Vector3(0, 0.5f, 0), 3f); //User Vars UserVars.addVar("Vertices"); UserVars.setValue("Vertices", data.Length); }
public override void Render() { PreRender(); //Renderizar modelos foreach (var box in boxes) { box.Render(); } //Renderizar BoundingBox del mesh seleccionado if (selected) { //Render de AABB selectedMesh.BoundingBox.Render(); //Cargar punto de colision UserVars.setValue("CollP-X:", collisionPoint.X); UserVars.setValue("CollP-Y:", collisionPoint.Y); UserVars.setValue("CollP-Z:", collisionPoint.Z); //Dibujar caja que representa el punto de colision collisionPointMesh.Position = collisionPoint; collisionPointMesh.Transform = TGCMatrix.Translation(collisionPointMesh.Position); collisionPointMesh.Render(); } else { //Reset de valores UserVars.setValue("CollP-X:", 0); UserVars.setValue("CollP-Y:", 0); UserVars.setValue("CollP-Z:", 0); } PostRender(); }
public override void Init() { //Crear VertexBuffer vertexBuffer = new VertexBuffer(typeof(CustomVertex.PositionColored), 3, D3DDevice.Instance.Device, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Default); //Cargar informacion de vertices: (X,Y,Z) + Color data = new CustomVertex.PositionColored[3]; data[0] = new CustomVertex.PositionColored(-1, 0, 0, Color.Red.ToArgb()); data[1] = new CustomVertex.PositionColored(1, 0, 0, Color.Green.ToArgb()); data[2] = new CustomVertex.PositionColored(0, 1, 0, Color.Blue.ToArgb()); //FPS Camara Camara = new TgcFpsCamera(new Vector3(0.5f, 0, -3)); //User Vars UserVars.addVar("Vertices", 0); UserVars.addVar("Triangles", 0); //Modifiers Modifiers.addFloat("translateX", -5, 5f, 0f); Modifiers.addFloat("rotationZ", 0, (float)(2.0f * Math.PI), 0f); Modifiers.addFloat("ScaleXYZ", 0, 3, 1f); }
public override void Init() { //En este ejemplo primero cargamos una escena 3D entera. var loader = new TgcSceneLoader(); scene = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Ciudad\\Ciudad-TgcScene.xml"); physicsExample = new CubePhysic(); //physicsExample.setHummer(mainMesh); scene.Meshes[0].Position = TGCVector3.Empty; physicsExample.setBuildings(scene.Meshes); physicsExample.Init(MediaDir); //Vamos a utilizar la camara en 3ra persona para que siga al objeto principal a medida que se mueve camaraInterna = new TgcThirdPersonCamera(physicsExample.getPositionHummer(), 250, 375); Camara = camaraInterna; UserVars.addVar("HummerPositionX"); UserVars.addVar("HummerPositionY"); UserVars.addVar("HummerPositionZ"); UserVars.addVar("HummerBodyPositionX"); UserVars.addVar("HummerBodyPositionY"); UserVars.addVar("HummerBodyPositionZ"); }
public override void Render() { PreRender(); //Actualizar parametros de la caja updateSphere(); UserVars.setValue("Vertices", sphere.VertexCount); UserVars.setValue("Triangulos", sphere.TriangleCount); //Renderizar esfera sphere.Transform = TGCMatrix.Scaling(sphere.Radius, sphere.Radius, sphere.Radius) * TGCMatrix.RotationYawPitchRoll(sphere.Rotation.Y, sphere.Rotation.X, sphere.Rotation.Z) * TGCMatrix.Translation(sphere.Position); sphere.Render(); //Mostrar Boundingsphere de la caja var boundingsphere = boundingsphereModifier.Value; if (boundingsphere) { sphere.BoundingSphere.Render(); } PostRender(); }
public override void Init() { //Cargar escenario con informacion especial exportada de PortalRendering var loader = new TgcSceneLoader(); scene = loader.loadSceneFromFile(MediaDir + "EscenarioPortal\\EscenarioPortal-TgcScene.xml"); //Descactivar inicialmente a todos los modelos scene.setMeshesEnabled(false); //Camara en 1ra persona Camara = new TgcFpsCamera(TGCVector3.Empty, 800f, 600f, Input); //Modifiers portalRenderingModifier = AddBoolean("portalRendering", "PortalRendering", true); wireFrameModifier = AddBoolean("WireFrame", "WireFrame", false); showPortalsModifier = AddBoolean("showPortals", "Show Portals", false); //UserVars UserVars.addVar("MeshCount"); //Crear portales debug scene.PortalRendering.createDebugPortals(Color.Purple); }