Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# .NET WPF graphics 3D
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,
 
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 31-Aug-11 6:13am
Edited 31-Aug-11 8:19am
RaisKazi33.1K
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
steersteer at 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
John Simmons / outlaw programmer at 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)

  Print Answers RSS
0 BillWoodruff 360
1 Mathew Soji 309
2 DamithSL 225
3 Afzaal Ahmad Zeeshan 202
4 Maciej Los 190
0 OriginalGriff 6,249
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 3,865


Advertise | Privacy | Mobile
Web03 | 2.8.1411019.1 | Last Updated 31 Aug 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100