getting normal in channeldata



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 15/10/2007 at 14:10, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R10 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Hi!

    I'm trying to write a shader and therefor I need the normal of a surfacepoint.

    > _
    > Vector Shader::Output(PluginShader *sh, ChannelData *sd)
    > {
    > if(sd- >vd != NULL)
    > {
    >     Vector vector1 = sd->n;
    >     Vector vector2 = sd->vd->orign;
    >     Vector vector3 = sd->vd->n;
    >     Vector vector4 = sd->vd->GetNormal(sd->vd->op,sd->vd->sid);
    > }
    > }
    > _

    Cinema crashes at all of these variants and I am not sure what I am doing wrong. I just want the normal of the actual surface point for further computations.

    Thanks a lot for your help.

    Nice greetings,
    Manuel



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 15/10/2007 at 14:16, xxxxxxxx wrote:

    hmm, not sure what you are doing wrong but sd->n will give you the actuall surface normal (use sd->vd->n for the phong normal). Why should it crash? It´s just reading. Are you sure it´s not crashing at a different location? Definetly doesn´t make sense.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 15/10/2007 at 14:55, xxxxxxxx wrote:

    Thanks for your reply.

    I need the actual surface normal in world coordinates.
    When I load my shader into the color channel, the shader correctly returns the normal. But if I add an object with my shader as the material and I start rendering, Cinema crashes and wants to send informations to maxon.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 15/10/2007 at 15:06, xxxxxxxx wrote:

    Okay, it was my lightsource, generating the crash because I want to get the position of all light sources.

    Do you know how I can get the position of the global light if no lightsource is in my scene?

    > _
    > for(long i=0; i <bdata.numberOfLights; i++)
    > {
    > Vector light = sd->vd->GetLight(i)->link->GetMg().off;
    > }
    > _

    Thank you very much.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 15/10/2007 at 16:42, xxxxxxxx wrote:

    Hmm, I don´t know. The global light is actually two light sources that are always there. I assume they are in the list just like normal light objects, but I honestly don´t know as I never tried. :) Searching the docs should do the trick maybe.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/11/2007 at 07:29, xxxxxxxx wrote:

    Hi!

    I am having a new problem with my plugin. Perhaps you can help me.

    > Vector cam = sd- >vd->GetRayCamera()->m.off;

    This gets a Vector to my active Camera in world coordinates. Now I need this vector in the local coordinates of my surface point.
    Is there a possibility to get this vector or do I have to transform my world-vector into this local coordinate system and how can I do this? Do I only need the transformation and rotation matrix of my surface point?

    Many thanks for your help!
    Manuel



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 09/11/2007 at 11:07, xxxxxxxx wrote:

    I am not quite sure what you mean. You could build a matrix around the surface point and multiply the global point with the inverted matrix to get a local point.

    cheers,
    Matthias



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 12/11/2007 at 10:25, xxxxxxxx wrote:

    Hi Matthias,

    thank you for your reply. If I understand your answer correctly, I can't get a vector from my surface point to my camera without calculating the transformation matrix, right?
    How can I get this transformation matrix?

    Thank you,
    Manuel



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 14/11/2007 at 05:09, xxxxxxxx wrote:

    Ah, ok, to get a vector pointing from your surface to your camera is quite easy. You just subtract the surface point position from the camera position.

    cheers,
    Matthias



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 14/11/2007 at 05:25, xxxxxxxx wrote:

    Yes, but that's not my problem. The vector I get if i subtract the global camera position from the global coordinates of the surface point is right, but if I rotate this surface, the vector is the same. If I do the same in local coordinates, the vector is not always the same because the local coordinate system changes and the surface normal has another direction.

    I hope you understand what I mean, otherwise I'll paint a graphic to illustrate my problem.

    Thank you very much for your patience.
    Manuel



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 14/11/2007 at 05:53, xxxxxxxx wrote:

    It seems you want to use the tangent space of a surface point. You can do this with the surface normal and the ddu, ddv vectors. So your tangent space matrix would look like this:

    off = surface point position
    v1 = ddu
    v2 = ddv
    v3 = surface normal

    Use the GetDUDV() function to obtain the ddu, ddv vectors. Keep in mind ddu, dduv vectors depend on texture coordinates.

    If this still isn't what you are looking for then please provide an illustration of your problem.

    cheers,
    Matthias



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 14/11/2007 at 06:09, xxxxxxxx wrote:

    Hm, I not sure if this could be a solution.

    My Problem:

    If I rotate my surface, the vector to my cam is always the same vector. If you calculate the vector in local coordinates, it isn't because the local coordinate system is rotated around an angle theta, for example.
    My surface normal now should be my local y-axis. Then I need a tangent and binormal I think. Or is there an easier way of getting my vector in local coordinates?

    I hope my problem ist understandable. ;)

    Manuel



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 14/11/2007 at 06:51, xxxxxxxx wrote:

    Well, the problem for a 3D surface is that there just isn't only one defined local matrix for a surface point. There are several ways to build a local matrix for a surface point. You could use a fixed vector and build a matrix with the crossproducts of the surface normal and this fixed vector. Or use the tangent space vectors ddu, ddv.

    Btw. what are you trying to achieve, maybe there is another better solution?

    cheers,
    Matthias


Log in to reply