Exemplo n.º 1
0
			public void TestBoxAndTextures()
			{
				Color defaultColor = Color.Yellow;
				var box = new Core.Box
				          	{
				          		XSize = 30,
				          		YSize = 30,
				          		ZSize = 30,
				          		DefaultColor = defaultColor,
#pragma warning disable 612,618
				          		Top = new PlaneImageBrush {Image = Resources.testtexture},
				          		Front = new PlaneImageBrush {Image = Resources.testtexture},
				          		Right = new PlaneImageBrush {Image = Resources.testtexture},
#pragma warning restore 612,618
				          	};
				_modelFactory.TryGetResult(box, out _model);
				Assert.AreEqual(6, _model.Mesh.GetMaterials().Length);
				Assert.AreEqual(3, _model.Textures.Count);
				foreach(ExtendedMaterial mat in _model.Mesh.GetMaterials())
				{
					Console.WriteLine("{0}: {1}", mat.TextureFileName, mat.MaterialD3D.Diffuse);
					
					if(string.IsNullOrEmpty(mat.TextureFileName))
						BrushConverterTests.CheckMaterial(defaultColor, mat.MaterialD3D);
					else BrushConverterTests.CheckMaterial(DirectXBrushConverter.DefaultColor, mat.MaterialD3D);
				}
			}
Exemplo n.º 2
0
 public override void Visit(Core.Box visitable)
 {
     if (!TryCreateFromStoredModel(visitable) && !visitable.IsInvisible())
     {
         InternalResult = DirectXModel.CreateCustomBoxModel(_device, visitable);
     }
 }
Exemplo n.º 3
0
        public Core.Box GetComponentsBoundingBox(bool includeNonCollidingComponents = false)
        {
            CheckDestroyedByUnrealGC();

            Core.Box result = new Core.Box();
            GetComponentsBoundingBoxNative(NativeObject, ref result, includeNonCollidingComponents);
            return(result);
        }
Exemplo n.º 4
0
        public static DirectXModel CreateCustomBoxModel(Device device,
                                                        Core.Box box)
        {
            Color defaultColor = box.DefaultColor;
            var   m            = new DirectXModel
            {
                Mesh           = Mesh.FromMemory(device, CVARC.Engine.KR.Properties.Resources.custombox, MeshFlags.Managed),
                ModifierMatrix = Matrix.Scaling((float)box.XSize,
                                                (float)box.YSize, (float)box.ZSize) * Matrix.Translation(0, 0, (float)box.ZSize / 2)
            };
            var brushesInOrder = new[]
            {
                box.Right, box.Left, box.Front, box.Back, box.Top,
                box.Bottom
            };

            m.Mesh.SetMaterials(GetMaterialsFromBrushes(device, defaultColor, m, brushesInOrder));
            return(m);
        }
Exemplo n.º 5
0
            public void TestBoxAndTextures()
            {
                Color defaultColor = Color.Yellow;
                var   box          = new Core.Box
                {
                    XSize        = 30,
                    YSize        = 30,
                    ZSize        = 30,
                    DefaultColor = defaultColor,
#pragma warning disable 612,618
                    Top = new PlaneImageBrush {
                        Image = Resources.testtexture
                    },
                    Front = new PlaneImageBrush {
                        Image = Resources.testtexture
                    },
                    Right = new PlaneImageBrush {
                        Image = Resources.testtexture
                    },
#pragma warning restore 612,618
                };

                _modelFactory.TryGetResult(box, out _model);
                Assert.AreEqual(6, _model.Mesh.GetMaterials().Length);
                Assert.AreEqual(3, _model.Textures.Count);
                foreach (ExtendedMaterial mat in _model.Mesh.GetMaterials())
                {
                    Console.WriteLine("{0}: {1}", mat.TextureFileName, mat.MaterialD3D.Diffuse);

                    if (string.IsNullOrEmpty(mat.TextureFileName))
                    {
                        BrushConverterTests.CheckMaterial(defaultColor, mat.MaterialD3D);
                    }
                    else
                    {
                        BrushConverterTests.CheckMaterial(DirectXBrushConverter.DefaultColor, mat.MaterialD3D);
                    }
                }
            }
Exemplo n.º 6
0
 private extern static void GetComponentsBoundingBoxNative(IntPtr NativeActor, ref Core.Box outBox, bool includeNonCollidingComponents);