本文整理汇总了C++中MEngine::getLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ MEngine::getLevel方法的具体用法?C++ MEngine::getLevel怎么用?C++ MEngine::getLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MEngine
的用法示例。
在下文中一共展示了MEngine::getLevel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void MShaderRef::update(void)
{
MEngine * engine = MEngine::getInstance();
MLevel * level = engine->getLevel();
MRenderingContext * render = engine->getRenderingContext();
char * text = readTextFile(getFilename());
if(text)
{
// gen shader if null
if(m_shaderId == 0)
{
switch(m_type)
{
case M_SHADER_VERTEX:
render->createVertexShader(&m_shaderId);
break;
case M_SHADER_PIXEL:
render->createPixelShader(&m_shaderId);
break;
}
}
// send shader source
render->sendShaderSource(m_shaderId, text);
SAFE_FREE(text);
MFXManager * FXManager = level->getFXManager();
unsigned int i;
unsigned int size = FXManager->getFXRefsNumber();
for(i=0; i<size; i++)
{
MFXRef * FXRef = FXManager->getFXRef(i);
if((FXRef->getPixelShaderRef() == this) || (FXRef->getVertexShaderRef() == this))
{
unsigned int FXId = FXRef->getFXId();
render->updateFX(FXId);
}
}
}
}
示例2: update
void MFilesUpdate::update(void)
{
MEngine * engine = MEngine::getInstance();
MLevel * level = engine->getLevel();
MDataManager * textureManager = level->getTextureManager();
MDataManager * shaderManager = level->getShaderManager();
MDataManager * soundManager = level->getSoundManager();
MDataManager * meshManager = level->getMeshManager();
MDataManager * armatureAnimManager = level->getArmatureAnimManager();
MDataManager * texturesAnimManager = level->getTexturesAnimManager();
MDataManager * materialsAnimManager = level->getMaterialsAnimManager();
updateRefs(textureManager);
updateRefs(shaderManager);
updateRefs(meshManager);
updateRefs(soundManager);
updateRefs(armatureAnimManager);
updateRefs(texturesAnimManager);
updateRefs(materialsAnimManager);
}
示例3: execute
void execute(const char* projName)
{
MEngine* engine = MEngine::getInstance();
MSystemContext* system = engine->getSystemContext();
MPackageManager* packageManager = engine->getPackageManager();
char directory[256], localFilename[256];
getGlobalFilename(directory, system->getWorkingDirectory(), "meshs");
vector<string> files;
readDirectory(directory, &files, 1, 1);
MLevel* currentLevel = engine->getLevel();
MLevel* tempLevel = new MLevel();
engine->setLevel(tempLevel);
MMesh* mesh = MMesh::getNew();
MArmatureAnim* armAnim = MArmatureAnim::getNew();
MTexturesAnim* texAnim = MTexturesAnim::getNew();
MMaterialsAnim* matAnim = MMaterialsAnim::getNew();
// open package and scan meshes
MPackage package = openProjectPackage(projName);
for(int i = 0; i < files.size(); ++i)
{
bool binarized = false;
if(strstr(files[i].c_str(), "._bin") != 0)
continue;
// export bin
if(strstr(files[i].c_str(), ".mesh") != 0)
{
if(engine->getMeshLoader()->loadData(files[i].c_str(), mesh))
binarized = exportMeshBin((files[i] + "._bin").c_str(), mesh);
}
else if (strstr(files[i].c_str(), ".maa") != 0)
{
if(engine->getArmatureAnimLoader()->loadData(files[i].c_str(), armAnim))
binarized = exportArmatureAnimBin((files[i] + "._bin").c_str(), armAnim);
}
else if (strstr(files[i].c_str(), ".mma") != 0)
{
if(engine->getMaterialsAnimLoader()->loadData(files[i].c_str(), matAnim))
binarized = exportMaterialsAnimBin((files[i] + "._bin").c_str(), matAnim);
}
else if (strstr(files[i].c_str(), ".mta") != 0)
{
if(engine->getTexturesAnimLoader()->loadData(files[i].c_str(), texAnim))
binarized = exportTexturesAnimBin((files[i] + "._bin").c_str(), texAnim);
}
else
{
// try to export unknow format
if(engine->getMeshLoader()->loadData(files[i].c_str(), mesh))
{
binarized = exportMeshBin((files[i] + "._bin").c_str(), mesh);
// try to export animation
MArmatureAnimRef * maaRef = mesh->getArmatureAnimRef();
if(maaRef)
{
exportArmatureAnimBin((files[i] + ".maa._bin").c_str(), maaRef->getArmatureAnim());
getLocalFilename(localFilename, system->getWorkingDirectory(), (files[i] + ".maa").c_str());
packageManager->addFileToPackage((files[i] + ".maa._bin").c_str(), package, localFilename);
}
}
}
tempLevel->clear();
// pack file
getLocalFilename(localFilename, system->getWorkingDirectory(), files[i].c_str());
if(binarized)
packageManager->addFileToPackage((files[i] + "._bin").c_str(), package, localFilename); // pack bin file
else
packageManager->addFileToPackage(files[i].c_str(), package, localFilename); // pack original file
}
packageManager->closePackage(package);
// clear mesh
mesh->destroy();
armAnim->destroy();
texAnim->destroy();
matAnim->destroy();
// remove bin
for(int i = 0; i < files.size(); ++i)
{
remove((files[i] + "._bin").c_str());
remove((files[i] + ".maa._bin").c_str());
}
// restore level
engine->setLevel(currentLevel);
SAFE_DELETE(tempLevel);
}
示例4: update
void MBLookAt::update(void)
{
MEngine * engine = MEngine::getInstance();
MLevel * level = engine->getLevel();
MScene * scene = level->getCurrentScene();
MObject3d * parent = getParentObject();
const char * targetName = m_targetName.getData();
if(strcmp(targetName, "none") == 0)
return;
// target object
MObject3d * object = scene->getObjectByName(targetName);
if(! object)
return;
// direction
MVector3 direction = object->getTransformedPosition() - parent->getTransformedPosition();
if(direction.x == 0 && direction.y == 0 && direction.z == 0)
return;
float angle;
float roll;
MVector3 axis;
// compute initial roll
MVector3 ZAxis = parent->getInverseRotatedVector(MVector3(0, 0, 1)).getNormalized();
ZAxis.z = 0;
ZAxis.normalize();
if(ZAxis.x == 0 && ZAxis.y == 0)
{
MVector3 YAxis = parent->getInverseRotatedVector(MVector3(0, 1, 0)).getNormalized();
YAxis.z = 0;
YAxis.normalize();
axis = MVector3(0, 1, 0).crossProduct(YAxis);
roll = acosf(MVector3(0, 1, 0).dotProduct(YAxis));
if(MVector3(0, 0, 1).dotProduct(axis) < 0)
roll = -roll;
}
else
{
axis = MVector3(0, 1, 0).crossProduct(ZAxis);
roll = acosf(MVector3(0, 1, 0).dotProduct(ZAxis));
if(MVector3(0, 0, 1).dotProduct(axis) < 0)
roll = -roll;
}
if(roll < 0.001f && roll > -0.001f) roll = 0;
// look-at
MVector3 cameraAxis = MVector3(0, 0, -1);
axis = cameraAxis.crossProduct(direction);
angle = acosf(cameraAxis.dotProduct(direction.getNormalized()));
parent->setAxisAngleRotation(axis, (float)(angle * RAD_TO_DEG));
parent->updateMatrix();
// set roll
ZAxis = parent->getInverseRotatedVector(MVector3(0, 0, 1)).getNormalized();;
ZAxis.z = 0;
ZAxis.normalize();
if(ZAxis.x == 0 && ZAxis.y == 0)
{
parent->addAxisAngleRotation(MVector3(0, 0, 1), (float)(-roll*RAD_TO_DEG));
}
else
{
axis = MVector3(0, 1, 0).crossProduct(ZAxis);
angle = acosf(MVector3(0, 1, 0).dotProduct(ZAxis));
if(angle < 0.001f && angle > -0.001f) angle = 0;
if(MVector3(0, 0, 1).dotProduct(axis) < 0)
angle = -angle;
parent->addAxisAngleRotation(MVector3(0, 0, 1), (float)((angle-roll)*RAD_TO_DEG));
}
}