English 中文(简体)
计算XNA重力
原标题:Calculating gravity in XNA
  • 时间:2011-04-21 15:15:52
  •  标签:
  • xna

右心是,我试图为3D XNA游戏建立自己的物理发动机,我有麻烦地计算我为什么要严肃地把物体转移。

XNA的游戏时间为每16毫米秒,因此,经过一些计算,使用9.81m/s作为我的游乐速度,你可以发现,你应当提高重物体的速率:

0.15696 meters/16milliseconds
- basically every update call should increase the object by 0.15696 meters

问题是,我如何将0.15696米的电梯改装成像。 显然,如果我只是使用1:1的关系,那么该物体只能移动9.81皮克/秒。 确实不是轻重的:P 是否有任何人对我如何确定我应该把这个物体移入多少个els?

感谢一切帮助!

最佳回答

虽然两轮游戏是更重要的,但三轮游戏本身却与这种磨擦有关的,而是涉及一些单位。 单位的规模完全是任意的。

典型的情况是,您的高速矢量,其大小相当于您的物体的二倍(或大小?)。 因此,通过增加这一速度* 更新了每个框架中的位置。 从重力中加快速度,以同样方式添加到速度矢量上:

Vector3 gravity = Vector3.Down * 9.81f;


//in the update loop
float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;//0.01666667 (or 16.67 ms) @ 60FPS
velocity += gravity * elapsed; 
position += velocity * elapsed;

例如,我任意确定1×na单位=1米。

问题回答

You just have to figure out how large an "area" your screen represents; then its simple scaling. If you have a 2D representation of a satellite orbiting earth, then your "Y" pixels represent ground to satellite (approximately 35,000 meters).

利用古典物理学(http://en.wikipedia.org/wiki/List_of_equations_in_classical_mechanics)的公式,然后将实际层面扩大到你的屏幕。





相关问题
copying a texture in xna into another texture

I am loading a Texture2D that contains multiple sprite textures. I would like to pull the individual textures out when I load the initial Texture to store into separate Texture2D objects, but can t ...

XNA Antialias question!

I ve got problems with XNA and antialiasing. I can activate it using graphics.PreferMultiSampling = true; graphics.ApplyChanges(); however - it s only 2x antialiasing. Even if I set ...

Take screen shot in XNA

How can I take a screen shot of the screen in XNA? Is it possible without System.Drawing.Graphics.CopyFromScreen or Win32API? If it s not possible, Is there any way to draw a System.Drawing.Bitmap to ...

XNA .Fbx textures

I m using the standard .fbx importer with custom shaders in XNA. The .fbx model is UV wrapped properly and is textured appropriately when I use BasicEffect. However when I use my custom effect I have ...

Can t install XNA

I m trying to install XNA. When the installation starts I got an error that says "XNA GSE 1.0 refresh requires Visual C# 2005 express edition sp1..." I use Windows 7 and I have Visual Studio 2008 &...

Is there a 3D equivalant to clamp in XNA?

I m building a 3D game but i only plan on using a 2D perspective thus not taking the z axis into the equasion, i want to be able to limit the movement of one of my models so it doesn t move out of the ...

Fetching the vertices from the backbuffer (HLSL) on XNA

Hello and sorry for the obscure title :} I`ll try to explain the best i can. First of all, i am new to HLSL but i understand about the pipeline and stuff that are from the fairy world. What i`m ...

Simple XNA 2d physics library

Working on a 2D project and wanted some recommendations on a simple 2d physics library for use in C# with the XNA framework. I was looking at Farseer or physics2d. Anyone have any other suggestions? ...

热门标签