Author Topic: How to achive this morphing sphere  (Read 14561 times)

0 Members and 1 Guest are viewing this topic.

Offline ryt

  • ZX 81
  • *
  • Posts: 10
  • Karma: 1
    • View Profile
How to achive this morphing sphere
« on: January 07, 2014 »
Probably some of you have seen this demo http://www.pouet.net/prod.php?which=11016. In these pictures in lower right corner is a sphere that is changing its shape. I wonder how I can build this sphere. What would be a starting point.
I assume it is some sin function with changing amplitude with random values.



There are also other demos that have a similar changing sphere but in this one it is really easy to see it.

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: How to achive this morphing sphere
« Reply #1 on: January 07, 2014 »
I would start by having each point on the sphere having coordinate values (longitude and latitude) and individual radius values.

You can then raise or lower individual points by adjusting the radius values and move them around a little by making slight adjustments to the coordinates.
You are our 9001st visitor.
Challenge Trophies Won:

Offline ryt

  • ZX 81
  • *
  • Posts: 10
  • Karma: 1
    • View Profile
Re: How to achive this morphing sphere
« Reply #2 on: January 07, 2014 »
I was thinking of something like that. So if we transform that to spherical coords so that longitude and latitude become theta and phi we would have:

x = A*cos(theta)*sin(phi)
y = A*sin(theta)*sin(phi)
z = A*cos(phi)

where 0<=theta<2PI and 0<=phi<=PI and A is the amplitude.

With that we can create a sphere.  So then I think we should make A a function of theta and phi. It could be a function of interpolated random values. Also the continuity should not be broken. But I don't know how to ensure that.
Maybe also there should be two amplitudes like A and B, one for theta and one for phi.

I don't know if I am going in right direction. Probably there are also errors in formulas I wrote.

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: How to achive this morphing sphere
« Reply #3 on: January 07, 2014 »
This sounds familiar. One of my previous contest entries generated a wireframe sphere using theta and phi values and a radius value, but only 3 points were raised or lowered at a time.

I've also put together a grid of floating cubes which undulate over a grid of sine waves, one controlling the x-coordinate of the waves and the other over the y-coordinate.

It shouldn't take much to combine both of these effects into one amazing demo! Now I've got to dig out my source codes.
You are our 9001st visitor.
Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: How to achive this morphing sphere
« Reply #4 on: January 08, 2014 »
Also the continuity should not be broken. But I don't know how to ensure that.
So you want a smoothly changing, repeatable value for two coordinates, theta & phi.
That's basically like creating a repeatable plasma pattern (like these for example).
Plasmas are done by adding several layers of sine waves over each other and change the starting phase of each wave to animate the whole pattern.
To make them repeatable, the width and height must be a decimal multiple of the wave-length.
Another (probably easier) way is to add several repeatable bitmaps over another and move each map into a different direction to get animation.

The effect in the screenshot seems to move each vertex-position along different x,y,z-offsets.
But displacing along the vertex-normal works very well, too.
Challenge Trophies Won:

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: How to achive this morphing sphere
« Reply #5 on: January 08, 2014 »
I've put up a basic dot-rendered sphere here: http://fx.barcodebattler.co.uk/waveSphere/

I'll add some comments to the code soon and add the wavey effects.
« Last Edit: January 09, 2014 by combatking0 »
You are our 9001st visitor.
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: How to achive this morphing sphere
« Reply #6 on: January 08, 2014 »
ohh nice one ck! K+

i am excited too see it wave about..
Challenge Trophies Won:

Offline ryt

  • ZX 81
  • *
  • Posts: 10
  • Karma: 1
    • View Profile
Re: How to achive this morphing sphere
« Reply #7 on: January 08, 2014 »
I gave it a little tought. We have theta and phi so we could animate about these two in their own direction, like in a 2D system. Actualy that is spherical coord system.
To animate in lets say phi we could make:

A = sin(phi*freq+time)

where freq could also change. To change it in theta we could just add another sin or cos like A = sin(phi*freq+time) + cos(theta*freq+time).
So we would get some animated values based on a normal as hellfire mentioned it.
I hope this makes sense and that this will animate the sphere. I wonder how this could be extended so it animates in x, y, z also.
« Last Edit: January 08, 2014 by ryt »

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: How to achive this morphing sphere
« Reply #8 on: January 08, 2014 »
I wonder how this could be extended so it animates in x, y, z also.
Have a look at this wonderful rgb plasma by Dr_D.
It creates smoothly changing rgb values for each x,y-coordinate.
That's pretty much like the (x,y,z) from (theta,phi) you're looking for!
You can simply add the resulting rgb to the original vertex position.
You just have to find a way to make it repeatable, though.
Challenge Trophies Won:

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: How to achive this morphing sphere
« Reply #9 on: January 08, 2014 »
I have annotated my source and adjusted the look of the sphere - the link to the page is in my previous post.

The sphere uses the phi/theta to x/y/z conversion you're looking for. If the annotations don't explain it well enough, please ask me for more details.

Waves will come tomorrow.
You are our 9001st visitor.
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: How to achive this morphing sphere
« Reply #10 on: January 09, 2014 »
@ck im just waiting till the waves come then i am going too have a proper dive into your source too see how you go about this.

Quote
Have a look at this wonderful rgb plasma by Dr_D.
It creates smoothly changing rgb values for each x,y-coordinate.
That's pretty much like the (x,y,z) from (theta,phi) you're looking for!
You can simply add the resulting rgb to the original vertex position.
You just have to find a way to make it repeatable, though.

nice one hellfire! im just in the middle of giving this a go, so too make the effect repeatable would it just be something like if (nticks>somenicetimeval) restarttimer(nticks); and adjust somenicetimeval too whatever gives a nice repeat with no skipping..
« Last Edit: January 09, 2014 by ninogenio »
Challenge Trophies Won:

Offline Canopy

  • Atari ST
  • ***
  • Posts: 208
  • Karma: 20
    • View Profile
Re: How to achive this morphing sphere
« Reply #11 on: January 09, 2014 »
sure i've seen a nice writeup on the "jelly cube" effect that works a similar way (the newer version of that effect, not the scanline one)

something like break a cube into a grid of sub cubes and wiggle the vertices

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: How to achive this morphing sphere
« Reply #12 on: January 09, 2014 »
It's wobbling all over the place now - just click on the checkboxes in the bottom-left corner of the page to get it started.
You are our 9001st visitor.
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: How to achive this morphing sphere
« Reply #13 on: January 10, 2014 »
ck thats awesome mate k++

i actually tried too modify your code too try hellfire's method but after spending hours trying too figure html out i threw the towel in  :). i am going too start a different thread for that though.

so i just turned too good old freebasic too try dr_d plasma effect out i havent looked in too making it seamless atm but it still looks quite good.. its just a different method of achieving roughly the same effect. so between me and you that's two ways down. which just leaves the multiple bitmap's traveling in different directions method hellfire mentioned i would like too give that a try too but would need a little more info on how too go about it.

any who the plasma effect is attached.... exe and code.
« Last Edit: January 10, 2014 by ninogenio »
Challenge Trophies Won:

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: How to achive this morphing sphere
« Reply #14 on: January 10, 2014 »
I guess my code is a bit hard to follow, as it is effectively two demos mashed together (Illumisphere and Ghoulish Cubes) with minimal optimisation. Where were you stuck with it? I'll do my best to explain.

Your exe looks cool, it's how I imagine a magnetic field to look if it were visible.

I can't imagine how the bitmap plasma would work, but it's probably viable.
You are our 9001st visitor.
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: How to achive this morphing sphere
« Reply #15 on: January 10, 2014 »
thanks ck. your code is perfectly readable mate, its when i started hacking at parts of it everything went belly up lol. i am having a little trouble with debugging(tracing vars etc) but rather than hijack this thread ill start a new post and hopefully work through some of the issues im having in html  :cheers:

i wasn't 100% happy with my point's version of this. i thought it was a little hard too see the effect. so i have modified my code too render faces or wireframe tris it looks much better now again source and exe attached
« Last Edit: January 10, 2014 by ninogenio »
Challenge Trophies Won:

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: How to achive this morphing sphere
« Reply #16 on: January 10, 2014 »
No problem - let me know when you want me to show you a method of debugging JS variables.

Hopefully the discussion so far has been helpful for the original topic.
You are our 9001st visitor.
Challenge Trophies Won:

Offline ryt

  • ZX 81
  • *
  • Posts: 10
  • Karma: 1
    • View Profile
Re: How to achive this morphing sphere
« Reply #17 on: January 11, 2014 »
I was a lot busy these days so I haven't implement any of formulas I wrote yet. But I red all the posts though.
combatking0 when I saw the first version of the sphere it just looked awesome even if it was only rotating. Now it is even better  :) and I can just say wow.
Now I will try to implement these formulas and take a look at your code and the tutorial for rgb plasma by Dr_D that hellfire mentioned.

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: How to achive this morphing sphere
« Reply #18 on: January 11, 2014 »
errmm....

i think you will find attached to my posts dr_d's plasma working on vertex's?!?...
Challenge Trophies Won:

Offline ryt

  • ZX 81
  • *
  • Posts: 10
  • Karma: 1
    • View Profile
Re: How to achive this morphing sphere
« Reply #19 on: January 11, 2014 »
Yes the vertex version is attached to one of your posts. I haven't looked it before.
It looks cool but it is really a little harder to see the whole object. I will check the source.