x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
DebugLine.cpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\DebugLine.cpp
旋转
特效
属性
历史版本
#include "DebugLine.h" #include "GameFactoryDemo.h" using namespace GameFactory; DebugLine::DebugLine(SceneManager* sceneManager) { this->initialized = false; initialize(sceneManager); } DebugLine::~DebugLine(void) { mSceneMgr->getRootSceneNode()->removeChild(mDebugNode); } void DebugLine::DrawDebugLine(Vector3 from, Vector3 to){ assert(initialized && "Must call Initialize before draw the first DebugLine"); Line3D* line = new Line3D(); line->addPoint(from); line->addPoint(to); line->drawLines(); line->setMaterial("lineMaterial"); mDebugNode->attachObject(line); pool.push_back(line); } void DebugLine::initialize(SceneManager* sceneManager){ if (initialized) return; initialized = true; mSceneMgr = sceneManager; mDebugNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(Vector3(0,0,0)); MaterialPtr mat = MaterialManager::getSingleton().create("lineMaterial", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); mat->setAmbient(ColourValue(1,0,1,1)); mat->setDiffuse(ColourValue(1,0,0,1)); } void DebugLine::ClearAll(){ for (vector
::iterator iter = pool.begin();iter!=pool.end();iter++){ mDebugNode->detachObject(*iter); } pool.clear(); } Vector3 DebugLine::GetMouse3DPos(int mouseX, int mouseY){ int width, height; Viewport* vp = SkeletalApplication::GetSingleton()->GetWindow()->getViewport(0); width = vp->getActualWidth(); height = vp->getActualHeight(); Real mX = (float)mouseX / width; Real mY = (float)mouseY / height; Ray ray = vp->getCamera()->getCameraToViewportRay(mX,mY); Vector3 hitPos; if (SkeletalApplication::GetSingleton()->RayCast(ray.getOrigin(),ray.getOrigin()+ray.getDirection(),&hitPos, NULL)){ return hitPos; } } void DebugLine::DrawFromMousePos(int mouseX, int mouseY){ //convert mouse pos to ratio form int width, height; Viewport* vp = SkeletalApplication::GetSingleton()->GetWindow()->getViewport(0); width = vp->getActualWidth(); height = vp->getActualHeight(); Real mX = (float)mouseX / width; Real mY = (float)mouseY / height; Ray ray = vp->getCamera()->getCameraToViewportRay(mX,mY); Vector3 hitPos, hitNorm; if (SkeletalApplication::GetSingleton()->RayCast(ray.getOrigin(),ray.getOrigin()+ray.getDirection(),&hitPos, &hitNorm)){ DrawDebugLine(hitPos,hitPos+hitNorm.normalisedCopy()*5); } //Real mX = (Real)(mouseX - width/2)/width*2; //Real mY = (Real)(mouseY - height/2)/height*2; //Camera* cam = vp->getCamera(); //Vector3 to = Vector3(mX/2,-mY/2,cam->getNearClipDistance()); //to = cam->getViewMatrix().inverse() * to; //Vector3 from = cam->getPosition(); //Vector3 hitPos; //if (SkeletalApplication::GetSingleton()->RayCast(from,to,&hitPos, NULL)){ // DrawDebugLine(from,hitPos); //} }
DebugLine.cpp
网页地址
文件地址
上一页
13/45
下一页
下载
( 2 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.