×
Menu

NiSwitchNode - notes

 
Примечание.
В отличие от LodNode для смены состояний используется "механическая" часть движка, т.е. что отвечает за взаимодействие игрока с миром.
Определение дистанции до камеры игрока, используемую в работе Лодов, можно отнести к графической части движка.
А при смены состояния "кнопок" - механическая, т.е. некоторое действие игрока и скриптов.
 
Примечание.
Поддержка экспорта NiSwitchNode в 3д МАХ добавлена в модуль экспорта начиная с 10.0 версии..
Gamebryo 1.1 и выше.
Здесь, это вынесено в отдельную утилиту.
 
Примечание.
Как писал уважаемый Хрнчмд, niSwitchNode не сохраняет своего положения после смены игроком ячейки и, не прописывается в сохранение.
Возможно было исправлено в МВСЕ, или в МСП 2.5 (не уточнялось!)
 
Примечание.
NiSwitchNode - активно используется только в курице (ака скуриме), где и применяется для смены положения контейнеров с ингредиентами. См. модель slaughterfisheggcluster01.nif например.
Остается лишь пожалеть, что в 2002 году беседка не сочла нужным нормально задействовать этот объект движка.
ГрафикХербализм мог бы существовать много раньше и много проще.
 
Примечание.
Возможно использование флага 32.
Это может давать дополнительные возможности.
См. переписку в конце страницы.
Фактически 32 флаг отвечает за активацию значения:
Некоторые иные флаги также приводят к активации этого значения.
 
Примечание.
Рекомендуется установка флагов приводящих к установке значения UpdateOnlyActive = true!
Т.е. обновление состояний будет происходить только при выполнении определенных условий.
И не будет постоянно мониториться.
Что, по идее, позволяет более экономно расходовать ресурсы повышая фпс.
См. об этом внизу страницы, в разделе аглицкой справки.
 
Примечание.
NiSwitchNode может содержать больше двух вложенных объектов.
Т.е. нажатие на объект в игре будет приводить к последовательной смене отображения вложенных объектов.
 
Примечание.
Упаковка СвитчНоды в Анимационную ноду, равно, как и добавление во вложенные узлы анимационных нод - результата не дало.
Равно как и смена флагов. 32, 42, 8, 10...
Т.е. без МВСЕ 2.Х в чистом МВ не срабатывает.
 
Примечание.
По состоянию на 02 2020 этот узел активно используется в некоторых МВСЕ плагинах.
На 2022 год, использование стало более активным и этот узел появляется все в большем кол-ве моделей.
 

Из переписки на одном форуме.
Речь в основном идет о пользе флага 32.
Который позволяет делать вызовы обновления только при соблюдении некоторых условий, а не каждый фрейм.
Верно и для niLodNode.
*лоднода получает при экспорте из МАХа флаг 42, что отличается от 32 только методом реакции на столкновения.
*32 = ноне, 42 = по треугольникам. Т.е. на состоянии анимации они влияют одинаково.
 
Greatness7
I think we should probably start using this flag in any NiSwitchNode/NiLODNode
flag 32
 
Greatness7
It is what updates the positions/bounds/etc for the node and all its descendants. For animated things it is usually called every frame. For other stuff it only needs to be called if they are modified.
With this flag it should only call update on the currently active switch index/LOD level, which can help performance if the hidden parts are animated.
in theory at least
 
Melchior Dahrk
We put a lot of particle effects behind LODnodes.
Would those still benefit from this since they're animated?
I guess it shouldn't hurt as a best practice in any case.
 
Greatness7 -
'update only active' flag... maybe if I had set this then animations from non-active children wouldnt have been an issue?
nifskope defaults it to 0, so I had probably not set it to 1... if thats what the unknown is
 
________________________________________________
Hrnchamd
Unknown Int 1 = Index of active child
NiSwitchNode class
 
    // flags
    enum
    {
        UPDATE_ONLY_ACTIVE_CHILD_MASK   = 0x0001
    };
 
Greatness7
so its always set?
 
Hrnchamd
Flags is 0 in that screenshot
It's a bitfield remember
 
Greatness7
the normal flags, set to 1==Hidden right
so I was thinking maybe this other int is the flag mentioned in that snippet
unless NiSwitchNode is overriding the default NiNode Flag handling?
 
Hrnchamd
I'm reading the code
Ok, it's one of those weird CPP macro bullshit things.
It declares a flags member with a macro
And every flags member variable has the same name in derived classes.
But of course that bullshit is allowed in C++.
 
Greatness7
lol
i tried setting the flag to 1 on the SwitchNode, but it just makes the entire thing invisible, same as Flag==1 would behave on NiNode
you are right about unknown == activeIndex
confirmed ingame
no idea how to access the update-only-active-child part
 
Hrnchamd
urrrgh
There's a subclass of NiSwitchNode called NiFltAnimationNode
no docs
 
Greatness7
Flt for Float?
 
Hrnchamd
Filter?
I'm reading the update function.
 
Greatness7
no idea, no info about it in nifksope src
 
Hrnchamd
Ok, for NiSwitchNode flags == 32 has some extra meaning. Try it.
 
Greatness7
k
seems to make my my index0 child invisible
lol
strange kind of hidden too.. i can still target it
i have index0 unanimated version, index1 animated
and hotkey bound to switch between them
with flag 32, if is switch back to index0 it is now invisible but sitll targettable
thats kinda cool
so it is doing something
 
Hrnchamd
flags 32 = "m_bUpdateOnlyActive"
should show up in console SSG
I guess the problem is the mesh doesn't get loaded initially
 
Greatness7
oh i didnt even think to check SSG for flag names
 
Hrnchamd
The more you know
 
Greatness7
do you know if the ssg command needs to be refresh to update?
 
Hrnchamd
It doesn't auto update.
That would cause instant lock up because too much changes per frame.
 
Greatness7
:thumbsup:

Еще с того же форума.
 
Merlord
@Greatness7  or @Melchior Dahrk could you please explain switchnodes to me?
 
- Do I need a "NiZBufferProperty", whatever that is?
- Can NiSwitchNodes have more than 2 switch states?
- Do I just put whatever shit inside the switchNodes that I want to toggle?
- Does it work with particles etc?
- Any Gotchas I should know about?
 
Greatness7
1. no
2. yes
3. assign different states as children, and set .switchIndex to the index of the child you want to be visible
4. probably
5. none come to mind
 
Merlord
looks like switchNode.switchIndex is 0 based indexed based on the order shown in the children field?
Thanks
Oh and it doesn't persist over saves or cell loads right?
 
Greatness7
changing cell does not unload a scene node immediately
but it wont persist through load/save etc
it may persist through cellchange sometimes, but dont rely on it
 
Merlord
You check it based on time in GitD just because it's based on time of day right
So I just need to do loaded, cellChanged, and when my campfire actually gets placed etc
 
Greatness7
dunno i didnt work on gitd
 
Merlord
Oh that wasn't you?
 
Greatness7
the example in graphic herbalism is pretty simple tho
nah gitd was null
 
Merlord
lol whoops
Alright well I think I have everything I need
 
И просто пример правильно настроенного файла.
- пустая РК
- собственно свитчнода определяющая смену состояний объекта через действие ЛУА.
- и шейп маркера
Модель используется в плагине GlowBugs от MelchorDark.
В качестве примера добавлена также в заметки.

 Выдержка из оригинальной справки. (NDL Gamebryo 1.1)
 
NiSwitchNode objects represent groups of multiple scene graph subtrees, only one of which (the "active child") is active (drawn) at any given time. They are useful for swapping different representations of the same object in and out (such as pristine, damaged or destroyed versions of a spaceship). They are also used as a base class for specific switch-like objects (such as geometric "flipbook" animations and level-of-detail switches. If you detach the "active child" the switch node will automatically set the active child to none (index = -1).
 
Set and retrieve the "update only active child" flag
If this flag is set, then Update passes will only update the active child instead of all children.  Setting this flag to true (the default) can increase application performance significantly.  If the active child changes between the Update and rendering of a NiSwitchNode, then the newly activated child of the NiSwitchNode will be updated immediately before being rendered.  This situation happens, for example, when an LOD switch occurs, when using NiLODNode, a class derived from NiSwitchNode.
 
Исправление в 1.1. версии движка.
Fixed NiSwitchNode bug. If you detach the active child, the switch node will set the active child index to -1 (no child active)