Nibba2018's Blog

Weekly Check-in #9

Nibba2018
Published: 07/26/2020

Tab UI, TabPanel2D, Tab UI Tutorial.

Hello and welcome to my 9th weekly check-in. I will be sharing my progress with TabUI and its corresponding tutorial. The official repository of my sub-org, FURY can always be found here.

What did you do this week?

This week I finished the basic implementation of TabUI. Apart from that I was also able to finish the tutorial which showcases different features of this said UI. With the help of this UI one can have multiple panels containing different UI elements within them. The basic implementation can be demonstrated as follows:

After finishing with the basic implementation I moved on to create its tutorial. For that, I decided to combine 3 of the existing UI tutorials to be rendered with the help of Tab UI. I implemented the following in individual tabs:

  • Controlling a cube with the help of LineSlider2D and RingSlider2D.
  • Using a CheckBox to render a cylinder or a sphere or both.
  • Using ComboBox to set the color of a label.

 

The above tutorial can be demonstrated as follows:

What is coming up next?

Next week I will continue working on the Physics engine integration. Previously we were facing a problem regarding the uncontrollable spinning of objects rendered by a single actor. There must be an issue with mismatching axes alignment of FURY and pyBullet. The spinning problem is as following:

Did you get stuck anywhere?

I did get stuck with the collapsing functionality of Tab UI and the uncontrollable spinning of the bricks in the Physics simulation. Apart from that I did not face any major issues.

Thank you for reading, see you next week!!  
View Blog Post

Weekly Check-in #8

Nibba2018
Published: 07/19/2020

ComboBox2D, TextBlock2D, Clipping Overflow.

Hello and welcome to my 8th weekly check-in. I will be sharing my progress with ComboBox2D and TextBlock2D UI components. After solving TextBlock2D sizing issue, I was finally able to complete the implementation of combo box. I also faced some problems while refactoring TextBlock2D. The official repository of my sub-org, FURY can always be found here.

What did you do this week?

This week I finished the implementation of TextBlock2D and ComboBox2D. I also added necessary tests and tutorials to aid the implementation. It still needs some color design, which will be decided later on. Here's an overview of the tutorial:

 

Its a simple tutorial where I change the color of the label based on the option selected on the combo box.

Now while refactoring TextBlock2D, I noticed that the Text Overflow workaround on ListBox2D broke and started acting weird. This was mainly because the size implementation was changed and the code that I wrote a few months back wasn't relevant anymore. So I removed the previous code and had to re-implement the same. I later found out that I would be needing such an implementation for most of my UI components so I decided to create a separate method for clipping overflowing texts.

I had to figure out a specific algorithm to achieve this as the height and width of each characters were different and the combined width of multiple characters were not equal to the sum of their widths. I decided to go for a binary search implementation as it was faster compared to a simple linear checking algorithm. The said algorithm works as expected and is more effective compared to its previous implementation. I tweaked the previous combo box example to showcase this algorithm.

The extremely long text is now clipped correctly.

What is coming up next?

Next week, I have a couple of things to work on. Firstly, the single actor wall brick simulation is yet to be completed. Once I am done with that I will continue working on Tab UI and try to finish its skeletal implementation.

Did you get stuck anywhere?

I did get stuck regarding the previous implementation of Text Overflow in ListBox2D. Before the current implementation it looked something like this:

Apart from that, I did not face any major issues.

Thank you for reading, see you next week!!
View Blog Post

Weekly Check-in #7

Nibba2018
Published: 07/12/2020

Orientation, Sizing, Tab UI.

Hello and welcome to my 7th weekly check-in. I will be sharing my progress with single actor physics simulation and TextBlock2D sizing issue which was pending for quite a while now. I will also be sharing my thoughts regarding the TAB UI component. The official repository of my sub-org, FURY can always be found here.

What did you do this week?

This week I was working with the orientation problem I mentioned in my previous check-in. I did have some problems regarding it, but thanks to my mentor I was able to figure it out and implement it with the help of scipy's Quaternion to Rotation Matrix method. After understanding the orientation implementation, I spent some time regarding the design of the TAB UI component. I expect the design to be something similar as follows:

Fortunately, we have good news this week. The TextBlock2D sizing issue that we were facing for quite a while has now been fixed. We simply have to keep track of the scene parameter in the _add_to_scene method of each UI component. This scene parameter inherits vtkViewport, hence it allows us to determine the necessary details about the environment of the 3D objects.

What is coming up next?

As the sizing issue regarding TextBlock2D has been fixed, I am very much eager to finish the remaining work left. ComboBox2D and TextBlock2D were left incomplete because of the issue. Therefore, my main objective next week would be to finish them first. Once I am done with it, I will move on to Tab UI. If not, I will continue with the physics simulation.

Did you get stuck anywhere?

Apart from the orientation and sizing problem, I did not face any major issues.

Thank you for reading, see you next week!!
View Blog Post

Weekly Check-in #6

Nibba2018
Published: 07/05/2020

Translation, Reposition, Rotation.

Hello and welcome to my 6th weekly check-in. The first evaluation period officially ends and I am very excited to move on to the second coding period. I will be sharing my progress with handling specific object's properties among various multiple objects rendered by a single actor. I am mainly focusing on making it easier to translate, rotate and reposition a particular object, so that I can use them to render physics simulations more efficiently. The official repository of my sub-org, FURY can always be found here.

What did you do this week?

Last week I worked on physics simulations rendered in FURY with the help of pyBullet. Now the simulations were highly un-optimized, specially the brick wall simulation as each brick was rendered by its own actor. In other words, 1 brick = 1 actor. Now my objective was to render all the bricks using a single actor, but before jumping into the simulation I had to figure out how to modify specific properties of an individual object. Thanks to my mentor's PR, I was able to experiment my implementations quickly.

Translation:

The algorithm behind translation is to first identify the vertices of the object, then bring the vertices to the origin by subtracting their centers and then adding the displacement vector. The said operation can be achieved by the following snippet:

# Update vertices positions
vertices[object_index * sec: object_index * sec + sec] = \
    (vertices[object_index * sec: object_index * sec + sec] -
     centers[object_index]) + transln_vector

Rotation:

The algorithm behind rotation is to first calculate the difference between the vertices and the center of the object. Once we get the resultant matrix, we matrix multiply it with the rotation matrix and then we further add the centers back to it so that we preserve the position of the object. Rotation matrix can be defined as:

where gamma, beta and alpha corresponds to the angle of rotation along Z-axis, Y-axis and X-axis.

def get_R(gamma, beta, alpha):
    """ Returns rotational matrix.
    """
    r = [
        [np.cos(alpha)*np.cos(beta), np.cos(alpha)*np.sin(beta)*np.sin(gamma) - np.sin(alpha)*np.cos(gamma),
        np.cos(alpha)*np.sin(beta)*np.cos(gamma) + np.sin(alpha)*np.sin(gamma)],
        [np.sin(alpha)*np.cos(beta), np.sin(alpha)*np.sin(beta)*np.sin(gamma) + np.cos(alpha)*np.cos(gamma),
        np.sin(alpha)*np.sin(beta)*np.cos(gamma) - np.cos(alpha)*np.sin(gamma)],
        [-np.sin(beta), np.cos(beta)*np.sin(gamma), np.cos(beta)*np.cos(gamma)]
    ]
    r = np.array(r)
    return r

vertices[object_index * sec: object_index * sec + sec] = \
    (vertices[object_index * sec: object_index * sec + sec] -
     centers[object_index])@get_R(0, np.pi/4, np.pi/4) + centers[object_index]

Reposition:

Repositioning is similar to that of translation, except in this case, while repositioning we update centers with the new position value.

new_pos = np.array([1, 2, 3])

# Update vertices positions
vertices[object_index * sec: object_index * sec + sec] = \
    (vertices[object_index * sec: object_index * sec + sec] -
     centers[object_index]) + new_pos

centers[object_index] = new_pos

What is coming up next?

Currently, I am yet to figure out the orientation problem. Once I figure that out I will be ready to implement simulations without any major issues. I am also tasked with creating a wrecking ball simulation and a quadruped robot simulation.

Did you get stuck anywhere?

I did face some problems while rotating objects. My mentors suggested me to implement it via rotation matrix. I still haven't figured out the orientation problem, which I plan to work on next. Apart from these I did not face any major issues.

Thank you for reading, see you next week!!
View Blog Post

Weekly Check-in #5

Nibba2018
Published: 06/28/2020

May the Force be with you!!

Hello and welcome to my 5th weekly check-in, I will be sharing my progress of pyBullet Physics Engine Integration with FURY. The official repository of my sub-org, FURY can always be found here.

What did you do this week?

Last week due to the vtkTextActor sizing issue I was not able to continue my work with ComboBox2D UI element. Thus, I decided to work on the "Physics Engine Integration" part of my project. It took me quite a while to understand the terminology of various methods and algorithms used for detection and physics simulation. Nevertheless, I was able to create a couple of rigid body examples to showcase the integration procedure. For physics calculations we used pyBullet and for rendering we used FURY. In other words, pyBullet will handle the backend part of the simulation and FURY will handle the frontend. I have documented the entire integration process here in detail.

Ball Collision Simulation:

For the first example, I created a simple collision between two balls in which two spheres were created both in FURY and pyBullet world and then both the worlds are connected by syncing the position and orientation of the said bodies. Timer callback is created to update the positions and to simulate Physics for each step.

Brick Wall Simulation:

For the second example I tried to increase the complexity of the simulations by increasing the number of dynamic objects. Here a brick-wall is created using 100 bricks and then a ball is thrown at it. The rest of it is simulated. The same concepts from the first example is used to render the second one. Timer callback is created to update position of all the objects and to simulate Physics for each step.

What is coming up next?

In the above examples I used a separate actor for each object which is highly un-optimized. Thus, my mentor suggested me to render all the bricks using a single actor, so that the simulation is more optimized. I am not very confident in changing the position and orientation of different objects rendered by a single actor. Therefore, I will have to research a bit more about it. Apart from that I will also try to work on Constraint based simulation examples if possible.

Did you get stuck anywhere?

The pyBullet documentation isn't well written for cross rendering, hence it was a bit of a challenge for me to implement the integration. I also faced a problem regarding the offset of actors between the FURY world and pyBullet world. Both use different coordinate systems for rendering and simulation because of which I had a constant offset between the objects during simulations. I was able to fix it by converting one coordinate system to the other. Apart from this I did not have any major issues.

Thank you for reading, see you next week!!
View Blog Post