<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://monobook.org/w/index.php?action=history&amp;feed=atom&amp;title=MonoGame%E3%81%A7%E3%83%9E%E3%82%A6%E3%82%B9%E4%BD%8D%E7%BD%AE%E3%82%923D%E5%B9%B3%E9%9D%A2%E3%81%AB%E6%8A%95%E5%BD%B1%E3%81%99%E3%82%8B</id>
	<title>MonoGameでマウス位置を3D平面に投影する - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://monobook.org/w/index.php?action=history&amp;feed=atom&amp;title=MonoGame%E3%81%A7%E3%83%9E%E3%82%A6%E3%82%B9%E4%BD%8D%E7%BD%AE%E3%82%923D%E5%B9%B3%E9%9D%A2%E3%81%AB%E6%8A%95%E5%BD%B1%E3%81%99%E3%82%8B"/>
	<link rel="alternate" type="text/html" href="https://monobook.org/w/index.php?title=MonoGame%E3%81%A7%E3%83%9E%E3%82%A6%E3%82%B9%E4%BD%8D%E7%BD%AE%E3%82%923D%E5%B9%B3%E9%9D%A2%E3%81%AB%E6%8A%95%E5%BD%B1%E3%81%99%E3%82%8B&amp;action=history"/>
	<updated>2026-06-06T11:29:45Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://monobook.org/w/index.php?title=MonoGame%E3%81%A7%E3%83%9E%E3%82%A6%E3%82%B9%E4%BD%8D%E7%BD%AE%E3%82%923D%E5%B9%B3%E9%9D%A2%E3%81%AB%E6%8A%95%E5%BD%B1%E3%81%99%E3%82%8B&amp;diff=11760&amp;oldid=prev</id>
		<title>2019年12月9日 (月) 04:49にAdministratorによる</title>
		<link rel="alternate" type="text/html" href="https://monobook.org/w/index.php?title=MonoGame%E3%81%A7%E3%83%9E%E3%82%A6%E3%82%B9%E4%BD%8D%E7%BD%AE%E3%82%923D%E5%B9%B3%E9%9D%A2%E3%81%AB%E6%8A%95%E5%BD%B1%E3%81%99%E3%82%8B&amp;diff=11760&amp;oldid=prev"/>
		<updated>2019-12-09T04:49:13Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2019年12月9日 (月) 04:49時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l2&quot;&gt;2行目:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;2行目:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[MonoGame]]での例だが、[[WebGL]]だろうと何だろうと同じだ。&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[MonoGame]]での例だが、[[WebGL]]だろうと何だろうと同じだ。&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;マウス座標をビュー座標に変換した場所から&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;マウス座標を[[ビュー座標]]に変換した場所から&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;画面の奥に向かって飛ぶベクトル（レイ）を求める。&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;画面の奥に向かって飛ぶ[[ベクトル]]（レイ）を求める。&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[レイ]]を生成できれば、あとは[[レイキャスティング]]で「当たり判定」をするだけだ。&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Administrator</name></author>
	</entry>
	<entry>
		<id>https://monobook.org/w/index.php?title=MonoGame%E3%81%A7%E3%83%9E%E3%82%A6%E3%82%B9%E4%BD%8D%E7%BD%AE%E3%82%923D%E5%B9%B3%E9%9D%A2%E3%81%AB%E6%8A%95%E5%BD%B1%E3%81%99%E3%82%8B&amp;diff=11759&amp;oldid=prev</id>
		<title>Administrator: ページの作成:「3D空間で物体を掴んだりするのに必要になる処理。 MonoGameでの例だが、WebGLだろうと何だろうと同じだ。  * マウス座標を…」</title>
		<link rel="alternate" type="text/html" href="https://monobook.org/w/index.php?title=MonoGame%E3%81%A7%E3%83%9E%E3%82%A6%E3%82%B9%E4%BD%8D%E7%BD%AE%E3%82%923D%E5%B9%B3%E9%9D%A2%E3%81%AB%E6%8A%95%E5%BD%B1%E3%81%99%E3%82%8B&amp;diff=11759&amp;oldid=prev"/>
		<updated>2019-12-09T04:48:25Z</updated>

		<summary type="html">&lt;p&gt;ページの作成:「3D空間で物体を掴んだりするのに必要になる処理。 &lt;a href=&quot;/wiki/MonoGame&quot; class=&quot;mw-redirect&quot; title=&quot;MonoGame&quot;&gt;MonoGame&lt;/a&gt;での例だが、&lt;a href=&quot;/wiki/WebGL&quot; title=&quot;WebGL&quot;&gt;WebGL&lt;/a&gt;だろうと何だろうと同じだ。  * マウス座標を…」&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;3D空間で物体を掴んだりするのに必要になる処理。&lt;br /&gt;
[[MonoGame]]での例だが、[[WebGL]]だろうと何だろうと同じだ。&lt;br /&gt;
&lt;br /&gt;
* マウス座標をビュー座標に変換した場所から&lt;br /&gt;
* 画面の奥に向かって飛ぶベクトル（レイ）を求める。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
    // マウスの座標&lt;br /&gt;
    var mouseState = Mouse.GetState();&lt;br /&gt;
    &lt;br /&gt;
    var nearScreenPoint = new Vector3(mouseState.X, mouseState.Y, 0);&lt;br /&gt;
    var farScreenPoint  = new Vector3(mouseState.X, mouseState.Y, 1);&lt;br /&gt;
&lt;br /&gt;
    var viewport = GraphicsDevice.Viewport;&lt;br /&gt;
    var nearWorldPoint = viewport.Unproject(nearScreenPoint, camera.Projection, camera.View, Matrix.Identity);&lt;br /&gt;
    var farWorldPoint  = viewport.Unproject(farScreenPoint , camera.Projection, camera.View, Matrix.Identity);&lt;br /&gt;
&lt;br /&gt;
    var direction = Vector3.Normalize( farWorldPoint - nearWorldPoint );&lt;br /&gt;
&lt;br /&gt;
    new Ray(nearWorldPoint, direction);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
このレイは画面に描画しようとしても、ディスプレイのXY平面と垂直なZ方向（画面奥）に向かって飛ぶので「点」にしかならない。画面に「線」が表示されるようなら[[バグ]]ってる。&lt;br /&gt;
&lt;br /&gt;
この計算後、かつ描画前にカメラを少しでも動かす処理が入ると表示がバグるよ。&lt;br /&gt;
&lt;br /&gt;
== 関連項目 ==&lt;br /&gt;
* [[MonoGameで画面空間からモデル空間に投影する]]&lt;br /&gt;
&lt;br /&gt;
[[category: MonoGame]]&lt;/div&gt;</summary>
		<author><name>Administrator</name></author>
	</entry>
</feed>