Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Best way of volume selection


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Kiel368   Members   -  Reputation: 215

Like
0Likes
Like

Posted 23 March 2014 - 11:49 AM

Hi!

I'm writing a sandbox game in Unity 3D based on voxel terrain. I need the player to interact with the world (place/remove blocks).

 

The problem is, that size of the smallest voxel is 6 cm, so placing voxels one-by-one is unacceptable if player wants to build somehthing big. To solve this problem I've created a crafting system, which lets the player create e.g. a 40x5x5 cube of stone.

 

Now, the problem is that player must be able to change the orintation of the created item and I don't know how to achieve this! Do you have any idea how could reorientating look like? Maybe according to mouse movement (but how)? or using keyboard...

 

I've attached a screenshot of what it is like now. Please think of a way how could player reorientate that box in a user-friendly way.

 

Thanks.

Kiel368

Attached Thumbnails

  • box.png


Sponsor:

#2 eppo   Crossbones+   -  Reputation: 2629

Like
1Likes
Like

Posted 24 March 2014 - 05:16 AM

How about a two-click mechanism? The first click lets you drag a rectangle of blocks over the XZ-plane, the second click scales along the Y-axis. This allows the user to create any combination of blocks.



#3 Waterlimon   Crossbones+   -  Reputation: 2643

Like
1Likes
Like

Posted 24 March 2014 - 09:58 AM

You can allow selecting a single axis at a time and resizing/moving on that axis. These tasks can be done by pressing a key, scrolling the mouse wheel, clicking, dragging, whatever.

 

For rotation you usually have some hard to comprehend system where you can rotate using keys. The user then hits the keys randomly until the object ends up with the correct orientation. You can make this easier by having the keys be fixed to global axes (instead of tied to local object axes). You can also add indicators to tell which key rotates on what axis (hovering thing with the key shown for each axis).

 

You can also have rotation by dragging the object or some GUI surrounding the object with the mouse but you should also have the keyboard version because the mouse tends get slow and annoying after you become a pro.

 

And last, you can implement some automatic detection of optimal positioning based on surroundings, but make sure it doesnt get in the way and randomly change the positioning while the user is trying to manually adjust it.


o3o


#4 TheComet   Crossbones+   -  Reputation: 1645

Like
1Likes
Like

Posted 24 March 2014 - 10:59 AM

The game Cosmo Bots demonstrated a 2D version of what you're after. It could accurately figure out your intentions through a combination of mouse movement and ray-tracing (I think it would prefer to rotate towards the nearest wall). If you weren't happy with its orientation, you could right-click the mouse to manually rotate it.

 

I think the most intuitive method would be to rotate the volume on the 2D surface of the currently selected block, according to an average mouse direction. This would be done as follows:

  1. Determine the surface normal the mouse cursor is over. For instance, if the mouse is on the top side of a block, the normal would be [0,1,0], where as if the mouse were on the side of a block, the normal would be [1,0,0] etc.
  2. Calculate a normalised directional mouse movement vector in 3D. This could be done by storing, say, the last 30 3D mouse positions in a ring buffer, and calculating the difference between the first and last point.
  3. The normal from step 1) is the axis around which you should rotate the volume selection. Using the mouse direction, you are able to calculate an optimal angle for the volume selection. You'd of course round the angle to 90° steps.
  4. Make sure the volume doesn't intersect with any other blocks, adjust position and angle accordingly.

Does that make any sense? I can create some illustrative images with MineCraft if not...


Edited by TheComet, 24 March 2014 - 11:01 AM.

YOUR_OPINION >/dev/null




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS