資源簡介
此程序來源于我的一篇博客,歡迎訪問。
http://blog.csdn.net/gamesdev/article/details/11994501
-------------------------------------
歡迎訪問我的博客。
http://blog.csdn.net/gamesdev
-------------------------------------
Qt的QWidget大家族已經成熟,不會得到太大的發展了,而隨著Qt5的發展,新的界面類會嶄露頭角,比如QWindow、QSurface、QScreen這些類。但現在的狀況(Qt5.2即將出了),這些類和模塊并不會對現有的GUI模塊造成威脅,更不用說取代Qt4的GUI(在Qt5是QtGui和QtWidgets)模塊了。自Qt4.4起,Qt擁有了Graphics-View框架,使用這個框架可以更加輕松地在窗口中嵌入任意你想要繪制的元素。但是據我所知,Qt5的那些類無法和Graphics-View框架進行整合,對于想要利用Qt中Graphics-View框架的同行們,只能退回Qt4的類進行開發了,Qt5的這些類對于創建純OpenGL還是有利的。
代碼片段和文件信息
/*?┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
?*?┃?????┏━┣━┣┓ ┏┓┏┓┳┓┏━━┓┣┣━┓ ┓ ┓┣┳━┓???????┃
?*?┃?????┏┏┏╯━┓┳┳━┛┏╯┃┃┃ ┃┣┣━┓┃┃ ┃┃┃ ???????┃
?*?┃?????┃┃┏━╮┃┗┗┏╯┗┃┃╯┃ ┃┏┣━┓┃┃ ┃╯┣━┓???????┃
?*?┃?????╰┫┏━┻╯┗┳┣┛┏┛┃┃┣━━┫┃┃ ┃┃┃┗╯ ┃ ???????┃
?*?┃?????┏┫━┳━┫┏┃┣┓┗┃┃╯┃ ┃┃┃ ┃ ┃ ┃ ┣━┓???????┃
?*?┃?????┗┗┗━━╯┗┛┛╯┗╯╰ ┗━━╯ ┛ ┛┗╯ ╰┛┗ ???????┃
?*?┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
?*?┃?????????????????????Copyright?(c)?2013?jiangcaiyang????????????????????┃
?*?┃?This?software?is?provided?‘as-is‘?without?any?express?or?implied??????┃
?*?┃?warranty.?In?no?event?will?the?authors?be?held?liable?for?any?damages??┃
?*?┃?arising?from?the?use?of?this?software.?????????????????????????????????┃
?*?┃????????????????????????????????????????????????????????????????????????┃
?*?┃?Permission?is?granted?to?anyone?to?use?this?software?for?any?purpose??┃
?*?┃?including?commercial?applications?and?to?alter?it?and?redistribute?it?┃
?*?┃?freely?subject?to?the?following?restrictions:?????????????????????????┃
?*?┃????????????????????????????????????????????????????????????????????????┃
?*?┃?1.?The?origin?of?this?software?must?not?be?misrepresented;?you?must????┃
?*?┃????not?claim?that?you?wrote?the?original?software.?If?you?use?this?????┃
?*?┃????software?in?a?product?an?acknowledgment?in?the?product?????????????┃
?*?┃????documentation?would?be?appreciated?but?is?not?required.?????????????┃
?*?┃?2.?Altered?source?versions?must?be?plainly?marked?as?such?and?must????┃
?*?┃????not?be?misrepresented?as?being?the?original?software.???????????????┃
?*?┃?3.?This?notice?may?not?be?removed?or?altered?from?any?source???????????┃
?*?┃????distribution.???????????????????????????????????????????????????????┃
?*?┃????????????????????????????????????????????????????????????????????????┃
?*?┃?jiangcaiyang?jiangcaiyang123@163.com???????????????????????????????????┃
?*?┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
?*?┃?file?name:?Camera.cpp??????????????????????????????????????????????????┃
?*?┃?create?date:?2013年9月21日星期六?20時5分30秒???????????????????????????┃
?*?┃?last?modified?date:?2013年9月24日星期二?22時12分23秒???????????????????┃
?*?┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
?*/
#include?
#include?“Camera.h“
/*---------------------------------------------------------------------------*/
Camera::Camera(?void?)
{
????m_Pos?=?QVector3D(?0?0?0?);
????m_RotateY?=?0.0;
????m_RotateH?=?0.0;
????m_Len?=?QVector3D(?0?0?0?);
????m_TryPos?=?QVector3D(?0?0?0?);
????m_TryRotateY?=?0.0;
????m_TryRotateH?=?0.0;
????m_Try?=?false;
}
/*---------------------------------------------------------------------------*/
void?Camera::SetPos(?const?QVector3D?pos?bool?_try?)
{
????m_Try?=?_try;
????if?(?m_Try?)?m_TryPos?=?pos;
????else
????{
????????m_Pos?+=?pos;
????????m_Offset2D?+=?QVector3D(?pos.x(?)?pos.y(?)?0?);
????????m_TryPos?=?QVector3D(?0?0?0?);
????}
}
void?Camera::SetRotateY(?float?rotateY?bool?_try?)
{
????m_Try?=?_try;
????if?(?m_Try?)?m_TryRotateY?=?rotateY;
????else
????{
????????m_RotateY?+
- 上一篇:基于Qt和GLSL的著色器演示程序+源代碼
- 下一篇:反向運動學演示程序含核心代碼
評論
共有 條評論