TK Dice – 3D Randomness Library – Demo


Hi everyone,
My name is Juan and I’d like to introduce
you to this project, called TK-Dice,
and as it is said in the logo, this is a “3D
randomness library”.
Given a 3D space and a physics environment,
the library provides another way of
calculating random results by using a short
graphic simulation.
Throwable objects with multiple resting
positions (such as dice or coins) are rolled about
until they reach an stable position.
These final positions return a result
based on the object’s orientation (commonly
a number) and are useful for further
calculations within or throughout
a given program’s logic,
such a game.
TK-Dice is developed in Java, and built
on top of Ardor3D and J-Bullet.
FEATURES
That said, before starting up the demo
let me go over some features
The library lets you customize the elements,
such as backgrounds, table runners,
dice colors and so on.
Also some adjustments of the logic
behavior can be performed,
, like safechecks, drop height
or rolling methods.
It can be easily integrated into
any SWING/AWT application.
If interested just check the last
point of this video “A word on
java code”
It supports single and multiple rolls
rolls of thowables,
in any number and types, all mixed up.
It’s interactive.
There’s a rolling method that allows the user
to pick up and roll a throwable
Supports different throwables.
So far the ones supported are common
dice
D6
the truncated version of the D6
the coin
Common RPG dice
D4
D8
D10
D10 in tens
D12
D20
Other not so common dice: those
based on Catalan solids
(They are called like that)
D12
D30
which is kind of “new”
finally, game specific dice,
like this one here, which is part of
of the heroquest board game
(hope you know what I’m talking about)
it has no numbers on its faces, instead
it has symbols which are supported by the library
as well
Let’s go ahead with the demo.
The panel on the right is the 3D space
where all the events occur.
The orthographic camera is pointing downwards
right into the tabletop or table runner,
which is the surface where
throwables are rolled.
It is plain and has a dimension,
usually a power of 800×600.
The limits of the camera also prevent
that no throwable slips away
from the viewport and disappears. Thus it will
bounce back and roll towards another
direction keeping it visible at all times.
The panel on the left is a control panel
with options,
helping me to set up the next roll I’m
about to execute.
Both panels are independent, so the
orders executed in one are interpreted
by the other using threads.
Now let’s make a single roll:
OneD6.
One D8.
One D12. As you can see the final result
is captured and shown in the console.
We are currently using the drop_roll,
which is the default method if
none is given.
The drop roll consists on exactly what it
it intends to mean:
drop the dice from a random height
into the tabletop.
Let’s make a multiple roll:
4D4
7D10
20D20
Let’s mix them up a bit and change the colors
randomly
5 D2 +
4D6 +
3D8 +
11D12
20D20 + 1D4
Alternatively, I can use a textual
representation for my next roll using
the String mode
(the standard string covering
all dice)
1D2-plat 1 D4-D6-1 plat plat 1 D8-plat …
Let’s change the roll method
Floor_Roll
Dice linger and swing fast at an initial position
a few inches over the
tabletop. Then they are released.
Row_roll
Dice are set up in vertical columns of five.
Dice linger and swing fast, then they are
released.
Pickup-roll
The interactive option,
only available for single rolls.
The die appears in the center of the tabletop
and by pressing and holding the left mouse button
it can be picked up, moved around and
released to make it drop and roll.
It can be tossed faster by moving and
releasing quicker the mouse button.
Before releasing it, you can use the mouse
wheel to spin the dice and change
its current orientation.
Simulation speed can be adjusted by
using this slider.
Let’s make a faster roll.
Now let’s make a slower roll.
What happens if some dice remain
on a tilt angle after a
roll?
The library implements a safe-check
that bounces off the die and forces it
to land on one of its faces
This safe-check can affect
other surrounding dice or not, depending
on how the simulation is setup.
The tablerunner can be covered with an
image, and even made transparent so
so your simulation looks like the dice
are rolling over your desktop
or over your own application.
A WORD ON JAVA CODE. I want
to show you some java code in order to
demonstrate how easy is to create a simple program
using TKDice.
We are to write a program that throws
10 d20,
One of them has a bright color while
the others have the default color.
After the roll completes the program must return
an ok message if the result
is higher than 10,
or an error message otherwise.
We first create a rollingpaneconfig object
with the default configuration.
We only change the background image.
Now we create a Rollingexecutor
with that config.
This object is to execute the simulation based on
a RollingProperties object that we’ll be creating next.
We create the rollingProperties object that defines
which throwables will be present
during the simulation
and how they’ll be called and rolled,
amongst other properties.
In this case we define 9 basic D20
and 1 D20 called “MyRedD20”
with a bright red color to make it distinguishable.
We add the rollingProperties created before
and run the rolling executor.
The simulation is visible at this point
and the flow waits until
it’s finished.
Once it is finished,
we capture the “MyredD20” result as
an integer and make the comparison,
writing the appropriate message to the console.
Okey, so this is pretty much it,
This library was developed to accomplish
my own needs
but I personally think it could be of
use to other programmers, developers out there.
If so please just leave a
comment or write me an email
with your thoughts or ideas.
leave your feedback,
thanks for watching
and see you soon.
Bye.

Author Since: Mar 11, 2019

  1. Un gran trabajo de 3D y programación. Me encantan los diferentes dados y el sistema de tiradas. Un video muy explicativo, es de agradecer. Enhorabuena!!

  2. http://rojrunning.com/wp-content/uploads/2013/12/Shut-up-and-take-my-money.jpg

    Very useful. Loved the different types of rolls. That'll sure come in handy for persnickety players 🙂

Related Post