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); }
/// <summary> /// Iniciar la creacion /// </summary> public override void initCreation(TGCVector3 gridPoint) { initSelectionPoint = gridPoint; //Crear caja inicial var sphereTexture = TgcTexture.createTexture(Control.CreationTexturePath()); mesh = new TGCSphere(); mesh.setTexture(sphereTexture); // mesh.BoundingSphere.setRenderColor(MeshCreatorUtils.UNSELECTED_OBJECT_COLOR); mesh.AutoTransformEnable = true; bb.setRenderColor(MeshCreatorUtils.UNSELECTED_OBJECT_COLOR); Layer = Control.CurrentLayer; }
/// <summary> /// Actualiza los parámetros de la caja en base a lo cargado por el usuario /// </summary> private void updateSphere() { var bTexture = useTextureModifier.Value; var color = colorModifier.Value; sphere.RenderEdges = edgesModifier.Value; sphere.Inflate = inflateModifier.Value; sphere.BasePoly = (TGCSphere.eBasePoly)baseModifier.Value; if (bTexture) { //Cambiar textura var texturePath = textureModifier.Value; if (texturePath != currentTexture || !useTexture || (sphere.RenderEdges && sphere.Color != color)) { currentTexture = texturePath; sphere.setColor(color); sphere.setTexture(TgcTexture.createTexture(D3DDevice.Instance.Device, currentTexture)); } } else { sphere.setColor(color); } useTexture = bTexture; //Radio, posición y color sphere.Radius = radiusModifier.Value; sphere.Position = positionModifier.Value; sphere.LevelOfDetail = (int)levelOfDetailModifier.Value; //Rotación, converitr a radianes var rotation = rotationModifier.Value; sphere.Rotation = new TGCVector3(Geometry.DegreeToRadian(rotation.X), Geometry.DegreeToRadian(rotation.Y), Geometry.DegreeToRadian(rotation.Z)); //Offset de textura sphere.UVOffset = offsetModifier.Value; //Tiling de textura sphere.UVTiling = tilingModifier.Value; //Actualizar valores en la caja. sphere.updateValues(); }
private void InitializeSphere() { // Got to set a texture, else the translation to mesh does not map UV var texture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\white.bmp"); var sphere = new TGCSphere(); sphere.Radius = 40.0f; sphere.LevelOfDetail = 3; sphere.setTexture(texture); sphere.updateValues(); sphereMesh = sphere.toMesh("sphere"); sphereMesh.Transform = TGCMatrix.Scaling(TGCVector3.One * 30f); sphereMesh.Effect = effect; sphereMesh.Technique = "PBR"; sphereMesh.DiffuseMaps = new TgcTexture[0]; sphereMesh.RenderType = TgcMesh.MeshRenderType.VERTEX_COLOR; sphere.Dispose(); }
private void InitializePBRMesh() { // Got to set a texture, else the translation to mesh does not map UV var texture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\white.bmp"); var sphere = new TGCSphere(); sphere.Radius = 40.0f; sphere.LevelOfDetail = 3; sphere.setTexture(texture); sphere.updateValues(); pbrMesh = sphere.toMesh("sphere"); pbrMesh.Effect = effect; pbrMesh.Technique = "PBRIBL"; pbrMesh.DiffuseMaps = new TgcTexture[0]; pbrMesh.RenderType = TgcMesh.MeshRenderType.VERTEX_COLOR; sphere.Dispose(); var texturePath = MediaDir + "Texturas\\"; var scaling = TGCMatrix.Scaling(TGCVector3.One * 25f); var harsh = new PBRTexturedMesh("Harsh-Metal", texturePath, scaling * TGCMatrix.Translation(0f, 100f, 100f), pbrMesh); var gold = new PBRTexturedMesh("Gold", texturePath, scaling * TGCMatrix.Translation(0f, 100f, 0f), pbrMesh); var marble = new PBRTexturedMesh("Marble", texturePath, scaling * TGCMatrix.Translation(0f, 100f, -100f), pbrMesh); var ground = new PBRTexturedMesh("Ground", texturePath, scaling * TGCMatrix.Translation(0f, 100f, -200f), pbrMesh); var metal = new PBRTexturedMesh("Metal", texturePath, scaling * TGCMatrix.Translation(0f, 100f, 200f), pbrMesh); pbrTexturedMeshes.AddRange(new List <PBRTexturedMesh> { harsh, gold, marble, ground, metal }); var greenSomething = new PBRMesh(new TGCVector3(0.05f, 0.74f, 0.3f), 0.5f, 0.5f, scaling * TGCMatrix.Translation(0f, 100f, 400f), pbrMesh); var redRubber = new PBRMesh(new TGCVector3(1f, 0.05f, 0.1f), 0.1f, 0.9f, scaling * TGCMatrix.Translation(0f, 100f, 300f), pbrMesh); var blueMetal = new PBRMesh(new TGCVector3(0f, 0.2f, 1.0f), 0.75f, 0.3f, scaling * TGCMatrix.Translation(0f, 100f, -300f), pbrMesh); pbrMeshes.AddRange(new List <PBRMesh> { redRubber, blueMetal, greenSomething }); }
public override void setTexture(TgcTexture texture, int slot) { mesh.setTexture(texture); }