/// <summary> /// The default values /// </summary> protected override void DefaultValues() { base.DefaultValues(); this.parsedTrackables = new Dictionary <string, TargetTypes>(); this.maxSimultaneousImageTargets = 1; this.maxSimultaneousObjectTargets = 1; this.extendedTracking = true; this.backgroundCameraMaterial = new StandardMaterial() { LayerId = DefaultLayers.Skybox, LightingEnabled = false, }; #if IOS this.platformSpecificARService = new ARServiceIOS(); #elif ANDROID this.platformSpecificARService = new ARServiceAndroid(); #elif UWP this.platformSpecificARService = new ARServiceUWP(); #else this.platformSpecificARService = null; #endif this.IsSupported = this.platformSpecificARService != null; }
protected StoryFlowchartNodeGizmoComponent(IEmbeddedResources embeddedResources, IViewService viewService) { this.viewService = viewService; GlobalRectangle = new AaRectangle2(Vector2.Zero, 1, 1); var squareModel = embeddedResources.SimplePlaneXyModel(); var material = StandardMaterial.New(this) .SetDiffuseColor(x => x.DiffuseColorToUse()) .SetDiffuseMap(x => x.DiffuseMapToUse()) .SetIgnoreLighting(true) .SetHighlightEffect(x => x.viewService.SelectedNode == ReferencedNode ? HighlightEffect.RainbowBorder : x.viewService.ClosestStoryNode == ReferencedNode ? HighlightEffect.Pulsating : HighlightEffect.None); visualElement = new ModelVisualElement <StoryFlowchartNodeGizmoComponent>(this) .SetModel(squareModel) .SetMaterial(material) .SetTransform(x => Transform.Translation(new Vector3(x.GlobalRectangle.Center, x.Depth * 0.1f))) .SetNonUniformScale(x => new Vector3(x.GlobalRectangle.HalfWidth, -/*todo: correct text-coords*/ x.GlobalRectangle.HalfHeight, 1)); hittable = new RectangleHittable <StoryFlowchartNodeGizmoComponent>(this, Transform.Identity, x => new AaRectangle2(Vector2.Zero, x.GlobalRectangle.HalfWidth, x.GlobalRectangle.HalfHeight), x => - x.Depth); }
private void BuildVisualElements() { if (Model == null) { visualElems = EmptyArrays <IVisualElement> .Array; return; } visualElems = new IVisualElement[Model.PartCount]; for (var i = 0; i < Model.PartCount; i++) { var iLoc = i; var material = StandardMaterial.New(this) .SetDiffuseColor(x => x.GetColor(iLoc)) .SetDiffuseMap(x => x.Texture) .SetNoSpecular(x => x.NoSpecular) .SetIgnoreLighting(x => x.IgnoreLighting); var elem = new ModelVisualElement <ModelComponent>(this) .SetModel(Model) .SetModelPartIndex(i) .SetMaterial(material) .SetRenderState(StandardRenderState.New(this) .SetCullFace(x => x.DontCull ? CullFace.None : CullFace.Back)) .SetTransformSpace(x => x.Ortho ? TransformSpace.Ortho : TransformSpace.Scene); visualElems[i] = elem; } }
/// <summary> /// Updates the behavior. Place each radar ticks /// </summary> /// <param name="gameTime"></param> protected override void Update(TimeSpan gameTime) { for (int i = 0; i < this.radarTicks.Count; i++) { var fighter = this.screenplay.FighterList[i]; Transform3D fighterTransform = fighter.Transform; Transform3D radarTransform = this.radarTicks[i]; Vector3 distance = fighterTransform.Position - this.transform.Position; float distanceLength = distance.Length(); if (distanceLength < radarRange) { StandardMaterial material = radarTickMaterials[i]; if (!radarTransform.Owner.Enabled) { radarTransform.Owner.Enabled = true; } float lerp = distanceLength / radarRange; float atenuationColor = (lerp < decay) ? 1 : 1 - ((lerp - decay) / decayInv); Color color = this.colors[(int)fighter.State] * atenuationColor; radarTransform.LocalPosition = (distance / radarRange) * radarSize; material.DiffuseColor = color; } else if (radarTransform.Owner.Enabled) { radarTransform.Owner.Enabled = false; } } }
public BlockView(Scene scene, int x, int y, int z, string keyCol = null) { dataMap = new DataMap(); Obj = Mesh.CreateBox("Obj", 10, scene); Obj.position.z = globalX = (decimal)(dataMap.sizeMapX * (-4.5) + (x * 10.15)); Obj.position.x = globalY = (decimal)(dataMap.sizeMapY * (-4.5) + (y * 10.15)); if (z == 0) { Obj.position.y = globalZ = 5; // 4 - высота обьекта } else { Obj.position.y = globalZ = 5 * (z + z) + 5; // 4 - высота обьекта } materialBox = new StandardMaterial("temp", scene); if (keyCol == "Ground") { materialBox.diffuseColor = new Color3((decimal)0.17, (decimal)0.17, (decimal)0.17); } if (keyCol == "Box") { materialBox.diffuseColor = new Color3((decimal)0.10, (decimal)0.10, (decimal)0.10); } if (keyCol == "Win") { materialBox.diffuseColor = new Color3(0, (decimal)0.8, 0); } Obj.material = materialBox; }
/// <summary> /// Initializes the radar behavior /// </summary> protected override void Initialize() { base.Initialize(); this.screenplay = this.EntityManager.Find("ScreenplayManager").FindComponent <ScreenplayManager>(); foreach (var fighter in this.screenplay.FighterList) { if (fighter.State == FighterState.Player) { continue; } Transform3D radarTickTransform; StandardMaterial radarTickMaterial; Entity radarTick = new Entity() .AddComponent(radarTickTransform = new Transform3D()) .AddComponent(new Model("Content/Models/Hud/HudRadarTick.FBX")) .AddComponent(new ModelRenderer()) .AddComponent(new MaterialsMap(radarTickMaterial = new StandardMaterial(typeof(CockpitAdditiveLayer), "Content/Textures/Hud/RadarTick.png") { DiffuseColor = colors[(int)fighter.State] })) ; radarTick.Enabled = false; this.Owner.AddChild(radarTick); this.radarTicks.Add(radarTickTransform); this.radarTickMaterials.Add(radarTickMaterial); } }
protected StoryFlowchartEdgeGizmoComponent(IEmbeddedResources embeddedResources) { var lineModel = embeddedResources.LineModel(); Material = StandardMaterial.New() .SetDiffuseColor(new Color4(0f, 0.5f, 0f)) .SetIgnoreLighting(true) .FromGlobalCache(); RenderState = StandardRenderState.New() .SetLineWidth(3) .FromGlobalCache(); visualElements = new IVisualElement[] { new ModelVisualElement <StoryFlowchartEdgeGizmoComponent>(this) .SetModel(lineModel) .SetMaterial(x => x.Material) .SetTransform(x => GetTransformForLine(x.FirstPoint, x.MiddlePoint)), new ModelVisualElement <StoryFlowchartEdgeGizmoComponent>(this) .SetModel(lineModel) .SetMaterial(x => x.Material) .SetTransform(x => GetTransformForLine(x.MiddlePoint, x.LastPoint)) }; }
/// <summary> /// Creates a new layer mesh /// </summary> /// <param name="startIndex">Start index.</param> /// <param name="count">Count indices</param> /// <param name="bufferIndex">The buffer index</param> /// <param name="image">Mesh material</param> /// <param name="boundingBox">Mesh bounding box</param> private void NewMesh(int startIndex, int count, int bufferIndex, Texture2D image, ref BoundingBox boundingBox) { var mesh = new Mesh( 0, this.vertices.Length, startIndex * IndicesPerTile, count * 2, this.vertexBuffer[bufferIndex], this.indexBuffer[bufferIndex], PrimitiveType.TriangleList) { DisableBatch = true, MaterialIndex = this.materials.Count, BoundingBox = boundingBox, }; var material = new StandardMaterial(this.LayerId, image) { LightingEnabled = false }; material.Initialize(this.Assets); this.materials.Add(material); this.meshes.Add(mesh); }
protected override void ResolveDependencies() { base.ResolveDependencies(); wo = Owner.Parent.FindComponent <WorldObject>(); particles = Owner.FindComponent <ParticleSystem2D>(); mat = (Owner.FindComponent <MaterialsMap>().DefaultMaterial as StandardMaterial); }
private static IStandardMaterial CreateUndefinedMaterial() { return(StandardMaterial.New() .SetDiffuseColor(Color4.Red) .SetNoSpecular(true) .FromGlobalCache()); }
public MuseumStoryLayout(IEmbeddedResources embeddedResources, IWorldTreeService worldTreeService) { this.worldTreeService = worldTreeService; floorModel = embeddedResources.PlaneModel(PlaneModelSourcePlane.Xy, PlaneModelSourceNormalDirection.Positive, globalRadius, globalRadius, 1, 1); ceilingModel = embeddedResources.PlaneModel(PlaneModelSourcePlane.Xy, PlaneModelSourceNormalDirection.Negative, globalRadius, globalRadius, 1, 1); exitWallModel = embeddedResources.PlaneModel(PlaneModelSourcePlane.Xz, PlaneModelSourceNormalDirection.Negative, exitHalfLength, ceilingHalfHeight, 1, 1); corridorWallModel = embeddedResources.PlaneModel(PlaneModelSourcePlane.Xz, PlaneModelSourceNormalDirection.Negative, corridorHalfWidth, ceilingHalfHeight, 1, 1); frustumModel = embeddedResources.SimpleFrustumModel(); floorMaterial = StandardMaterial.New() .SetDiffuseMap(embeddedResources.Image("Textures/museum_floor.jpg")) .SetNoSpecular(true) .FromGlobalCache(); ceilingMaterial = StandardMaterial.New() .SetDiffuseMap(embeddedResources.Image("Textures/museum_ceiling.jpg")) .SetNoSpecular(true) .FromGlobalCache(); wallMaterial = StandardMaterial.New() .SetDiffuseMap(embeddedResources.Image("Textures/museum_wall.jpg")) .SetNoSpecular(true) .FromGlobalCache(); frustumMaterial = StandardMaterial.New() .SetDiffuseColor(Color4.Green) .SetIgnoreLighting(true) .FromGlobalCache(); }
private void SpawnCubeAtPosition(Vector3 position) { var go = new GameObject("Cube"); Scene.current.Add(go); go.Transform.LocalPosition = position; var cube = go.AddComponent <MeshRenderer>(); cube.Geometry = new CubeMesh(); cube.Geometry.Size = new Vector3(1.0f); cube.Geometry.Build(); cube.CastShadow = true; cube.ReceiveShadow = false; var material = new StandardMaterial(Scene.current); material.DiffuseColor = RandomHelper.GetColor(); material.MainTexture = Application.Content.Load <Texture2D>("Textures/Terrain/Rock"); material.NormalTexture = Application.Content.Load <Texture2D>("Textures/Terrain/Rock_Normal"); cube.Material = material; var collider = cube.AddComponent <BoxCollider>(); var rb = cube.AddComponent <Rigidbody>(); rb.AddComponent <RigidbodyRenderer>(); }
public TeleportView(Scene scene, PositionPair pos) { dataMap = new DataMap(); Obj = Mesh.CreateTorus("torus", 10, 1, 10, scene); Obj.position.z = globalX = (decimal)(dataMap.sizeMapX * (-4.5) + (pos.pairPosition[0].x * 10.15)); Obj.position.x = globalY = (decimal)(dataMap.sizeMapY * (-4.5) + (pos.pairPosition[0].y * 10.15)); if (pos.pairPosition[0].z == 0) { Obj.position.y = 1; } else { Obj.position.y = (decimal)5 * (pos.pairPosition[0].z + pos.pairPosition[0].z); } Obj2 = Mesh.CreateTorus("torus", 10, 1, 8, scene); Obj2.position.z = globalX = (decimal)(dataMap.sizeMapX * (-4.5) + (pos.pairPosition[1].x * 10.15)); Obj2.position.x = globalY = (decimal)(dataMap.sizeMapY * (-4.5) + (pos.pairPosition[1].y * 10.15)); if (pos.pairPosition[1].z == 0) { Obj2.position.y = 1; } else { Obj2.position.y = (decimal)5 * (pos.pairPosition[1].z + pos.pairPosition[1].z); } materialBox = new StandardMaterial("temp", scene); materialBox.diffuseColor = new Color3(pos.red, pos.green, pos.blue); Obj.material = materialBox; Obj2.material = materialBox; }
public override void Initialize() { base.Initialize(); // Add a camera with a FPS controller var cameraGo = AddGameObject("Camera"); GameObjectFactory.CreateCamera(new Vector3(0, 2, -10), new Vector3(0, 0, 0), Vector3.Up); var camera = cameraGo.GetComponent <Camera>(); camera.Setup(new Vector3(0, 2, 5), Vector3.Forward, Vector3.Up); camera.Far = 10000; camera.AddComponent <EditorController>(); // And a light var lightGo = AddGameObject("Directional"); lightGo.Transform.LocalPosition = new Vector3(500, 500, 0); lightGo.Transform.LocalRotation = new Vector3(MathHelper.PiOver2, -MathHelper.PiOver4, 0); var directionalLight = lightGo.GetComponent <Light>(); // Sun Flares var content = Application.Content; var glowTexture = content.Load <Texture2D>("Textures/Flares/SunGlow"); var flareTextures = new Texture2D[] { content.Load <Texture2D>("Textures/Flares/circle"), content.Load <Texture2D>("Textures/Flares/circle_sharp_1"), content.Load <Texture2D>("Textures/Flares/circle_soft_1") }; var direction = directionalLight.Direction; var sunflares = directionalLight.AddComponent <LensFlare>(); sunflares.Setup(glowTexture, flareTextures); // Skybox var blueSkybox = new string[6] { "Textures/Skybox/bluesky/px", "Textures/Skybox/bluesky/nx", "Textures/Skybox/bluesky/py", "Textures/Skybox/bluesky/ny", "Textures/Skybox/bluesky/pz", "Textures/Skybox/bluesky/nz" }; RenderSettings.Skybox.Generate(Application.GraphicsDevice, blueSkybox); // Grid var grid = new GameObject("Grid"); grid.Tag = EditorGame.EditorTag; grid.AddComponent <Grid>(); _defaultMaterial = new StandardMaterial(); _defaultMaterial.MainTexture = TextureFactory.CreateColor(Color.WhiteSmoke, 1, 1); SceneInitialized?.Invoke(new[] { cameraGo, lightGo }); }
public SphereStoryLayout(IEmbeddedResources embeddedResources) { frustumModel = embeddedResources.SimpleFrustumModel(); frustumMaterial = StandardMaterial.New() .SetDiffuseColor(Color4.Green) .SetIgnoreLighting(true) .FromGlobalCache(); }
public static GameObject ToMeshRenderers(this Model model, Scene scene) { var boneTransforms = new Matrix[model.Bones.Count]; model.CopyAbsoluteBoneTransformsTo(boneTransforms); var gameObject = new GameObject("Model"); scene.Add(gameObject); foreach (ModelMesh mesh in model.Meshes) { var meshPartIndex = 0; var parent = new GameObject(mesh.Name); scene.Add(parent); parent.Transform.Parent = gameObject.Transform; var matrix = boneTransforms[mesh.ParentBone.Index]; Vector3 position; Quaternion rotation; Vector3 scale; matrix.Decompose(out scale, out rotation, out position); parent.Transform.LocalPosition = position; parent.Transform.LocalRotation = rotation.ToEuler(); parent.Transform.LocalScale = scale; foreach (var part in mesh.MeshParts) { var effect = (BasicEffect)part.Effect; var material = new StandardMaterial(scene); material.MainTexture = effect.Texture; material.DiffuseColor = new Color(effect.DiffuseColor.X, effect.DiffuseColor.Y, effect.DiffuseColor.Z); material.SpecularColor = new Color(effect.SpecularColor.X, effect.SpecularColor.Y, effect.SpecularColor.Z); material.Shininess = effect.SpecularPower; material.EmissiveColor = new Color(effect.EmissiveColor.X, effect.EmissiveColor.Y, effect.EmissiveColor.Z); var child = new GameObject($"{mesh.Name}_{meshPartIndex}"); scene.Add(child); var renderer = child.AddComponent <MeshRenderer>(); renderer.material = material; renderer.CastShadow = true; renderer.ReceiveShadow = true; var geometry = new Mesh(); geometry.VertexBuffer = part.VertexBuffer; geometry.IndexBuffer = part.IndexBuffer; renderer.Geometry = geometry; child.Transform.Parent = parent.Transform; } } return(gameObject); }
/// <summary> /// Initializes the instance. /// </summary> protected override void Initialize() { base.Initialize(); this.material = new StandardMaterial() { DiffuseColor = Color.White, LightingEnabled = false, LayerId = this.LayerId }; }
/// <summary> /// Initializes the instance. /// </summary> protected override void Initialize() { base.Initialize(); this.material = new StandardMaterial() { DiffuseColor = Color.White, LightingEnabled = false, LayerType = DefaultLayers.Alpha }; }
/// <summary> /// Instantiate model hierarchy /// </summary> /// <param name="entityName">The entity name</param> /// <param name="setMaterials">Set the materials to entities</param> /// <returns>The entity hierarchy</returns> public Entity InstantiateModelHierarchy(string entityName, bool setMaterials) { var nodeEntities = new Entity[this.Nodes.Length]; for (int i = 0; i < this.Nodes.Length; i++) { nodeEntities[i] = this.CreateNodeEntity(this.Nodes[i]); } Material material = new StandardMaterial(); Entity rootEntity = null; if (this.RootNodes.Length == 1) { var rootNodeIx = this.RootNodes[0]; rootEntity = nodeEntities[rootNodeIx]; this.GenerateModelsHierarchy(nodeEntities, rootNodeIx, material, null); } else { rootEntity = new Entity() .AddComponent(new Transform3D()); for (int i = 0; i < this.RootNodes.Length; i++) { this.GenerateModelsHierarchy(nodeEntities, this.RootNodes[i], material, rootEntity); } } for (int i = 0; i < this.Nodes.Length; i++) { this.FillNode(i, nodeEntities, setMaterials); } if (this.Animations.Count > 0) { var animation = new Animation3D() { ModelPath = this.AssetPath }; rootEntity.AddComponent(animation); } if (string.IsNullOrEmpty(entityName)) { rootEntity.Name = Entity.NextDefaultName(); } else { rootEntity.Name = entityName; } return(rootEntity); }
void ImportMaterialLibraries(ObjLine materialLine, BabylonScene scene) { for (int i = 1; i < materialLine.Tokens.Length; i++) { string fileName = materialLine.Tokens[i]; var mtlDocument = new Document <MtlLine>(File.ReadAllText(fileName)); StandardMaterial currentMaterial = null; foreach (var lines in mtlDocument.Blocks) { foreach (MtlLine line in lines) { switch (line.Header) { case MtlHeader.Material: currentMaterial = new StandardMaterial(line.Tokens[1]); currentMaterial.BackFaceCulling = false; materials.Add(currentMaterial); break; case MtlHeader.DiffuseColor: currentMaterial.Diffuse = line.ToColor(); break; case MtlHeader.DiffuseTexture: currentMaterial.Diffuse = new Color3(1, 1, 1); currentMaterial.DiffuseTexture = line.Tokens[1].Replace("//", @"\"); break; case MtlHeader.Alpha: currentMaterial.Alpha = line.ToFloat(); break; case MtlHeader.EmissiveColor: currentMaterial.Emissive = line.ToColor(); break; case MtlHeader.SpecularColor: currentMaterial.Specular = line.ToColor(); break; case MtlHeader.SpecularPower: currentMaterial.SpecularPower = line.ToFloat(); break; } } } } foreach (var material in materials) { material.CreateBabylonMaterial(scene); } }
protected override bool OnAttached() { var material = this.Managers.AssetSceneManager.Load <Material>(EvergineContent.Materials.Car.CarPaint); this.targetStandardMaterial = new StandardMaterial(material); this.interaction.CarColorChanged += this.OnColorChanged; return(base.OnAttached()); }
public void OnQueryServiceUpdated() { visualElements.Clear(); optionRects.Clear(); currentQuery = queryService.Queries.LastOrDefault() as OptionsUserQuery; if (currentQuery == null || !currentQuery.Options.Any()) { return; } const float OptionMargin = 0.1f; const float OptionHalfHeight = 0.09f; const float OptionHalfWidth = 0.9f; var currentY = 1f; for (var i = 0; i < currentQuery.Options.Count; i++) { currentY -= OptionMargin; currentY -= OptionHalfHeight; optionRects.Add(new AaRectangle2(new Vector2(0, currentY), OptionHalfWidth, OptionHalfHeight)); currentY -= OptionHalfHeight; currentY -= OptionMargin; } var totalHeight = 1f - currentY; var centerY = 1f - totalHeight / 2; for (int i = 0; i < currentQuery.Options.Count; i++) { var option = currentQuery.Options[i]; var rect = optionRects[i]; rect.Center.Y -= centerY; optionRects[i] = rect; var textBox = RichTextHelper.Label(option, new IntSize2((int)(2 * 512 * OptionHalfWidth), (int)(2 * 512 * OptionHalfHeight)), RtParagraphAlignment.Center, Color4.Black, RtTransparencyMode.Opaque, "Arial", 32, Color4.Orange, FontDecoration.None); var textImageRgba = textImageBuilder.BuildImageRgba(textBox); var textImage = new RawImage(ResourceVolatility.Immutable, textBox.Size, false, textImageRgba); visualElements.Add(ModelVisualElement.New() .SetModel(planeModel) .SetMaterial(StandardMaterial.New() .SetDiffuseMap(textImage) .SetIgnoreLighting(true) .FromGlobalCache()) .SetTransform(Transform.Translation(new Vector3(rect.Center, 0))) .SetNonUniformScale(new Vector3(rect.HalfWidth, rect.HalfHeight, 1))); } }
protected override void Start() { if (this.materialComponent != null) { if (!Application.Current.IsEditor) { this.materialComponent.Material = this.materialComponent.Material.Clone(); } this.material = new StandardMaterial(this.materialComponent.Material); } }
protected ImageRectangleComponent(IEmbeddedResources embeddedResources) { var material = StandardMaterial.New(this) .SetDiffuseMap(x => x.Image) .SetIgnoreLighting(true); visualElement = new ModelVisualElement <ImageRectangleComponent>(this) .SetModel(embeddedResources.SimplePlaneXyModel()) .SetMaterial(material) .SetTransform(x => Transform.Translation(new Vector3(x.Rectangle.Center, 0))) .SetNonUniformScale(x => new Vector3(x.Rectangle.HalfWidth, x.Rectangle.HalfHeight, 1)); }
public override void Initialize() { base.Initialize(); // First we add a Skybox RenderSettings.Skybox.Generate(Application.GraphicsDevice, Application.Content, DemoGame.StarsSkybox); // And a camera with some components var camera = new CameraPrefab("camera"); camera.AddComponent <ControllerSwitcher>(); camera.AddComponent <DemoBehaviour>(); Add(camera); // A light is required to illuminate objects. var lightPrefab = new LightPrefab("light", LightType.Directional); lightPrefab.Transform.Rotation = new Vector3(-1, 1, 0); lightPrefab.Light.ShadowGenerator.SetShadowMapSize(Application.GraphicsDevice, 1024); lightPrefab.EnableShadows = true; Add(lightPrefab); // A terrain with its material. var terrainMaterial = new StandardMaterial(scene); terrainMaterial.Texture = Application.Content.Load <Texture2D>("Textures/Terrain/Rock"); terrainMaterial.Shininess = 150; terrainMaterial.Tiling = new Vector2(8); var terrain = new TerrainPrefab("terrain"); terrain.Renderer.Geometry.Size = new Vector3(2); terrain.Renderer.ReceiveShadow = true; terrain.Randomize(4, 12); terrain.Renderer.Material = terrainMaterial; terrain.Transform.Translate(-terrain.Width >> 1, 0, -terrain.Depth / 2); Add(terrain); // Lava ! var lavaMaterial = new LavaMaterial(this); lavaMaterial.Texture = Application.Content.Load <Texture2D>("Textures/lava_texture"); lavaMaterial.NormalMap = Application.Content.Load <Texture2D>("Textures/lava_bump"); var lava = new WaterPrefab("water"); lava.Renderer.Material = lavaMaterial; lava.Renderer.ReceiveShadow = true; lava.Renderer.Geometry.Size = new Vector3(terrain.Width * 0.5f); lava.Renderer.Geometry.Build(); Add(lava); }
protected override void Start() { base.Start(); if (WaveServices.CameraCapture.IsConnected) { WaveServices.VideoPlayer.OnComplete += (s, e) => { this.StopVideo(); }; WaveServices.CameraCapture.Start(CameraCaptureType.Front); this.tvScreenMaterial = this.Assets.LoadModel <MaterialModel>(WaveContent.Assets.Material.TVScreenMaterial).Material as StandardMaterial; this.tvScreenMaterial.Diffuse = WaveServices.CameraCapture.PreviewTexture; } }
public OrbitStoryLayout(IEmbeddedResources embeddedResources) { frustumModel = embeddedResources.SimpleFrustumModel(); circleModel = embeddedResources.CircleModel(256); frustumMaterial = StandardMaterial.New() .SetDiffuseColor(Color4.Green) .SetIgnoreLighting(true) .FromGlobalCache(); circleMaterial = StandardMaterial.New() .SetDiffuseColor(Color4.Yellow) .SetIgnoreLighting(true) .FromGlobalCache(); }
private Material GetEmissiveMaterial() { StandardMaterial mat = MaterialModule.CreateSniperBase().Clone(); this.sniperTextures.Apply(mat); foreach (MaterialModifier mod in this.materialModifiers[SniperMaterial.Emissive]) { mod(mat); } SniperMain.AddMaterial(mat, String.Format("{0} {1}", this.name, "Emissive")); return(mat.material); }
private Material GetRailMaterial() { StandardMaterial mat = MaterialModule.GetRailBase().Clone(); this.railTextures.Apply(mat); foreach (MaterialModifier mod in this.materialModifiers[SniperMaterial.Rail]) { mod(mat); } SniperMain.AddMaterial(mat, String.Format("{0} {1}", this.name, "Railgun")); return(mat.material); }
private Material GetThrowKnifeMaterial() { StandardMaterial mat = MaterialModule.GetThrowKnifeBase().Clone(); this.throwKnifeTextures.Apply(mat); foreach (MaterialModifier mod in this.materialModifiers[SniperMaterial.ThrowKnife]) { mod(mat); } SniperMain.AddMaterial(mat, String.Format("{0} {1}", this.name, "ThrowKnife")); return(mat.material); }
void ParseEffect(Effect effect, BabylonScene scene) { var material = new StandardMaterial(effect.GetHashCode().ToString()); exportedMaterials.Add(material); var basicEffect = effect as BasicEffect; var skinnedEffect = effect as SkinnedEffect; if (basicEffect != null) { material.Alpha = basicEffect.Alpha; material.Diffuse = basicEffect.DiffuseColor.ToColor3(); material.Emissive = basicEffect.EmissiveColor.ToColor3(); material.Specular = basicEffect.SpecularColor.ToColor3(); material.SpecularPower = basicEffect.SpecularPower; } else { material.Alpha = skinnedEffect.Alpha; material.Diffuse = skinnedEffect.DiffuseColor.ToColor3(); material.Emissive = skinnedEffect.EmissiveColor.ToColor3(); material.Specular = skinnedEffect.SpecularColor.ToColor3(); material.SpecularPower = skinnedEffect.SpecularPower; } var texture = basicEffect != null ? basicEffect.Texture : skinnedEffect.Texture; if (texture != null) { var id = texture.GetHashCode().ToString(); if (!exportedTexturesFilename.ContainsKey(id)) { var tempPath = Path.GetTempPath(); var width = texture.Width; var height = texture.Height; string filename; if (texture.Format != SurfaceFormat.Dxt1) { filename = Path.Combine(tempPath, texturesCount + ".png"); } else { filename = Path.Combine(tempPath, texturesCount + ".jpg"); } texturesCount++; using (var file = new FileStream(filename, FileMode.Create, FileAccess.Write)) { if (texture.Format != SurfaceFormat.Dxt1) { texture.SaveAsPng(file, width, height); } else { texture.SaveAsJpeg(file, width, height); } } exportedTexturesFilename.Add(id, filename); } material.DiffuseTexture = exportedTexturesFilename[id]; } material.CreateBabylonMaterial(scene); }