Page 1 of 1
Elastic surface symulator
Posted: December 29th, 2013, 8:11 pm
by fliper
Hi guys
I was bored so i made this silly program that poorly emulates the plane in 2d space.
I jus started to learn programming from this tut series so my skills are rather on a very poor level
I was planning to use this effect in future projects ( games ).
use the 'left mouse button'
Hope you enjoy it
Re: Elastic surface symulator
Posted: December 29th, 2013, 8:36 pm
by LuX
Nice work! this looks pretty cool.
I wonder if you could use that in some game. Maybe like a magnifying glass for a grid based game.
Re: Elastic surface symulator
Posted: December 30th, 2013, 4:09 am
by mogu
Neat looking effect, I like it and your code is very well written, thumps up
Keep up the good work.
Re: Elastic surface symulator
Posted: December 30th, 2013, 12:49 pm
by fliper
Thanks for the update I really appreciate it
Even if it looks nice it is not what i was aiming for :/
I made some modyfications to the program and tried to make a mesh of particles that stays in the solid distance from each other, and when they are disturbed they behave like a spring and try to get back to its default state.
I was able to acomplish that task in about 50% rate. That is because when i disturb it it waves unstopably
I dont know much about regulation stuff so
If you guys have any idea how to fix that oscylation i would be mucho obliged ;p
grab the code
Code: Select all
if ( (l > TABX ) && ( l < TABLENGHT - TABX - 1 ) ) // I MADE SURE THAT PROGRAM WILL NOT
{
if ( l%TABX != 0 && (l)%(TABX) != TABX - 1 ) // INCLUDE BORDER POINTS IN CHECKING STATE
{
par[ l ].gre = 0;
par[ l ].blu = 0;
int crap = 1; // dont know why but if i change amplification this whole block stops working :(
par[l].x = par[l].x + crap*(par[l-1].x - par[l].x + par[l+1].x - par[l].x); // In here I was trying to move only current state point
par[l].y = par[l].y + crap*(par[l-TABX].y - par[l].y + par[l+TABX].y - par[l].y); // thats motion made relation only for the nearest points ( 4 point influance )
//*****************************************************************************************************************************************************************************
//par[l].x = par[l].x + crap*(par[l-1].x - par[l].x + par[l+1].x - par[l].x + // Same as before but i added aditional point
// par[l-1-TABX].x - par[l].x + par[l+1-TABX].x - par[l].x + // in the 45deg directions ( 8 point influance )
// par[l-1+TABX].x - par[l].x + par[l+1+TABX].x - par[l].x +
// par[l-TABX].x - par[l].x + par[l+TABX].x - par[l].x);
//par[l].y = par[l].y + crap*(par[l-TABX].y - par[l].y + par[l+TABX].y - par[l].y +
// par[l-TABX+1].y - par[l].y + par[l+TABX+1].y - par[l].y +
// par[l-TABX-1].y - par[l].y + par[l+TABX-1].y - par[l].y +
// par[l-1].y - par[l].y + par[l+1].y - par[l].y); // Another failure
//*****************************************************************************************************************************************************************************
//par[l+1].x = par[l+1].x + crap*(par[l+1].x - par[l].x + par[l-1].x - par[l].x); // Final aproach if this wont work i dont know what will :( ( 4 point displacement )
//par[l-1].x = par[l-1].x + crap*(par[l+1].x - par[l].x + par[l-1].x - par[l].x);
//par[l+TABX].y = par[l+TABX].y + crap*(par[l+TABX].y - par[l].y + par[l-TABX].y - par[l].y);
//par[l-TABX].y = par[l-TABX].y + crap*(par[l+TABX].y - par[l].y + par[l-TABX].y - par[l].y);
}
}
Anyway happy new year ;D
Re: Elastic surface symulator
Posted: December 30th, 2013, 3:47 pm
by mogu
Hi yah,
don't know what you were going after in your code, but when I click once and stop the mouse movements the ripples are getting back to their default state, more or less.
Here's the project where I added your code.
If you could explain a little more what you are after, maybe some of us would know what to look for.
Either way the effect is still kinda cool.
Re: Elastic surface symulator
Posted: December 30th, 2013, 4:54 pm
by LuisR14
this is some nice effect
, mouse in effect happens, mouse out effect stops
Re: Elastic surface symulator
Posted: December 30th, 2013, 6:23 pm
by fliper
I see what you did there but it's still not what i am trying to do. Right now it just goes back to it's default position initialized in IniParticles() function which i still very cool effect.
I want this mesh to behave like a real elasto-like sheet. Not sure if you get what i mean "crazy man talking ;p".
I have few ideas how to do it but right now now much time ;p
I will make another update after new year.
Anyway thanks for help and happy new year ;p
Re: Elastic surface symulator
Posted: December 30th, 2013, 11:13 pm
by thetoddfather
I'm picturing a sniper game with this one haha, very cool
Re: Elastic surface symulator
Posted: December 30th, 2013, 11:46 pm
by GreatJake
Lol this is a really neat effect, the math sounds really complicated
. Do you mean your trying to make the mesh behave like a flag on a pole or something?
Re: Elastic surface symulator
Posted: December 31st, 2013, 6:21 am
by chili
Neat little simulation there fliper. Makes my fingertips itchy to code.
I'm not sure if I can solve your problem because I'm not 100% sure of what you're aiming for. If my guess is correct though, I think you need to model your simulation more closely to the laws of physics. Specifically, you probably need to implement Hooke's Law + Newton's Second Law.
I've made a simple simulation that does this (more for the lawz than to solve your problem). It's pretty simple, but it's also highly object-oriented. If you're down with OOP, it should be easy to follow. Take a look at it
here if you're interested; it may or may not give you some clues.