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

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

搜索

  •  

積分與排名

  • 積分 - 1812208
  • 排名 - 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>
              亚洲国产1区| 国产精品久久久久aaaa| 欧美精品成人一区二区在线观看 | 国产精品免费福利| 久久久久国产成人精品亚洲午夜| 国产精品乱人伦中文| 久久不见久久见免费视频1| 亚洲主播在线| 好吊一区二区三区| 欧美国产免费| 欧美高潮视频| 欧美一区二区三区在线免费观看| 欧美一区二区高清| 亚洲国产成人在线播放| 在线播放中文字幕一区| 亚洲另类在线一区| 日韩亚洲精品在线| 国产亚洲欧美日韩日本| 蜜桃av综合| 中文av字幕一区| 国产一区二区精品久久91| 裸体女人亚洲精品一区| 欧美精品首页| 久久国产免费| 欧美成人免费全部| 久久不射电影网| 欧美高清成人| 久久亚洲精品网站| 欧美日韩国产精品一卡| 久久精品一本| 欧美日韩另类一区| 老鸭窝91久久精品色噜噜导演| 欧美一区二区三区四区视频| 亚洲美女色禁图| 午夜精品区一区二区三| 日韩视频一区二区三区| 羞羞色国产精品| 亚洲调教视频在线观看| 久久婷婷麻豆| 欧美在线免费视频| 欧美日本在线视频| 男女精品网站| 国产视频亚洲| 亚洲深夜激情| 一本色道88久久加勒比精品| 久久久精品五月天| 午夜久久tv| 欧美日韩国产欧美日美国产精品| 久久久久久久久久久久久女国产乱| 欧美久久在线| 亚洲人成小说网站色在线| 国内伊人久久久久久网站视频| 99这里只有精品| a4yy欧美一区二区三区| 美女尤物久久精品| 欧美成人国产一区二区| 国产毛片一区| 亚洲一区二区三区在线看| 亚洲视频图片小说| 欧美日韩国产成人在线免费 | 亚洲精品一二三区| 免费一级欧美片在线播放| 国产精品综合久久久| 野花国产精品入口| 久久久久久亚洲精品杨幂换脸| 好吊视频一区二区三区四区| 欧美一区二区播放| 久久亚洲高清| 尹人成人综合网| 久久久爽爽爽美女图片| 久久久噜噜噜久久人人看| 国产精品女主播| 亚洲午夜羞羞片| 性色av一区二区三区红粉影视| 国产精品分类| 亚洲欧美日韩在线| 欧美在线亚洲| 一区视频在线| 蜜桃av噜噜一区| 亚洲欧洲综合另类| aa亚洲婷婷| 欧美视频在线看| 亚洲免费影视| 免费观看久久久4p| 日韩视频在线观看一区二区| 欧美日韩国产专区| 亚洲免费视频成人| 女人香蕉久久**毛片精品| 91久久黄色| 国产精品国产福利国产秒拍| 日韩香蕉视频| 亚洲天堂视频在线观看| 国产亚洲精品自拍| 蜜桃久久精品乱码一区二区| 亚洲精品国产精品国产自| 中文亚洲免费| 国产一区在线观看视频| 久久香蕉国产线看观看网| 国产一级一区二区| 欧美.www| 亚洲一区二区三区激情| 欧美一区二区三区精品电影| 国产精品你懂的在线欣赏| 欧美在线免费视屏| 欧美国产日韩视频| 欧美影院在线| 亚洲欧洲综合另类在线| 国产精品永久在线| 欧美高清免费| 久久久久久一区| 亚洲一级二级| 最新日韩欧美| 久久尤物视频| 亚洲一区区二区| 国产精品一级| 欧美日韩国产麻豆| 欧美a级片网| 久久av一区二区三区亚洲| 欧美激情亚洲激情| 久久躁日日躁aaaaxxxx| 亚洲欧美日韩区| 亚洲黄色一区| 久久国产精品99国产| 亚洲美女在线看| 欧美激情影音先锋| 久久久夜精品| 亚洲欧美亚洲| 亚洲午夜女主播在线直播| 亚洲欧洲日韩女同| 红桃视频国产一区| 国产一区二区无遮挡| 国产精品久久夜| 欧美视频专区一二在线观看| 男女激情视频一区| 久久精品亚洲精品| 欧美在线视频一区| 国产精品www色诱视频| 国产日韩欧美中文| 欧美日韩国产在线| 欧美日韩精品在线观看| 欧美激情a∨在线视频播放| 久久综合999| 久久天天综合| 麻豆精品国产91久久久久久| 久久久精品一品道一区| 亚洲私人影院在线观看| 亚洲一区二区少妇| 亚洲在线中文字幕| 午夜精品国产更新| 午夜国产一区| 久久久xxx| 久久久亚洲一区| 久久久999精品免费| 久久综合狠狠综合久久激情| 久久久久一区二区| 免费观看欧美在线视频的网站| 久久中文字幕一区| 艳妇臀荡乳欲伦亚洲一区| 亚洲第一福利视频| 亚洲人成网站在线观看播放| 99国产精品久久| 在线一区观看| 欧美一级视频精品观看| 久久精品国产69国产精品亚洲| 久久精品国产在热久久| 久久亚洲欧美国产精品乐播| 女人天堂亚洲aⅴ在线观看| 久久久www成人免费毛片麻豆| 免费成人激情视频| 欧美日韩国产一区二区三区地区 | 欧美1区2区视频| 亚洲国产另类 国产精品国产免费| 亚洲老板91色精品久久| 在线一区二区三区四区| 久久精视频免费在线久久完整在线看| 欧美伊久线香蕉线新在线| 久久精品最新地址| 欧美午夜无遮挡| 国精产品99永久一区一区| 日韩视频一区二区三区| 久久国内精品自在自线400部| 久热精品在线视频| 亚洲精选中文字幕| 亚洲午夜影视影院在线观看| 久久国产精品亚洲va麻豆| 欧美激情1区2区| 国产一区在线观看视频| 一区二区三区高清不卡| 久久精品一区四区| 亚洲黄一区二区| 久久国产精品久久久| 免费观看久久久4p| 国产片一区二区| 国际精品欧美精品| 亚洲一区免费| 欧美国产视频在线观看| 欧美高清视频一二三区| 亚洲免费在线精品一区| 欧美日韩第一页| 亚洲高清在线观看|