Work in progress. Features may not be complete and the API may change.
This is a framework for developing 3D sketching applications in Unity.
- smoothly interpolated lines
- patch surfaces
- ribbon shaped lines
- organisation of sketch objects with groups
- undo and redo
- serialization of sketches
- OBJ export of sketches
- open the Package Manager
- click on "+"
- choose "Add package from disk..."
- locate the downloaded package
- select the package.json file within the package
- open the Package Manager
- click on "+"
- choose "Add package from git URL..."
- enter the URL
https://github.com/hunsri/VRSketchingGeometryUP.git#0.1.0
- open the Package Manager
- locate the installed package
- click on "Samples"
- click on "Import"
- files will be imported under
Assets/Samples/
Read the developer guide and API documentation at the GitHub pages site.
Alternatively, you can host these yourself too,
check out the Docs Reference for further details!
The following example script shows how to create a new line sketch object and add few control points to it using a command invoker.
At the end one command is undone.
You will have to reference a DefaultReference
Scriptable Object in the inspector.
An example can be found under SharedAssets/Assets/DefaultReferences.asset
.
To access SharedAssets
you have to import it in the Package Manager (see Import the examples)
using UnityEngine;
using VRSketchingGeometry.SketchObjectManagement;
using VRSketchingGeometry;
using VRSketchingGeometry.Commands;
using VRSketchingGeometry.Commands.Line;
public class CreateLineSketchObject : MonoBehaviour
{
public DefaultReferences Defaults;
private LineSketchObject LineSketchObject;
private SketchWorld SketchWorld;
private CommandInvoker Invoker;
void Start()
{
SketchWorld = Instantiate(Defaults.SketchWorldPrefab).GetComponent<SketchWorld>();
LineSketchObject = Instantiate(Defaults.LineSketchObjectPrefab).GetComponent<LineSketchObject>();
Invoker = new CommandInvoker();
Invoker.ExecuteCommand(new AddObjectToSketchWorldRootCommand(LineSketchObject, SketchWorld));
Invoker.ExecuteCommand(new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 2, 3)));
Invoker.ExecuteCommand(new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 4, 2)));
Invoker.ExecuteCommand(new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 5, 3)));
Invoker.ExecuteCommand(new AddControlPointCommand(this.LineSketchObject, new Vector3(1, 5, 2)));
Invoker.Undo();
}
}
- Instantiate a sketch world prefab. Easy access to prefabs is provided through the DefaultReferences asset at
SharedAssets/Assets/DefaultReferences.asset
. - Create sketch objects and groups from prefabs and add them to the sketch object world. Execute commands using a CommandInvoker object for undo and redo functionality. All scripts are in the VRSketchingGeometry namespace.
- Serialize or export using methods of the sketch world script.
- Load serialized sketch world from the serialized xml file for further editing.
The LegacyExample also shows this process in practice.
Various examples are provided under VRSketchingGeometryPackage/Samples
.
These can be imported via the Unity Package Manager.
(see Import the examples)
Contains all the assets required to run the examples. Can be used as a reference for the creation of own assets.
Contains various examples. For further details please refer to this readme.
Contains a static scene with various messy test scripts and corresponding game objects.
This is a conversion from the plugin version (https://github.com/tterpi/VRSketchingGeometry) to a package version. Originally based on code from: https://github.com/bittermanq/KochanekBartelsSplines
There are unit tests using Unity Testing Framework. (https://docs.unity3d.com/Packages/com.unity.test-framework@1.1/manual/index.html) They mostly cover the undoable commands and the generation and applying of data objects. Coverage of the unit tests should be expanded.
Before you can run the tests, you have to make sure the CommandTestScene
is added in the Build Settings
The tests are located at Assets/VRSketchingGeometryPackage/Tests
.
To do that go to "File>Build Settings..." and check if VRSKetchingGeometryPackage/Tests/Scenes/CommandTestScene
is present there.
If that's not the case you have to add it.
To run the tests you have to open the Test Runner
You can find it under "Window>General>Test Runner".
Once the Test Runner is open, click on "Play Mode".
You can then select and perform the tests of your choice!