Войти
CryengineФорум

Cryengine V : Tips

#0
11:46, 10 дек. 2016

Я складирую у себя короткие текстовые описания по типу (проблема -> решение, или просто указание на особенность какую-либо), подумал надо завести одноименную тему(Советы)

TIP_1 (phys setting for acticulated on water)

for water silk pe_articulated
mass = x
water density = x / 10.f
water resistance = x

TIP_2 (not removed on demand time)

if (m_pObject != nullptr)
{

  gEnv->pEntitySystem->RemoveEntity(m_pObject ->GetId());

  m_pObject = nullptr;

}

removeentity(..., true) as second param
if you dont do right now, the system will try to delete the entity in the next frame but you destroyed already the pointer, so...


TIP_3 (SkyBox = OpenSpace)
No need of a sphere.
1.remove the terrain
2.remove the water
3.modify the skybox material, and under shader generation params, you check no night sky gradien and no day sky gradien
4.Ajust the tod(TimeOfDay), and you got it!(stars intensity, fog and sun params)

TIP_4 (ProcessEvent vs HandleEvent )

ProcessEvent - handles things on the entity level. For example, if something collides with the entity. Looking at the SEntityEvent structure will give you a good idea of what those entail.

HandleEvent - works on the game level with specifically defined events. Say you want a debuff to be applied to all players when a certain condition is applied. You make your SGameObjectEvent with the properties you want and have it broadcasted (this event needs to be registered along with the existing CryGameEvents to be valid). Your game object listens for these SGameObjectEvents and calls HandleEvent passing that structure on as an argument.


TIP_5 (Показать FPS'ы)
прописать в autoexec.cfg строчку r_displayinfo 3

TIP_6 Clear scene: disable sun, terrain, water, fog...
добавить в Assets/Game.cfg строчки
e_waterocean=0
e_fog=0
e_skybox=0
e_clouds=0
e_terrain=0
e_sun=0

TIP_7 add anim on demand (for Mannequin)

IActionController *pActionController = m_pPlayer->m_pAnimatedCharacter->GetActionController();
SAnimationContext &animContext = pActionController->GetContext();

const FragmentID enterBackpackId = animContext.controllerDef.m_fragmentIDs.Find("enterInventory");
const int actionPriority = 10;

IActionPtr pAction = new TAction<SAnimationContext>(actionPriority, enterBackpackId);
pActionController->Queue(*pAction);

TIP_8 Физические свойства материалов
Assets\Libs\MaterialEffects\SurfaceTypes.xml

TIP_9 Кубомапа уровня (5 сторон без дна) задается материалом в файле Environment.xml
Assets\Levels\example\leveldata\Environment.xml

<Environment>
...
 <SkyBox Material="EngineAssets/Materials/Sky/Sky" MaterialLowSpec="EngineAssets/Materials/Sky/Sky" Angle="0" Stretching="0.5"/>
...
</Environment>

TIP_10 Navigation Mesh не генерируется и в Debug -> Debut Agent Type нет ни одного пункта для визуализации "синих областей"
Причина: в проекте отсутствует файл Assets/Scripts/AI/Navigation.xml с описанием агентов
Типовой пример файла можно скопировать из документации http://docs.cryengine.com/display/SDKDOC2/Agent+Types или из примера IsometricPathfinding

+ Показать

TIP_11 (Показать физику моделей (коллайдеры), например для отладки размеров PE_LIVING... )
прописать в autoexec.cfg строчку p_draw_helpers 1

TIP_12 (Force to use CAFs files (Cryengine Animation File) instead of using animations from IMG db  )
прописать в autoexec.cfg строчку ca_UseIMG_CAF 0


TIP_13 Rotate Bone

std::shared_ptr<IAnimationOperatorQueue> pOperatorQueue;
CryCreateClassInstanceForInterface(cryiidof<IAnimationOperatorQueue>(), pOperatorQueue);

int32 jointId = pCharacter->GetIDefaultSkeleton().GetJointIDByName("Bip01 L Hand"); 
pOperatorQueue->PushPosition(jointId, IAnimationOperatorQueue::eOp_Additive, Vec3(0, 0, 0.1f)); 
pCharacter->GetISkeletonAnim()->PushPoseModifier(0, pOperatorQueue);

TIP_14 For debug volumes

  AABB aabb;
  GetEntity()->GetLocalBounds(aabb);

  OBB obb(OBB::CreateOBBfromAABB(Matrix33(GetEntity()->GetWorldTM()), aabb));

  gEnv->pRenderer->GetIRenderAuxGeom()->DrawOBB(obb, GetEntity()->GetWorldTM(), false, ColorB(255, 255, 0), EBoundingBoxDrawStyle::eBBD_Faceted);

TIP_15 ReBind keys in runtme for ActionMap
IPlayerProfileManager* pManager = gEnv->pGameFramework->GetIPlayerProfileManager();
const char* user = pManager->GetCurrentUser();
IPlayerProfile* pProfile = pManager->GetCurrentProfile(user);
IActionMap* pActionMap = pProfile->GetActionMap("player");
pActionMap->ReBindActionInput(g_pGameActions->jump, "space", "k");

IPlayerProfileManager::EProfileOperationResult result;
pManager->SaveProfile(user, result, ePR_All);


#1
12:04, 10 дек. 2016

TIP_16 Чтобы не запускался CRYENGINE Launcher (веб морда с проектами) при старте Sandbox.exe
добавляем в editor.cfg параметр ed_useDevManager = 0
You can also make it happen per project by adding the cvar to the cryproject file

TIP_17 Загрузка ToD

  ITimeOfDay* tod = gEnv->p3DEngine->GetTimeOfDay();
  tod->LoadPreset("Assets\\libs\\environmentpresets\\example.xml");
  tod->SetTime(21.0f);
  tod->Update(true, true);

TIP_18 if the level is corrupted delete the level.pak file

TIP_19 to get RWI hit by PE_Living phys entity
pe_living's capsule doesn't include geom_colltype_ray in its part flags, and rwi requires this flag by default. you can change that by adding rwi_colltype_any(geom_colltype0) to rwi flags (or you can use any other colltype that the player's capsule has, or a combination of flags, such as geom_colltype_solid)

    unsigned int flags = rwi_stop_at_pierceable | rwi_colltype_any(geom_colltype0) | rwi_ignore_back_faces;
    hit = gEnv->pPhysicalWorld->RayWorldIntersection(RayOrigin, DirectionWithRange, entity_query_flags::ent_all, flags, &rayHit, 1, physSkip, physSkipNum);
    if (hit)
      pEntity = (IEntity*)rayhit.pCollider->GetForeignData(PHYS_FOREIGN_ID_ENTITY);
http://docs.cryengine.com/display/CEPROG/Ray+and+Primitive+Tracing


TIP_20 handy helper to add to your project CMakeLists.txt if you want easier switching between attaching to Editor and Launcher

правится файл %templateBasedProject%\Code\CMakeLists.txt

#BEGIN-CUSTOM

add_library(Launch STATIC "${CRYENGINE_DIR}/Code/CryEngine/CryCommon/CryCore/Platform/platform.h")
set_target_properties(Launch PROPERTIES LINKER_LANGUAGE CXX) 
if (WIN32)     
  set_visual_studio_debugger_command(Launch "${CRYENGINE_DIR}/bin/win_x64/GameLauncher.exe" "-project \"C:/CryProjects/DF2/Game.cryproject\"") 
 endif()
add_library(Editor STATIC "${CRYENGINE_DIR}/Code/CryEngine/CryCommon/CryCore/Platform/platform.h") 
set_target_properties(Editor PROPERTIES LINKER_LANGUAGE CXX) 
if (WIN32)     
  set_visual_studio_debugger_command(Editor "${CRYENGINE_DIR}/bin/win_x64/Sandbox.exe" "-project \"C:/CryProjects/DF2/Game.cryproject\"") 
endif()

#END-CUSTOM


TIP_21  understanding how nested area setup works with 5.4 in regards to ambient audio

Видео:

+ Показать


TIP_22 Доковырятся до PhysX Actor'a (если юзается PhysX вместо CryPhys)

physx::PxRigidActor* pActor = (physx::PxRigidActor*)gEnv->pPhysicalWorld->GetInternalImplementation(1, pPhysicalEntity);
pActor->is<physx::PxRigidDynamic>()->addForce(physx::PxVec3(10, 0, 0), physx::PxForceMode::eACCELERATION);

settings

p_physics_library = "CryPhysX"
e_OnDemandPhysics = 0
e_onDemandMaxSize = 999999
p_draw_helpers_num = 0
e_PhysOceanCell=0


TIP_23 Velocity vs Impulse
Управляя скоростью IPhysEntity вы получаете движение сквозь стены, товарисчи юзаете импульсы, чтобы солвер все разрулил!
и несколько коментариев по теме от разработчика физики

if you keep setting velocity each frame the physics will have no choice but to move the object with it
through walls if necessary


if you apply impulse instead, you can set it to apply after the move (it's set to that by default), but before the solver, so the solver will react to collisions and the next step will be made with solver-modified velocity

if you apply impulse each frame it won't

it's best to do it in an immediate callback from the physics in poststep event
to avoid threading lag

TIP_24 Animations.pak собранной игры, не содержит файлов типа - *.CAF (поэтому анимации не воспроизводятся т.к. возможно нет даже скомпилированных анимаций в виде файлов *.DBA). Как поправить билд-скрипт чтобы CAF'ы паковались в pak'и?
it's seem what they forgot include CAFs JOB into RC script `CRYENGINE_5.4\Tools\CryVersionSelector\rc_jobs\rcjob_release_game_assets.xml`
need add CAF job
like so (last job in batch)

<!-- Convert animation template -->

    <AnimationsJob>

        <DefaultProperties DbaStreamPrepare="1" />

        <DefaultProperties CafAlignTracks="1" />

        <DefaultProperties AnimConfigFolder="Animations" />

        <Job Input="*.i_caf" Refresh="1" />

        <Job Input="*.anm" CopyOnly="1" />

        <Job Input="*.caf" CopyOnly="1" />

    </AnimationsJob>
#2
12:04, 10 дек. 2016

reserved for tips

CryengineФорум

Тема в архиве.