In Qt, I added a Mesh using QSceneLoader, but I wanted to rig the mesh manually in QT using the classes from Qt3D: QJoint, QSkeleton, and QArmature. I have not seen a lot of documentation on creating a skeleton that's applied to a mesh through C++ alone.
Even without C++, I found you can give an armature value in QML, but the file needs to be a .gltf. What I want to do is use C++ directly to make a skeleton so the programming-side has full control of the bone hierarchy.
QSkeleton gives one the abilitiy to add joints and child joints, but how are these joints then applied to the mesh? If there's any examples on this that would also be a great help.
Here's what I've tried:
Qt3DCore::QSkeleton* skeleton = new Qt3DCore::QSkeleton();
Qt3DCore::QJoint* joint = new Qt3DCore::QJoint();
joint->setTranslation(entityTransform->translation());
skeleton->setRootJoint(joint);
Qt3DCore::QArmature* a = new Qt3DCore::QArmature();
a->setSkeleton(skeleton);
entity->addComponent(a);
I also have an update function where I change the joint's translation/rotation and re-apply the skeleton to the armature, but it does nothing, so I don't know if the joint/armature has been applied properly to the mesh.
Related
Is it possible to interact with the RStudio application using R code inside it? I mean interactions like opening a file in a card, creating a tab for a new unsaved file or changing some text inside an opened tab.
I know a very similar thing can be obtained by just simply creating a new text file or changing its content with R but this way it doesn't interact anyway with the RStudio app itself.
Some context: I was thinking of a tool that could automate inserting some reprexes / snippets of code which could work as a line of code that, when run from a file, replaces itself with a block of code or make a new unsaved file tab and put some code inside it. And yes, I know a very similar thing can be achieved other ways (e.g. simply copying the intended code block into the clipboard) but I'm curious and exploring the possibilities.
Thanks to the link provided by Konrad Rudolph I managed to find the answer myself.
There is a package called rstudioapi built into the RStudio that allows many different functionalities and doesn't require using plugins or addins.
All the features can be found in the official manual.
Opening a new unsaved file tab with some code in it can be obtained by running:
rstudioapi::documentNew(
"example code here",
type = "r",
position = rstudioapi::document_position(0, 0),
execute = FALSE
)
Inserting code can be easily done with insertText(text = "") which inserts text at the current position of the text cursor.
Changing one line into another can be obtained with the combination of getActiveDocumentContext(), which returns among others the document content and the selection range which is basically equivalent to the cursor position. Then the changing itself can be done with modifyRange() respectively to the cursor position and/or the document content.
That allows many possibilities including for example some smoother automation of the workflow.
As a new user of PCL, I have to work with some ply files containing a class property (in addition to the label property).
I decided to modify the library to create a new PointType which may be called PointXYZLC;
So far, I have modified
the point_types.h file by adding a struct PointXYZLC (around l.103)
the point_types.h through POINT_CLOUD_REGISTER_POINT_STRUC(pcl::PointXYZLC ...) (around l.424)
the point_types.cpp for the std::ostream part.
However, I tested by creating a cloud with the class but the library failed to recognise the new class.
Any idea for further modifications?
Thanks in advance,
I used a trick to use the existing PointType classes. I reattributed the classes into labels and used pcl::PointXYZL
As already mentioned I'm using the Atom text editor.
I'm currently working on a project written in c++. Of course it is desirable to jump to the definition of a function (in another project file), or other uses of this function (within the project). As far as I know this can be achieved with the packages I'll mention below. I want the package to display me the definition along with the path to the corresponding file which holds the definition and ideally the line where it occurs.
I'll welcome any comments and suggestions on how to solve the below mentioned problem(s) I have with (one of) the packages. Moreover I'm also thankful about pointers to possible solutions or posts concerning my problem(s), or how I can achieve this with another package.
Here is what I found / tried / did so far.
goto
Currently I'm using this package, although it is rather slow and does not show the arguments of the function as e.g. atom-ctags does, but it's the only package which displays me the files I need to see.
It shows me where the function is defined as well as where it is also used. However it does not show me the path to the file corresponding file it refers to.
atom-ctags
I also tried this package, building the tags is quite fast and moreover it show me the path to the file. But this package only lists the .cc files and not the .h files. It appears to me as if it only shows me the other uses but not the definition, which is obviously a problem.
I also tried generating the ctags myself and changing the command options in the settings of the package, unfortunately without any success.
Atoms built-in symbols-view
In order to get this to work, one needs to generate the symbols. This can be, for example, achieved with the symbol-gen package. However, it shows me some of the definitions, but also no .h files. Moreover, jumping to the definition results in a Selected file does not exist., therefore it is not usable at all.
goto-definition
Just for completeness, there is also this package. It does not work for me, since c++ is not supported but maybe others will find it useful.
symbols-plus
Again, for completeness, this should be a replacement for the atom built-in, but when disabling the build-in it does not show me any jump functionality nor is a short cut mentioned.
So, basically, nothing really works well. I have tried Symbol Tree View but it but barely works.
I imagine this is fairly straight-forward, but I admit I'm not well-versed in CMake (or Qt for that matter), so here's the problem:
I have a form that was built in Qt Designer (with a .ui file). Two classes have been created that are based on this form. Both classes have a lot of duplicated code. So, I wanted to create a base class that inherited the formname.ui file using the multiple inheritance method to manage that common code.
The problem is that I don't know how to get CMake to build it correctly. Compiling gives me the error ui_formname.h: No such file or directory.
I've identified the following elements as necessary to get CMake to buld this correctly:
set (UI_HDR ${CMAKE_SOURCE_DIR}/path/to/formname.ui)
QT4_WRAP_UI (COMPONENT_UI_HDR ${UI_HDR})
include_directories(${CMAKE_CURRENT_BINARY_DIR}) #Necessary here?
The difference between this and the other two cases is that this cmakefile is not building an executable, whereas in the other two cases, it was. It may be I'm missing something else, but the lack of an add_executable line is the most obvious difference that I can see, as the COMPONENT_UI_HDR variable would be included in that list, were it there.
Any suggestions on how to work around that?
Solved the problem. Indeed, I was right about the "add_executable" difference. Since this was a library and not an executable, I had to add a reference to the wrapped variable in the add_library call, i.e.:
add_library ( ${...} ${COMPONENT_UI_HDR} )
Compiled without a hitch...
I just started using ipython, and I'm creating figures such as:
fig, axes = plt.subplots()
xs = range(0,100)
axes.plot(xs, [x*x for x in xs], 'r')
I know that the figures can be rendered as svgs, see here. Unfortunately, the figures are always rendered as a rasterized image. The rasterized images become very ugly when I'm using the notebook's zoom feature. Is there a way to change this behavior, such that figures are displayed as svg by default?
The magic I was looking for:
%matplotlib inline
%config InlineBackend.figure_format = 'svg'
import matplotlib.pyplot as plt
Alternatively you might still want to show png but save a figure into a file:
plt.savefig(fig_filename, format='svg')
You can change the default figure format in the ipython profile configuration files. What I did was create a configuration profile especially for the notebook server, using:
ipython profile create nbserver
At the command line. This creates a whole bunch of files under ~/.ipython/profile_nbserver which have example lines for almost every setting you could want to change (it might be somewhere such as ~/.config/ipython instead depending on your OS, not sure about where it would be under windows). You need to look in the file ipython_notebook_config.py. You should then add the the line:
c.InlineBackend.figure_formats = ['svg']
Note that this only applied to IPython 3.x, and that you can also specify additional formats as per #HarrySchreiner's comment. For IPython 2.x, you should set c.InlineBackEnd.figure_format='svg'. To use this profile you should start the notebook with
ipython notebook --profile=nbserver
If this is too much trouble then don't give a profile name when running create, and modify the default profile instead.
Also, you may want to have the line
c.IPKernelApp.matplotlib = 'inline'
so that each notebook will automatically start with the matplotlib inline backend used.
Originally I also wanted to use the svg backend instead of png to enable zooming etc. However, I found that certain plots, such as pcolor with a large number of points can just kill my browser when using the svg backend. So I find it easier to use png, and just use the xlim and ylim commands to zoom in manually if I need to.
Also, you should definitely tweak the line c.InlineBackend.rc to set more reasonable defaults for the figure size and the fonts used.
edit
Current recommended best practice is not to use pylab, but to explicitly import matplotlib and numpy instead, so I modified my answer to stop encouraging this. See this post for the reasons why:
http://carreau.github.io/posts/10-No-PyLab-Thanks.html
Also, if svg rendering is too slow for particular plot elements (such as pcolor or plot_surface), you can pass the option rasterized=True to these plot commands. This means that those particular parts of the plot will have fast pixel based rendering, but all the other plot elements will be nicely vectorized.