New nub library released

Hello,

I’m pleased to let you know that I recently have released the nub library which supersedes and at the same time simplifies proscene. Please check the README for its usage and main features which include:

  1. Interaction: 2D/3D navigation, object picking & manipulation through the mouse or any other device.
  2. Rendering and animation frameworks which provides the ground to easily implement advanced effects such as shadow mapping and others.

You can import the library directly from the PDE. Please report issues you may find at the project page and discuss questions and ideas here at the discourse. Please also consider sharing your creations with nub here at the Processing discourse.

Enjoy!

7 Likes

I just saw this on GitHub… I think some screenshots either here or there would be useful

2 Likes

Hello @nakednous .
Thanks a lot for sharing and all the amazing code. Love the library.
I was wondering how could I save a bunch of keyframes and later read them from a file.
Can be done?
Can I access the internal keyFrames storing structure?
I found no way of accessing it via API. But maybe I’m just not finding it…
: )

Anyway, thanks a lot.
cheers
vk

ps: Actually I’m willing to save each frame and play it back later. I’m not using, or willing to use, the interpolation. Just the “state” of each object/eye each frame.

My first test code goes like:

if (rec) {
    scene.eye().addKeyFrame();
    master.addKeyFrame();
  } else {
    if (scene.eye().removeKeyFrame(0.0) != null) {
      master.animate();
      scene.eye().animate();
    }
  }

I’m saving this data every frame, than later I’ll play it back, saving each frame as an image.
This is necessary to keep the skecth flowing without the lag introduced by saving each frame.

Hello @vkbr,

Apologies for the delayed response. I’ve just caught up with your query.

As of now, there isn’t a built-in method to achieve what you’re looking for. However, you can create a JSON serialization process to handle this. Below is a suggested approach:

JSONObject toJSONObject(Node node, float time) {
  JSONObject jsonNode = new JSONObject();
  jsonNode.setFloat("time", time);
  jsonNode.setFloat("magnitude", node.worldMagnitude());
  jsonNode.setJSONArray("position", _toJSONArray(node.worldPosition()));
  jsonNode.setJSONArray("orientation", _toJSONArray(node.worldOrientation()));
  return jsonNode;
}

JSONArray _toJSONArray(Vector vector) {
  JSONArray jsonVec = new JSONArray();
  jsonVec.setFloat(0, vector.x());
  jsonVec.setFloat(1, vector.y());
  jsonVec.setFloat(2, vector.z());
  return jsonVec;
}

JSONArray _toJSONArray(Quaternion quaternion) {
  JSONArray jsonRot = new JSONArray();
  jsonRot.setFloat(0, quaternion.x());
  jsonRot.setFloat(1, quaternion.y());
  jsonRot.setFloat(2, quaternion.z());
  jsonRot.setFloat(3, quaternion.w());
  return jsonRot;
}

This code defines a method, toJSONObject, which converts a Node object into a JSONObject. Additionally, it includes helper methods to convert vectors and quaternions to JSONArray representations.

1 Like

What is nub, can you please explain in simple terms

1 Like

nub is a scene graph.

Hey man, thank you very much. Will implement that. :slight_smile: