//---カメラアングルを移動 void CrBattleCharacter::MoveCamera(float angle,float r,int run_time,int camera /*= 0*/) { float cx,cy,cz,dx,dy,dz; GetCameraAngle(angle,r,&cx,&cy,&cz,&dx,&dy,&dz); crbatMoveCamera(camera,cx,cy,cz,dx,dy,dz,run_time); }
// 一定距離内に居るアクターをすべて返す VMArray<Actor*> FindCloseActor(float distance, UInt32 sortOrder) { enum Order { kSortOrder_distance = 0, // 距離が近い順 kSortOrder_crosshair = 1, // クロスヘアに近い順 kSortOrder_zaxis_clock = 2, // Z軸時計回り kSortOrder_zaxis_rclock = 3, // Z軸逆時計回り kSortOrder_invalid = 4 }; double fovThreshold = (double)PlayerCamera::GetSingleton()->worldFOV / 180.0 * M_PI /2; VMArray<Actor*> result; result.arr = NULL; tArray<UInt32>* actorHandles = &(*s_cellInfo)->actorHandles; if (actorHandles->count == 0) return result; std::vector<std::pair<double, Actor*>> vec; vec.reserve(actorHandles->count); PlayerCharacter* player = *g_thePlayer; NiPoint3 camPos; GetCameraPos(&camPos); UInt32 handle; size_t i = 0; while (actorHandles->GetNthItem(i++, handle)) { TESObjectREFR* ref = NULL; if (handle != *g_invalidRefHandle) LookupREFRByHandle(&handle, &ref); if (ref && ref->formType == kFormType_Character) { Actor* actor = (Actor*)ref; NiPoint3 pos; GetTargetPos(actor, &pos); double dx = pos.x - camPos.x; double dy = pos.y - camPos.y; double dz = pos.z - camPos.z; double dd = sqrt(dx*dx + dy*dy + dz*dz); if (distance <= 0 || dd <= distance) { double point; NiPoint3 cameraAngle; GetCameraAngle(&cameraAngle); double angleZ = NormalRelativeAngle(atan2(dx, dy) - cameraAngle.z); double angleX = NormalRelativeAngle(atan2(-dz, sqrt(dx*dx + dy*dy)) - cameraAngle.x); if (abs(angleZ) < fovThreshold) { switch (sortOrder) { case kSortOrder_distance: point = dd; break; case kSortOrder_crosshair: point = sqrt(angleZ*angleZ + angleX*angleX); break; case kSortOrder_zaxis_clock: point = NormalAbsoluteAngle(atan2(dx, dy) - cameraAngle.z); break; case kSortOrder_zaxis_rclock: point = 2*M_PI - NormalAbsoluteAngle(atan2(dx, dy) - cameraAngle.z); break; default: point = 0; break; } if (point >= 0) { vec.push_back(std::make_pair(point, actor)); } } } } } if (vec.size() == 0) return result; if (sortOrder < kSortOrder_invalid) std::sort(vec.begin(), vec.end()); // Papyrusに返す配列を確保 if (result.Allocate(vec.size())) { for (i = 0; i < vec.size(); i++) { result.Set(&vec[i].second, i); } } return result; }