本文整理汇总了C#中TgcViewer.Utils.TgcSceneLoader.TgcSceneLoader.loadSceneFromFile方法的典型用法代码示例。如果您正苦于以下问题:C# TgcSceneLoader.loadSceneFromFile方法的具体用法?C# TgcSceneLoader.loadSceneFromFile怎么用?C# TgcSceneLoader.loadSceneFromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TgcViewer.Utils.TgcSceneLoader.TgcSceneLoader
的用法示例。
在下文中一共展示了TgcSceneLoader.loadSceneFromFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
示例2: init
public override void init()
{
Device d3dDevice = GuiController.Instance.D3dDevice;
TgcSceneLoader loader = new TgcSceneLoader();
TgcScene sceneOriginal = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Iglesia\\" + "Iglesia-TgcScene.xml");
TgcScene sceneOriginal2 = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Iglesia\\" + "Iglesia-TgcScene.xml");
//sceneOriginal = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\CajaVerde\\" + "CajaVerde-TgcScene.xml");
//sceneOriginal = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Avion\\" + "Avion-TgcScene.xml");
//sceneOriginal = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Iglesia\\" + "Iglesia-TgcScene.xml");
//TgcScene sceneOriginal = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Box\\" + "Box-TgcScene.xml");
//TgcScene sceneOriginal2 = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Box\\" + "Box-TgcScene.xml");
string destFolder = GuiController.Instance.ExamplesDir + "\\" + "PruebaExporter";
TgcScene unifiedScene = new TgcScene("PruebaExporter", destFolder);
unifiedScene.Meshes.AddRange(sceneOriginal.Meshes);
unifiedScene.Meshes.AddRange(sceneOriginal2.Meshes);
TgcSceneExporter exporter = new TgcSceneExporter();
//string fileSaved = exporter.exportSceneToXml(unifiedScene, destFolder);
//string fileSaved = exporter.exportAndAppendSceneToXml(unifiedScene, destFolder);
TgcSceneExporter.ExportResult r = exporter.exportAndAppendSceneToXml(sceneOriginal, destFolder);
sceneRecover = loader.loadSceneFromFile(r.filePath);
}
示例3: 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));
}
示例4: 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;
}
示例5: 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;
}
示例6: 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);
}
示例7: 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);
}
示例8: init
public override void init()
{
Device d3dDevice = GuiController.Instance.D3dDevice;
//Cargar mesh
TgcSceneLoader loader = new TgcSceneLoader();
mesh = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\LogoTGC\\LogoTGC-TgcScene.xml").Meshes[0];
//Cargar Shader de PhongShading
mesh.Effect = GuiController.Instance.Shaders.TgcMeshPhongShader;
mesh.Technique = GuiController.Instance.Shaders.getTgcMeshTechnique(mesh.RenderType);
//Texto help
textHelp = new TgcText2d();
textHelp.Position = new Point(15, 260);
textHelp.Size = new Size(500, 100);
textHelp.changeFont(new System.Drawing.Font("TimesNewRoman", 16, FontStyle.Regular));
textHelp.Color = Color.Yellow;
textHelp.Align = TgcText2d.TextAlign.LEFT;
textHelp.Text = "¿Por dónde empezar? Presionar \"H\"";
//Help form
string helpRtf = File.ReadAllText(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\LogoTGC\\help.rtf");
helpForm = new EjemploDefaultHelpForm(helpRtf);
//Camara
GuiController.Instance.RotCamera.Enable = true;
GuiController.Instance.RotCamera.CameraCenter = new Vector3(0, 0, 0);
GuiController.Instance.RotCamera.CameraDistance = 150;
GuiController.Instance.BackgroundColor = Color.Black;
}
示例9: 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;
}
示例10: 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));
}
示例11: init
public override void init()
{
Device d3dDevice = GuiController.Instance.D3dDevice;
//Cargar escenario
TgcSceneLoader loader = new TgcSceneLoader();
scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml");
//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));
//Mesh para la luz
lightMesh = TgcBox.fromSize(new Vector3(10, 10, 10), Color.Red);
//Modifiers de la luz
GuiController.Instance.Modifiers.addBoolean("lightEnable", "lightEnable", true);
GuiController.Instance.Modifiers.addVertex3f("lightPos", new Vector3(-200, -100, -200), new Vector3(200, 200, 300), new Vector3(60, 35, 250));
GuiController.Instance.Modifiers.addColor("lightColor", Color.White);
GuiController.Instance.Modifiers.addFloat("lightIntensity", 0, 150, 20);
GuiController.Instance.Modifiers.addFloat("lightAttenuation", 0.1f, 2, 0.3f);
GuiController.Instance.Modifiers.addFloat("specularEx", 0, 20, 9f);
//Modifiers de material
GuiController.Instance.Modifiers.addColor("mEmissive", Color.Black);
GuiController.Instance.Modifiers.addColor("mAmbient", Color.White);
GuiController.Instance.Modifiers.addColor("mDiffuse", Color.White);
GuiController.Instance.Modifiers.addColor("mSpecular", Color.White);
}
示例12: 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();
}
示例13: 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);
}
示例14: 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;
}
示例15: 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);
}