3D API Overview - 1.3.2 Beta

@Simeon - I’m assuming this is alright to ask due to the fact this is beta discussion, what is all this saving the images off the web in 1.3.5 beta about? Is it diners in general coming or what? Thanks!

Zoyt, it’s a mesh of stars - the same stars as in the close up - placed at random positions on a large sphere. That ensures that it rotates correctly as the camera moves.

Alright. Thanks @Andrew_Stacey. Just curiouse if you found a way to tile the background in a sphere.

So, how would we make a sphere or a cylinder? Would we have to use meshes or what? Can you give us some sample code if someone manages to do it? And also, how would we do backgrounds. Would we need a giant sphere and texture it?

Something a bit like this, you mean:

sphere with texture

I’m strongly tempted to say “Go to school and pay attention in math(s), particularly trigonometry.”. If I get a moment, I’ll post some code but you won’t understand it if you don’t know trigonometry. What you need to find out about are parametrisations of surfaces. If you know how to do that, you can build a mesh for it.

As for tiling to a sphere or cylinder, there you’re going to have a little difficulty. A cylinder is easy because it is flat. A sphere is not flat so there will be distortion and you need to take that into account with your image. I chose my globe image very carefully to minimise this distortion.

Thanks. I’m temped to say “Did you know much trigonometry in middle school?” It’s my plan to homeschool next year so I can actually learn these things. Web the honors class is holding me back. I’ll just do my best to use other people’s libraries. Something that would be good for all of us that don’t know trigonometry would be a library for adding spheres, cylinders, cones, and all the other often used shapes with rounded surfaces. Thanks!

So, I did take trig, and on up further, but I’m old and don’t do this lots - and I’m not looking to re-invent the wheel either. Math is HARD. Computers are easier.

Do we have sample code somewhere for mapping a texture to a mesh sphere? Something good and canonical and best-practice and fast?

My goal is semi-nice-looking procedural planets, ideally with basic lighting. I’m thinking texture-mapping some noise to a mesh may do the trick. maybe nested spheres with a semi-transparent outer one for atmosphere. I’d rather spend my time on the “pretty” than the sphere.

Alternatively, I’m open to suggestions as to how to cheese the effect - the end goal is to have random, but repeatable, alien worlds. They’d be static images in-game rendered during startup.

Off topic? Yep. But the shot above is closest to the effect I’m looking for.

Take a look at Xavier’s 3D stuff - the original idea behind what he was doing was creating realistic-looking but cheap planets.

@Bortels, I’m hoping that you’re working on the game I’ve been dying to play for twenty+ years.

I doubt anyone else remembers, but the old GEnie service used to have a game called Space Empire. At the start of each month, a randomly generated universe of stars and planets was created. Players started at a random location with a simple exploration ship and scrambled to find an inhabitable world. Once you had taken a planet, you could set up mines and industry, build defenses, and ultimately create shipyards capable of larger and larger ships. A week into the game, you’d see small fleets of frigates and corvettes fighting to capture prime worlds. A week after that, the evolution of systems meant that whole systems would be under siege by massive battleship-led armadas. In the last days, civilizations with the technological edge would tear through the universe in dreadnoughts, laying waste to planets to deprive anyone of their resources. At the end of the month, whoever controlled the most of what was left was declared emperor and… Reset.

I loved this game. Loved it. It was the first massively multiplayer game I ever participated in, and it did almost everything right. Even though the display was entirely text based, diving out of hyperspace into an occupied system and sending your ships down the gravity well to square off with planetary defenses literally made my heart race. Plus it allowed for a semi-formal system of alliances where you could cover for pals who were offline. It was everything I’ve hoped other space games (from Earth & Beyond to EVE) would be, but just aren’t.

Imagine the compulsive play of MOO or Saceward Ho! combined with the building strategies of FarmVille, then give everyone playing the chance to be backstabbing SOBs or loyal comrades.

I’m still dying to play an updated version of that game with a graphic interface and bigger universe.

@Mark - yes. yes!

But my original was VGAPlanets. Same basic gameplay - you started with a homeworld, a scout ship, and a cargo ship, and you colonized nearby worlds, built up an industrial base, fleets of ships, and whupped the tar out of your neighbors. VGAP had up to 11 players at once, each taking a race loosely based on popular sci fi - you could be the Federation, the Pirates, the Rebels, the Evil Empire, the Colonials, the Robots, the Cyborg, etc. And each race had different special abilities.

The awesome part was the meta-game - the out-of-game emails. The diplomacy, the side-deals, empty threats and bluffs, the backstabbing, the public Taunting. OH, THE TAUNTING! (I plan to have in-game messaging as well)

Each game took anywhere from a couple of weeks, to a couple of months, with turns running either 5 days a week or MWF (this was with co-workers, email at work was the exchange medium; I later did a web-based version).

My longish-term plan is to take the victor of each game, give them a point of rank, and them matchmake games with players of similar rank - a giant leaderboard.

I’ve got the skeleton of the server-side “done” - you can create a universe, manage objects in it, ships move, planets grow - and the client side can load/view from that server. To add shortly are basic ship and planet orders (build, move), and registration (I already have login) and it’ll be at “0.1”.

I’m implementing both sides in lua - Codea, obviously, for the client, and lua in CGIs now on the server side, with the goal being that certain logic (see below) can be shared. The whole thing is backed by a redis keystore.

Version 0.2 is “combat”. That’s where I saw battle chips and the little hairs on the back of my neck stood up. One thing that lacked in VGAPlanets was ship combat, in that if two fleets met - it was a round-robin of ships one-on-one. It was cool - you could watch the battle - but not as satisfying as a good fleet battle. To see my ultimate dream of that, google for “Gratuitous Space Battles”. I think I might be repeating myself, but the original idea was to have each ship with a stance/AI - “run away”, or “snipe small ships”, or “shoot at whatever target our biggest ship is shooting at”, or “stand way off and shoot missiles”, or “protect the capital ship”. But I absolutely love the concept of building a combat program, with chips like “target biggest enemy” or “target closest enemy” or “return fire” (ie. target whoever is shooting you), or “run away from target”. Each ship could be assigned a group, and have basic swarming functionality, for fighter groups and the lot.

The BIG PROBLEM I have - and have had - is that, as you can see, my goals are frankly far grander than my time and skills allow. I’m hoping with Codea this changes - it lets me prototype a nice-enough graphical client (I’m nearly there), and it lets other people see the code and add to it. If I can get this rolling fast enough, it’s possible the community will start pushing too, like they have with cargo bot and battle chips - things like graphics, and good ideas, and so on.

@frosty - how did you do the lighting effects? not by tinting the images, I hope.

If I’m going to get realistic looking spheres - lighting is a must. If it’s not part of the 3d stuff, I’ll have to fake it anyway, and that would mean my research toward a 3d sphere is a dead-end - for this particular project, anyway.

(I intend to generate a 3D sphere via old fashioned polar coordinates, and using the 3d noise function as a colormap - this should give me a seamless texture, if I understand it right. But if lighting is only ambient, well, it’s not going to look like a planet in space, it’s going to look like a ball. I guess I could alter the color/brightness based on where it is, but the goal here was to leverage the GPU… I’m thinking that if I have to do that, the mesh is more and more a red herring. Problem is - I’ve generated pixel-by-pixel imagemaps, it takes a while…)

You can tint a texture. If you give the vertices colours as well as texture coordinates then you can simulate light by varying the intensity of the colour. I do that in my 3D stuff - both the shape explorer and the roller coaster.

I need to find me some good hight colormaps…

https://twitter.com/#!/bortels/status/197067181970829312/photo/1

Ugly, but getting there. I bailed on “real” 3D - this is from my old Pic library, spiffied up a bit. Not that it’s not real 3D, but it’s not using the GPU. Need to add height color maps, cloud layer (another perlin noise layer, alpha-transparent, methinks), icecaps, and a “gas giant” mode.

Having said that - I’d like a more fractal coastline. Not sure how to implement it, really. I think I use one noise for “continents”, then add another with a finer grain but less variance as the small-detail. I’ll mess with it.

In the end, this is all (sea level, noise size, type, etc) going to come from a single seed, so that an entire planet is specified by a single number. I think the game will actually use “schematic” planets - circles with numbers and so on - and when you select it, I’ll use these as the “beauty shot”, and while it’s calculating I can do a “scanning” type of deal, then cache the results.

@Bortels, I’d love to contribute a bit toward this gaming nirvana. To fit the Battle Chips controls to ships, I’m thinking that turns would need to be free-form and instead of stepping forward, there would be acceleration. Oh, and lots of nice shields, missiles, advanced radars, cloaking…

@Bortels - This sounds like an awesome project. I would love to help in any way. It wouldn’t be a bad idea to collect a team for this project, because it seems pretty big. I may not be as good a coder as you (by far), but I can also do graphics, sound effects (not only with CFXR), websites, and I’m kind of good at music.

My biggest gap right now is graphics assets - That’s why I’m working on the procedural planets thing. But - we’ll need spaceships. Lots of spaceships. Ideas for Alien races (and ideally, a picture of them - think about Star Control 2). I have, somewhere in my assets, lists of planet names from just about everywhere in fiction.

@Mark, yes, I’m thinking along the same lines. Again, go look at Gratuitous Space Battles as the Holy Grail of “how it should look”, or at least where I’m aiming at, super long term. Toss in a bit of HomeWorld 2, and some battle sequence from “Return of the Jedi”.

For chips, I’m thinking that battle chips is too low a level, but only by a bit - there should be targeting, for both weapons and movement, range-seeking, damage sensing (so you could turn and run at 10%, say), and the firing of various weapons, all with differing rates of fire and ammo - from a tiny point-defense laser that has a short range and can fire almost continuously, to a big missile launcher that packs a punch but has limited ammo, to a death-star like beam weapon that only can fire occasionally. Shields, Armor. Damage Control (Scotty, I need shields up NOW), engines (both impulse for tactical manuvering, and warp). Idea being you could have combinations of ships do things like like “Target Largest enemy, fire when power > 80%, when damage < 10%, all energy to shields and engines, run”. A fighter program might be “stay with wing leader, fire at closest foe”.

The idea for ships is you get a hull, which has a fixed amount of space, and you fill it with equipment - a tiny hull with a pilot, laser, and engine is a fighter (no warp engine means it needs a carrier to move strategically). A bigger ship, a system patrol boat, may have 2 engines, shields, laser, bridge, and a small cargo space. A capital ship might have 2 warp engines, 6 impulse engines, 8 phasers, 4 torpedo bays, shields, armor, engineering, life support, bridge, sick-bay, labs, and so on - all with in-game and in-combat effects. Think Star Fleet Battles (och, I’m old) or the Lucasarts X-Wing vs. Tie-Fighter games - you can’t fire all your phasers and still have enough energy for full shields, armor doesn’t take energy but adds mass (which either slows you down, or needs more engines), etc. The bigger ships would be able to do things like repair (slowly) during battle, or beam over assault troops, or shield other ships. System patrol boats would get a bit of an advantage by not needing warp engines, etc.

You may guess I’ve thought about this a bit. :slight_smile:

@Bortels this project is super cool, I want to play already :slight_smile:

And that planet drawing is amazing even if you say it’s ugly

@Bortels, could be interesting to try out some game mechanics early, even if very schematic and without fancy graphics, to see what works.

Heh - it’ll be very early - as soon as I can get user registration and movement down, and a few ships in, I’ll share all the code. I’m hoping I’m less than a week away (it depends very much on my real-world job - some weeks are slow, and some are killer…)

@Bortels - You might want to split this thread. You want me to get started on graphics by any chance?
Thanks!