How to animate root controller without effecting the children node animation with respect to world? - maya

In Maya, I have an animation of a human character in which he is taking a step to its right and then turning 180 degrees, but the problem is that the root of the object is not animating and is still.
Whereas in the animation the feet of the character are moving to right and taking the character away from its root.
What I want to do is animate the root of the object without changing the position of other nodes with respect to world,
So In then end the animation is supposed to look exactly the way it is looking now but the root of the character also needs to move with the character.
The Long Solution
One Way to do this is to duplicate the character as D and on the original one i animate the the root of the character whichever way I want and then keeping the duplicated model as a reference to the animation, I re animate the original character
Read below if you want to know what I tried. and what definately wont work
Another way i tried was to deparent all children then shift the root and then reparent the children back, but this only works for which ever frame I was at, rest of the animation gets spoilt.
How actual solution might work-
Basically is there a way by which I can make all the animation fixed in the world coordinates and automatically adjust their local position and rotation the remain fixed in respect the world until I animate the root.

It almost sounds like the root is the top node of your rig that you would use for initial placement of the character within a scene... if that's correct, and you want to move it but have all of the other controls seem like they're in the same parent space as the root control while actually moving with the root, you'll have to counter animate them in some way...
If you can change the hierarchy of your scene, re-parent those controls in the same parent space as the root control, so you would actually be moving all of the controls together (although you would not be able to rotate from that root and affect the character in the same way).
If you have a way of giving the controls a space switch, you could put them in the global space with that...
You could also possibly have some other nodes outside of the character's hierarchy that you animate and then parent constrain the other controls to those nodes.
It might be difficult just about any way you go about it because of the animation curves on that root node which could cause the other controls to move in a 'floaty' behavior unless you add a bunch of keys to lock them back down again.... but even then...

Related

WPF Custom Panels - Split the final element's visual between the end and start of a panel region

I am currently attempting to write a control(s) that will display a collection of elements, each of which have a start time between 0 and 1. The desired visual look we're aiming for is something akin to a simple timeline.
I've already created a FrameworkElement that renders an individual element as a line (this line represents the transition between one element and the next, e.g. y(x) = x) and my intention is to use this element as part of the DataTemplate for my custom ItemsControl. By flipping the odd elements horizontally and butting them together in a panel, it should be possible to see a continuous series of transitions between the elements. I'm having difficulty in deciding how to implement this panel, in particular with filling 'dead space' that might occur at the start of the panel.
The collection of elements that I'm trying to draw represents a looping effect, but the first element may not start at time T=0. Because the effect loops back on itself this means that the gap between T=0 and the first effect's start time is actually made up of the final part of the last element in the collection. This means I have to find a way of chopping up the last visual element in the panel so that the front part sits at the end of the panel and the back part sits at the start.
Another way to think of this is in terms of a circle/pie chart - if element A starts at 15% and element B starts at 50%, element B would occupy the regions 50-100% and 0%-15% continuously.
I'm really looking for a way to get this done in WPF visually rather than by modifying the collection of items (e.g. by adding a fake 'padding' element between 0 and the first element) as this would create complications down the line when it comes to things like modifying/selecting items, etc.
Someone has suggested drawing this as a 0-1 effect (removing any offset on the first element if there is one) then recreating the offset using a pair of cameras/viewports, which is something I'm not familiar with and seems a bit overkill. Can anyone suggest a simpler or more elegant way?
The 3D XAML question posed below contains code that achieves the kind of effect I was looking for, with some modifications. I set it up as an orthographic camera and made the position and texture co-ordinates of the MeshGeometry3D into dependency properties:
Why does TextureCoordinates work as expected for a Viewport2DVisual3D, but not for a GeometryModel3D?

Canvas - dynamic drawing and managing shapes

I'm trying to make an application which allows the user to draw shapes to the canvas. Once drawn, I would like for the user to be able to select, move, resize, basically manipulate the shapes in any which way.
I have done something similar in XNA and that was quite easy due to the fact that there was a draw loop. In Silverlight there is no such thing as far as I understand and I am having trouble figuring out how to manage the objects on the canvas. As in what is the best way to manage the canvas' children collection to ensure appropriate response of the UI to what the user does.
Most examples out there are pretty basic and do not go anywhere near this kind of thing. I would be grateful if somebody who has done this before could tell me how they approached the problem.
Thinking about it for a while I think I figured out how it works.
There is a draw loop for the canvas, which is the draw loop of the top level parent container which it lives on.
The difference with XNA I guess is that the collection of items to draw on the canvas doesn't need to be explicitly drawn, since the canvas takes care of drawing its children automatically.
So, what I need is some way to hold on to any object I add to the canvas' children... I can then update the objects drawing properties and the changes will be reflected in the canvas next time it refreshes.
I guess a dictionary of some sort in which to store the items I put in the list might be best...?
Not a finished answer yet, but I guess I understand half of it now.

is FrameworkElement rendered or not?

Is there a way to know is certain FrameworkElement was rendered to the screen. For example. I have two rectangles, and one overlap other. But I'm not sure about "how much" one overlap other.
So I need to know is user will see both rectangles, or will see only one, or will see one fully and one partially?
It all depends on what kind of parent container it is, if both rectangles are inside StackPanel then they will not, you have to either make a custom container or use canvas as parent of these rectangles.
Then you can get LocalToScreen or such similar methods to get their absolute positions compared to screen or top parent window and find out whether they overlap or not.

Reversing an animation in Silverlight on button press or any other event

How would I reverse a double animation in Silverlight on an event? For example, lets say I have an ellipse as a path and I am moving a shape along this path in an infinite loop. If I press a button, I want to reverse the direction of the spin (clockwise <-> counterclockwise).
To be more specific, I am using the PathListBox object that is new in SL4. It has a start property from 0 to 100% (double 0 - 1) that will place the first item at the specified location along the path. By animating this property from 0 to 1 and 1 to 0, I can make an object spin clockwise and counter clockwise.
Lets say I have a button and on the button press, I want to reverse the direction. How do I go about doing it? I've tried pausing the animation and swapping the To and From values of the animation and resuming it, but this causes the animation to jump. So if its at "3 o'clock" on the ellipse, it jumps to "9 o'clock" and goes backwards from there. I tried doing something like setting the storyboard's CurrentTime property to "Duration - CurrentTime", but that property doesn't seem to be settable.
So, in conclusion, any ideas about how to reverse an animation on demand?
PS: I know there is a PathListBoxUtils that provides scroll behaviors for PathListBox, but that doesn't quite implement what I want. Or to put it another way, I am looking to modify the PathListBoxUtils to have an infinitely rotating, reversible carousel rather than scrolling one item at a time.
Ok, the way I got it working was by pausing the animation, swapping the To and From values, and using the Seek method to move the animation forward by a set amount. The amount I needed it to move forward is "Duration.TimeSpan() - GetCurrentTime()", but accessing Duration seems to throw an exception (Operation not valid for the current state of the object).
For now, I just hard coded the Duration value for a test and seems to be working fine. I guess for a real implementation the Duration can be bound to some value and the calculation can use that value too.

In WPF, can you hittest segments of a PathFigure?

I'm making a control that involves dragging pieces of a displayed element around. Since part of it is an arc, I have to use a PathFigure so I can use ArcSegments. I'd like to be able to know if the mouse is over a particular segment of the figure, but I don't see an obvious way to do this. Is it impossible or am I missing something?
the root Path object has the normal UI events for Mouse, instead of one Path with lots of Arcs you will need lots of Paths with an arc in each.

Resources