Panda3D/Manual/Instancing: diferenças entre revisões

[edição não verificada][edição não verificada]
Conteúdo apagado Conteúdo adicionado
Sem resumo de edição
Sem resumo de edição
Linha 9:
 
Aqui está o grafico de cena que acabamos de criar:
 
[[Ficheiro:Instancing1.jpg]]
 
Isso funciona direito, mas é meio dispendioso. Animar um modelo envolve muitos calculos de matrix por vertice. Nesse caso, nós estamos animando 50 copias do mesmo modelo usando 50 copias da mesma animação. Isso é um bocado de calculo desnecessario. Parece que deve haver uma forma de evitar calcular o mesmo valor 50 vezes. Realmente existe: A tecnica é chamada instancionar.
This works fine, but it is a little expensive. Animating a model involves a lot of per-vertex matrix calculations. In this case, we're animating 50 copies of the exact same model using 50 copies of the exact same animation. That's a lot of redundant calculation. It would seem that there must be some way avoid calculating the exact same values 50 times. There is: the technique is called instancing.
 
TheA ideaidéia isé thisessa: insteadAo ofinvés creatingde criar 50 separateinimigos dancersseparados, createcrie onlyapenas oneum dancerinimigo, soentão that thea engine onlyvai hasatualizar toa updateanimação herdo animationinimigo once.uma Causevez. theA engine torenderiza rendero herinimigo 50 timesvezes, byao insertinginserir herele intono thegrafico scenede graphcena inem 50 differentlugares placesdiferentes. HereAqui isestá howcomo itisso isé donefeito:
 
dancer = Actor.Actor("chorus-line-dancer.egg", {"kick":"kick.egg"})
Linha 24 ⟶ 25:
 
Here is a diagram of the scene graph we just created:
 
[[Ficheiro:Instancing2.jpg]]
 
It's not a tree any more, it is a directed acyclic graph. But the renderer still traverses the graph using a recursive tree-traversal algorithm. As a result, it ends up traversing the dancer node 50 times. Here is a diagram of the depth-first traversal that the renderer takes through the graph. Note that this is not a diagram of the scene graph - it's a diagram of the renderer's path through the scene graph:
 
[[Ficheiro:Instancing3.jpg]]
 
Linha 57 ⟶ 60:
 
Here is the scene graph I just created:
 
[[Ficheiro:Instancing4.jpg]]