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

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 夢在天涯 閱讀(1978) 評論(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

搜索

  •  

積分與排名

  • 積分 - 1816188
  • 排名 - 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>
              亚洲国产精品999| 久久精品一区四区| 久久精品免费播放| 亚洲精品视频免费| 久久久久9999亚洲精品| 国产精品国产三级欧美二区| 亚洲精品九九| 免费观看在线综合| 欧美一级电影久久| 国产精品美女久久久久av超清| 日韩视频在线你懂得| 久久久久久伊人| 亚洲欧美日韩国产精品| 国产精品福利久久久| 亚洲最新视频在线| 亚洲国产欧美日韩另类综合| 久久国产日韩欧美| 国产三级欧美三级| 欧美在线观看一区二区| 亚洲免费婷婷| 国产精品久久久久毛片大屁完整版 | 一区二区三区高清| 欧美不卡在线视频| 亚洲黄色影片| 欧美成人免费播放| 久久精品99国产精品| 国产亚洲精品美女| 欧美一级淫片aaaaaaa视频| 一区二区三区四区五区视频 | 美乳少妇欧美精品| 亚洲成人影音| 免费观看亚洲视频大全| 久久综合中文色婷婷| 在线成人激情黄色| 免费一级欧美片在线播放| 久久久久国内| 亚洲国产精品电影| 欧美韩日高清| 欧美国产第一页| 99国产精品| 亚洲美女毛片| 国产精品户外野外| 欧美亚洲免费在线| 性娇小13――14欧美| 国产综合欧美| 欧美aⅴ99久久黑人专区| 榴莲视频成人在线观看| 亚洲国产一区二区在线| 欧美肥婆在线| 欧美精品 国产精品| 亚洲精品一区二区三区蜜桃久| 亚洲欧洲精品天堂一级| 欧美视频免费在线观看| 午夜精品久久久久久久男人的天堂| 亚洲一区久久久| 国产日本欧美一区二区三区在线 | 亚洲国产综合视频在线观看| 欧美日本在线看| 亚洲一区二区三区影院| 午夜精品999| 在线播放豆国产99亚洲| 亚洲福利在线看| 欧美日韩专区在线| 欧美中文字幕在线观看| 久久久久国产一区二区| 亚洲久色影视| 亚洲天天影视| 国内伊人久久久久久网站视频| 欧美韩日亚洲| 欧美亚洲第一区| 久久久人成影片一区二区三区| 女同性一区二区三区人了人一| 亚洲视频免费观看| 亚洲男人第一网站| 亚洲国产成人高清精品| 亚洲美洲欧洲综合国产一区| 国产农村妇女精品| 亚洲大片av| 欧美日韩精品| 久久久亚洲影院你懂的| 欧美激情精品久久久久久黑人| 亚洲欧美日韩一区二区在线| 久久久久国产精品厨房| 一区二区三区日韩精品视频| 欧美一区二区三区在线视频| 亚洲精品自在久久| 亚洲欧美日本精品| 亚洲区第一页| 亚洲欧美另类综合偷拍| 亚洲精品1区| 亚洲欧美在线看| 亚洲第一页中文字幕| 亚洲乱码日产精品bd| 国产一区二区黄| 91久久综合亚洲鲁鲁五月天| 国产日韩精品电影| 亚洲欧洲一二三| 狠狠色狠狠色综合日日91app| 亚洲第一在线视频| 国产日韩欧美中文| 欧美激情亚洲一区| 国产欧美日韩一级| 亚洲美女视频| 国产一区二区三区高清在线观看 | 国产日韩专区在线| 亚洲精品久久久久久下一站| 国产一区二区高清不卡| 99re6这里只有精品| 1769国内精品视频在线播放| 亚洲日本无吗高清不卡| 国产一区欧美| 在线视频你懂得一区| 激情久久五月天| 一区二区三区免费网站| 亚洲精品少妇| 久久精品国产一区二区三区免费看 | 一本色道久久88综合日韩精品| 在线看欧美日韩| 欧美一级欧美一级在线播放| 亚洲欧美国产制服动漫| 裸体一区二区三区| 久久嫩草精品久久久精品| 欧美午夜不卡影院在线观看完整版免费| 久久三级福利| 国产亚洲激情在线| 亚洲一级高清| 亚洲天堂久久| 欧美福利电影在线观看| 老色鬼久久亚洲一区二区| 国产精品一区在线观看| 亚洲精品一二三| 亚洲国产精品123| 久久久久国产精品一区二区| 久久精品91| 国产精品热久久久久夜色精品三区 | 国内揄拍国内精品少妇国语| 国产精品99久久久久久久久| 宅男66日本亚洲欧美视频| 欧美激情一区二区三区在线| 欧美大尺度在线观看| 国产一区亚洲| 亚洲精品日韩久久| 日韩午夜电影在线观看| 欧美 日韩 国产 一区| 亚洲精品一区二区三区四区高清| 久久激五月天综合精品| 久久久久久高潮国产精品视| 国产精品视频免费观看www| 一区二区三区视频免费在线观看| 亚洲丶国产丶欧美一区二区三区| 久久国产精品久久久久久久久久| 久久久久亚洲综合| 国产精品一区二区你懂的| 亚洲丰满在线| 日韩亚洲国产欧美| 欧美日韩国产欧| 在线视频精品| 欧美一区二区三区日韩| 国产精品亚洲激情| 午夜视频在线观看一区二区| 久久国产精品99精品国产| 国产欧美短视频| 久久国产日韩欧美| 欧美成人黄色小视频| 亚洲国产精品高清久久久| 欧美成人黄色小视频| 亚洲激情影院| 亚洲尤物精选| 国产日韩成人精品| 久久精品色图| 亚洲国产日韩欧美在线99| 99re热这里只有精品视频| 欧美日韩一区二区三区在线看 | 久久人人爽人人爽爽久久| 欧美刺激性大交免费视频| 日韩视频免费看| 国产精品啊v在线| 欧美亚洲在线观看| 欧美成人激情视频| 亚洲美女在线国产| 国产精品盗摄久久久| 午夜欧美电影在线观看| 免费成人在线视频网站| 999亚洲国产精| 国产精品videossex久久发布| 欧美亚洲一区二区在线| 猫咪成人在线观看| 在线免费观看视频一区| 免费影视亚洲| 亚洲一区二区动漫| 久久综合激情| 在线视频你懂得一区二区三区| 国产欧美精品一区二区色综合| 久久蜜臀精品av| 9l视频自拍蝌蚪9l视频成人| 亚洲欧美日韩一区二区三区在线| 在线成人av.com| 欧美视频中文字幕| 久久精品一区蜜桃臀影院| 免费在线日韩av|