青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

C++ Programmer's Cookbook

{C++ 基礎} {C++ 高級} {C#界面,C++核心算法} {設計模式} {C#基礎}

managed directx 實現太陽系的模擬

c#代碼:
//------------------------------------------------------------------------------
//???????????Name:?dx9cs_transforms.cs
//?????????Author:?Kevin?Harris
//??Last?Modified:?06/28/05
//????Description:?Demonstrates?how?to?use?translation,?rotation,?and?scaling?
//?????????????????matrices?to?create?a?simulated?solar?system.
//
//???Control?Keys:?F1????-?Speed?up?rotations
//?????????????????F2????-?Slow?down?rotations
//?????????????????Space?-?Toggle?orbiting?on/off
//------------------------------------------------------------------------------

using?System;
using?System.Drawing;
using?System.Windows.Forms;
using?Microsoft.DirectX;
using?Microsoft.DirectX.Direct3D;

namespace?DX9Sample
{
????
public?class?DX9Form?:?System.Windows.Forms.Form
????
{
????????
private?Device?d3dDevice?=?null;
????????
private?bool?mousing?=?false;
????????
private?Point?ptLastMousePosit;
????????
private?Point?ptCurrentMousePosit;
????????
private?Mesh?sunMesh;
????????
private?Mesh?earthMesh;
????????
private?Mesh?moonMesh;
????????
private?MatrixStack?matrixStack;

????????
static?private?float?elapsedTime;
????????
static?private?DateTime?currentTime;
????????
static?private?DateTime?lastTime;

????????
private?float?speedmodifier?=?1.0f;
????????
private?bool?orbitOn?=?true;

????????
static?private?float?fSunSpin?=?0.0f;
????????
static?private?float?fEarthSpin?=?0.0f;
????????
static?private?float?fEarthOrbit?=?0.0f;
????????
static?private?float?fMoonSpin?=?0.0f;
????????
static?private?float?fMoonOrbit?=?0.0f;

????????
struct?Vertex
????????
{
????????????
public?float?x,?y,?z;?//?Position?of?vertex?in?3D?space
????????????public?int?color;?????//?Diffuse?color?of?vertex

????????????
public?Vertex(float?_x,?float?_y,?float?_z,?int?_color)
????????????
{
????????????????x?
=?_x;?y?=?_y;?z?=?_z;
????????????????color?
=?_color;
????????????}


????????????
public?static?readonly?VertexFormats?FVF_Flags?=?VertexFormats.Position?|?VertexFormats.Diffuse;
????????}
;

????????
public?DX9Form()
????????
{
????????????
this.ClientSize?=?new?System.Drawing.Size(640,?480);
????????????
this.Text?=?"Direct3D?(DX9/C#)?-?Transforms";
????????????
this.SetStyle(ControlStyles.AllPaintingInWmPaint?|?ControlStyles.Opaque,?true);
????????}


????????
protected?override?void?OnPaint(System.Windows.Forms.PaintEventArgs?e)
????????
{
????????????currentTime?
=?DateTime.Now;
????????????TimeSpan?elapsedTimeSpan?
=?currentTime.Subtract(lastTime);
????????????elapsedTime?
=?(float)elapsedTimeSpan.Milliseconds?*?0.001f;
????????????lastTime?
=?currentTime;

????????????
this.Render();
????????????
this.Invalidate();
????????}


????????
protected?override?void?OnKeyDown(System.Windows.Forms.KeyEventArgs?e)
????????
{
????????????
switch?(e.KeyCode)
????????????
{
????????????????
case?System.Windows.Forms.Keys.Escape:
????????????????????
this.Dispose();
????????????????????
break;

????????????????
case?System.Windows.Forms.Keys.Space:
????????????????????orbitOn?
=?!orbitOn;
????????????????????
break;

????????????????
case?System.Windows.Forms.Keys.F1:
????????????????????
++speedmodifier;
????????????????????
break;

????????????????
case?System.Windows.Forms.Keys.F2:
????????????????????
--speedmodifier;
????????????????????
break;
????????????}

????????}


????????
protected?override?void?Dispose(bool?disposing)
????????
{
????????????
base.Dispose(disposing);
????????}


????????
static?void?Main()
????????
{
????????????
using?(DX9Form?frm?=?new?DX9Form())
????????????
{
????????????????frm.Show();
????????????????frm.Init();
????????????????Application.Run(frm);
????????????}

????????}


????????
///?<summary>
????????
///?This?method?basically?creates?and?initialize?the?Direct3D?device?and
????????
///?anything?else?that?doens't?need?to?be?recreated?after?a?device?
????????
///?reset.
????????
///?</summary>

????????private?void?Init()
????????
{
????????????
//
????????????
//?Do?we?support?hardware?vertex?processing??If?so,?use?it.?
????????????
//?If?not,?downgrade?to?software.
????????????
//

????????????Caps?caps?
=?Manager.GetDeviceCaps(Manager.Adapters.Default.Adapter,
???????????????????????????????????????????????DeviceType.Hardware);
????????????CreateFlags?flags;

????????????
if?(caps.DeviceCaps.SupportsHardwareTransformAndLight)
????????????????flags?
=?CreateFlags.HardwareVertexProcessing;
????????????
else
????????????????flags?
=?CreateFlags.SoftwareVertexProcessing;

????????????
//
????????????
//?Everything?checks?out?-?create?a?simple,?windowed?device.
????????????
//

????????????PresentParameters?d3dpp?
=?new?PresentParameters();

????????????d3dpp.BackBufferFormat?
=?Format.Unknown;
????????????d3dpp.SwapEffect?
=?SwapEffect.Discard;
????????????d3dpp.Windowed?
=?true;
????????????d3dpp.EnableAutoDepthStencil?
=?true;
????????????d3dpp.AutoDepthStencilFormat?
=?DepthFormat.D16;
????????????d3dpp.PresentationInterval?
=?PresentInterval.Immediate;

????????????d3dDevice?
=?new?Device(0,?DeviceType.Hardware,?this,?flags,?d3dpp);

????????????
//?Register?an?event-handler?for?DeviceReset?and?call?it?to?continue
????????????
//?our?setup.
????????????d3dDevice.DeviceReset?+=?new?System.EventHandler(this.OnResetDevice);
????????????OnResetDevice(d3dDevice,?
null);
????????}


????????
///?<summary>
????????
///?This?event-handler?is?a?good?place?to?create?and?initialize?any?
????????
///?Direct3D?related?objects,?which?may?become?invalid?during?a?
????????
///?device?reset.
????????
///?</summary>

????????public?void?OnResetDevice(object?sender,?EventArgs?e)
????????
{
????????????Device?device?
=?(Device)sender;
????????????device.Transform.Projection?
=
????????????????Matrix.PerspectiveFovLH(Geometry.DegreeToRadian(
45.0f),
????????????????(
float)this.ClientSize.Width?/?this.ClientSize.Height,
????????????????
0.1f,?100.0f);

????????????device.RenderState.Lighting?
=?false;
????????????device.RenderState.CullMode?
=?Cull.None;
????????????device.RenderState.FillMode?
=?FillMode.WireFrame;

????????????
//
????????????
//?We'll?use?the?Mesh.Sphere?method?to?create?three?simple?sphere?
????????????
//?meshes?to?experiment?with.
????????????
//

????????????sunMesh?
=?Mesh.Sphere(device,?1.0f,?20,?20);
????????????earthMesh?
=?Mesh.Sphere(device,?1.0f,?10,?10);
????????????moonMesh?
=?Mesh.Sphere(device,?0.5f,?8,?8);

????????????
//
????????????
//?Unfortunately,?the?Mesh.Sphere?utility?function?creates?a?mesh?
????????????
//?with?no?color,?so?we'll?need?to?make?a?clone?of?the?original?
????????????
//?meshes?using?a?FVF?code?that?does?include?color?so?we?can?set?up?
????????????
//?the?Earth?and?Sun?with?color.
????????????
//
????????????
//?Once?that's?been?done,?we'll?need?to?set?the?color?values?to??
????????????
//?something?appropriate?for?our?solar?system?model.
????????????
//

????????????
//
????????????
//?Clone?the?original?Earth?mesh?and?make?it?blue
????????????
//

????????????Mesh?tempMesh?
=?earthMesh.Clone(earthMesh.Options.Value,?Vertex.FVF_Flags,?device);

????????????Vertex[]?vertData?
=
????????????????(Vertex[])tempMesh.VertexBuffer.Lock(
0,?typeof(Vertex),
???????????????????????????????????????????????????????LockFlags.None,
???????????????????????????????????????????????????????tempMesh.NumberVertices);

????????????
for?(int?i?=?0;?i?<?vertData.Length;?++i)
????????????????vertData[i].color?
=?Color.Blue.ToArgb();

????????????tempMesh.VertexBuffer.Unlock();

????????????earthMesh.Dispose();
????????????earthMesh?
=?tempMesh;

????????????
//
????????????
//?Clone?the?original?Sun?mesh?and?make?it?yellow
????????????
//

????????????tempMesh?
=?sunMesh.Clone(sunMesh.Options.Value,?Vertex.FVF_Flags,?device);

????????????vertData?
=
????????????????(Vertex[])tempMesh.VertexBuffer.Lock(
0,?typeof(Vertex),
???????????????????????????????????????????????????????LockFlags.None,
???????????????????????????????????????????????????????tempMesh.NumberVertices);

????????????
for?(int?i?=?0;?i?<?vertData.Length;?++i)
????????????????vertData[i].color?
=?Color.Yellow.ToArgb();

????????????tempMesh.VertexBuffer.Unlock();

????????????sunMesh.Dispose();
????????????sunMesh?
=?tempMesh;

????????????
//
????????????
//?Create?a?matrix?stack
????????????
//

????????????matrixStack?
=?new?MatrixStack();
????????}


????????
//*
????????/*????///?<summary>
????????????///?This?method?is?dedicated?completely?to?rendering?our?3D?scene?and?is
????????????///?is?called?by?the?OnPaint()?event-handler.
????????????///?
????????????///?Render?a?solar?system?using?the?D3DXMATRIX?utility?class.
????????????///?</summary>
????????????private?void?Render()
????????????{
????????????????//?Now?we?can?clear?just?view-port's?portion?of?the?buffer?to?red
????????????????d3dDevice.Clear(?ClearFlags.Target?|?ClearFlags.ZBuffer,?
?????????????????????????????????Color.FromArgb(255,?0,?0,?0),?1.0f,?0?);

????????????????d3dDevice.BeginScene();

????????????????//
????????????????//?Have?the?view?matrix?move?the?view?move?us?to?a?good?vantage?point?so?
????????????????//?we?can?see?the?Sun?sitting?at?the?origin?while?the?Earth?orbits?it.
????????????????//

????????????????d3dDevice.Transform.View?=?Matrix.LookAtLH(?new?Vector3(0.0f,?2.0f,?-25.0f),?//?Camera?position
????????????????????????????????????????????????????????????new?Vector3(0.0f,?0.0f,?0.0f),???//?Look-at?point
????????????????????????????????????????????????????????????new?Vector3(0.0f,?1.0f,?0.0f));??//?Up?vector

????????????????if(?orbitOn?==?true?)
????????????????{
????????????????????fSunSpin?+=?speedmodifier?*?(elapsedTime?*?10.0f);

????????????????????fEarthSpin??+=?speedmodifier?*?(elapsedTime?*?100.0f);
????????????????????fEarthOrbit?+=?speedmodifier?*?(elapsedTime?*?20.0f);

????????????????????fMoonSpin??+=?speedmodifier?*?(elapsedTime?*?50.0f);
????????????????????fMoonOrbit?+=?speedmodifier?*?(elapsedTime?*?200.0f);
????????????????}

????????????????//
????????????????//?The?Sun?is?easy?because?the?mesh?for?it?is?initially?created?centered??
????????????????//?at?origin.?All?we?have?to?do?is?spin?it?by?rotating?it?about?the?Y?axis
????????????????//?and?scale?it?by?5.0f.
????????????????//

????????????????Matrix?mSunScale?=?Matrix.Identity;
????????????????Matrix?mSunSpinRotation?=?Matrix.Identity;
????????????????Matrix?mSunMatrix?=?Matrix.Identity;
????
????????????????mSunSpinRotation.RotateY(?Geometry.DegreeToRadian(?fSunSpin?)?);
????????????????mSunScale.Scale(?5.0f,?5.0f,?5.0f?);

????????????????//?Now,?concatenate?them?together
????????????????mSunMatrix?=?mSunScale?*???????//?1.?Uniformly?scale?the?Sun?up?in?size
?????????????????????????????mSunSpinRotation;?//?2.?and?then?spin?it?on?its?axis.

????????????????d3dDevice.Transform.World?=?mSunMatrix;
????????????????sunMesh.DrawSubset(0);

????????????????//
????????????????//?The?Earth?is?a?little?more?complicated?since?it?needs?to?spin?as?well?
????????????????//?as?orbit?the?Sun.?This?can?be?done?by?combining?three?transformations?
????????????????//?together.
????????????????//
????????????
????????????????Matrix?mEarthTranslationToOrbit?=?Matrix.Identity;
????????????????Matrix?mEarthSpinRotation?=?Matrix.Identity;
????????????????Matrix?mEarthOrbitRotation?=?Matrix.Identity;
????????????????Matrix?mEarthMatrix?=?Matrix.Identity;

????????????????mEarthSpinRotation.RotateY(?Geometry.DegreeToRadian(?fEarthSpin?)?);
????????????????mEarthTranslationToOrbit.Translate(?0.0f,?0.0f,?10.0f?);
????????????????mEarthOrbitRotation.RotateY(?Geometry.DegreeToRadian(?fEarthOrbit?)?);

????????????????//?Now,?concatenate?them?together
????????????????mEarthMatrix?=?mEarthSpinRotation?*???????//?1.?Spin?the?Earth?on?its?own?axis.
???????????????????????????????mEarthTranslationToOrbit?*?//?2.?Then?translate?it?away?from?the?origin?(where?the?Sun's?at)
???????????????????????????????mEarthOrbitRotation;???????//?3.?and?rotate?it?again?to?make?it?orbit?the?origin?(or?the?Sun).

????????????????d3dDevice.Transform.World?=?mEarthMatrix;
????????????????earthMesh.DrawSubset(0);

????????????????//
????????????????//?The?Moon?is?the?hardest?to?understand?since?it?needs?to?not?only?spin?on
????????????????//?its?own?axis?and?orbit?the?Earth,?but?needs?to?follow?the?Earth,?
????????????????//?which?is?orbiting?the?Sun.
????????????????//
????????????????//?This?can?be?done?by?combining?five?transformations?together?with?the?last
????????????????//?two?being?borrowed?from?the?Earth's?transformation.
????????????????//

????????????????Matrix?mMoonTranslationToOrbit?=?Matrix.Identity;
????????????????Matrix?mMoonSpinRotation?=?Matrix.Identity;
????????????????Matrix?mMoonOrbitRotation?=?Matrix.Identity;
????????????????Matrix?mMoonMatrix?=?Matrix.Identity;

????????????????mMoonSpinRotation.RotateY(?Geometry.DegreeToRadian(?fMoonSpin?)?);
????????????????mMoonOrbitRotation.RotateY(?Geometry.DegreeToRadian(?fMoonOrbit?)?);
????????????????mMoonTranslationToOrbit.Translate(?0.0f,?0.0f,?2.0f?);

????????????????//
????????????????//?The?key?to?understanding?the?first?three?transforms?is?to?pretend?that?
????????????????//?the?Earth?is?located?at?the?origin.?We?know?it's?not,?but?if?we?pretend?
????????????????//?that?it?is,?we?can?set?up?the?Moon?just?like?the?we?did?the?Earth?since?
????????????????//?the?Moon?orbits?the?Earth?just?like?the?Earth?orbits?the?Sun.
????????????????//
????????????????//?Once?the?Moon's?transforms?are?set?up?we?simply?reuse?the?Earth's?
????????????????//?translation?and?rotation?matrix,?which?placed?it?in?orbit,?to?offset
????????????????//?the?Moon?out?to?where?it?should?be?following?the?Earth.
????????????????//?

????????????????//?Now,?concatenate?them?together
????????????
????????????????mMoonMatrix?=?mMoonSpinRotation?*????????//?1.?Spin?the?Moon?on?its?own?axis.
??????????????????????????????mMoonTranslationToOrbit?*??//?2.?Then?translate?it?away?from?the?origin?(pretending?that?the?Earth?is?there)
??????????????????????????????mMoonOrbitRotation?*???????//?3.?and?rotate?it?again?to?make?it?orbit?the?origin?(or?the?pretend?Earth).
??????????????????????????
??????????????????????????????mEarthTranslationToOrbit?*?//?4.?Now,?translate?out?to?where?the?Earth?is?really?at
??????????????????????????????mEarthOrbitRotation;???????//?5.?and?move?with?it?by?matching?its?orbit?of?the?Earth.

????????????????d3dDevice.Transform.World?=?mMoonMatrix;
????????????????moonMesh.DrawSubset(0);

????????????????d3dDevice.EndScene();

????????????????d3dDevice.Present();
????????????}
*/

????????
//******************************************************************************//


????????
//<summary>
????????
//This?method?is?dedicated?completely?to?rendering?our?3D?scene?and
????????
//is?called?by?the?OnPaint()?event-handler.

????????
//Render?a?solar?system?using?the?D3DXMATRIX?utility?class?and?a??
????????
//matrix?stack?similar?to?OpenGL's.?See?the?note?below?for?details.

????????
//Note:

????????
//Direct3D?uses?the?world?and?view?matrices?that?we?set?to?configure?
????????
//several?internal?data?structures.?Each?time?we?set?a?new?world?or?
????????
//view?matrix,?the?system?is?forced?to?recalculate?these?internal?
????????
//structures.?Therefore,?setting?these?matrices?frequently,?which?is?
????????
//the?case?for?applications?that?require?a?high?frame-rate,?is?
????????
//computationally?expensive.?We?can?minimize?the?number?of?required?
????????
//calculations?by?concatenating?our?world?and?view?matrices?into?a?
????????
//combined?world-view?matrix?that?we?set?as?the?world?matrix.?

????????
//With?the?view?matrix?combined?in?with?each?world?matrix?that?we?set,?
????????
//we?no?longer?have?to?set?the?view?matrix?separately?and?incur?its?
????????
//overhead.?Instead,?we?simply?set?the?view?matrix?to?the?identity?
????????
//once?and?leave?it?untouched?during?all?calculations.

????????
//For?clarity,?Direct3D?samples?rarely?employ?this?optimization?since?
????????
//it?confuses?beginners.
????????
//</summary>
????????private?void?Render()
????????
{
????????????
//Now?we?can?clear?just?view-port's?portion?of?the?buffer?to?red
????????????d3dDevice.Clear(ClearFlags.Target?|?ClearFlags.ZBuffer,
?????????????????????????????Color.FromArgb(
255,?0,?0,?0),?1.0f,?0);

????????????d3dDevice.BeginScene();


????????????
//Have?the?view?matrix?move?the?view?move?us?to?a?good?vantage?
????????????
//point?so?we?can?see?the?Sun?sitting?at?the?origin?while?the?
????????????
//Earth?orbits?it.


????????????d3dDevice.Transform.View?
=?Matrix.LookAtLH(new?Vector3(0.0f,?2.0f,?-25.0f),?//?Camera?position
????????????????????????????????????????????????????????new?Vector3(0.0f,?0.0f,?0.0f),???//?Look-at?point
????????????????????????????????????????????????????????new?Vector3(0.0f,?1.0f,?0.0f));??//?Up?vector

????????????matrixStack.LoadMatrix(d3dDevice.Transform.View);

????????????
if?(orbitOn?==?true)
????????????
{
????????????????fSunSpin?
+=?speedmodifier?*?(elapsedTime?*?10.0f);

????????????????fEarthSpin?
+=?speedmodifier?*?(elapsedTime?*?100.0f);
????????????????fEarthOrbit?
+=?speedmodifier?*?(elapsedTime?*?20.0f);

????????????????fMoonSpin?
+=?speedmodifier?*?(elapsedTime?*?50.0f);
????????????????fMoonOrbit?
+=?speedmodifier?*?(elapsedTime?*?200.0f);
????????????}



????????????
//The?Sun?is?easy?because?the?mesh?for?it?is?initially?created?
????????????
//centered??at?origin.?All?we?have?to?do?is?spin?it?by?rotating?it?
????????????
//about?the?Y?axis?and?scale?it?by?5.0f.


????????????Matrix?mSunScale?
=?Matrix.Identity;
????????????Matrix?mSunSpinRotation?
=?Matrix.Identity;
????????????Matrix?mSunMatrix?
=?Matrix.Identity;

????????????mSunSpinRotation.RotateY(Geometry.DegreeToRadian(fSunSpin));
????????????mSunScale.Scale(
5.0f,?5.0f,?5.0f);

????????????
//Now,?concatenate?them?together
????????????mSunMatrix?=?mSunScale?*???????//?1.?Uniformly?scale?the?Sun?up?in?size
?????????????????????????mSunSpinRotation;?//?2.?and?then?spin?it?on?its?axis.

????????????matrixStack.Push();
????????????
{
????????????????matrixStack.MultiplyMatrixLocal(mSunMatrix);

????????????????d3dDevice.Transform.World?
=?matrixStack.Top;
????????????????sunMesh.DrawSubset(
0);
????????????}

????????????matrixStack.Pop();


????????????
//The?Earth?is?a?little?more?complicated?since?it?needs?to?spin?as?
????????????
//well?as?orbit?the?Sun.?This?can?be?done?by?combining?three?
????????????
//transformations?together.


????????????Matrix?mEarthTranslationToOrbit?
=?Matrix.Identity;
????????????Matrix?mEarthSpinRotation?
=?Matrix.Identity;
????????????Matrix?mEarthOrbitRotation?
=?Matrix.Identity;
????????????Matrix?mEarthMatrix?
=?Matrix.Identity;

????????????mEarthSpinRotation.RotateY(Geometry.DegreeToRadian(fEarthSpin));
????????????mEarthTranslationToOrbit.Translate(
0.0f,?0.0f,?12.0f);
????????????mEarthOrbitRotation.RotateY(Geometry.DegreeToRadian(fEarthOrbit));

????????????
//Now,?concatenate?them?together
????????????mEarthMatrix?=?mEarthSpinRotation?*???????//?1.?Spin?the?Earth?on?its?own?axis.
???????????????????????????mEarthTranslationToOrbit?*?//?2.?Then?translate?it?away?from?the?origin?(where?the?Sun's?at)
???????????????????????????mEarthOrbitRotation;???????//?3.?and?rotate?it?again?to?make?it?orbit?the?origin?(or?the?Sun).

????????????matrixStack.Push();
????????????
{
????????????????matrixStack.MultiplyMatrixLocal(mEarthMatrix);

????????????????d3dDevice.Transform.World?
=?matrixStack.Top;
????????????????earthMesh.DrawSubset(
0);
????????????}

????????????matrixStack.Pop();


????????????
//The?Moon?is?the?hardest?to?understand?since?it?needs?to?not?only?
????????????
//spin?on?its?own?axis?and?orbit?the?Earth,?but?needs?to?follow?
????????????
//the?Earth,?which?is?orbiting?the?Sun.

????????????
//This?can?be?done?by?combining?five?transformations?together?
????????????
//with?the?last?two?being?borrowed?from?the?Earth's?transformation.


????????????Matrix?mMoonTranslationToOrbit?
=?Matrix.Identity;
????????????Matrix?mMoonSpinRotation?
=?Matrix.Identity;
????????????Matrix?mMoonOrbitRotation?
=?Matrix.Identity;
????????????Matrix?mMoonMatrix?
=?Matrix.Identity;

????????????mMoonSpinRotation.RotateY(Geometry.DegreeToRadian(fMoonSpin));
????????????mMoonOrbitRotation.RotateY(Geometry.DegreeToRadian(fMoonOrbit));
????????????mMoonTranslationToOrbit.Translate(
0.0f,?0.0f,?2.0f);


????????????
//The?key?to?understanding?the?first?three?transforms?is?to?
????????????
//pretend?that?the?Earth?is?located?at?the?origin.?We?know?it's?
????????????
//not,?but?if?we?pretend?that?it?is,?we?can?set?up?the?Moon?just?
????????????
//like?the?we?did?the?Earth?since?the?Moon?orbits?the?Earth?just?
????????????
//like?the?Earth?orbits?the?Sun.

????????????
//Once?the?Moon's?transforms?are?set?up?we?simply?reuse?the?Earth's?
????????????
//translation?and?rotation?matrix,?which?placed?it?in?orbit,?to?
????????????
//offset?the?Moon?out?to?where?it?should?be?following?the?Earth.


????????????
//Now,?concatenate?them?together

????????????mMoonMatrix?
=?mMoonSpinRotation?*????????//?1.?Spin?the?Moon?on?its?own?axis.
??????????????????????????mMoonTranslationToOrbit?*??//?2.?Then?translate?it?away?from?the?origin?(pretending?that?the?Earth?is?there)
??????????????????????????mMoonOrbitRotation?*???????//?3.?and?rotate?it?again?to?make?it?orbit?the?origin?(or?the?pretend?Earth).

??????????????????????????mEarthTranslationToOrbit?
*?//?4.?Now,?translate?out?to?where?the?Earth?is?really?at
??????????????????????????mEarthOrbitRotation;???????//?5.?and?move?with?it?by?matching?its?orbit?of?the?Earth.

????????????matrixStack.Push();
????????????
{
????????????????matrixStack.MultiplyMatrixLocal(mMoonMatrix);

????????????????d3dDevice.Transform.World?
=?matrixStack.Top;
????????????????moonMesh.DrawSubset(
0);
????????????}

????????????matrixStack.Pop();

????????????d3dDevice.EndScene();

????????????d3dDevice.Present();
????????}



????}

}

注意:
兩個render()函數同樣的效果,但是2個中用了MatrixStack.
最后的效果:
o_simulated solar system.jpg

by:mzty
at:2006年6月22日

posted on 2006-06-22 15:39 夢在天涯 閱讀(1974) 評論(2)  編輯 收藏 引用 所屬分類: DirectX

評論

# re: managed directx 實現太陽系的模擬 2008-01-09 16:11 lsh2011

好。正 在 學這個。

不過,要是能把文件打包 放上去供人 測試就更好。

謝謝  回復  更多評論   

# re: managed directx 實現太陽系的模擬 2008-12-12 17:05 饅頭

這個能打包發給我嗎?  回復  更多評論   

公告

EMail:itech001#126.com

導航

統計

  • 隨筆 - 461
  • 文章 - 4
  • 評論 - 746
  • 引用 - 0

常用鏈接

隨筆分類

隨筆檔案

收藏夾

Blogs

c#(csharp)

C++(cpp)

Enlish

Forums(bbs)

My self

Often go

Useful Webs

Xml/Uml/html

搜索

  •  

積分與排名

  • 積分 - 1815003
  • 排名 - 5

最新評論

閱讀排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
      <noscript id="pjuwb"></noscript>
            <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
              <dd id="pjuwb"></dd>
              <abbr id="pjuwb"></abbr>
              欧美在线视频一区| 在线免费观看日本一区| 99综合在线| 亚洲永久免费视频| 欧美日韩免费观看中文| 亚洲精品美女免费| 亚洲一区二区三区四区在线观看| 一区视频在线| 一区二区三区精品在线 | 亚洲毛片视频| 午夜精品999| 一本一本a久久| 久久久精品国产一区二区三区 | 久久久久se| 亚洲欧美国产高清| 女仆av观看一区| 久久九九国产精品| 欧美国产精品专区| 久久偷窥视频| 国产精品人人做人人爽人人添| 欧美国产精品va在线观看| 国产女主播在线一区二区| 亚洲成色www8888| 国产精品女人毛片| 亚洲国产高潮在线观看| 国内精品**久久毛片app| 99热这里只有成人精品国产| 亚洲国产精品综合| 久久久久欧美精品| 久久久久高清| 国产丝袜一区二区| 午夜精品成人在线| 亚洲欧美一区二区三区久久 | 亚洲性感美女99在线| 国产午夜精品在线观看| 一区二区三区久久网| 日韩亚洲欧美在线观看| 麻豆久久久9性大片| 久久久视频精品| 欧美日韩一区精品| 另类av一区二区| 国产一区999| 亚洲欧美日韩一区二区三区在线观看 | 国产真实乱偷精品视频免| 亚洲欧洲综合| 亚洲激情一区| 久久久蜜桃一区二区人| 久久精品欧洲| 国产日韩欧美二区| 亚洲欧美一区二区三区极速播放| 午夜精品免费| 国产欧美一区二区精品忘忧草| 亚洲一级影院| 亚洲小少妇裸体bbw| 欧美日韩国产另类不卡| 亚洲日本欧美日韩高观看| 久久久国产精品一区二区中文| 欧美一级淫片播放口| 亚洲一区观看| 国产精品亚洲网站| 欧美在线你懂的| 六月天综合网| 黄色亚洲大片免费在线观看| 午夜精品理论片| 久久只精品国产| 亚洲第一页自拍| 免费久久久一本精品久久区| 亚洲激情国产| 中文精品99久久国产香蕉| 欧美日韩国产一区二区三区| 亚洲老司机av| 欧美在线在线| 在线看片欧美| 欧美精品成人一区二区在线观看 | 欧美巨乳在线| 一区二区三区日韩欧美精品| 欧美一区二区三区视频免费| 黄色精品在线看| 欧美黄色大片网站| 亚洲一区在线播放| 欧美r片在线| 亚洲一区二区在线播放| 国产视频久久久久久久| 老鸭窝91久久精品色噜噜导演| 亚洲欧洲综合另类| 欧美一二区视频| 最近中文字幕mv在线一区二区三区四区| 欧美成人激情在线| 亚洲线精品一区二区三区八戒| 久久国产一区| 亚洲理论在线| 国产色爱av资源综合区| 欧美1区视频| 午夜欧美精品| 亚洲欧洲一区二区在线播放| 久久狠狠久久综合桃花| 亚洲日本中文| 好看不卡的中文字幕| 欧美日韩日日骚| 久久久久www| 亚洲一区二区欧美日韩| 亚洲国产导航| 亚洲欧美日韩精品在线| 国产在线播放一区二区三区| 欧美国产日韩视频| 欧美亚洲自偷自偷| 亚洲乱码国产乱码精品精天堂 | 一区二区三区视频在线播放| 久久电影一区| 亚洲一区二区三区精品在线观看| 国语自产精品视频在线看| 欧美日韩国产专区| 久久嫩草精品久久久久| 亚洲欧美激情一区| 亚洲人成网站色ww在线| 久久夜色撩人精品| 久久精品99无色码中文字幕| 一本久久a久久精品亚洲| 在线观看成人一级片| 日韩视频在线播放| 久久精品一区二区国产| 亚洲乱码日产精品bd| 欧美www在线| 久久看片网站| 欧美在现视频| 99国产精品久久久久老师| 国产主播一区二区| 国产精品青草综合久久久久99| 欧美日韩中文字幕综合视频| 老色批av在线精品| 久久久青草婷婷精品综合日韩| 亚洲免费在线视频| 一本在线高清不卡dvd | 久久亚洲春色中文字幕久久久| 午夜激情综合网| 一区二区三区视频在线观看 | 亚洲女与黑人做爰| 亚洲精品久久久久久一区二区| 亚洲国产欧美一区二区三区久久| 久久久久久一区二区| 亚洲欧美中文日韩v在线观看| 亚洲精品乱码久久久久久日本蜜臀| 亚洲二区视频| 黑丝一区二区三区| 国产私拍一区| 国产三级精品在线不卡| 国产一区清纯| 国产亚洲欧洲997久久综合| 国产精品永久免费在线| 国产视频欧美| 国产一区二区久久精品| 国产日本欧美一区二区三区在线 | 欧美在线一级视频| 欧美一区2区三区4区公司二百| 亚洲一区二区三区在线| 亚洲天堂av综合网| 亚洲午夜成aⅴ人片| 性欧美18~19sex高清播放| 午夜精品久久久久久久99水蜜桃| 亚洲一区二区三区免费观看| 欧美一区二区三区啪啪| 久久久国产一区二区| 久久久一本精品99久久精品66| 另类天堂av| 亚洲精品日韩综合观看成人91| 亚洲美女av黄| 亚洲尤物视频在线| 欧美在线观看视频一区二区三区| 一二三区精品福利视频| 亚洲日本va午夜在线影院| 亚洲国产精品美女| 欧美黄免费看| 日韩视频中文| 亚洲欧美日韩国产成人| 欧美一区二区在线看| 久久九九全国免费精品观看| 欧美电影在线播放| 欧美午夜久久| 国产一区二区三区四区老人| 亚洲欧洲中文日韩久久av乱码| 99热在线精品观看| 亚洲影视中文字幕| 久久久久在线| 99re视频这里只有精品| 亚洲欧美在线播放| 久久综合久久综合久久| 国产精品白丝av嫩草影院 | 亚洲国产精品精华液网站| 亚洲蜜桃精久久久久久久 | 黄色在线一区| 亚洲一区二区免费视频| 久久精品在线免费观看| 欧美激情欧美狂野欧美精品| 亚洲午夜免费视频| 久久久成人精品| 欧美日韩午夜在线视频| 国内精品久久久久影院优 | 久久久久九九视频| 欧美视频一区二区| 伊人久久男人天堂|