- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我对 3D 很笨,就像我的问题可能是:
我在 WPF 中制作了一个“查看器”程序,可以在屏幕上呈现内容,以及可以旋转的内容。我用它来轮换适合我的口味:
代码:WPF
Transform3DGroup tg = new Transform3DGroup();
tg.Children.Add(new ScaleTransform3D(sx, sy, 1));
tg.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), rx)));
tg.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), ry)));
tg.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), rz)));
tg.Children.Add(new TranslateTransform3D(x, y, z));
darabka.Transform = tg;
TeljesModell.Children.Add(darabka);
我决定在 XNA 中编写这个程序,因为它似乎更快一些,但我无法让它工作。
尝试过这种方式(代码,XNA):
Pozició = Matrix.CreateScale(sx, sy, 1f); //méretezés
Pozició *= Matrix.CreateFromAxisAngle(Vector3.UnitX, rx); //forgatás
Pozició *= Matrix.CreateFromAxisAngle(Vector3.UnitY, ry);
Pozició *= Matrix.CreateFromAxisAngle(Vector3.UnitZ, rz);
Pozició *= Matrix.CreateTranslation(x, y, z); //középpont
我什至也尝试了 CreateFromYawPitchRoll、CreateRotationX(YZ),但运气不好,屏幕上绘制的内容总是以不同的方式旋转。所以我想我问过这里的大脑他们是否知道我要在这两种技术之间放入什么数学。
提前致谢。
编辑:我在其他要求我提供详细信息的论坛上尝试过。我也在这里复制/粘贴它们XNA 代码如下:
主要
...
protected override void LoadContent()
{
t3 = new Airplane(); //this is a "zone" object, having zone regions and zone objects in it. all of them together give the zone itself as a static object, where player walks in
Kamera.Példány.Pozició = new Vector3(1362, 627, -757); //starting pozition in the zone - this is camera position so the player's starting pozition. (camera is FPS)
...
}
...
protected override void Update(GameTime gameTime)
{
...
Kameramozgatása(); //kamera mozgatását vezérlő billentyűk
//this moves the FPS camera around
}
...
protected override void Draw(GameTime gameTime)
{
...
ÁltalánosGrafikaiObjektumok.Effect.View = Kamera.Példány.Idenézünk; //camera views this
ÁltalánosGrafikaiObjektumok.Effect.Projection = projectionMatrix; //... and camera views FROM is set in Kameramozgatása()
...
t3.Rajzolj(); //draw zone object
...
}
区域对象
constructor: set the effect and device to the same as main, set the Pozició (a matrix containing the current position and rotations) to origo
...
public virtual Alapmodel Inicializálás(float x, float y, float z, float rx, float ry, float rz, float sx, float sy)
{
//this initializer starts when the coordinates are from a file and not set with Pozició = Matrix....., so we are to convert. this runs only one time. overrides set the vertex positions and textures
VertexDeclaration = new VertexDeclaration(device, VertexPositionTexture.VertexElements);
Pozició = Matrix.CreateScale(sx, sy, 1f); //méretezés
Pozició *= Matrix.CreateFromAxisAngle(Vector3.UnitX, rx); //forgatás
Pozició *= Matrix.CreateFromAxisAngle(Vector3.UnitY, ry);
Pozició *= Matrix.CreateFromAxisAngle(Vector3.UnitZ, rz);
Pozició *= Matrix.CreateTranslation(x, y, z); //középpont
//we set the starting position - nowhere else we do it, from here only the main loop can modify this,... could.. but does not. this is zone, and has only static objects - never moving
}
public void Rajzolj()
{
//this draws the object (what can be a zone or a static object in it)
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
foreach (Elem elem in Elemek)
{
//végigmegyünk az elemeken
effect.Texture = elem.Textúra;
//pozicionálás
effect.World = Pozició; //we take the initialized position
effect.CommitChanges(); //this is needed. if you do not use this, the textures will be screwed up
device.VertexDeclaration = VertexDeclaration;
device.DrawUserIndexedPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, Poziciók, 0, Poziciók.Length, elem.Indexek, 0, elem.Indexek.Length / 3);
}
pass.End();
}
}
就是这样。我仍然猜测这是一些转换而不是绘图代码。其他地方的位置都没有改变。我猜想矩阵就像 WPFs 堆叠变换一样——我的问题是我不知道在两者之间转换的数学。 WPF 代码完美运行,区域中的模型显示良好。 XNA 代码在某种程度上是错误的,因为 Inicializálás() 从 x、y、z 等进行了错误的转换。在里面。在这方面我确实需要帮助。
提前致谢。
最佳答案
我建议不要以这种方式以角度方式存储您的方向...
但有时您的问题可以在 xna 版本中解决,只需先应用 Z 旋转,然后 X,然后 Y。
关于c# - WPF AxisAngleRotation3D 与 XNA CreateFromAxisAngle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4345007/
我可以将内容项目引用到非 XNA 项目(MonoGame,如果它很重要)? 最佳答案 不直接。 将内容项目引用添加到项目的功能仅适用于“XNA 游戏”和“XNA 游戏库”类型的项目。 当我想在 Win
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 4年前关闭。 Improve thi
您如何看待 xna 和大型多人游戏?例如服务器和 100 个客户端?有没有很好的教程如何在 xna 中创建客户端服务器应用程序? 最佳答案 当然有关于如何做到这一点的教程。我个人使用 Lidgren
好的,所以我正在开发这个游戏,我是 XNA 的新手(我使用的是 4.0),我想做的是每次产生敌人时都有不同的纹理。 所以我有这些图像“image1.png”、“image2.png”等等。我希望它在每
我最近开始检查XNA。一切进展顺利,我什至开始了一个工作样本。困扰我的一件事是,每当我将鼠标放在游戏窗口上时,它就会消失。我不知道这是否是默认行为,但我想更改此设置以便可以看到鼠标。任何和所有建议,不
我刚从 XNA 开始,有一个关于轮换的问题。当你在 XNA 中将一个向量乘以一个旋转矩阵时,它会逆时针旋转。这个我明白。 但是,让我举一个我不明白的例子。假设我将一个随机艺术 Assets 加载到管道
我正在使用 Visual Studio 2010 Ultimate,在谷歌上搜索 XNA 下载后,我找到了这个页面: http://blogs.msdn.com/b/xna/archive/2010/
我有一个字典来存储SoundEffects,例如: public static Dictionary Hangok = new Dictionary(); 我从文件(正常.wav格式)加载声音,例如:
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 10年前关闭。 Improve this
好吧,我正在尝试为 3D XNA 游戏创建自己的物理引擎,但我在计算我应该将物体移动多少时遇到重力问题。 XNA 的游戏计时器每 16 毫秒出现一次,所以经过一些计算,并使用 9.81m/s 作为我的
我正在尝试对以下粒子系统进行修改。 http://create.msdn.com/en-US/education/catalog/sample/particle_3d 我有一个功能,当我按下Space
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be
也许这更像是一个数学问题而不是一个编程问题,但我一直在尝试在 XNA 中实现旋转卡尺算法。 我已经使用维基百科上详述的单调链从我的点集中推导出了一个凸包。 现在,我正在尝试对我的算法进行建模,以在此处
我正在 XNA 中制作一个简单的 2 人游戏,并开始研究保存玩家的高分。 我希望游戏能在 XBox 360 和 Windows 上运行,所以我必须使用框架来保存数据。 您似乎将数据保存到特定用户的玩家
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我需要使用不同字体大小的 spritefont,我必须为每个大小创建新的 spritefont 吗? 最佳答案 基本上是的。 有一个overload的 SpriteBatch.DrawString这为
我对在我的游戏中存储 *.txt 级别文件的位置和方式感到非常困惑。 我想要在我的游戏中提供一些随游戏一起安装的“预烘焙”关卡的可用性,以及用户创建自己的关卡的能力。 所以我所做的是在 Visual
我有一个足够简单的着色器,它支持多个点光源。 灯光存储为一组灯光结构(最大大小),当事件灯光发生变化时,我会传入事件灯光的数量。 问题出在 PixelShader 函数中: 这是基本的东西,从纹理中获
我有 19 张图像,它们是我的播放器的动画帧 在下面,我创建了 Frog 纹理数组,这是我的播放器。并且有 19 个图像。如何对它们进行动画处理。 公共(public)类纹理 { 公共(public)
所以,我要直截了本地说,我正在尝试在我正在制作的 XNA 游戏中制作一个聊天系统。我可以很容易地找出正在按下的键但是我无法知道实际键入的是什么。在我看来,他们好像在说:OemShifthello bi
我是一名优秀的程序员,十分优秀!