I just dowloaded MKL in intend to try its sparse BLAS, the first thing I tried was the conversion of full matrix to sparse one with MKL_SDNSCSR
Here my code:
implicit none
real::A(2,5)
integer::job(8)
INTEGER:: info,n=2,m=5
INTEGER ja(10), ia(6)
REAL acsr(10)
A(1,:)=(/1, 0 ,1,0,2/)
A(2,:)=(/2,0,0,0,1/)
job=0
job(1)=0
job(2)=1
job(3)=1
job(4)=2
job(5)=10
job(6)=1
print*,A
print*,job
call mkl_sdnscsr(job,n,m,A,m,acsr,ja,ia,info)
end
It gives the following error:
Intel MKL ERROR: Parameter 1 was incorrect on entry to MKL_SDNSCSR.
What did I did wrong?
Best
I see no problems with this example. I tried the MKL v.2020 on win64.
here is the output I obtained:
1.000000 2.000000 0.0000000E+00 0.0000000E+00 1.000000
0.0000000E+00 0.0000000E+00 0.0000000E+00 2.000000 1.000000
0 1 1 2 10 1
0 0
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
As far as I can see from OpenGL draw rectangle outline - given a proper array of vertices, GL_LINE_LOOP should draw a square.
So, I'm trying this Wavefront .obj file:
v 0.0 0.0 0.0
v 1.0 0.0 0.0
v 1.0 1.0 0.0
v 0.0 1.0 0.0
g myPlane
f 1 2 3 4
... and I would have expected x,y of (0,0) -> (1,0) -> (1,1) -> (0,1) would have provided a square. However, I'm trying this in a program which is a reduced version of the https://github.com/julianstorer/JUCE/blob/master/examples/Demo/Source/Demos/OpenGLDemo.cpp ... there it is used:
attributes.enable (openGLContext);
glDrawElements (GL_LINE_LOOP, vertexBuffer.numIndices, GL_UNSIGNED_INT, 0); //GL_TRIANGLES
attributes.disable (openGLContext);
... as C++ drawing code, and the output for the above .obj file is:
... that is - there is a diagonal line, and I have no idea how it is possible for it to end up there, if I use GL_LINE_LOOP? (there are images like this one that show that GL_LINE_LOOP should not draw a diagonal for this sequence of vertices)? So why do I get a diagonal - what could be the problem causing it, and how can I get rid of it?
Thanks to the comment by #genpfault, found that it is indeed the parser that decomposes into triangles; the parser is WavefrontObjParser.h, and it contains, among other things:
struct Face
{
Face (String::CharPointerType t)
{
while (! t.isEmpty())
triples.add (parseTriple (t));
}
Array<TripleIndex> triples;
...
... which, I guess, indicates that the original mesh is split into a new mesh...
I would very much like to create a repeating texture on a 3D object.
I tried exporting from Maya to .obj. The material file (.mtl) looks like this:
newmtl lambert10SG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
map_Kd -s 0.1 0.1 grass.jpg
Ni 1.00
the line "map_Kd -s 0.1 0.1 grass.jpg" should indicate that the texture is repeating. However this doesn't work at all. The texture doesn't show until I remove "-s 0.1 0.1". Then it gets stretched.
I tried exporting to .fbx and then convert to .c3b. Same result. Texture gets stretched.
Then I tried creating my own texture. I know that in OpenGL I would have to set texture coordinates to >1 to make the texture repeat itself. These seems to be equivalent to maxS and maxT in the texture(?).
This is my texture setup:
cocos2d::Image *textImage = new (std::nothrow) cocos2d::Image();
textImage->initWithImageFile("grass.jpg");
cocos2d::Texture2D *texture = new (std::nothrow)cocos2d::Texture2D();
texture->initWithImage(textImage);
cocos2d::Texture2D::TexParams texParam;
texParam.wrapS = GL_REPEAT;
texParam.wrapT = GL_REPEAT;
texParam.minFilter = GL_LINEAR;
texParam.magFilter = GL_LINEAR;
texture->setTexParameters(texParam);
texture->setMaxS(10.0f);
texture->setMaxT(10.0f);
sprite->getMesh()->setTexture(texture);
Texture is still stretching.
From searching the internet it seems I would be able to set texture coordinates on a 2D sprite in Cocos with the setTextureRect function. However this doesn't seem to exist for sprite3D.
Any ideas will be very much appreciated!
UPDATE:
I managed to get a texture tiling by editing the .obj file manually.
Obviously the CCObjLoader doesn't understand the line in the material file (.mtl):
map_Kd -s 0.1 0.1 grass.jpg
Removing "-s 0.1 0.1" makes the loader recognize the texture (still stretched though).
After this I had to manually change all vt coordinates in the .obj file, by multiplying with 10. Still the texture didn't repeat, until I changed the texture parameters to GL_REPEAT instead of GL_CLAMP_TO_EDGE.
cocos2d::Texture2D::TexParams texParam;
texParam.wrapS = GL_REPEAT;
texParam.wrapT = GL_REPEAT;
texParam.minFilter = GL_LINEAR;
texParam.magFilter = GL_LINEAR;
sprite->getMesh()->getTexture()->setTexParameters(texParam);
This is not a solution to my problem as such, as I would need the app to recognize when a texture should repeat automatically.
I haven't yet deciphered where texture coordinates are kept in the cocos2d structure, hence haven't been able to change these after the sprite has been loaded. A solution could be to fix the objLoader, however this is not very prone to cocos updates. Or maybe make a small .obj file fixer. None of these seems to be ideal solutions...
I'm trying to import *.x files to my engine and animate them using OpenGL (without shaders for now, but that isn't really relevant right now). I've found the format reference at MSDN, but it doesn't help much in the problem.
So - basically - I've created a file containing a simple animation of a demon-like being with 7 bones (main, 2 for the tail, and 4 for the legs), from which only 2 (the ones in the right leg) are animated at the moment. I've tested the mesh in the DXViewer, and it seems to work perfectly there, so the problem must be the side of my code.
When I export the mesh, I get a file containing lots of information, from which there are 3 important places for the skeletal animation (all the below matrices are for the RLeg2 bone):
SkinWeights - matrixOffset
-0.361238, -0.932141, -0.024957, 0.000000,
0.081428, -0.004872, -0.996669, 0.000000,
0.928913, -0.362066, 0.077663, 0.000000,
0.139213, -0.057892, -0.009323, 1.000000
FrameTransformMatrix
0.913144, 0.000000, -0.407637, 0.000000,
0.069999, 0.985146, 0.156804, 0.000000,
0.401582, -0.171719, 0.899580, 0.000000,
0.000000, -0.000000, 0.398344, 1.000000
AnimationKey matrix in bind pose
0.913144, 0.000000, -0.407637, 0.000000,
0.069999, 0.985146, 0.156804, 0.000000,
0.401582, -0.171719, 0.899580, 0.000000,
0.000000, -0.000000, 0.398344, 1.000000
My question is - what do I exactly do with these matrices? I've found an equation on the Newcastle University site (http://research.ncl.ac.uk/game/mastersdegree/graphicsforgames/skeletalanimation/), but there's only 1 matrix there. The question is - how do I combine these matrices to get the vertex transform matrix?
This post is not pretend to be a full answer, but a set of helpful links.
How to get all information needed for animation
The question is how do you import your mesh, and why do you do this. You can fight with .x meshes for a months, but this doesn't make any sense, because .x is a very basic, old and really not good enough format. You don't find many fans of .x format on StackOverflow. =)
.x file stores animation data in a tricky way. It was intended to load via set of D3DX*() functions. But, to get bones and weights from it manually, you must preprocess loaded data. Much things to code. Here is a big post, explaining how to:
Loading and displaying .X files without DirectX
Good way to do things is just switch to some mesh loading library. The most popular and universal one is Assimp. At least, look at their docs and/or source code, on how they handle loading and preprocessing, and what whey have as output. Also, here is a good explanation:
Tutorial 38 - Skeletal Animation With Assimp
So, with assimp you can stop fighting and begin animating right now. And maybe later, when you'll find idea on how it's works, you can write your own loader.
When you've got all information needed for animation
Skeletal animation is a basic topic that explained in details all around the web.
You can find basic vertex shader for animation here:
OpenGL Wiki: Skeletal Animation
Here is a explanation of how all works (but implemented in fixed-function style): Basic Bones System
Hope it helps!
Since Drop provided links that talk about the problem, and give clues on how to solve it, but don't quite provide a simple answer, i feel obliged to leave the solution here, in case someone else stumbles on the same problem.
To get the new vertex position in "bind pose"
v'(i) = v(i)*Σ(transform(bone)*W(bone,i))
where:
v'(i) - new vertex position,
v(i) - old vertex position, and
W(bone,i) - weight of the transformation.
(and of course Σ is the sum from 0 to the amount of bones in the skeleton)
The transform(bone) is equal to sw(bone) * cM(bone), where sw is the matrix found inside the SkinWeights tag, and cM(bone) is calculated using a recursive function:
cM(bone)
{
if(bone->parent)
return localTransform*cM(bone->parent);
else
return localTransform;
}
The localTransform is the matrix located inside the FrameTransformMatrix tag.
To get the new vertex position in a certain animation frame
Do the exact same operation as mentioned above, but instead of the matrix in FrameTransformMatrix, use one of the matrices inside the appropriate AnimationKey tag. Note that when an animation is playing, the matrix inside the FrameTransformMatrix tag becomes unused. Which means, you'll probably end up ignoring it most of the time.
I am trying to parse line items from "mtl" file and use the values as parameters to opengl functions.
I could use values of ambience (Ka), specular(Ks) and diffuse(Kd) using glMaterialfv. But I don't know the use for Ni (optical density), d (dissolve), illum (illumination) values given in the mtl file.
Which opengl function should be used with these values?
Any help with these line items?
....
Ni 1.000000
d 1.000000
illum 2
...
Dissolve means transparency. 1.0 means fully opaque object, 0.0 means fully transparent. You can control rendering of transparent objects by using functions like glBlendFunc().
For a full definition of mtl files, including illum, please see http://people.sc.fsu.edu/~jburkardt/data/mtl/mtl.html.
Ni seems to be unsupported and can be ignored.