setting IVertexController

Started by raft, March 03, 2010, 06:39:20 AM

Previous topic - Next topic

raft

is it expensive to set an IVertexController ?

say i have two IVertexController's to operate on same mesh, does it make sense to set each one again each frame ? if they create an array of vectors and copy mesh vertices into it each time they are set, this is definetely expensive and shouldnt be done

EgonOlsen

The GenericVertexController makes a copy of the mesh's data each time you set it and removes it each time you remove it...so yes, this is rather expensive. If it wouldn't work this way, the old controller wouldn't know which changes any other controller made to the mesh in the meantime. Do you absolutely have to do it this way? In that case, we might have to look for another solution...

raft

Quote from: EgonOlsen on March 03, 2010, 07:36:47 AM
Do you absolutely have to do it this way? In that case, we might have to look for another solution...
not really. i'm looking for alternatives

what other options do i have ?
* use single vertex controller and do both jobs there
* implement by own vertex controllers without extending GenericVertexController
* ?

EgonOlsen

Maybe doing it all in one controller is the best way.

The problem with implementing your own is, that you don't have access to the package public stuff in Object3D that you would need to update the actual mesh. So either i would have to expose these structures directly (not nice) or via a kind of DirectVertexController that skips the SimpleVector-part and works on the array data of the mesh. This will give you better performance in addition but is more awkward to handle.

raft

ok, no need for such complexity. i can live with this ;)

this may seem hacking or abusing but, am i safe if i modify destination vertices outside of vertex controller ? ::)
i use "preserve source mesh" mode, so source mesh remains the same all the time. seems as dest also remains same as i left last time. so if i modify dest somewhere else then call mesh.applyVertexController() to notify jPCT mesh has changed, will it be ok ?

btw, in "preserve source mesh" mode, source vertices arent copied again and again i suppose ?

EgonOlsen

You don't have to do it in apply(), if that's what you mean. You might even try to add it, remove it and use it as a hook into the Object3D later without being attached to the mesh anymore. The destroy() of the GenericVertexController doesn't dispose any of the data structures, so if you call update() yourself, this should actually work too. It's rather hacky though...

Preserve source mesh creates one copy at initialization time.

raft

i will possibly use a single vertex controller, so i dont need to remove it.

what i'm trying to do is to preserve analogy with skeletal part. there i have a skeleton pose as animation target which can be reached and modified anywhere. but that's not the case for mesh vertices.

so in this case -if i dont remove controller- calling update() or mesh.applyVertexController() will result the same ?

EgonOlsen

As long as you are doing the apply()-part yourself somewhere else, then yes.

raft

should this hack work on AE edition too ?

EgonOlsen

Yes. Nothing has changed in that part except for some performance optimizations for Android.

raft

i still couldn't make this run on android ???

can u please have a look at this test case. it contains a simple animated object, a desktop app and an android activity. in desktop app object is animated but in android one it's not, it's the same code ???

thanks

EgonOlsen

You have to call Object3D.touch() on objects, whose meshes are using a vertex controller in AE each time you apply the controller. This is mentioned in the documentation for touch(), but not for the controller or the apply-method...i think i should add that... ;D

In addition, AE decides what kind of object an Object3D is when calling build(). If it should be modifiable at runtime, you have to have an animation or a vertex controller attached. Or otherwise, it will compile the mesh to static.

raft

thanks it's ok now ;D

i suppose the transfer is done at render stage ? so calling touch unnecessarily (many times or in software renderer) wont cost anything ?

EgonOlsen

Yes, the magic happens at render stage. The method itself just sets a flag.

raft

Quote from: EgonOlsen on March 05, 2010, 09:37:36 PM
You have to call Object3D.touch() on objects, whose meshes are using a vertex controller in AE each time you apply the controller.

what if several objects share the same mesh and animation ? is touch necessary on all of them ? can we avoid transfering of vertex data for other (non-master) objects ?