SDK questions.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/08/2007 at 11:24, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 10
Platform: Mac OSX ;
Language(s) : C++ ;---------
Hi,I'm developing my first C4D plugin so I'm probably going to be asking a lot of questions as I run into problems, so be for warned! ; )
My first question is how do I find out which joint a specific point is effected by?
My second question is how would I go about finding the normals of the points in a object?
Thats all for now.
Thanks.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/08/2007 at 16:08, xxxxxxxx wrote:
Don't forget to set "Show Topics" to All and then search when looking for possible solutions.
No idea on the first question so I'll answer the second.
Vertex normals are indirect quantities. They need to be calculated as the average vector of all of the polygons' normals to which the vertex (point) is attached:
From Wikipedia, the free encyclopedia:
In the geometry of computer graphics, a vertex normal at a vertex of a polyhedron is the normalized average of the surface normals of the faces that contain that vertex. The average can be weighted by the area of the face or it can be unweighted. Vertex normals are used in Gouraud shading, Phong shading and other lighting models.
With that information at hand, any source that discusses Gouraud or Phong shading (most of the text sources listed in the SDK documentation) should give code to finding the vertex normals of a polygon object.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/08/2007 at 00:12, xxxxxxxx wrote:
Quote: _My first question is how do I find out which joint a specific point is effected by?
>
> * * *
_
Take a look at the CAWeightTag an dthe CAJointObject classes in the SDK docu.
> Quote: _My second question is how would I go about finding the normals of the points in a object?
>
> * * *
_
Use the CreatePhongNormals() function of the PolygonObject class to create a normal for each point of a polygon. The function takes custom and angle based phong breaks into account. Much better than calculating your own normals.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/08/2007 at 02:23, xxxxxxxx wrote:
Quote: Originally posted by Matthias Bober on 09 August 2007
>
> * * *
>
> Use the CreatePhongNormals() function of the PolygonObject class to create a normal for each point of a polygon. The function takes custom and angle based phong breaks into account. Much better than calculating your own normals.
>
>
> * * *Hi Matthias,
What about speed of this routine? How fast is it compared to calculating one´s own normals without Phong Breaks etc.?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/08/2007 at 08:23, xxxxxxxx wrote:
@ kuroyume0161
Thanks for that info. on Gouraud or Phong shading, although I know a little about normals I never knew how they calculate the Phong and Gouraud shading for an object.Yes I did look up normals in the SDK documentation and there seems to be a couple of ways of getting an objects normals. It might help to know that I'm making an exporter for C4D, or what the SDK calls a Filter, and that the program I'm trying to export to wants the normal of each point in an object, which is fine. But when I try to get an objects normals in C4D it gives me an array. This is what the SDK documentation says the array contains "The array contains 4*GetPolygonCount() vectors, one for each point of each face (including the unused fourth point of a triangle)". Now the last couple of times I've tried exporting I have been skipping the forth vector, maybe that's what's casing the problem? What I'd really like is a function that goes through each point and gets the normal for that point, but until I find that function or find what the problem is I'll just have to take the x,y, and z vector of a point and normalize it and use that as the normal, which seems to work fine, but I'd rather get the normals from C4D so that the model looks the same in both programs.
@ Matthias Bober
Yes, thanks a lot for that info. on CAWeightTag that was really helpful I can't believe I missed that. Thanks again.Thanks for the info. on normals Matthias that is the function I'm currently using. But like I told kuroyume0161 I'm having some problems with that function. Another problem I'm having with that function is that it gives me the normals for each point in a polygon which makes many duplicate normals for each point in an object, which I could work around but I was hoping I wouldn't have to.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/08/2007 at 09:11, xxxxxxxx wrote:
I wouldn't just normalize the x,y,z vertex coordinates. This is just the vector from the object's origin to that point which will result in incorrect vertex normals.
For CreatePhongNormals(), you could pick out the values in the array returned. First, make sure that there is a Phong tag - since it is required. You can easily add one temporarily while doing the export:
// Check for existing Phong tag Bool phongAdded = FALSE; if (!obj->GetTag(Tphong)) { if (obj->MakeTag(Tphong)) phongAdded = TRUE; else // whoops, couldn't add a Phong tag, so try the other method of calculating vertex normals } // continue on with CreatePhongNormals() ... // after processing, remove added Phong tag if (phongAdded) obj->KillTag(Tphong);
You'll probably also want to remove n-gons as CreatePhongNormals() doesn't appear to consider them. Unfortunately, it gets complex so if you never expect n-gons you might assume standard polygons.
Then you call CreatePhongNormals() to get your 4*polygoncount 'CPN' array. Create a vector 'VN' array the size of GetPointCount(). Now, you need to go through both the CPN array and the Polygon array simultaneously and fill in the VN array by vertex index. Unless you have another array to track which VN elements have already been set, you'll just fill in the same values multiple times. In the end, you'll have a single array with the vertex normals correlated to the point array. GeFree() the CPN array.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/08/2007 at 03:18, xxxxxxxx wrote:
Quote: Originally posted by 3D Designer on 09 August 2007
>
> * * *
>
>
> Hi Matthias,
>
> What about speed of this routine? How fast is it compared to calculating one´s own normals without Phong Breaks etc.?
>
>
> * * *Hi Samir,
I have no idea if it is faster compared to calculating your own normals. But it seems quite speedy to me. Also getting the normals right on your own can be quite tricky so it's no bad idea to use this function.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/08/2007 at 04:33, xxxxxxxx wrote:
thanks Matthias. I´ll do some performance tests then.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/08/2007 at 06:25, xxxxxxxx wrote:
Thanks kuroyume0161 I'll see if I can get that to work. I use BaseDocument::Polygonize() so n-gons shouldn't be a problem.
When I said that I normalize the x, y, and z vertex coordinates I left out that I first subtract the point's vector with the object's center vector and then I normalize it.