1. I swear the Germans are mocking me... C_STRUCT aiMeshAnim** mMeshChannels (what?)

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.

new topic     » topic index » view message » categorize

2. Re: I swear the Germans are mocking me... C_STRUCT aiMeshAnim** mMeshChannels (what?)

ssallen said...

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.

ssallen said...

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: I swear the Germans are mocking me... C_STRUCT aiMeshAnim** mMeshChannels (what?)

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?

new topic     » goto parent     » topic index » view message » categorize

4. Re: I swear the Germans are mocking me... C_STRUCT aiMeshAnim** mMeshChannels (what?)

ssallen said...

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

new topic     » goto parent     » topic index » view message » categorize

5. Re: I swear the Germans are mocking me... C_STRUCT aiMeshAnim** mMeshChannels (what?)

Ohhhh, I get it. Thanks for the Eu code, that simplified it greatly.

new topic     » goto parent     » topic index » view message » categorize

6. Re: I swear the Germans are mocking me... C_STRUCT aiMeshAnim** mMeshChannels (what?)

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. 
 
 
new topic     » goto parent     » topic index » view message » categorize

7. Re: I swear the Germans are mocking me... C_STRUCT aiMeshAnim** mMeshChannels (what?)

ssallen said...

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

new topic     » goto parent     » topic index » view message » categorize

8. Re: I swear the Germans are mocking me... C_STRUCT aiMeshAnim** mMeshChannels (what?)

Awesome, thanks everyone!

Steve A.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu