World editor update

Planning and Development

Here’s the latest scene from the world editor:

You can see a few objects I’ve added and the terrain is a bit of a mess, but the point is to show that with the world editor I can now edit the terrain pretty easily.  The terrain moves up and down in increments of 5 meters at this point and that will change eventually but it’s really pretty simple to modify terrain at this point.  Just click or shift-click and it moves.  Easy peasy.

I need to change the selection tool from an big elongated cone into a sphere, and I would like to be able to just click and drag to move terrain, but I may save that improvement for later since it actually works pretty well using discrete clicks.  Scale is going to be important here.  Once I get some objects in the scene it will be easier to model the terrain around them because right now each click moves the terrain up or down by 5 meters.  That’s a really big jump but with the camera zoomed out to see almost an entire 1,024 meter x 1,024 meter block, smaller changes are not noticeable.  However, once there are houses and trees and fences and other objects in the scene, it will be easier to model the terrain in a way that make sense at scale.  That’s just hard to do without correctly scaled objects in the scene to use as a reference.

One other feature I’m finding I will need eventually is a scene explorer.  That is, a text listing of all of the objects in a scene.  As it is now, if I have an object in the scene but it’s hidden underneath the terrain or inside another object there is no way for me to select it to move or delete it.  This may not be a huge deal since I can always just edit the .json file directly, but it’s probably worth implementing sooner rather than later just to keep things clean.

Terrain editing

Planning and Development

I’m making good progress with my improved terrain editing tools.  Right now I can right click to select the terrain and a goofy cone shows up.  The cone points down and shows the area that will be affected by clicking the mouse.  You can scroll the mouse wheel to move the cone up or down, changing the size of the circle within which vertices will be affected.  Right after I finished implementing all this I realized that a scaleable sphere centered on the mouse cursor makes so much more sense, so I’ll have to fix that.  In any case, if you have the magical cone up and click the left mouse button, any vertices within the circle of influence™ will move along the y-axis by 5 units.  You can then save the scene and the changes persist.  There are lots of things that need to be improved here but the basic functionality of being able to select a group of vertices with the mouse and change them with a click is totally working.  I honestly didn’t think I would get this far this fast, so hopefully I can polish this up a bit then make a real scene very soon.

Still more editor updates

Planning and Development

I’m getting really close to a functional tool with the world editor.  I can now load a scene, add objects, select objects, translate, rotate, and scale objects, and save the scene.  The editor saves the scene in two passes.  First it writes a .png to the server that is a height map built from the scene’s terrain, then it writes a .json file that contains the name, location, rotation, and scale of each object in the scene.  Those two files can then be used to load the scene later.  There are just a few more abilities I want to add.

  • Remove objects
    • This should be really straightforward, but it will definitely be handy to be able to remove objects that are no longer needed without having to manually edit the .json file.
  • Add lights
    • I might actually save this one till later since it’s easy enough to just add a sunlight lamp or some ambient light to the whole world, but it would be nice for things like lamp posts or other cool atmospheric effects.
  • Edit terrain
    • I had a simple terrain editing tool in place but I was only able to select one vertex at a time and move it up or down.  For managing a large scene this really isn’t practical.  I want to have a scale-able circle projected onto the terrain where clicking raises all of the vertices in the circle and shift-clicking lowers them.  I’m hoping this will be relatively easy to implement.

Once these basic abilities are in place I will start adding to the library of objects that can be placed into a scene.  After I have the basic assets for Penrith Forest available, I’ll make the very first iteration of that area.  Hopefully I can release a small demo shortly after that.  I’m pretty excited to be at this point.

Editor – add assets!

Planning and Development

Check this out:What’s that on top of the hill?  A flower?  How did that get there, you may ask.  Through that nifty little button at the top of the screen that says “Add Assets” would be the answer.  I can now add objects to a scene using the world editor, then move them into place wherever they belong.  Next I’ll need to implement the scene saving function, and then we’ll be cooking with gas.

New tree

Asset Spotlight

I modeled a little tree today.

I like this one because it leans a little and has the crotch right below the leaves, but also because it’s exactly 100 triangles.  It will be fun to see just how low-poly I can create more complicated objects and still keep things interesting.

Raycasting

Planning and Development

Raycasting has been giving me fits.  The problems I was having with raycasting are what really pushed me to switch to a perspective camera in the world editor but it turns out that wasn’t really the issue.  I’m not completely sure what was causing the problem but after a fair amount of digging I discovered that rays were always being shot just below the pointer’s location on the screen.  No matter which way the camera was oriented, rays were always just low.  I really banged my head against a wall on this one but finally figured out that the menu at the top of the editor was throwing off something.  I had the <div> containing the menu nested inside the <div> to which THREE.js adds a canvas for rendering.  This was messing up some kind of calculation and making THREE.js think the screen was shorter than reality and consistently pushing rays down.  To fix this I just moved the nav bar <div> beside the display <div> and set its location to “absolute” with CSS.  This fixed the issue with raycasting and also made the background of the menu not stretch all the way across the screen, which I kind of like, so that was a happy accident.  Now that raycasting is working again, I can work on selecting objects and improving the tools to manipulate them in a scene.

Editor camera

Planning and Development

I’ve been struggling with the camera in the world editor for the last few days.  I had an orthographic camera as the primary view and I liked that look but it came with some complications.  What it really comes down to is that I don’t 100% understand how orthographic cameras work but in any case I was having trouble getting it to act the way I wanted.  The near and far clipping planes confused me and even when it worked the way I wanted it to I wasn’t exactly sure why.  Zooming the view versus moving the camera seemed to cause problems with raycasting, which I need for selecting objects in the scene.

For some reason I was worried that a perspective camera would be more difficult to work with for editing.  I guess I thought it would distort things that are far away or off to the side in the view, but I changed the primary camera over to a perspective camera and it works fine.  It’s different from an orthographic view, of course, but not drastically so.  It may actually work out well because the native view in the editor will be closer to what players will see in the actual game.

At some point I may add the ability to the editor to switch between perspective and orthographic cameras, but that’s definitely a bonus feature for some time down the road.  Now I can get back to working on things that will actually help me get content created, instead of ridiculous, minor issues with the way things are rendered to the screen.

More editor update

Planning and Development

The world editor is really starting to come together.  Here’s the latest:

World editor with a terrain and a few objects

It’s still pretty rudimentary, I realize, but in the editor I can now hit the little “Load Scene” button in the menu at the top and it opens a box that lists scenes that are available to load.  It then reads the scene file and the associated height map and creates a terrain and adds any objects from the scene file to the scene itself.  That white thing is a light helper that will probably eventually go away.  Once the scene is loaded you can rotate around, pan, and zoom to your heart’s content.  Again, I know this is pretty basic stuff but it’s cool to me that I’m emulating some of the basic functionality of Blender but in a browser.  I now need to implement that button that says “Add Asset” so that I can actually add stuff to the scene.  I also need improve the tools to manipulate objects in the scene, add lights, improve the terrain editor, etc., etc., etc.

Also, GIMP 2.10.0 is out and looks great so far.

Also, happy birthday Josh!

Editor update

Planning and Development

I’m still working on the world editor.  I got the camera rotation, panning, and zooming working pretty much exactly the way I want, and I put a little octahedron at the point of the camera target just so I can tell where it’s looking.  Now I’m working on a UI design for the editor.  So far I’ve created a little menu at the top of the screen with a few options and some drop-down options too.  I also added a dynamic box so that I can select which chunk I want to edit.  As a side note I’ve finalized that the chunks are 1,024 x 1,024 meters, and the center of the world is at chunk [127, 127].  Assuming that the world extends out equally from this point, which is not strictly a requirement moving forward, it is 256 x 256 chunks.  That’s a square world that is 262,144 meters on a side, or 162 miles.  The total potential area is over 26,000 square miles.  That’s actually way, way too big to fit within the lore of Tright.  Lyridia will actually be closer to the size of Jamaica, maybe around 4,000 square miles.  That’s still almost 100 x 100 chunks.  There’s is absolutely no way I would be able to create 10,000 chunks of content by myself, but that’s ok.  If I make a settlement on the east edge of the island and then one on the west edge I don’t necessarily have to create all 98 chunks in between them, so long as players can’t venture into areas that don’t exist.

World editor improvements

Planning and Development

I started to not work on the game tonight but I’m really glad I did.  In the world editor now you can pan, rotate, and zoom the camera.  Rotate and zoom both work pretty much perfectly at this point.  Panning also works, but doing so moves you along the x and z axes no matter the camera’s orientation.  Obviously I want the camera to pan along the axes of the camera’s viewport, but I think that should be relatively easy to implement.  Other than that it is really quite cool to be able to zoom in and out and rotate around the scene to see things from any angle.  Of course, there’s nothing to really see at this point other than a really basic test terrain, but it’s a start and I like it.