Game Development Community

Interfacing Ideas?

by Demolishun · in Torque Game Engine · 01/21/2007 (11:05 am) · 10 replies

Continuation of this thread to discuss engine code:
www.garagegames.com/mg/forums/result.thread.php?qt=56893

About the author

I love programming, I love programming things that go click, whirr, boom. For organized T3D Links visit: http://demolishun.com/?page_id=67


#1
01/21/2007 (11:16 am)
Heh.
umm.. i didn't actually have a lot more to say about the EditorTSCtrl.
;)

have you used the terrain editor ?
it seems like getting control over those selection squares might be a good place to start.
#2
01/21/2007 (11:23 am)
I will have to look at the code and see what I can use. Your right that the code is already there for selecting points on a map.

Right now I need to think about how to make a spherical map. I would like to calculate the area of the sphere and automatically determine the spacing of the cells based upon a distance tolerance. This would allow arbitrary sized spheres that would increase or decrease the play area. It would also make the interface more one dimensional. The torus idea is not bad and I like that you can rotate the object to get and see all sides.

Thanks for giving me the idea about using a continuous map. That will certainly make it more interesting.
#3
01/21/2007 (11:39 am)
The sphere is interesting.

note that mapping a regular grid onto a sphere is a mathematically non-trivial task.
that is, if you want to have a constant density of cells (ie say one cell per "inch" or whatever) with an arbitrary-sized sphere, you'll probably have to do something dynamic.

i fooled around with something related - trying to distrube an arbitrary number of points evenly over the surface of a sphere. my approach was to first distribute them randomly on the surface, and then have them repell each other via an anti-gravitational model. it works fairly well. i've got an example exe up here. d'oh! i didn't put the source code up tho. crap, and i think it's on a hardrive that's offline right now. anyhow, if that interests you, let me know.

you should definitely have a look at this page by Paul Bourke.

a torus is nice because it maps perfectly to a rectangular grid. - but it's harder to interact with, definitely.
#4
01/21/2007 (11:56 am)
I was thinking this could be done like this:
as = surface area of sphere
ap = area of points
as/ap = number of possible cells (rounded down to whole number)

360/sqrt(as/ap) = angle 1 on sphere x axis
360/sqrt(as/ap) = angle 2 on sphere y axis

My gut feeling is this will work, but I need to test it.
#5
01/21/2007 (11:59 am)
Another thought is using verlet calcs to determine positions by creating two constraints:
1 distance to center of sphere must remain at fixed radius
2 distance between neighbors must be equal

Then just run the verlet rules on each point.
#6
01/21/2007 (11:59 am)
Hmm, possibly.
very interested to see what you turn up !
#7
01/21/2007 (12:35 pm)
So far the math is panning out as expected:
$math::pi = 3.1416; //3.141592653

function clife::drawSphereGrid(%sphereRadius, %pointRadius)
{
   // calculate sphere surface area
   %sphereSurfaceArea = 4*$math::pi*%sphereRadius*%sphereRadius;
   %pointArea = $math::pi*%pointRadius*%pointRadius;
   %numCells = %sphereSurfaceArea/%pointArea;
   
   echo("As:" SPC %sphereSurfaceArea SPC "Ac:" SPC %pointArea SPC "Cn:" SPC %numCells);
   
   %xPeriod = 2*$math::pi/(mSqrt(%numCells));
   %yPeriod = 2*$math::pi/(mSqrt(%numCells));
   
   echo("Xa:" SPC %xPeriod SPC "Ya:" SPC %yPeriod);
}

The results are as follows:
==>clife::drawspheregrid(1,1);
As: 12.5664 Ac: 3.1416 Cn: 4
Xa: 3.1416 Ya: 3.1416
#8
01/21/2007 (12:39 pm)
Sounds cool !

the verlet idea is pretty similar to what i was proposing as 'antigravitational repulsion',
except that rule 2 would be "distance between neighbors must be maximal".

i do know that it's mathematically impossible to distribute an arbitrary number of points perfectly evenly over a sphere, (hence the finite number of platonic solids) but you can get pretty close.

eg 500 points here:
elenzil.com/progs/separate/dictators500.jpg
#9
01/21/2007 (1:52 pm)
One way to ensure conformity is to always generate distances with numbers that are multiples of 3. I think that would help.
#10
01/21/2007 (4:50 pm)
What a nightmare! You are right in saying this is non-trivial! I think I will mess with a terrain based version for now.

Thanks