Adam's Lair Forum

[RELEASED] Frozen Core plugin - now with nuGet
Page 1 of 6

Author:  SirePi [ 2014/12/05, 16:03 ]
Post subject:  [RELEASED] Frozen Core plugin - now with nuGet

  • Core updated to 2.0.1
  • FX updated to 2.0.1
  • Procedural updated to 2.0.1
  • UI updated to 2.0.1 - compatible with Duality 2

  • Core updated to 2.0.0 - compatible with Duality 2
  • FX updated to 2.0.0 - compatible with Duality 2
  • Procedural updated to 2.0.0 - compatible with Duality 2

  • Core updated to 1.0.5
  • FX updated to 1.0.5
  • UI updated to 1.0.7

  • Core updated to 1.0.4
  • UI updated to 1.0.4
  • Added UI Editor 1.0.4
  • Added sample project for UI design

  • v 1.0.3 released (small fixes and improvements, SitesToBitmap added)

Well.. it has been long and difficult, but in the end it's done :)
you can now install Frozen Core plugins from the package manager, as seen here (it's easy to find! it's the one with the cute frozen block icon :mrgreen: )


For the moment I will leave only this information here.. I plan to prepare a number of examples and, if possible, a sample project describing the various features and stuff available; the information found here are still more or less valid anyway.

If someone uses it and needs some help, feel free to ask here!
Or you can snoop at the source code on GitHub

@Adam: I think it would be better to lock the old thread, since it will probably become obsolete (hopefully) soon. Also sorry.. I will reserve the next 4 slots in the topic to describe the 4 plugins.

Cheers :mrgreen:

Author:  SirePi [ 2014/12/05, 16:04 ]
Post subject:  Re: [RELEASED] Frozen Core plugin - now with nuGet

The Core is the first plugin in the bunch: it includes general purpose classes and utilities that are used by the other plugins and, of course, can be used by everyone.

Core namespace
Colors is basically the transformation of .net's standard Color instances in ColorRgba instances, and in addition it lets you convert a Vector4 to a ColorRgba by using FromBase1Vector4 (in case your vector's components are in the range 0-1) or FromBase255Vector4 (in case they are in the range 0-255), where the vector's X, Y, Z, W are mapped to R, G, B, A components.

FastMath is a helper class to improve the performances of commonly used Math functions; for the moment it only contains a FastFloor method.

FastRandom is the Random generator as it is implemented in Mono; after testing, it appeared that the previous Xor-shift based approach had in fact become slower than the default Random implementation of the latest versions of .net. To my surprise, Mono's implementation is even faster than that.
Being a derived class from Random, all the extensions included in Duality apply to this class as well.

MultiSpacePoint is a struct used extensively by the UI plugin to manage Widgets. It's simply used to keep track of a point coordinates in different spaces (Scene space, World space, and UV space). Don't know if it could be useful outside of the plugin, but it's there.

Utilities, as the name implies, contains a bunch of general-purpose methods. At the moment it contains a IsDualityEditor property to determine if the plugin is currently being executed inside the Editor, and a DrawCross method to draw a cross using Canvas (since it was removed in Duality).

Core.Commands namespace
Commands are a group of classes that work in conjunction with the Commander Component in order to assign, you guessed it, Commands, to a GameObject. These Commands are executed in sequence by the Commander they are assigned to and can be synchronized between GameObject by using specific control Commands.
Commands can be simple Commands or TimedCommands. The difference is that Commands are executed immediately and terminate in the frame they are started, while TimedCommands take a number of frames to complete their execution. This duration can be set absolutely, or it can depend on the desired speed and "length" of the Command.

The list of Commands available for now is:
  • ColorizeSprite: timed - changes the ColorTint of a SpriteRenderer until the desired Color is reached.
  • Destroy: instantaneous - destroys the GameObject.
  • Move: timed - moves the GameObject to the desired absolute or relative position.
  • Rotate: timed - rotates the GameObject to the desired absolute or relative angle.
  • Scale: timed - scales the GameObject to the desired absolute or relative (to itself) scale factor.
  • Signal: instantaneous - sets a flag to the Commander, so that it can be read by other Commanders for synchronization purposes.
  • Wait: timed - does nothing for the desired time.
  • WaitFor: timed - does nothing until the target Commander sets the correct Signal flag, or the target Commander has no more Commands to execute.

In addition, a ParallelCommand can be used to perform a number of Commands at the same time, with the exception of Wait, WaitFor or ParallelCommands; the ParallelCommand is considered complete when all its subcommands are complete.

New Commands can be added by deriving the base Command or TimedCommand class.

Core.Components namespace

There are a number of Components available, though not all of them are actually useful at the moment.
BaseInputReceiver and InputReceiverVisual are two abstract classes that can be used in conjunction with InputController to directly control a GameObject using Keyboard and Mouse events. The selection of the GameObject to control is currently done via Camera Picking so it's not exactly the best solution, although it doesn't have a huge impact on the performances.

Commander, as described before, is the component in charge of managing Commands.

VisualTreeHideris a Component that can Activate or Deactivate all ICmpRenderers in the Scene tree, starting from the GameObject where it is instanced at; it can be used, for example, to show or hide an entire branch of the Scene without travelling it by hand. Note that all the other Components in the tree remain active so that they can continue with their execution.

Core.Data namespace
Ranges are a group of classes deriving from the base Range class, made with the goal to allow you to specify a Min-Max range of values for the following types: IntegerRange, FloatRange, Vector3Range and ColorRange. Once a Range is instanced, you can use it to get a random value inside the Range, or a lerp (linearly interpolated) value, given a key between 0 and 1.

Map<K, V> is a generic data structure modeled as a double dictionary where each key-value pair can be searched both by Key or Value. Of course this means that both the Keys set and Values set must contain only unique values.

Core.Extensions namespace
Here there are a number of extensions methods available such as:
  • Camera.FadeTo: creates a fade effect to the Camera by adding a rectangular SpriteRenderer at the Camera's FocusDistance and making it fade from one color to the other (i.e. fade from Black to Transparent to fade in, from Transparent to Black to fade out); the sprite is destroyed afterwards.
  • Camera.FocusOn: alters the Camera's XY position and FocusDist in order to show all the desired area in the screen's viewport. Camera's Z remains fixed.
  • Camera.LookAt: alters the Camera's XYZ position in order to show all the desired area in the screen's viewport. Requires the target Z position.
  • ColorRgba.ToFloatArray: converts the color to an array of float whose values are in the range 0...1.
  • ColorRgba.ToVector4: converts the color to a Vector4 whose values are in the range 0...255.
  • GameObject.FindAncestorWithComponent<T>: returns the first ancestor in the Scene tree with a Component of type T or null if not found.
  • OpenTK.Rect.Expand: returns a Rect whose sides were extended by the specified amount in each direction.

Core.Geometry namespace
Contains utility classes to model Circles, Segments and Polygons; mostly used in the procedural plugin.

Author:  SirePi [ 2014/12/05, 16:04 ]
Post subject:  Re: [RELEASED] Frozen Core plugin - now with nuGet


The FX plugin allows you to add Particle and Lightning emitters to the Scene. Both these Components do not require a Transform by themselves, but their effects are visible inside specific FXArea Components, which in turn can be positioned and rotated as desired.

A Particle Emitter lets you specify a number of properties such as the minimum and maximum number of particles active, the initial velocity, direction, rotation and scale ranges as well as the velocity, rotation and scale ranges that will be applied to the particles when generated; in addition you will be able to specify the starting and ending colors, the time to live range for the particles, and if particles off screen should be drawn or not.

A Lightning emitter, on the other hand, lets you specify the color, sway, and thickness of the bolts, as well as the time to live of each bolt, and the emit frequency.

All FXAreas are centered around the GameObject's Transform and, in particular, can be one of the following:
  • FXCircle: it's a flat, circular area with a defined Radius.
  • FXCube: it's not exactly a cube, but a cuboid area, with a defined Height, Width and Depth.
  • FXPoint: simply a point.
  • FXRectangle: it's a flat, rectangular area with a defined Width and Height.
  • FXSphere: it's a spherical area with a defined Radius.
The idea for Sphere and Cube have been shamelessly stolen from Adam's sample game :mrgreen:

Please note that, although Cube and Sphere are three-dimensional areas, all particles generated will move only in 2D (i.e. XY movement only; Z will remain constant).

And finally, this is what happens when you set them up as shown in the pictures above:
ParticleEmitter targeting an FXCube and Lightning going from an FXPoint to an FXSphere
Gfycat Video - Click to Play. [Source]

Author:  SirePi [ 2014/12/05, 16:04 ]
Post subject:  Re: [RELEASED] Frozen Core plugin - now with nuGet

The UI plugin consists of a collection of Widgets Components, managed by a WidgetController (which is quite similar to the Core.InputController), but instead of using Camera picking to determine which Widget is currently being selected, works by verifying if the mouse position is inside the ActiveArea (more on that later) of one or more Widgets and, if yes, it picks the one closer to the Camera.

Widgets can be easily extended and modified, as they allow to override basically every event (MouseEnter, MouseLeave, KeyUp, KeyDown, etc..) as well as Drawing and Picking code.
And since each one of them has its own Transform property, they can be placed everywhere in the Scene, as well as scaled, moved, rotated and still work properly.

Currently the following Widgets are available as Skinned Widgets:
  • Button
  • CheckButton
  • CommandGrid: think of this as the FinalFantasy battle command interface.. a list of commands that you can navigate via keyboard. It requires to be focused manually as it doesn't react to mouse input.
  • DropDownButton: aka Combobox
  • ListBox
  • Panel
  • ProgressBar: Value goes from 0 to 100.
  • RadioButton: you need to define the correct RadioGroup in order to correctly group the RadioButtons together
  • ScrollBar
  • TextBlock: a long, scrolling block of text
  • TextBox
  • Window

SkinnedWidgets require a Skin, which is a specific Resource that defines which parts of a Texture have to be used for the 4 states of a Widget:
  • Normal
  • Hover
  • Active
  • Disabled
Other than the basic Skin for the Widget, certain Widgets require also other skins, in order to compose the various sub-widgets; for example, a ScrollBar requires a Skin for the ScrollBar, one for the Increase Button, one for the Decrease Button and one for the Cursor. A TextBlock will require a Skin for itself, plus all the Skins required by the ScrollBar.
Being Resources, they can easily be shared between Widgets and, if properly done (i.e. all coming from the same texture) won't add overhead to the drawing as they can all be managed in the same batch.

In addition, certain Widgets lets you assign a Script Resource, which is basically the code that should be executed when an event happens (LeftClick, RightClick, ...). Since this is a case-by-case situation, Scripts have to be manually created in the game plugin by inheriting the base Script class.

Finally, it is necessary to add a WidgetController to the main Camera in order to be able to control the Widgets.

This is a small example of what can be done:

and this is the project used to generate the form depicted above

Author:  SirePi [ 2014/12/05, 16:04 ]
Post subject:  Re: [RELEASED] Frozen Core plugin - now with nuGet

The Procedural plugin is a little unorthodox, since it's not a Duality plugin per-se but instead uses some the Core classes to provide a set of new classe that deal with noise generation and combination, and triangulation.

Noise namespace
a Noise generator is a class that generates a 2D matrix of float values that can be used for anything you want (for example, heightmap, or textures, or even just the values as they are). Each Noise generator contains an integer Seed property that can be used to recreate the exact Noise whenever you need it.

Once you defined your Noise, you can call the Generate method, which takes a Width and Height parameters, that will then be used to compute one noise value for each of the cells of the matrix defined as [Width][Height]. This also means that your Noise can be stretched (hopefully) without issues :)

CellNoise generates noise based on a Voronoi tessellation of the plane; a number of Distance functions such as Euclidean (the default used by Voronoi diagrams), EuiclideanSquared, Quadratic, Manhattan, Chebychev, and Minkowsky are already predefined. In addition, you can always define your own Distance function (just take care not to make it so that it becomes impossible to use for determining the "nearest" site point).
A Site is one of the points that are used to define the tessellation; the list of Sites can be generated starting by a numeric Seed or assigned manually.
CellNoises can be configured in order be tileable (Wrapping).

SimplexNoise generates noise based on the Simplex Perlin algorithm. It lets the user define values such as the number of Octaves, Gain, Lacunarity, and the starting Frequency and Amplitude.
SimplexNoises can always be tiled.

ColoredNoise is a work in progress where I plan to allow the generation of White, Pink and Brown noises. Currently, only White noise is supported.
ColoredNoises can always be tiled.

On the other hand, a Combination is a special case of Noise where it doesn't generate noise by itself, but it can combine one or two Noise generators to obtain more complex noises at the end. The resulting Noise is the combination "cell by cell" of the input Noise(s)
The available Combinations (given 2 noises: a and b) are:
  • Add: returns a + b
  • Max: returns max(a, b)
  • Min: returns min(a, b)
  • Multiply: returns a * b
  • Normalize: changes all points of a so that they are in the required [min, max] range (defaults to [0-1])
  • Not: returns 1 - a
  • Subtract: returns a - b
In addition, Add, Max, Min, Multiply and Subtract allow to use a float value instead of Noise b.

Being a Combination a Noise itself, you can have complex chains like
Noise result = Normalize(Max(Add(a, b), Not(Min(b, 0.5f))));

Finally, a Noise provides a convenient ToBitmap method you can use to generate a Bitmap for use, for example, as the source of a Pixmap in Duality.

CellNoise also provides a SitesToBitmap which can be used to generate a Bitmap based on which Site is assigned to each pixel, instead of the Value of the pixel itself. See below for an example of how the Distance function affects the noise generation.

One special note: I think it's better to always apply a Normalize combination or call the Normalize method of a Noise before starting to use it: that way you can be sure that there won't be values outside the bounds you expect.

Triangulation namespace
This is nothing special, as it simply is a small refactoring and cleanup of the Unity-based csDelaunay library (here), which in turn is a porting of the actionscript library as3delaunay (here); everything is accessible from the Voronoi class.

This, in conjunction with the Procedural.Graph class allows for the generation of Delaunay triangulation, convex hull, spanning tree and some other graph-related functions.

For example, you can do something like this with a small class :D
Gfycat Video - Click to Play. [Source]

Author:  Adam [ 2014/12/05, 16:27 ]
Post subject:  Re: [RELEASED] Frozen Core plugin - now with nuGet

Awesome :D Will take a look when I get around to it. The icons are quite nice, too.

Edit: By the way, maybe you should submit a "Bump! New stuff" posting when you edit those placeholders, so everyone can see that you added new content.

Author:  SirePi [ 2014/12/09, 15:19 ]
Post subject:  Re: [RELEASED] Frozen Core plugin - now with nuGet

Core explained
FX explained

Author:  SirePi [ 2014/12/11, 11:18 ]
Post subject:  Re: [RELEASED] Frozen Core plugin - now with nuGet

Updated FX package with FXCube fixes

Author:  SirePi [ 2014/12/11, 14:00 ]
Post subject:  Re: [RELEASED] Frozen Core plugin - now with nuGet

All packages updated with the correct dependencies. Sorry for the issues guys

Author:  SirePi [ 2014/12/12, 11:37 ]
Post subject:  Re: [RELEASED] Frozen Core plugin - now with nuGet

Fixed a wrong information on Lightning emitter, and pictures! and a video!

Page 1 of 6 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group