Computer Science Canada Particle Syestem |
Author: | Tallguy [ Fri Nov 04, 2011 1:32 pm ] |
Post subject: | Particle Syestem |
Hello all, Been awhile since I've been on the forums, last time i was doing turing now C!!!!!!!!!!!!!! (College foe Compsci Engineering) My question: I need to implement a linked List and create a Particle Syestem with characteristics of my design, are there any tutorial to this, i need to OpenGL to run it, I have no idea of how to start with my profs instructions, can anyone point me in the right direction? not do it for me.... |
Author: | DemonWasp [ Fri Nov 04, 2011 2:30 pm ] |
Post subject: | RE:Particle Syestem |
First, the assignment only says that "A front end in OpenGL will be posted, so you could visualize your particle system". You don't need to write ANY OpenGL. This assignment is basically "write a linked list" with some "particle" sugar on top. Start with the particle struct (given) and implement the functions in the order given. The first function, particle_init, is very simple: just populate the values in the given particle struct. For now, just use some sensible defaults: make your particles red, at (0,0,0) with speed and direction (0,0,0). Make sure that the "next" pointer is NULL. The second function, particle_add, is where you start dealing with the linked list implementation. You are given the head of the list, and you want to add a new particle to the end of the list. You will have three main steps: 1. Find the end of the existing particle list using the "next" pointer. 2. Create a new particle using your particle_init method. 3. Set the "next" pointer of the last part of the list to point to your new particle. I'll leave the rest up to you; if you need more help later on, post back here. |
Author: | Tallguy [ Thu Nov 10, 2011 2:01 pm ] | ||||
Post subject: | Re: Particle Syestem | ||||
I have an issue of having all the particles showing up, if i put the constant as 10, i only see about 8 or so? I took of the transparent color and each x,y is rand so none should be riding on top of each other.
I have a feeling it is with this function
i will attach the parent class we are using (teachers code) |
Author: | DemonWasp [ Thu Nov 10, 2011 2:50 pm ] |
Post subject: | RE:Particle Syestem |
Hmm...try running your code with velocities set to (0,0,0) and count the number exactly. I suspect you'll find that there are exactly 9 (not 8, not 10). The reason I say that is that I'm pretty sure I found a bug in the supplied OpenGL code. It's fairly obvious even if you don't know OpenGL: look at particles_OpenGL.c on lines 243 and 253. Note that the while condition is wrong and won't draw the last particle in the list (which has next == NULL). I don't see a problem with your code, except that it could be formatted and commented a bit better. |
Author: | Tallguy [ Thu Nov 10, 2011 3:43 pm ] |
Post subject: | RE:Particle Syestem |
but if you even put like 1000 particles in, only about 20 show |
Author: | DemonWasp [ Thu Nov 10, 2011 5:15 pm ] |
Post subject: | RE:Particle Syestem |
By the way, please be more exact about what you see. Details matter! Okay. Clearly we need to go back to the basics to solve this. There are a few realistic possible problems: 1. The list implementation is wrong. 2. The particles aren't visible for some reason, though they are in the list. Let's assume for the moment that #1 is not happening, since your implementation of that looks reasonable. So we'll investigate just #2 for the moment. First, we want to eliminate the trouble of things moving around, so comment out the contents of particle_update() for the moment. Second, we want to make sure things appear in a recognizable pattern, so change your particle_init() from using random numbers to using an increasing series of numbers. For example, let's put all the particles along the line from (0,0,0) to (n,0,0), and let's only look at a very small number, such as 2. You can set the speed and direction vectors to be (0,0,0). With those changes, exactly how many particles do you see on screen? Where are they, relative to the window? Feel free to post a screenshot. |
Author: | Tallguy [ Fri Nov 11, 2011 8:54 am ] | ||
Post subject: | Re: Particle Syestem | ||
Thanks for your help man, Sorry for not being specific and kinda hasty on my last post so stressed out with college ATM..I think i got it......I fixed up my teachers code (will post) I changed the GLUT imports for mac settings (wont work on Linux) VM drags down my system. I was NOT thinking when doing this..more coffee so this is my code ATM i need to add a delete list function and delete one node function TY for your man, much appreciated /*format for some reason is messed when i post :/*/
I do want to add a function that calls 'keyboard' in the openGL code so that when any key is pressed all particles return to origin (0,0) and then continue moving..if time permits, but my partner has to do some code.. lol |
Author: | DemonWasp [ Fri Nov 11, 2011 10:38 am ] |
Post subject: | RE:Particle Syestem |
No problem. I'm also impressed that you managed to modify OpenGL settings without screwing anything up -- that's a bit of a feat even for an experienced developer. Word of caution though: you may want to avoid posting full name / student ID combinations on a public website. I also have to say, I'm confused by these method signatures. For example, particle_remove can be done from the signature given, but it's not obvious how and it's frankly kinda dangerous (it involves deleting a node other than the one you were told to delete, I think). Additionally, particle_update gets called with struct particle **head, but should probably be called with struct particle *first, because it shouldn't be modifying the head pointer (your code doesn't, but it is possible). And then there's the (incredibly obvious) bug in the linked-list code in the code your teacher supplied. Let's just say I'm a little less-than-impressed with my first taste of Algonquin here. |
Author: | Tallguy [ Fri Nov 11, 2011 11:42 am ] |
Post subject: | RE:Particle Syestem |
Whoops my bad on the header,(can't edit my code to delete my name etc, gotta wait for Tony or Dan to do it lol) We just changed the while loop conditions within our prof's source code Yea...those method signatures..working on them Agian? I will take at look at her code, not too good with linkedList yet...LOL most of our profs are RLY good, just happens to be that my prof isnt one of them... |
Author: | DemonWasp [ Fri Nov 11, 2011 2:26 pm ] |
Post subject: | RE:Particle Syestem |
Not "again", just the bug I pointed out earlier. That's a rookie-level mistake, and should easily be caught by testing. |
Author: | Tallguy [ Fri Nov 11, 2011 3:08 pm ] |
Post subject: | Re: Particle Syestem |
Awesome man, thanks for all your help. Got all issues fixed and program works!! -run the make file 'make' -press 'o' to make all particles go back to the origin (0,0) -each one has a random live time, will disappear after a few seconds **Linux run cmd only ATM** |