[4.1] Mesh Merge Alignment

Software: Away3D 4.x

Tempy111, Sr. Member
Posted: 03 September 2016 01:51 PM   Total Posts: 128   [ # 16 ]

Rebuilding the class..

using just the average, hat is placed in the right place.. now need to figure out alignment.. can’t see how to use the normal for this right now though ^_^


.... either my models are totally screw up or I just can’t figure this out.. as far as I can see, all I have done is taken the references to the face used for getting vertex points and normal, and replaced it with a different working way of getting that, but it just doesn’t like it. Right now this is a losing battle as it is clearly telling me I’m just not good enough to do this code.



yomyom, Newbie
Posted: 04 September 2016 02:48 PM   Total Posts: 11   [ # 17 ]

I just opened your facelink and take a (very) quick look : I have 2 questions. I haven’t even read your class until the end (sorry) , so it may be some dumb questions but


1) 9*_FaceNum : does it mean you consider that one vertex can be used by only one face? not the adjacent faces?

2) I’m not sure that the subMeshes[0].vertexData[] is updated according to the animation : For me it defines only the original static mesh, which is animated afterward by the GPU. Are you sure you get the vertex positions considering the animation state?



Tempy111, Sr. Member
Posted: 04 September 2016 02:56 PM   Total Posts: 128   [ # 18 ]

1) yeah, I’m a little unsure on that.. index data pretty much seams to say each one is only used once.. the Number of faces does tie in with the number of Vertex Points so I deciding that some how, it must re-define he vertexes.. it’s a bit tricky to figure out which ones are reused when.. but I’m pretty sure the vertex data array repeats vertex points (I got a dump of the array but it’s a pain to look through but it does seam to confirm that fact.

2) I’ve updated the line to:
_Vec0.x = (_source.subMeshes[0].subGeometry.vertexPositionData[(9 * _faceNum)]);

VertexData is in blocks of 13 which seams to update when animated to me, VertexPositionData doesn’t have the UV details. the attached mesh does change as if the animation is taking place but not right with it.. I would attached a swf demo but for some reason, right now the Swf’s don’t want to work in any browser.. just off line.. away debug claims there is no view oh but well.. deal with that later



Tempy111, Sr. Member
Posted: 09 September 2016 05:38 PM   Total Posts: 128   [ # 19 ]

Nothing of any real interest was changed but just for the sake of things (and possible help) here is the last version I did any thing with.

I would upload a swf to show what it does but.. still can’t figure out why the view won’t render in any browser at the moment ^_^;


SWF Link->

the Arrow keys (left and right) move between faces but as you can see, doesn’t work right.. but there is SOME movement as the waiting animation runs.. doubt it’ll help much seeing this but oh well


File Attachments
FaceLink.as  (File Size: 11KB - Downloads: 172)

Tempy111, Sr. Member
Posted: 13 September 2016 06:32 PM   Total Posts: 128   [ # 20 ]

Looking at code again… I think I didn’t get it wrong.. I think it IS working.. to some degree.. I think the model might be what they call small (personally I don’t think so but oh well).. if I change the offset value to a fraction like 0.2, shows that offset seam to be working.. the alignment might be working to look at the normal as well.. so.. it might be working.. apart from two things…

It’s not moving smoothly with the model’s animation.. the update line is put into ‘onEnterFrame’ while this might be going with the framerate of the swf, Does the animation time have a possible event listener to move It to (Will look into).

I think I figured it out, but not how to fix it.. It’s the vertex animation.. the Hat model is moving with updated vertex’s but ONLY at the frame. If the animation has say 3 frames. Standing still, movement, back to still. the Vertex animator is filling in the gaps to make it smooth. that’s a good and great thing, BUT, it seams the VertexData might not be updated at them inbetween points. As a result, the Hat jumps. careful study seams to show this is the case.. So I just need to make sure (or somehow get) the vertex points BETWEEN animation frames…
[-End of EDIT]
all the Away3d Events I can find so far deal with a node being complete, or the animation cycle being complete, or starting. there are 4 nodes in this standing animation. Start, bounce up, bounce down, Start. .. But then, it has to be updating at the right time cause that is when the render line is.. if I was only running at each node point, the animation wouldn’t render smoothly (and if you haven’t figured it out, I love using forums and stuff as a sounding board.. I also think I can be useful to follow the progress and process people do to get somewhere to figure something out ^_^)

anyway.. So it’s clear the Vertex data I’m getting is only updated at node points, not inbetween.. There is a animatorSubGeometry property which has vertexdata. so I wondered about getting it from there, might be more direct.. but that returns as null.

I have found where the data for each frame is, but as the animation moves between frames to make it smooth, this is a different matter..

Wondering if the answer is to give the hat an animation to match via code.. so it takes the vertex points it’s currently at, finds out where it has to go and just smoothly moves to match.. but while I can get some information from the vertex animator, i’m not sure frame where frame number and animation number (more then name) is right now.. and also, i’m not quite sure about a couple of other bits.. but i’m looking into this a possible.

[End of Edit B]

Second, when using the arrow keys for the face changing.. for some reason, there is a face which completely screws up the hat location for good.. even going back doesn’t make it re-appear.. I’m not sure at all about this but some heavy debugging should fix it up



yomyom, Newbie
Posted: 14 September 2016 09:35 PM   Total Posts: 11   [ # 21 ]

It’s why most commercial games use animation based on joints : easier to animate, easier to “attach” something to the mesh etc…

one of the solution would be to “attach” your hat to only one of the vertex of the head : you extract the animation data of this vertex, and apply it to your hat through a dedicated vertex animator ( all the vertex of your hat with the same animation) or through a skeleton animator ( would imply the implementation of one joint in your hat).

someone else may have a better solution



Tempy111, Sr. Member
Posted: 15 September 2016 08:24 AM   Total Posts: 128   [ # 22 ]

thanks but I think that might have been commented on before. but right now, the mission is to do the update for the facelink function.

I think i’m getting pretty damn close.. atleast in the way i’m doing it which might be the best or not, but working anyway ^_^

I can’t find away to access the time property of an animation. Blendweight’s information says it’s ‘the fractional value between 0 and 1 representing the blending ratio of the current playhead position between the current frame (0) and the next frame (1) of the animation” that sounds great. I have the current frame vertex points, I have the next frame ones. using a fractional value between 0 and 1, I can work out where the vertex location IS to put the hat in the right place, BUT.. the blendweight returns 0 all the time.. which I useless.. so looking I say the internal time of the animation (how long it has been playing for) and the active animation total duration. taking the total time divide by the duration gives me a good value. removing the whole number (making a copy of the number as an int so I don’t have the fraction) means I have a value between 0 and 1 of where it is between the two frames. just what Blendweight says it should be..

BUT.. I can’t seam to access the duration or the total time… I think i’m just missing a call to the right place.. give me a couple of days for this ^_^



Fabrice Closier, Administrator
Posted: 15 September 2016 09:34 AM   Total Posts: 1265   [ # 23 ]

I may be wrong, as i’ve just looked for a sec,
Seams VertexAnimator updateDeltaTime updates the vars that you need.
_poses—> current frame and next frame buffers
_weights—> the blending factors
aren’t they the one you need?



Tempy111, Sr. Member
Posted: 15 September 2016 04:03 PM   Total Posts: 128   [ # 24 ]

i would have though so but updateDeltaTime is a protected function.. i’m not quite up on the accessing of them i’m afraid.. and I can’t see the pose and weights in the vertexanimator class…  sometimes I miss old help files.. great search function ^_^

the Animator via AnimatorBase has both a time and an absoluteTime.. when debugging, it gives a good value BUT when it try to access it like a normal property, it seams to always return 0 (i’m trying to store it in a Number so it should be fine)..

http://away3d.com/livedocs/away3d/4.1Alpha/away3d/animators/VertexAnimator.html is the page for for the VertexAnimator but.. I can’t see the poses and weights.. a bit confusing cause while it might not be the best, I seams like i’m pretty damn close now..

it seams VertexState.nextGeometry stuff doesn’t update with the next frame’ geometry for some reason.. so that’ out ¬_¬ (I passed a vertexclipnode made from the source mesh’s animator.animationset.getAnimation method, and passed the animator to make the VertexClipState.

I see the function for updateDeltaTime.. I remembered how to access protected functions.. though.. i’m still having to give it a bit of work as I can’t see how to normally access _poses it seams.. weird…

[EDIT 2]
Okay.. nope.. I don’t remember how to access Protected Methods it seams cause my method I remember (using a Class that extends, in this case, Extends VertexAnimator) throws back errors saying either updateDeltaTime is an undefined method OR an inaccessible Method…



Tempy111, Sr. Member
Posted: 19 September 2016 10:35 AM   Total Posts: 128   [ # 25 ]

not done a lot of work.. the NaN issue, seams to be related to times when two of the vertex point share a position.. like the same Z or the same Y or the same Z (not all three though.. though it seams I have atleast two points where the X and Y is the same…

this ends up bring in 0s into the Normals sum which brings in NaN’s (and a few infinities), which completely screws things up.. I’ve patched it so where as before, this seam to screw it up for good, now it only screws it up for that face, the next one is fine.

things are still.. off..

I’ve updated the SWF online to the latest build

SWF Link->
arrow key movement left and right to scroll

I also notice I’ll need to add a update to the where it looks.. maybe add an offset or allow a second face to be added.. the Normal might be good to look at in order to figure out rotation of the character, but doesn’t always mean it faces the right way in the first place… for example, I put the hat on some face.. I think in an ear right now.. when on the head, it should face forward but it doesn’t seam likely or possible for that. so I need someway for it to face forward, but then use the normal to detect if/when the head looks left or right.

still.. I think it’s coming along.. slowly but it is..



Tempy111, Sr. Member
Posted: 21 September 2016 10:40 AM   Total Posts: 128   [ # 26 ]

Temporary, I’ve written a new function in the VertexAnimator because 1) I couldn’t access the protected functions and private variables I needed to 2) because the updateDeltaTime function isn’t quite right for me)

anyway.. with my new ‘PositionUpdate’ function in VertexAnimator class, I’ve got this working! almost.. I need to look into the Look at function now BUT if I just have the hat always facing forward, it locks onto the face perfectly!


Check out that and tell me it’s not a thing of beauty ^_^

anyway.. I’m not happy about adding a new function to the VertexAnimator so I might (as I think I failed when I made the FaceLink and extension of the VertexAnimator) create a second class with the Facelink which is the extension to have this new function..

For the looking? well.. I’ve already said I need to work on that so there is kinda a direction offset worked out which would then use the normal to see how much it’s moved left or right.. I give that a couple of weeks tops..

it might not be much and not worth celebrating but hell, any success is a reason to be happy and keep going! so.. Yay me!



Fabrice Closier, Administrator
Posted: 21 September 2016 11:05 AM   Total Posts: 1265   [ # 27 ]

Check out that and tell me it’s not a thing of beauty ^_^
—> it is! smile
I haven’t checked, but does using arcane space does not give you access to these vars?

I’m not happy about adding a new function to the VertexAnimator
its not like the engine is updated on regular basis anymore, so i’d say, if arcane doesn’t fix, just hack what you need.

Think also that you can use containers, where moving right/left could be an easy thing to do for the children, while the container remains “facelinked”



Tempy111, Sr. Member
Posted: 21 September 2016 11:12 AM   Total Posts: 128   [ # 28 ]

I can’t remember how to use arcane space.. need to brush up on that.. sadly, I find if you don’t use something often, you easily forget it and I don’t normally have a lot of use for it ^_^ shouldn’t take long to brush up

Containers would be no real problem but I was more thinking about during animation. for example, if the waiting animation has the character looking left and right as if searching for something or being a bit nervous. containers probably wouldn’t be too much of a help there. All I should need is, like I said, to allow a set direction for looking (really, 0 for forward is fine but I like to give a bit of flexibility), store the normal point for that, so if the normal is more to the left, move more to the left, if more to the right, move more to the right etc.. shouldn’t be hard at all.

I’m not quite sure how well the linking would hold up when the linked mesh turns or moves left or right.. that’s the next stage after I get this bit done but for that a container does seam the best approach.

Currently trying to use Triangle base code to work out the positioning of the lookat point using the position of the hat, the normal of the face, and the directional point a the three vertices, and making sure it’s always a right angle triangle (which it should be). not fully going well so far



Tempy111, Sr. Member
Posted: 25 September 2016 01:19 PM   Total Posts: 128   [ # 29 ]


try that.. Notice the dot, I put that just to show the ‘lookat’ point… I think it’s working… while a bit tricky to see on this animation, I’ve checked it for some rotation left and right, and that seams okay too… so.. I think this works..



Fabrice Closier, Administrator
Posted: 25 September 2016 03:13 PM   Total Posts: 1265   [ # 30 ]

woohoo! wink




Away3D Forum

Member Login