x
Yes
No
Do you want to visit DriveHQ English website?
Inicio
Características
Precios
Prueba gratuita
Software cliente
Acerca de nosotros
Servidor de archivos
|
Solución de copias de seguridad
|
Servidor FTP
|
Servidor de correo electrónico
|
Alojamiento web
|
Software cliente
Servidor de archivos
Solución de copia de seguridad
Servidor FTP
Servidor de correo electrónico
Alojamiento web
Software cliente
DebugLine.cpp - Hosted on DriveHQ Cloud IT Platform
Arriba
Subir
Descargar
Compartir
Publicar
Nueva carpeta
Nuevo archivo
Copiar
Cortar
Eliminar
Pegar
Clasificación
Actualizar
Ruta de la carpeta: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\DebugLine.cpp
Girar
Efecto
Propiedad
Historial
#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
Dirección de la página
Dirección del archivo
Anterior
13/45
Siguiente
Descargar
( 2 KB )
Comments
Total ratings:
0
Average rating:
No clasificado
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.