1. I swear the Germans are mocking me... C_STRUCT aiMeshAnim** mMeshChannels (what?)
- Posted by ssallen Mar 07, 2013
- 1244 views
Ok, I working on porting the ASSIMP library to openEuphoria for all its 3d model loading goodness. Everything was going swimmingly until I came upon this abomination:
struct aiAnimation { C_STRUCT aiString mName; double mDuration; .. Snipped .. unsigned int mNumMeshChannels; C_STRUCT aiMeshAnim** mMeshChannels; }Am I missing something or shouldn't the last line be:
C_STRUCT aiMeshAnim **mMeshChannels;
Are they the same thing and the Germans are just having a good laugh at my expense? If so, what does ** mean anyway? All the C documentation I have found online only explains *.
The aiMeshAnim struct is a structure comprised of other structures which doesn't make any sense to mean the pointer pointed to by X.
Thanks! Steve A.
2. Re: I swear the Germans are mocking me... C_STRUCT aiMeshAnim** mMeshChannels (what?)
- Posted by mattlewis (admin) Mar 07, 2013
- 1232 views
Am I missing something or shouldn't the last line be:
C_STRUCT aiMeshAnim **mMeshChannels;
Are they the same thing and the Germans are just having a good laugh at my expense?
They mean the same thing. This is a style issue. Some insist that the asterisks should be with the type, because they do, in fact, affect the type. But it is very common to see the asterisk next to the variables. It's all the same to the compiler.
If so, what does ** mean anyway? All the C documentation I have found online only explains *.
The double asterisk just means a pointer to a pointer. It's an additional level of indirection.
Matt
3. Re: I swear the Germans are mocking me... C_STRUCT aiMeshAnim** mMeshChannels (what?)
- Posted by ssallen Mar 07, 2013
- 1226 views
So if the aiMeshAnim struct looks like this:
struct aiMeshAnim { /** Name of the mesh to be animated. An empty string is not allowed, * animated meshes need to be named (not necessarily uniquely, * the name can basically serve as wildcard to select a group * of meshes with similar animation setup)*/ C_STRUCT aiString mName; /** Size of the #mKeys array. Must be 1, at least. */ unsigned int mNumKeys; /** Key frames of the animation. May not be NULL. */ C_STRUCT aiMeshKey* mKeys; }What is actually being referenced? Is it a pointer to an array of the aiMeshAnim structures?
4. Re: I swear the Germans are mocking me... C_STRUCT aiMeshAnim** mMeshChannels (what?)
- Posted by mattlewis (admin) Mar 07, 2013
- 1242 views
So if the aiMeshAnim struct looks like this:
struct aiMeshAnim { /** Name of the mesh to be animated. An empty string is not allowed, * animated meshes need to be named (not necessarily uniquely, * the name can basically serve as wildcard to select a group * of meshes with similar animation setup)*/ C_STRUCT aiString mName; /** Size of the #mKeys array. Must be 1, at least. */ unsigned int mNumKeys; /** Key frames of the animation. May not be NULL. */ C_STRUCT aiMeshKey* mKeys; }What is actually being referenced? Is it a pointer to an array of the aiMeshAnim structures?
Possibly. But not necessarily. Pointers and arrays in C are kinda interchangeable. It's possible that it's pointing to an array of pointers, but I wouldn't assume that. A pointer to a pointer is just that.
Here's an example using euphoria code (portable, 4.1 style):
-- going to create an int** atom ptr_to_ptr, ptr ptr = allocate( 4 ) poke4( ptr, 12345 ) ptr_to_ptr = allocate( sizeof( C_POINTER ) ) poke_pointer( ptr_to_ptr, ptr )
Now, ptr_to_ptr is itself a pointer, which points to ptr, which points to an integer with the value of 12345.
Matt
5. Re: I swear the Germans are mocking me... C_STRUCT aiMeshAnim** mMeshChannels (what?)
- Posted by ssallen Mar 07, 2013
- 1214 views
Ohhhh, I get it. Thanks for the Eu code, that simplified it greatly.
6. Re: I swear the Germans are mocking me... C_STRUCT aiMeshAnim** mMeshChannels (what?)
- Posted by ssallen Mar 07, 2013
- 1271 views
Whoops, one last question and I will get out of everyone's hair.
An import function uses a bunch of flags that are Or'd together as a parameter:
aiProcess_CalcTangentSpace = 0x1, aiProcess_Triangulate = 0x8, aiProcess_JoinIdenticalVertices = 0x2, aiProcess_SortByPType = 0x8000, -SNIP- const aiScene* scene = importer.ReadFile( pFile, aiProcess_CalcTangentSpace | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_SortByPType);
Is the correct way to implement that in Eu something like this?
public constant AIPROCESS_CALCTANGENTSPACE = #0001 public constant AIPROCESS_JOINIDENTICALVERTICES = #0002 public constant AIPROCESS_MAKELEFTHANDED = #0004 public constant AIPROCESS_TRIANGULATE = #0008 public constant AIPROCESS_SORTBYPTYPE = #8000 - SNIP - atom flagbits flagbits = or_bits(or_bits(or_bits(AIPROCESS_TRIANGULATE, AIPROCESS_CALCTANGENTSPACE), AIPROCESS_JOINIDENTICALVERTICES), AIPROCESS_SORTBYPTYPE) aobj = ai_ImportFile("character.md2", flagbits) Is that correct? If so, is there a cleaner way to do it? Thanks! Steve A.
7. Re: I swear the Germans are mocking me... C_STRUCT aiMeshAnim** mMeshChannels (what?)
- Posted by jimcbrown (admin) Mar 07, 2013
- 1214 views
An import function uses a bunch of flags that are Or'd together as a parameter:
- SNIP -
Is the correct way to implement that in Eu something like this?
- SNIP - atom flagbits flagbits = or_bits(or_bits(or_bits(AIPROCESS_TRIANGULATE, AIPROCESS_CALCTANGENTSPACE), AIPROCESS_JOINIDENTICALVERTICES), AIPROCESS_SORTBYPTYPE) aobj = ai_ImportFile("character.md2", flagbits)
Is that correct? If so, is there a cleaner way to do it?
Thanks!
Steve A.
Yes. There is a cleaner way though - or_all() in std/math.e
8. Re: I swear the Germans are mocking me... C_STRUCT aiMeshAnim** mMeshChannels (what?)
- Posted by ssallen Mar 07, 2013
- 1234 views
Awesome, thanks everyone!
Steve A.