Login Form

 


УСТАНВКА АЛЬФА КАНАЛА НОДЕ


bool setAlphaToNode(Ogre::SceneNode* node, float alpha)
{
Ogre::Entity* ent = (Ogre::Entity*)node->getAttachedObject(0);
if(!ent) return false;
int cnt = ent->getNumSubEntities();
for(int i=0;i<cnt;i++)
{
Ogre::MaterialPtr material = ent->getSubEntity(i)->getMaterial()->clone("R_m");
Ogre::ColourValue sc = material->getTechnique(0)->getPass(0)->getDiffuse();
sc.a = alpha;
material->getTechnique(0)->getPass(0)->setDiffuse(sc);
material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
material->getTechnique(0)->getPass(0)->setDepthCheckEnabled(true); 
material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
ent->getSubEntity(i)->setMaterial(material);
}
return true;
}


ПИКАНЬЕ ОБЪЕКТА

Ogre::MovableObject* test::getObjFromCam(float x, float y)

{
Ogre::RaySceneQuery* ray = mSceneMgr->createRayQuery(Ogre::Ray());
Ogre::Ray mray = mCamera->getCameraToViewportRay(x,y);
ray->setRay(mray);
ray->setSortByDistance(true);
Ogre::RaySceneQueryResult &res = ray->execute();
Ogre::RaySceneQueryResult::iterator itr;
for(itr=res.begin();itr!=res.end();itr++)
{
//Ogre::Vector3 pos = itr->worldFragment->singleIntersection;
return itr->movable; 
}
return NULL;
}
 вызов функции
 

bool test::mpress( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
float x=arg.state.X.abs;
float y=arg.state.Y.abs;
float w=arg.state.width;
float h=arg.state.height;
Ogre::SceneNode* nd = getObjFromCam(1/w*x,1/h*y);
if(nd!=NULL)
{
}
}