本文整理汇总了C#中TgcViewer.Utils.TgcSceneLoader.TgcSceneLoader类的典型用法代码示例。如果您正苦于以下问题:C# TgcSceneLoader类的具体用法?C# TgcSceneLoader怎么用?C# TgcSceneLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TgcSceneLoader类属于TgcViewer.Utils.TgcSceneLoader命名空间,在下文中一共展示了TgcSceneLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: init
public override void init()
{
Device d3dDevice = GuiController.Instance.D3dDevice;
TgcSceneLoader loader = new TgcSceneLoader();
TgcScene sceneOriginal = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Box\\" + "Box-TgcScene.xml");
TgcMesh meshOriginal = sceneOriginal.Meshes[0];
TgcMesh meshInstance1 = new TgcMesh(meshOriginal.Name + "-1", meshOriginal,
new Vector3(50, 0, 0), meshOriginal.Rotation, meshOriginal.Scale);
meshInstance1.Enabled = true;
TgcMesh meshInstance2 = new TgcMesh(meshOriginal.Name + "-2", meshOriginal,
new Vector3(100, 0, 0), meshOriginal.Rotation, meshOriginal.Scale);
meshInstance2.Enabled = true;
meshes = new List<TgcMesh>();
meshes.Add(meshOriginal);
meshes.Add(meshInstance1);
meshes.Add(meshInstance2);
TgcTexture texture = TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Piso\\Textures\\piso2.jpg");
meshOriginal.changeDiffuseMaps(new TgcTexture[] { texture });
GuiController.Instance.FpsCamera.Enable = true;
}
示例2: init
public override void init()
{
Device d3dDevice = GuiController.Instance.D3dDevice;
//Activamos el renderizado customizado. De esta forma el framework nos delega control total sobre como dibujar en pantalla
//La responsabilidad cae toda de nuestro lado
GuiController.Instance.CustomRenderEnabled = true;
//Cargar shader de este ejemplo
effect = TgcShaders.loadEffect(GuiController.Instance.ExamplesMediaDir + "Shaders\\EjemploGetZBuffer.fx");
//Cargamos un escenario
TgcSceneLoader loader = new TgcSceneLoader();
TgcScene scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml");
meshes = scene.Meshes;
foreach (TgcMesh mesh in meshes)
{
mesh.Effect = effect;
}
//Crear textura para almacenar el zBuffer. Es una textura que se usa como RenderTarget y que tiene un formato de 1 solo float de 32 bits.
//En cada pixel no vamos a guardar un color sino el valor de Z de la escena
//La creamos con un solo nivel de mipmap (el original)
zBufferTexture = new Texture(d3dDevice, d3dDevice.Viewport.Width, d3dDevice.Viewport.Height, 1, Usage.RenderTarget, Format.R32F, Pool.Default);
//Camara en 1ra persona
GuiController.Instance.FpsCamera.Enable = true;
GuiController.Instance.FpsCamera.MovementSpeed = 400f;
GuiController.Instance.FpsCamera.JumpSpeed = 300f;
GuiController.Instance.FpsCamera.setCamera(new Vector3(-20, 80, 450), new Vector3(0, 80, 1));
}
示例3: init
public override void init()
{
Device d3dDevice = GuiController.Instance.D3dDevice;
meshes = new List<TgcMesh>();
TgcSceneLoader loader = new TgcSceneLoader();
TgcScene scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\BoxAlpha\\Box-TgcScene.xml");
TgcMesh originalMesh = scene.Meshes[0];
meshes.Add(originalMesh);
originalMesh.Position = new Vector3(0,0,0);
originalMesh.AlphaBlendEnable = true;
TgcMesh instanceMesh;
for (int i = 0; i < 5; i++)
{
instanceMesh = originalMesh.createMeshInstance("Box" + (i+1));
instanceMesh.Position = new Vector3(0, 0, i * 50);
instanceMesh.AlphaBlendEnable = true;
meshes.Add(instanceMesh);
}
GuiController.Instance.FpsCamera.Enable = true;
}
示例4: init
public override void init()
{
Device d3dDevice = GuiController.Instance.D3dDevice;
//Cargar 25 cajas formando una matriz
TgcSceneLoader loader = new TgcSceneLoader();
boxes = new List<TgcBox>();
TgcTexture texture = TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesMediaDir + "Texturas\\granito.jpg");
Vector3 boxSize = new Vector3(30, 30, 30);
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
Vector3 center = new Vector3((boxSize.X + boxSize.X / 2) * i, (boxSize.Y + boxSize.Y / 2) * j, 0);
TgcBox box = TgcBox.fromSize(center, boxSize, texture);
boxes.Add(box);
}
}
//Iniciarlizar PickingRay
pickingRay = new TgcPickingRay();
//Camara fija
GuiController.Instance.RotCamera.Enable = false;
GuiController.Instance.setCamera(new Vector3(94.9854f, 138.4992f, -284.3344f), new Vector3(86.4563f, -15.4191f, 703.7123f));
//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
GuiController.Instance.UserVars.addVar("CollP-X:");
GuiController.Instance.UserVars.addVar("CollP-Y:");
GuiController.Instance.UserVars.addVar("CollP-Z:");
}
示例5: init
public override void init()
{
Microsoft.DirectX.Direct3D.Device d3dDevice = GuiController.Instance.D3dDevice;
//Cuerpo principal que se controla con el teclado
box = TgcBox.fromSize(new Vector3(0, 10, 0), new Vector3(10, 10, 10), Color.Blue);
//triangulo
triangle = new CustomVertex.PositionColored[3];
triangle[0] = new CustomVertex.PositionColored(-100, 0, 0, Color.Red.ToArgb());
triangle[1] = new CustomVertex.PositionColored(0, 0, 50, Color.Green.ToArgb());
triangle[2] = new CustomVertex.PositionColored(0, 100, 0, Color.Blue.ToArgb());
triagleAABB = TgcBoundingBox.computeFromPoints(new Vector3[] { triangle[0].Position, triangle[1].Position, triangle[2].Position });
//box2
box2 = TgcBox.fromSize(new Vector3(-50, 10, -20), new Vector3(15, 15, 15), Color.Violet);
//sphere
sphere = new TgcBoundingSphere(new Vector3(30, 20, -20), 15);
//OBB: computar OBB a partir del AABB del mesh.
TgcSceneLoader loader = new TgcSceneLoader();
TgcMesh meshObb = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vehiculos\\StarWars-ATST\\StarWars-ATST-TgcScene.xml").Meshes[0];
obb = TgcObb.computeFromAABB(meshObb.BoundingBox);
meshObb.dispose();
obb.move(new Vector3(100, 0, 30));
obb.setRotation(new Vector3(0, FastMath.PI / 4, 0));
//Configurar camara en Tercer Persona
GuiController.Instance.ThirdPersonCamera.Enable = true;
GuiController.Instance.ThirdPersonCamera.setCamera(box.Position, 30, -75);
}
示例6: init
public override void init()
{
Device d3dDevice = GuiController.Instance.D3dDevice;
//Cargar modelo
TgcSceneLoader loader = new TgcSceneLoader();
TgcScene scene = loader.loadSceneFromFile(
GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vehiculos\\StarWars-ATST\\StarWars-ATST-TgcScene.xml");
mesh = scene.Meshes[0];
//Computar OBB a partir del AABB del mesh. Inicialmente genera el mismo volumen que el AABB, pero luego te permite rotarlo (cosa que el AABB no puede)
obb = TgcObb.computeFromAABB(mesh.BoundingBox);
//Otra alternativa es computar OBB a partir de sus vertices. Esto genera un OBB lo mas apretado posible pero es una operacion costosa
//obb = TgcObb.computeFromPoints(mesh.getVertexPositions());
//Alejar camara rotacional segun tamaño del BoundingBox del objeto
GuiController.Instance.RotCamera.targetObject(mesh.BoundingBox);
//Modifier para poder rotar y mover el mesh
GuiController.Instance.Modifiers.addFloat("rotation", 0, 360, 0);
GuiController.Instance.Modifiers.addVertex3f("position", new Vector3(0, 0, 0), new Vector3(50, 50, 50), new Vector3(0, 0, 0));
}
示例7: import
public List<TgcMesh> import(string path)
{
TgcSceneLoader loader = new TgcSceneLoader();
TgcScene scene = loader.loadSceneFromFile(path);
List<TgcMesh> instances = new List<TgcMesh>();
foreach (TgcMesh m in scene.Meshes)
{
if (m.ParentInstance == null)//Si es un mesh original
{
//Lo agrego al diccionario
if (!meshes.ContainsKey(m.Name)) meshes.Add(m.Name, m);
else
{
//Por ahora no se puede cargar mas de un mesh original con el mismo nombre.
//TODO: Ver de que otro modo indexarlas y como unificar instancias de un mismo mesh que se cargo dos veces.
meshes[m.Name].dispose();
meshes.Remove(m.Name);
}
//Si no tenia hijos, creo una instancia para que se vea.
if (m.MeshInstances.Count == 0)
{
instances.Add(instanceOf(m));
}
}
else instances.Add(m);
}
return instances;
}
示例8: init
public override void init()
{
Device d3dDevice = GuiController.Instance.D3dDevice;
string sphere = GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Sphere\\Sphere-TgcScene.xml";
TgcSceneLoader loader = new TgcSceneLoader();
//Cargar modelos para el sol, la tierra y la luna. Son esfereas a las cuales le cambiamos la textura
sun = loader.loadSceneFromFile(sphere).Meshes[0];
sun.changeDiffuseMaps(new TgcTexture[] { TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesDir + "Transformations\\SistemaSolar\\SunTexture.jpg") });
earth = loader.loadSceneFromFile(sphere).Meshes[0];
earth.changeDiffuseMaps(new TgcTexture[] { TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesDir + "Transformations\\SistemaSolar\\EarthTexture.jpg") });
moon = loader.loadSceneFromFile(sphere).Meshes[0];
moon.changeDiffuseMaps(new TgcTexture[] { TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesDir + "Transformations\\SistemaSolar\\MoonTexture.jpg") });
//Deshabilitamos el manejo automático de Transformaciones de TgcMesh, para poder manipularlas en forma customizada
sun.AutoTransformEnable = false;
earth.AutoTransformEnable = false;
moon.AutoTransformEnable = false;
//Color de fondo
GuiController.Instance.BackgroundColor = Color.Black;
//Camara en primera persona
GuiController.Instance.FpsCamera.Enable = true;
GuiController.Instance.FpsCamera.setCamera(new Vector3(705.2938f, 305.347f, -888.1567f), new Vector3(183.6915f, 19.6596f, -84.2204f));
}
示例9: init
public override void init()
{
Device d3dDevice = GuiController.Instance.D3dDevice;
//Crear loader
TgcSceneLoader loader = new TgcSceneLoader();
//Cargar los mesh:
scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir
+ "MeshCreator\\Meshes\\Vehiculos\\TanqueFuturistaRuedas\\TanqueFuturistaRuedas-TgcScene.xml");
mesh = scene.Meshes[0];
mesh.Scale = new Vector3(0.5f, 0.5f, 0.5f);
mesh.Position = new Vector3(0f, 0f, 0f);
//Cargar Shader personalizado
effect = TgcShaders.loadEffect(GuiController.Instance.ExamplesDir + "Shaders\\WorkshopShaders\\Shaders\\BasicShader.fx");
// le asigno el efecto a la malla
mesh.Effect = effect;
// indico que tecnica voy a usar
// Hay effectos que estan organizados con mas de una tecnica.
mesh.Technique = "RenderScene";
//Centrar camara rotacional respecto a este mesh
GuiController.Instance.RotCamera.targetObject(mesh.BoundingBox);
time = 0;
}
示例10: init
public override void init()
{
Device d3dDevice = GuiController.Instance.D3dDevice;
//Cargar escenario con información especial exportada de PortalRendering
TgcSceneLoader loader = new TgcSceneLoader();
scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesDir + "PortalRendering\\EscenarioPortal\\EscenarioPortal-TgcScene.xml");
//Descactivar inicialmente a todos los modelos
scene.setMeshesEnabled(false);
//Camara en 1ra persona
GuiController.Instance.FpsCamera.Enable = true;
GuiController.Instance.FpsCamera.MovementSpeed = 800f;
GuiController.Instance.FpsCamera.JumpSpeed = 600f;
GuiController.Instance.FpsCamera.setCamera(new Vector3(0, 0, 0), new Vector3(0, 0, 1));
//Modifiers
GuiController.Instance.Modifiers.addBoolean("portalRendering", "PortalRendering", true);
GuiController.Instance.Modifiers.addBoolean("WireFrame", "WireFrame", false);
GuiController.Instance.Modifiers.addBoolean("showPortals", "Show Portals", false);
//UserVars
GuiController.Instance.UserVars.addVar("MeshCount");
//Crear portales debug
scene.PortalRendering.createDebugPortals(Color.Purple);
}
示例11: EscenarioManager
public EscenarioManager()
{
EscenarioManager.Instance = this;
sonido = SoundManager.getInstance();
arboles = new List<TgcMesh>();
pasto = new List<TgcMesh>();
barriles = new List<Barril>();
loader = new TgcSceneLoader();
casillasPorEje = 50;
divisionesPiso = new Vector3[2500];
_random = new Random();
piso = new TgcBox();
piso.UVTiling = new Vector2(300, 300);
pisoSize = (int) tamanio;
piso.setPositionSize(new Vector3(0, 0, 0), new Vector3(pisoSize*2, 0, pisoSize*2));
piso.updateValues();
piso.setTexture(TgcTexture.createTexture(GuiController.Instance.D3dDevice, GuiController.Instance.AlumnoEjemplosMediaDir + "\\RenderMan\\texturas\\nieve.png"));
generarSkyBox();
colisionables = new List<TgcBoundingCylinder>();
limites = new TgcBoundingBox(new Vector3(-tamanio, 0, -tamanio), new Vector3(tamanio, 5000, tamanio));
GuiController.Instance.Modifiers.addInt("Viento en X", 0, 30, 5);
GuiController.Instance.Modifiers.addInt("Viento en Z", 0, 30, 5);
}
示例12: Chispa
public Chispa()
{
TgcSceneLoader loader = new TgcSceneLoader();
mesh = loader.loadSceneFromFile(sphere).Meshes[0];
mesh.changeDiffuseMaps(new TgcTexture[] { TgcTexture.createTexture(d3dDevice, Shared.mediaPath + "\\otros\\giallo.png") });
mesh.Scale = new Vector3(0.08f, 0.08f, 0.08f);
}
示例13: init
public override void init()
{
Device d3dDevice = GuiController.Instance.D3dDevice;
//Crear loader
TgcSceneLoader loader = new TgcSceneLoader();
//Cargar mesh
TgcScene scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Olla\\Olla-TgcScene.xml");
mesh = scene.Meshes[0];
//Crear caja para indicar ubicacion de la luz
lightMesh = TgcBox.fromSize(new Vector3(20, 20, 20), Color.Yellow);
//Modifiers de la luz
GuiController.Instance.Modifiers.addBoolean("lightEnable", "lightEnable", true);
GuiController.Instance.Modifiers.addVertex3f("lightPos", new Vector3(-500, -500, -500), new Vector3(500, 800, 500), new Vector3(0, 500, 0));
GuiController.Instance.Modifiers.addColor("ambient", Color.Gray);
GuiController.Instance.Modifiers.addColor("diffuse", Color.Blue);
GuiController.Instance.Modifiers.addColor("specular", Color.White);
GuiController.Instance.Modifiers.addFloat("specularEx", 0, 40, 20f);
//Centrar camara rotacional respecto a este mesh
GuiController.Instance.RotCamera.targetObject(mesh.BoundingBox);
}
示例14: init
public override void init()
{
Device d3dDevice = GuiController.Instance.D3dDevice;
TgcSceneLoader loader = new TgcSceneLoader();
TgcScene scene = loader.loadSceneFromFile(
GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Box\\" + "Box-TgcScene.xml",
GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Box\\");
mesh = scene.Meshes[0];
mesh.Scale = new Vector3(0.25f, 0.25f, 0.25f);
GuiController.Instance.FpsCamera.Enable = true;
GuiController.Instance.FpsCamera.setCamera(new Vector3(7.9711f, 11.7f, -32.5475f), new Vector3(7.972f, 11.4178f, -31.5475f));
GuiController.Instance.Modifiers.addVertex3f("origin", new Vector3(-100, -100, -100), new Vector3(100, 100, 100), new Vector3(0, 0, 0));
GuiController.Instance.Modifiers.addVertex3f("dimension", new Vector3(-100, -100, -100), new Vector3(1000, 1000, 100), new Vector3(10, 10, 10));
GuiController.Instance.Modifiers.addInterval("orientation", new string[] { "XY", "XZ", "YZ" }, 0);
GuiController.Instance.Modifiers.addVertex2f("tiling", new Vector2(0,0), new Vector2(10,10),new Vector2(1,1));
string texturePath = GuiController.Instance.ExamplesMediaDir + "Texturas\\Quake\\TexturePack2\\brick1_1.jpg";
currentTexture = TgcTexture.createTexture(d3dDevice, texturePath);
GuiController.Instance.Modifiers.addTexture("texture", currentTexture.FilePath);
updateWall();
}
示例15: init
/// <summary>
/// Método que se llama una sola vez, al principio cuando se ejecuta el ejemplo.
/// Escribir aquí todo el código de inicialización: cargar modelos, texturas, modifiers, uservars, etc.
/// Borrar todo lo que no haga falta
/// </summary>
public override void init()
{
//GuiController.Instance: acceso principal a todas las herramientas del Framework
//Device de DirectX para crear primitivas
Microsoft.DirectX.Direct3D.Device d3dDevice = GuiController.Instance.D3dDevice;
TgcSceneLoader loader = new TgcSceneLoader();
nivel = new Nivel1();
fpsCamara = new Camara();
GuiController.Instance.CurrentCamera = fpsCamara;
fpsCamara.MovementSpeed = 1000f;
fpsCamara.RotationSpeed = 2f;
fpsCamara.setCamera(nivel.posicionInicial(), nivel.orientacionCamara());
fpsCamara.updateViewMatrix(d3dDevice);
colisionador = new ManejadorColisiones(fpsCamara, nivel.Obstaculos);
//Iniciarlizar PickingRay
pickingRay = new TgcPickingRay();
}