Use the Fastai-PythorchVR Sample

In this section we are going to go throughhow to use, set the sample for your needs. What parameters you can change, to get a better visualization. How to add/change texts. How to load the images.

You can find the file we need here : ...\ApertusVR\plugins\jsAPI\nodeJsPlugin\js\api\index.js In this file there is a function called'/setfastai', function (req, res, next). This function handles all that we need.

First of all we will need the outermost else. In this section we get the image file names, and we create planes for them, and two coordiante axes.

  1. First we need a parentnode, we will call it 'xBox' (we are going to be using box objext for the x and y axes)

  2. We set the position of the parentnode, now to -20, 0, 10 = x,y,z

  3. Then we create the box with the name 'xAxis', we set it's dimension to 0.2, 200, 0.2 (it goes from bottom to top)

  4. Then we set it's parentnode to the one we created

  5. We color it with Manualmaterial, that we can create similalry, it's name will be 'xmat', and it will be red (1,0,0 RGB), after we creaated it we can add it to the box.

  6. Next we create Text so we can see what the axis represents, we will need a parentnode for that too(we create it the same way as before).

  7. createText() needs a string parameter, that will be it's name, and by default it will be the text displayed by it. You can change it with the setCaption() function.

  8. After this we have an x axis, you can create a y and/or a z axis likewise, but you must give them different names.

After the axis creation there is a for cycle that loads the images. This function '/setfastai' will be called with the data in req.body. The function need an 'IDs' field in the data, that contains the file names. or the file paths.

As you can see we start of by creating a parentnode again. After the we create a manualMaterial and a fileTexture. The createFileTexture function must be called with the file name. Unlike for the axis, now we don't give an RGB color but the fileTexture to the manualMaterial. After all of this is ready, the only thing left is to create the plane that will conain the image. It need 3 parameters, but we only need to care about size. You can set the other 2 to (1,1). We set the planes parentnode, and it's material.

Now we are ready, all the images are loaded, and displayed. The only problem is that they are in the same space. The outermost if takes care of moving the images to their appropriate positions.

In the branch first we check if all data that that we need is provided. Namely x, y, z positions.

If everything is there, we move on to go through all that positions, and put the planes(with the images) their corresponding place. The position data must be in the same order as the image paths/file names.

The first 3 lines are the most important. The coordinates are calculated outside of Apertus. As I mentioned above x, y, z positions will be sent from the model. So it is up to you how you calculate them. In this example we use a very basic calculation, because of this the images can have almost identical positions. For better visual we multiply the values, so we can see structures, and groups bettter. You can change these values to whatever you like. After that we just simple set the parentnodes' positions to the right spot. We set them by name in the same order we got the filenames.

If you don't use full paths just file names, then you need to place your files in this directory ...\ApertusVR\macros\sceneMaker\resources