我有一个非常简单的场景(相机,照常设置灯光)。我想在模型上应用一个简单的图像材料。如果我使用其中一种便利模型Sphere
,则对象可以使用材质进行渲染:
var model = modelNode.CreateComponent<Sphere>();
model.SetMaterial(Material.FromImage("Textures/small.jpg"));
如果我切换到静态模型(它是 Blender 的默认立方体),则不会呈现任何内容(或者可能呈现不可见)。有了彩色材料,它就可以正常工作,因此模型本身毫无疑问。
var model = modelNode.CreateComponent<StaticModel>();
model.Model = ResourceCache.GetModel("Models/Cube.mdl", false);
//model.SetMaterial(CoreAssets.Materials.DefaultGrey);
//model.SetMaterial(Material.FromColor(Color.Yellow));
model.SetMaterial(Material.FromImage("Textures/small.jpg"));
作为参考,场景的其余部分是:
scene = new Scene();
octree = scene.CreateComponent<Octree>();
var cameraNode = scene.CreateChild();
cameraNode.Position = new Vector3(0, 0, -10);
cameraNode.SetDirection(new Vector3(0, 0, 0));
camera = cameraNode.CreateComponent<Camera>();
var lightNode = cameraNode.CreateChild();
lightNode.Position = new Vector3(5, 5, -5);
lightNode.SetDirection(new Vector3(0, 0, 0));
var light = lightNode.CreateComponent<Light>();
light.LightType = LightType.Directional;
light.Brightness = 1.5f;
light.CastShadows = true;
light.Color = Color.White;
light.Range = 10;