本文整理汇总了C++中Obj类的典型用法代码示例。如果您正苦于以下问题:C++ Obj类的具体用法?C++ Obj怎么用?C++ Obj使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Obj类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setObject
void Explosion::setObject( Obj& object )
{
std::vector<glm::vec3> originalVertices;
std::vector<glm::vec2> originalUVs;
std::vector<glm::vec3> originalNormals;
m_zeroPositionVertices.clear();
m_zeroPositionUVs.clear();
m_zeroPositionNormals.clear();
m_triangleRotation.clear();
object.getInnerData( originalVertices, originalUVs, originalNormals );
// get mesh data and triangle indices
std::vector<Mesh*>& meshList = object.getMeshList();
// Generate a mesh for each triangle
for( std::vector<Mesh*>::iterator mesh = meshList.begin() ; mesh != meshList.end() ; ++mesh )
{
for( int i = 0 ; i < static_cast<int>((*mesh)->m_vertexIndex.size()) ; i=i+3 )
{
int a = (*mesh)->m_vertexIndex[i];
int b = (*mesh)->m_vertexIndex[i+1];
int c = (*mesh)->m_vertexIndex[i+2];
// Generate vertex list
m_zeroPositionVertices.push_back( originalVertices[a] );
m_zeroPositionVertices.push_back( originalVertices[b] );
m_zeroPositionVertices.push_back( originalVertices[c] );
m_zeroPositionUVs.push_back( originalUVs[a] );
m_zeroPositionUVs.push_back( originalUVs[b] );
m_zeroPositionUVs.push_back( originalUVs[c] );
m_zeroPositionNormals.push_back( originalNormals[a] );
m_zeroPositionNormals.push_back( originalNormals[b] );
m_zeroPositionNormals.push_back( originalNormals[c] );
// Generate mesh
Mesh* m = new Mesh();
m->m_vertexIndex.push_back(i);
m->m_vertexIndex.push_back(i+1);
m->m_vertexIndex.push_back(i+2);
m_meshList.push_back(m);
// generate random rotation scheme
glm::vec3 rot(rand(), rand(), rand());
m_triangleRotation.push_back(glm::normalize(rot));
}
}
// Store the meshes
setInnerData( m_zeroPositionVertices, m_zeroPositionUVs, m_zeroPositionNormals );
m_objectCenterPoint = glm::vec3(0,0,0);
// find the center point of the object using the middle point of the elements
for( std::vector<glm::vec3>::iterator it = m_vertices.begin() ; it != m_vertices.end() ; ++it )
{
m_objectCenterPoint += (*it);
}
int nVertices = static_cast<int>(m_vertices.size());
m_objectCenterPoint.x /= nVertices;
m_objectCenterPoint.y /= nVertices;
m_objectCenterPoint.z /= nVertices;
}
示例2: hStep
void HGame::hStep()
{
for(unsigned int i = 0; i<objectList.size(); i++)
{
Obj* o = objectList.at(i);
if(didRoomChange){break;}
o->onStep();
}
}
示例3: httpReader
void Obj::httpReader(void *_obj, Http *http)
{
Obj *obj = (Obj *) _obj;
if (! obj) return;
FILE *f = Cache::openCache(obj->getUrl(), http);
obj->loadFromFile(f);
if (! obj->flgpart) obj->displaylist();
File::closeFile(f);
}
示例4: QS_DEF
void IndigoInchi::saveMoleculeIntoInchi (Molecule &mol, Array<char> &inchi)
{
inchi_Input input;
QS_DEF(Array<inchi_Atom>, atoms);
QS_DEF(Array<inchi_Stereo0D>, stereo);
// Check if structure has aromatic bonds
bool has_aromatic = false;
for (int e = mol.edgeBegin(); e != mol.edgeEnd(); e = mol.edgeNext(e))
if (mol.getBondOrder(e) == BOND_AROMATIC)
{
has_aromatic = true;
break;
}
Molecule *target = &mol;
Obj<Molecule> dearom;
if (has_aromatic)
{
dearom.create();
dearom->clone(mol, 0, 0);
try
{
dearom->dearomatize();
}
catch (DearomatizationsGroups::Error &)
{
}
target = dearom.get();
}
generateInchiInput(*target, input, atoms, stereo);
inchi_Output output;
int ret = GetINCHI(&input, &output);
if (output.szMessage)
warning.readString(output.szMessage, true);
if (output.szLog)
log.readString(output.szLog, true);
if (output.szAuxInfo)
auxInfo.readString(output.szAuxInfo, true);
if (ret != inchi_Ret_OKAY && ret != inchi_Ret_WARNING)
{
// Construct error before dispoing inchi output to preserve error message
IndigoError error("Indigo-InChI: InChI generation failed: %s. Code: %d.", output.szMessage, ret);
FreeINCHI(&output);
throw error;
}
inchi.readString(output.szInChI, true);
FreeINCHI(&output);
}
示例5: OutputVTK
PetscErrorCode OutputVTK(const Obj<ALE::Mesh>& mesh, Options *options)
{
PetscViewer viewer;
PetscErrorCode ierr;
PetscFunctionBegin;
if (options->outputVTK) {
ALE::LogStage stage = ALE::LogStageRegister("VTKOutput");
ALE::LogStagePush(stage);
ierr = PetscPrintf(mesh->comm(), "Creating VTK mesh files\n");
CHKERRQ(ierr);
ierr = PetscViewerCreate(mesh->comm(), &viewer);
CHKERRQ(ierr);
ierr = PetscViewerSetType(viewer, PETSC_VIEWER_ASCII);
CHKERRQ(ierr);
ierr = PetscViewerSetFormat(viewer, PETSC_VIEWER_ASCII_VTK);
CHKERRQ(ierr);
ierr = PetscViewerFileSetName(viewer, "testMesh.vtk");
CHKERRQ(ierr);
ierr = VTKViewer::writeHeader(viewer);
CHKERRQ(ierr);
ierr = VTKViewer::writeHierarchyVertices(mesh, viewer, options->zScale);
CHKERRQ(ierr);
ierr = VTKViewer::writeHierarchyElements(mesh, viewer);
CHKERRQ(ierr);
ierr = PetscViewerDestroy(viewer);
CHKERRQ(ierr);
const ALE::Mesh::topology_type::sheaf_type& patches = mesh->getTopology()->getPatches();
#if 0
for(ALE::Mesh::topology_type::sheaf_type::iterator p_iter = patches.begin(); p_iter != patches.end(); ++p_iter) {
ostringstream filename;
filename << "coarseMesh." << *p_iter << ".vtk";
ierr = PetscViewerCreate(mesh->comm(), &viewer);
CHKERRQ(ierr);
ierr = PetscViewerSetType(viewer, PETSC_VIEWER_ASCII);
CHKERRQ(ierr);
ierr = PetscViewerSetFormat(viewer, PETSC_VIEWER_ASCII_VTK);
CHKERRQ(ierr);
ierr = PetscViewerFileSetName(viewer, filename.str().c_str());
CHKERRQ(ierr);
ierr = VTKViewer::writeHeader(viewer);
CHKERRQ(ierr);
ierr = VTKViewer::writeVertices(mesh, *p_iter, viewer);
CHKERRQ(ierr);
ierr = VTKViewer::writeElements(mesh, *p_iter, viewer);
CHKERRQ(ierr);
//ierr = FieldView_Sieve(mesh, "spacing", viewer);CHKERRQ(ierr);
ierr = PetscViewerDestroy(viewer);
CHKERRQ(ierr);
}
#endif
}
PetscFunctionReturn(0);
}
示例6: GET_MONSTER_SCENE
VOID AI_Monster::AI_Logic_Approach( UINT uTime )
{
__ENTER_FUNCTION
/** 先进行Approach类型的判断 */
GET_MONSTER_SCENE((VOID)0)
Obj* pObj = pScene->GetObjManager()->GetObj(m_CurEnemyID);
if (!pObj
|| !IsCharacterObj(pObj->GetObjType())
|| !((Obj_Character*)pObj)->IsAlive()
|| !((Obj_Character*)pObj)->IsCanViewMe(pMonster)
)
{/** 当前敌人无效后转向下一个敌人,直到全部找完为止 */
DelEnemy(m_CurEnemyID);
m_CurEnemyID = GetNextEnemy();
if (INVALID_ID == m_CurEnemyID) {
ToGoHome();
}
return ;
}
Obj_Character* pCurEnemy = (Obj_Character*)pObj;
FLOAT fMTDist,fETDist;
if (!pCurEnemy)
{
Assert(NULL && "AI_Monster::Logic_Approach...pCurEnemy=NULL...");
ToGoHome();
return ;
}
FLOAT fDist = MySqrt(pMonster->getWorldPos(), pCurEnemy->getWorldPos());
if ( IsToGoHome(fMTDist, fETDist) )
{
return ;
}
if (ZERO_VALUE > fMTDist)
{/** 如果到达目的地 */
ToAttack();
}
else
{
if( fETDist > (FLOAT)AIParam(AIPARAM_RESETTARGET_DIST)/1000.0f)
{/** 如果目标位置和敌人位置的距离大与一定值则需要重新制定移动目标 */
ToApproachTar( ) ;
}
else if(!GetCharacter()->IsMoving())
{
ToApproachTar( );
}
}
ExcuteAIScript(SAPPROACH);
__LEAVE_FUNCTION
}
示例7: Impact_GetLogic
BOOL ImpactCore_T::SendImpactToUnit(Obj_Character& rTar, ID_t nDataIndex, ObjID_t nSender, Time_t nDelayTime, BOOL bCriticalFlag, INT nRefixRate, INT nReserveParam1, INT nReserveParam2) const
{
__ENTER_FUNCTION
OWN_IMPACT impact;
if(INVALID_ID == nDataIndex)
{
return FALSE;
}
//根据nDataIndex对应的效果逻辑初始化rImp
if(TRUE == InitImpactFromData(nDataIndex, impact, rTar, nReserveParam1))
{
//获得逻辑对象
ImpactLogic_T const* pLogic = Impact_GetLogic(impact);
if(NULL==pLogic)
{
Assert(NULL=="[ImpactCore_T::SendImpactToUnit]: Can't find sprcific logic for this impact.");
return FALSE;
}
//设置会心标记
if(TRUE == bCriticalFlag)
{
impact.MarkCriticalFlag();
}
if(0!=nRefixRate)
{
//向效果逻辑设置修正率
pLogic->RefixPowerByRate(impact, nRefixRate);
}
if(0>nDelayTime)
{
nDelayTime = 0;
}
Scene* pScene = rTar.getScene();
Obj_Character* pChar = NULL;
if(NULL!=pScene)
{
Obj* pObj = pScene->GetSpecificObjByID( nSender );
if( IsCharacterObj(pObj->GetObjType()) )
{
pChar = static_cast<Obj_Character*>(pObj);
SkillInfo_T& rSkillInfo = pChar->GetSkillInfo();
impact.SetSkillID( rSkillInfo.GetSkillID() );
rSkillInfo.SetSendSkillImpactID(impact.GetDataIndex());
}
pScene->GetEventCore().RegisterImpactEvent(rTar.GetID(), nSender, impact, nDelayTime);
return TRUE;
}
}
// start to fill impact struct
return TRUE;
__LEAVE_FUNCTION
return FALSE;
}
示例8: Assert
uint CGLockTargetHandler::Execute( CGLockTarget* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION
GamePlayer* pGamePlayer = (GamePlayer*)pPlayer ;
Assert( pGamePlayer ) ;
Obj_Human* pHuman = pGamePlayer->GetHuman() ;
if(NULL==pHuman)
{
AssertEx(FALSE,"[CGLockTargetHandler::Execute]: NULL Obj_Human pointer found!!");
return PACKET_EXE_ERROR ;
}
Scene* pScene = pHuman->getScene() ;
if( pScene==NULL )
{
Assert(FALSE) ;
return PACKET_EXE_ERROR ;
}
//检查线程执行资源是否正确
Assert( MyGetCurrentThreadID()==pScene->m_ThreadID ) ;
ObjID_t nMeID = pHuman->GetID();
if( nMeID == INVALID_ID )
{
Assert(FALSE) ;
return PACKET_EXE_ERROR ;
}
//update target
if(NULL==pPacket)
{
AssertEx(FALSE,"[CGLockTargetHandler::Execute]: NULL packet pointer found!!");
return PACKET_EXE_ERROR ;
}
pHuman->SetLockedTarget(pPacket->getTargetID());
// 当锁定的目标是NPC时将会触发NPC的泡泡说话
Obj* pTarget = pScene->GetObjManager()->GetObj(pPacket->getTargetID());
if (pTarget->GetObjType() == Obj::OBJ_TYPE_MONSTER)
{
((Obj_Monster*)pTarget)->ProcessPaoPao();
}
g_pLog->FastSaveLog( LOG_FILE_1, "CGLockTargetHandler: ok obj=%d scene=%d",
nMeID, pScene->SceneID() ) ;
return PACKET_EXE_CONTINUE ;
__LEAVE_FUNCTION
return PACKET_EXE_ERROR ;
}
示例9: Obj
Obj* Obj::create()
{
Obj* pObj = new Obj();
if (false == pObj->initialize())
{
delete pObj;
pObj = NULL;
}
return pObj;
}
示例10: execute
void ConcurrencyTest::execute()
{
bslma::Allocator *Z = d_allocator_p;
Obj *mX = d_description_p; const Obj *MX = mX;
Format A(Z), B(Z), C(Z), D(Z), E(Z), F(Z);
const Format *FORMATS[] = { &A, &B, &C, &D, &E, &F };
const int NUM_FORMATS = sizeof FORMATS / sizeof *FORMATS;
Type::Value TYPES[] = { Type::e_TOTAL,
Type::e_COUNT,
Type::e_MIN,
Type::e_MAX,
Type::e_AVG,
Type::e_RATE,
Type::e_UNSPECIFIED
};
const int NUM_TYPES = sizeof TYPES / sizeof *TYPES;
F.setFormatSpec(Type::e_MIN, balm::MetricFormatSpec(2, "%f"));
ASSERT(!MX->format());
for (int iteration = 0; iteration < 20; ++iteration) {
d_barrier.wait();
for (int j = 0; j < NUM_TYPES; ++j) {
mX->setPreferredPublicationType(TYPES[j]);
int x = (int)MX->preferredPublicationType();
ASSERT(0 <= x && x < Type::k_LENGTH);
}
for (int i = 0; i < NUM_FORMATS; ++i) {
bsl::shared_ptr<const Format> fmt(FORMATS[i],
bslstl::SharedPtrNilDeleter(),
Z);
mX->setFormat(fmt);
ASSERT(MX->format());
}
d_barrier.wait();
// Note that '&F' may not equal 'MX->format()'.
ASSERT(F == *MX->format());
// Prevent the shared pointers from other threads being destroyed
// before the preceding comparison.
d_barrier.wait();
}
}
示例11: Assert
uint CGCharAskBaseAttribHandler::Execute( CGCharAskBaseAttrib* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION
GamePlayer* pGamePlayer = (GamePlayer*)pPlayer ;
Assert( pGamePlayer ) ;
Obj_Human* pHuman = pGamePlayer->GetHuman() ;
Assert( pHuman ) ;
Scene* pScene = pHuman->getScene() ;
if( pScene==NULL )
{
Assert(FALSE) ;
return PACKET_EXE_ERROR ;
}
//检查线程执行资源是否正确
Assert( MyGetCurrentThreadID()==pScene->m_ThreadID ) ;
ObjID_t ObjID = pPacket->getTargetID() ;
if( ObjID == INVALID_ID )
{
return PACKET_EXE_ERROR ;
}
Obj* pObj = pScene->GetObjManager()->GetObj( ObjID ) ;
if( pObj==NULL )
{
g_pLog->FastSaveLog( LOG_FILE_1, "CGCharAskBaseAttribHandler: not find obj=%d", ObjID ) ;
return PACKET_EXE_CONTINUE ;
}
if( !IsCharacterObj( pObj->GetObjType() ) )
{
g_pLog->FastSaveLog( LOG_FILE_1, "CGCharAskBaseAttribHandler: not character obj=%d", ObjID ) ;
return PACKET_EXE_CONTINUE ;
}
Obj_Character* pCharacter = (Obj_Character*)pObj ;
pCharacter->AskMsg_BaseAttrib( pHuman );
//影响效率关掉Log
//g_pLog->FastSaveLog( LOG_FILE_1, "CGCharAskBaseAttribHandler: obj=%d", ObjID ) ;
return PACKET_EXE_CONTINUE ;
__LEAVE_FUNCTION
return PACKET_EXE_ERROR ;
}
示例12: ut_obj
void ut_obj(){
Obj obj;
rapidjson::StringBuffer sb;
rapidjson::Writer<rapidjson::StringBuffer> writer(sb);
obj.Serialize(writer);
cout << "Writer:\n"<< sb.GetString() << endl;
cout << endl;
sb.Clear();
rapidjson::PrettyWriter<rapidjson::StringBuffer> prettyWriter(sb);
obj.Serialize(prettyWriter);
cout << "PrettyWriter:\n"<< sb.GetString() << endl;
cout << endl;
}
示例13: VisitTypedefDecl
bool VisitTypedefDecl(TypedefDecl * TD) {
if(TD == TD->getCanonicalDecl() && TD->getDeclContext()->getDeclKind() == Decl::TranslationUnit) {
llvm::StringRef name = TD->getName();
QualType QT = Context->getCanonicalType(TD->getUnderlyingType());
Obj typ;
if(GetType(QT,&typ)) {
typ.push();
general.setfield(name.str().c_str());
} else {
SetErrorReport(name.str().c_str());
}
}
return true;
}
示例14: main
int main(int argc, char *argv[])
{
MPI_Comm comm;
Options options;
PetscErrorCode ierr;
PetscFunctionBegin;
ierr = PetscInitialize(&argc, &argv, (char *) 0, NULL);CHKERRQ(ierr);
comm = PETSC_COMM_WORLD;
try {
ierr = ProcessOptions(comm, &options);CHKERRQ(ierr);
Obj<ALE::Mesh> mesh;
Mesh mesh_set[options.levels];
for (int i = 0; i < options.levels; i++) {
ierr = MeshCreate(comm, &mesh_set[i]);CHKERRQ(ierr);
};
ierr = CreateMesh(comm, mesh, &options);CHKERRQ(ierr);
MeshSetMesh(mesh_set[0], mesh);
ierr = MeshIDBoundary(mesh_set[0]);
mesh->markBoundaryCells("marker");
ierr = PetscPrintf(mesh->comm(), "%d boundary vertices, %d boundary cells\n", mesh->getLabelStratum("marker", 1)->size(), mesh->getLabelStratum("marker", 2)->size());
ierr = MeshSpacingFunction(mesh_set[0]);
//ierr = MeshIDBoundary(mesh_set[0]);
// mesh->createLabel("marker");
// mesh->markBoundaryCells("marker", 1, 2, false);
MeshCreateHierarchyLabel_Link(mesh_set[0], options.coarseFactor, options.levels, &mesh_set[1],NULL,options.curvatureCutoff );
Obj<ALE::Mesh> ale_meshes[options.levels];
for (int i = 0; i < options.levels; i++) {
MeshGetMesh(mesh_set[i], ale_meshes[i]);
}
Hierarchy_qualityInfo(ale_meshes, options.levels);
//ierr = MeshCoarsenMesh(m, pow(options.coarseFactor, 2), &n);
//ierr = MeshGetMesh(n, mesh);
//ierr = MeshLocateInMesh(m, n);
// Obj<ALE::Mesh::sieve_type> sieve = new ALE::Mesh::sieve_type(mesh->comm(), 0);
// mesh->getTopology()->setPatch(options.levels, sieve);
// mesh->getTopology()->stratify();
char vtkfilename[128];
for (int i = 0; i < options.levels; i++) {
sprintf(vtkfilename, "testMesh%d.vtk", i);
ierr = OutputVTK(ale_meshes[i], &options, vtkfilename);CHKERRQ(ierr);
}
} catch (ALE::Exception e) {
std::cout << e << std::endl;
}
ierr = PetscFinalize();CHKERRQ(ierr);
PetscFunctionReturn(0);
}
示例15: GetFuncType
bool GetFuncType(const FunctionType * f, Obj * typ) {
Obj returns,parameters;
resulttable->newlist(&returns);
resulttable->newlist(¶meters);
bool valid = true; //decisions about whether this function can be exported or not are delayed until we have seen all the potential problems
QualType RT = f->getResultType();
if(!RT->isVoidType()) {
Obj rt;
if(!GetType(RT,&rt)) {
valid = false;
} else {
rt.push();
returns.addentry();
}
}
const FunctionProtoType * proto = f->getAs<FunctionProtoType>();
//proto is null if the function was declared without an argument list (e.g. void foo() and not void foo(void))
//we don't support old-style C parameter lists, we just treat them as empty
if(proto) {
for(size_t i = 0; i < proto->getNumArgs(); i++) {
QualType PT = proto->getArgType(i);
Obj pt;
if(!GetType(PT,&pt)) {
valid = false; //keep going with attempting to parse type to make sure we see all the reasons why we cannot support this function
} else if(valid) {
pt.push();
parameters.addentry();
}
}
}
if(valid) {
PushTypeFunction("functype");
parameters.push();
returns.push();
lua_pushboolean(L, proto ? proto->isVariadic() : false);
lua_call(L, 3, 1);
typ->initFromStack(L,ref_table);
}
return valid;
}