﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-findman-文章分类-Ogre学习</title><link>http://www.cppblog.com/findman/category/4450.html</link><description>迷失无需寻觅</description><language>zh-cn</language><lastBuildDate>Tue, 20 May 2008 15:47:02 GMT</lastBuildDate><pubDate>Tue, 20 May 2008 15:47:02 GMT</pubDate><ttl>60</ttl><item><title>OGRE1.4.1版按键响应</title><link>http://www.cppblog.com/findman/articles/25745.html</link><dc:creator>找东西</dc:creator><author>找东西</author><pubDate>Thu, 07 Jun 2007 08:52:00 GMT</pubDate><guid>http://www.cppblog.com/findman/articles/25745.html</guid><wfw:comment>http://www.cppblog.com/findman/comments/25745.html</wfw:comment><comments>http://www.cppblog.com/findman/articles/25745.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/findman/comments/commentRss/25745.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/findman/services/trackbacks/25745.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在看Xavier得教程，发现InputReader类已经不存在了。只好看SDK里面的带的samples。无奈，我的C++水平实在是菜的可以，昨天花了一下午也没给弄出来。后来，发现原来OGRE的按键触发已经没有使用自己的库了。在<font color=#ff0000><em>ExampleFrameListener.h</em></font>中我们可以找到以下代码：<br><font color=#ff0000><em>ExampleFrameListener.h</em> </font>42行左右<br><em>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">1</span><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #008000">//</span><span style="COLOR: #008000">Use&nbsp;this&nbsp;define&nbsp;to&nbsp;signify&nbsp;OIS&nbsp;will&nbsp;be&nbsp;used&nbsp;as&nbsp;a&nbsp;DLL<br></span><span style="COLOR: #008080">2</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">(so&nbsp;that&nbsp;dll&nbsp;import/export&nbsp;macros&nbsp;are&nbsp;in&nbsp;effect)</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">3</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000">&nbsp;OIS_DYNAMIC_LIB</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">4</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">OIS</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">OIS.h</span><span style="COLOR: #000000">&gt;</span></div>
<br></em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 它在使用另一个开源的库，比较郁闷的是，在API文档里面，没有包含这个库的相关信息，感觉做起来会比较的麻烦。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 花了点时间来分析代码，基本确定了，和按键触发相关的代码，如下：<br><font color=#0000ff><em>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">&nbsp;1</span><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">ParamList是一个存储触发对象的列表</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">&nbsp;2</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">ParamList&nbsp;pl;<br></span><span style="COLOR: #008080">&nbsp;3</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;size_t&nbsp;windowHnd&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">&nbsp;4</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;std::ostringstream&nbsp;windowHndStr;<br></span><span style="COLOR: #008080">&nbsp;5</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;win</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">getCustomAttribute(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">WINDOW</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">windowHnd);<br></span><span style="COLOR: #008080">&nbsp;6</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;windowHndStr&nbsp;</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">&nbsp;windowHnd;<br></span><span style="COLOR: #008080">&nbsp;7</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">将Windows句柄对象插入触发对象列表</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">&nbsp;8</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;pl.insert(std::make_pair(std::</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">WINDOW</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">),&nbsp;windowHndStr.str()));<br></span><span style="COLOR: #008080">&nbsp;9</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">创建输入管理，它的参数就是需要触发的对象</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">10</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;mInputManager&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;InputManager::createInputSystem(&nbsp;pl&nbsp;);<br></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">创建键盘对象&#8230;&#8230;&#8230;&#8230;，我第一次改的时候就把它给忘了</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">12</span><span style="COLOR: #008000"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;mKeyboard&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;static_cast</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">Keyboard</span><span style="COLOR: #000000">*&gt;</span><span style="COLOR: #000000">(mInputManager</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">createInputObject(&nbsp;OISKeyboard,&nbsp;bufferedKeys&nbsp;));</span></div>
<br></em></font>&nbsp;&nbsp;&nbsp;&nbsp; 就这些东西了，其他的变化不大。<br><br>&nbsp;&nbsp;&nbsp;&nbsp; <a title=实例代码 href="http://www.cppblog.com/Files/findman/ReWindow.rar">实例代码</a>下载<br>&nbsp;&nbsp;&nbsp;&nbsp; 
<img src ="http://www.cppblog.com/findman/aggbug/25745.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/findman/" target="_blank">找东西</a> 2007-06-07 16:52 <a href="http://www.cppblog.com/findman/articles/25745.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>