Start a new topic

Vertex Color

Original Post by: Tue Dec 9 12:25:20 2014


I want to change vertex alpha to 10, used followed code but its not working.


static mgbool vertexClrApply (mgrec* db, mgrec* parent, mgrec* rec, void* verclr)

{

toolrec* toolRec = (toolrec*)verclr;


unsigned int valp = 10;

if (mgGetCode(rec) == fltVertex)

{

mgSetAttList(rec,fltVAlpha,&valp;,MG_NULL);

}

return MG_TRUE;

}


any idea why?


Original Post by: SteveThompson Wed Dec 10 17:33:10 2014


Ah, I think I might know what is going on.


When you call mgWalk the default is for mgWalk to NOT visit vertices. You must add the MWALK_VERTEX flag. If you don't your walk function won't be called for fltVertex nodes. Since the code is not being called, the vertex nodes are not being changed!


If this is the only flag you want to set just write this:

mgWalk (db, preAction, postAction, toolRec, MWALK_VERTEX);


If you want to set multiple flags, write this:

mgWalk (db, preAction, postAction, toolRec, MWALK_ON | MWALK_VERTEX);


The flags I chose in the example are just examples. You put the flags you want in your code.


Did you ever get the debugger going? If so, then you could set a break in the walk function to make sure the code is being called. If you don't have the mgWalk flags correctly, this code will never "break" in the debugger and you would get a clue as to what the problem might be.


As your questions are getting pretty involved (the UNDO question specifically) you will ABSOLUTELY NEED THE DEBUGGER to do your job. So, again, please consider using it. Thanks.

Original Post by: Wed Dec 10 17:13:02 2014


This vertex alpha problem might be similar. So please help us to distinguish between the two problems:


1) the vertex value is not updated on the attribute page

2) the vertex value is correct but the face is not drawing as you expect


Yeah I checked in Attributes page of vertices, its not showing any change.

Original Post by: SteveThompson Wed Dec 10 15:34:17 2014


In the other thread

support/discussions/topics/2182

we suggested some strategies when you find that an attribute is not being applied like you expect.


From that thread we suggested that you first look at the vertex attribute page. Is the value being change there?


As we said in the other post, the value might be the value you expect but the graphic view is not drawing as you think it should. I am trying to understand which of these two problems you are really having. As was the case with vertex color (in the other post) the value on the vertex node was correct but the vertex was not drawing as you thought it should. In that case, we learned that vertex color is only "drawn" when the face is in gouraud mode.


This vertex alpha problem might be similar. So please help us to distinguish between the two problems:


1) the vertex value is not updated on the attribute page

2) the vertex value is correct but the face is not drawing as you expect

Original Post by: Wed Dec 10 03:48:08 2014


I tried with this code but its not changing the vertex alpha. I also tried to add vertex intensity but both are not making any changes to vertices.


 

static mgbool vertexClrApply (mgrec* db, mgrec* parent, mgrec* rec, void* verclr)

{

toolrec* toolRec = (toolrec*)verclr;


if (mgGetCode(rec) == fltVertex)

{

mgSetAttList(rec,fltVIntensity,1,MG_NULL);

mgSetAttList(rec,fltVAlpha,255,MG_NULL);

}


return MG_TRUE;

}


Original Post by: SteveThompson Tue Dec 9 17:15:40 2014


We have found a workaround for this if you really want your code to be precise here on the forum. Put a space character between the "&" and the variable name. So write "& name". For some reason the & immediately preceding triggers some special character handling in the forum software. & is a token used in HTML to mean something so I am guessing it has something to do with that. Anyway, just stick a space between as in:


mgGetAttList (vertex, fltVAlpha, & value, MG_NULL);


And don't worry about this in C because the space won't affect the compiler's interpretation of what you are writing. It looks a little funny but will still compile and run ok.

Original Post by: Tue Dec 9 17:10:47 2014


Sorry, I forgot about the forum bug that puts in the semicolon whenever it finds an ampersand. I think the ampersand is your only problem.

Yeah I got it after retyping it for about 3 times ;)

Original Post by: SteveThompson Tue Dec 9 16:59:44 2014


And don't forget to check the OpenFlight API Reference page for the functions you are calling when you have problems. The reference lists the parameters and types required for each of the API functions and can be a programmers "best friend". In the case of mgSetAttList, the reference states that you need to pass the value of the attribute. For mgGetAttList, it states that you should pass the address of the value.

Original Post by: ChrisRogers Tue Dec 9 16:56:48 2014


Sorry, I forgot about the forum bug that puts in the semicolon whenever it finds an ampersand. I think the ampersand is your only problem.

Original Post by: ChrisRogers Tue Dec 9 15:19:11 2014


You are passing the address of the value rather than the value itself. Instead of 10, the function sees some large number. mgSetAttList is not like mgGetAttList in that it expects the actual values rather than pointers. Try removing the & in front of valp in your code.


You also have a semicolon in your parameter list. The compiler should be throwing an error for that. Also remove the ; after valp.

Login to post a comment