【发布时间】:2019-09-16 19:15:58
【问题描述】:
我正在尝试使用 Blender 制作一张简单的扑克牌,正面和背面的两侧都有纹理,并将其加载到 Monogame。模型本身很好,运行时会在模拟器上显示,但我似乎无法获得包含的纹理。
卡片上的纹理在 Blender 中似乎可以正常渲染。材质设置为“无阴影”,因此它们不应该受到光照水平的影响,对吗?
导出文件时,我尝试使用不同的版本设置和从“复制”到“条带路径”的各种不同路径模式。
内容管理器将输出目录设置为主内容文件夹,因此我希望纹理不存在引用问题。
所有纹理本身都在同一个文件夹中。
内容全部手动加载到 Visual Studio 中。
这是我用来绘制卡片的代码,显示了我玩过的不同灯光设置。
private void DrawCard(Model m, Vector3 v, CardFacing c, PlayerFacing p)
{
foreach (var mesh in m.Meshes)
{
foreach (var effect1 in mesh.Effects)
{
var effect = (BasicEffect)effect1;
effect.TextureEnabled = true;
effect.EnableDefaultLighting();
//effect.PreferPerPixelLighting = true;
//effect.AmbientLightColor = Color.White.ToVector3();
effect.DiffuseColor = Color.White.ToVector3();
//effect.EmissiveColor = Color.White.ToVector3() * 2f;
//effect.DirectionalLight0.Direction = Vector3.Normalize(new Vector3(0, 0, 1));
effect.Alpha = 1;
effect.VertexColorEnabled = false;
Matrix mCardFacing = new Matrix();
switch(c)
{
case CardFacing.Down:
mCardFacing = Matrix.CreateRotationY((float)(Math.PI / 180) * 180) * Matrix.CreateRotationX((float)(Math.PI / 180) * 90) * Matrix.CreateTranslation(new Vector3(0, 0, 0));
break;
case CardFacing.Up:
mCardFacing = Matrix.CreateRotationZ((float)(Math.PI / 180) * 180) * Matrix.CreateRotationX((float)(Math.PI / 180) * 90) * Matrix.CreateTranslation(new Vector3(0, 0, 0));
break;
case CardFacing.Hand:
mCardFacing = Matrix.CreateRotationX((float)(Math.PI / 180) * -20);
break;
}
Matrix mPlayerFacing = new Matrix();
switch (p)
{
case PlayerFacing.North:
mPlayerFacing = Matrix.CreateRotationZ((float)(Math.PI / 180) * 0);
break;
case PlayerFacing.East:
mPlayerFacing = Matrix.CreateRotationZ((float)(Math.PI / 180) * 90);
break;
case PlayerFacing.South:
mPlayerFacing = Matrix.CreateRotationZ((float)(Math.PI / 180) * 180);
break;
case PlayerFacing.West:
mPlayerFacing = Matrix.CreateRotationZ((float)(Math.PI / 180) * 270);
break;
}
effect.World = mCardFacing * Matrix.CreateTranslation(v) * mPlayerFacing;
effect.View = view;
effect.Projection = projection;
}
mesh.Draw();
}
}
有什么想法吗?谢谢。
【问题讨论】:
-
“材质设置为 'shadeless' 所以它们不应该受到光照水平的影响,对吗?”,目标/效果支持导出定义的材质:答案是否定的。没有通过
.fbx提供的“照明信息”将灯(或缺少灯)关联为发射通道。
标签: visual-studio xna blender monogame fbx