Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using a timer-based animation to animate three 3dobjects. I have used a dispatcher timer for this purpose, and within the timer task method I have called my 3Dobject creation method thrice. Right below that and within the same Timer task method I have included a set of statements that generates new position for the objects.
For example,

C#
private void timertask(object sender, EventArgs e)
       {
createsolid(x[0], y[0], z[0]); ->this creates the first cube w.r.t x,y,z positions
createsolid(x[1], y[1], z[1]);
createsolid(x[2], y[2], z[2]);
...
...
for(int i=0;i<4;i++)
{
...
...
x[i] = update_x[i];
y[i] = update_y[i];
z[i] = update_z[i];
}}



So, everytime the timer is triggered(currently set to trigger 10 times a second), the cubes are created in a new updated position(very slow though). But the problem I face right now that I could not delete the cubes in old positions. Thus, it leaves a whole trail of cubes when the timer progresses. I want to delete the cube in old position when the cube is created for the new position. Or I would like to use some repaint method or something that just allows me to create the cubes just once and after that it should just allow me to move the cube according to the new positions generated in time.

Just one humbe request. I am a beginner and please go easy on me. I would greatly appreciate a striaght forward answer. Links are welcome too, but I don't need solutions in xaml. I am working completely on C#.

Thanks
Posted
Updated 31-Aug-11 7:19am
v2

1 solution

I'm guessing, but...

0) To delete/erase one, shouldn't you just be able to delete it form the parent group's Children collection?

1) To change it, retrieve it from the parent group's Children collection and change the appropriate values.
 
Share this answer
 
Comments
steersteer 31-Aug-11 11:37am    
Thanks for your reply. I guess you are right too. I am trying to use "group.Children.Remove" or "group.Children.RemoveAt" at the end of my time_task method ? (how about group.Children[0].Remove for first cube). I honestly don't know how it works. Please give me a syntax or example to use them with in a method. would really appreciate it. thanks
#realJSOP 31-Aug-11 13:33pm    
I'm using the same resources that you would be - google. I have to look up each answer I give you. Children is a collection. It might be a collection of objects that themselves have collections. See if intellisense will guide you. Failing that, google is your friend. I don't generally hold people's hand - I'm more of a "shove 'em in the right direction" kinda person.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900