Elastic surface symulator

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
fliper
Posts: 14
Joined: December 29th, 2012, 7:07 pm

Elastic surface symulator

Post by fliper » December 29th, 2013, 8:11 pm

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 :)
Attachments
ElasticPlaneSymulator.zip
Elastic surface symulator
(170.66 KiB) Downloaded 360 times

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Elastic surface symulator

Post by LuX » December 29th, 2013, 8:36 pm

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.
ʕ •ᴥ•ʔ

mogu
Posts: 34
Joined: November 12th, 2013, 4:24 pm
Location: Finland

Re: Elastic surface symulator

Post by mogu » December 30th, 2013, 4:09 am

Neat looking effect, I like it and your code is very well written, thumps up :!:

Keep up the good work.

fliper
Posts: 14
Joined: December 29th, 2012, 7:07 pm

Re: Elastic surface symulator

Post by fliper » December 30th, 2013, 12:49 pm

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
Attachments
ElasticPlaneSymulator_v1.01.rar
(135.02 KiB) Downloaded 303 times

mogu
Posts: 34
Joined: November 12th, 2013, 4:24 pm
Location: Finland

Re: Elastic surface symulator

Post by mogu » December 30th, 2013, 3:47 pm

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.
ElasticPlaneSymulator 2.rar
(134.9 KiB) Downloaded 315 times
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.

User avatar
LuisR14
Posts: 1248
Joined: May 23rd, 2013, 3:52 pm
Location: USA
Contact:

Re: Elastic surface symulator

Post by LuisR14 » December 30th, 2013, 4:54 pm

this is some nice effect :), mouse in effect happens, mouse out effect stops :D
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat :mrgreen: --

fliper
Posts: 14
Joined: December 29th, 2012, 7:07 pm

Re: Elastic surface symulator

Post by fliper » December 30th, 2013, 6:23 pm

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

User avatar
thetoddfather
Posts: 338
Joined: October 1st, 2012, 9:53 pm
Location: Canada

Re: Elastic surface symulator

Post by thetoddfather » December 30th, 2013, 11:13 pm

I'm picturing a sniper game with this one haha, very cool

User avatar
GreatJake
Posts: 169
Joined: January 6th, 2013, 5:13 pm
Location: USA

Re: Elastic surface symulator

Post by GreatJake » December 30th, 2013, 11:46 pm

Lol this is a really neat effect, the math sounds really complicated :P. Do you mean your trying to make the mesh behave like a flag on a pole or something?

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Elastic surface symulator

Post by chili » December 31st, 2013, 6:21 am

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.
Chili

Post Reply