当前位置: 首页>>代码示例>>C++>>正文


C++ MatrixT::Mul0方法代码示例

本文整理汇总了C++中MatrixT::Mul0方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixT::Mul0方法的具体用法?C++ MatrixT::Mul0怎么用?C++ MatrixT::Mul0使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MatrixT的用法示例。


在下文中一共展示了MatrixT::Mul0方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BackToLightMap

void FaceNodeT::BackToLightMap(const cf::PatchMeshT& PatchMesh)
{
    assert(PatchMesh.Width ==LightMapInfo.SizeS);
    assert(PatchMesh.Height==LightMapInfo.SizeT);
    assert(PatchMesh.Patches.Size()==PatchMesh.Width*PatchMesh.Height);

    assert(PatchMesh.WrapsHorz==false);
    assert(PatchMesh.WrapsVert==false);

    assert(PatchMesh.Node    ==this);
    assert(PatchMesh.Material==Material);


    // This duplicates the code of InitRenderMeshesAndMats() above!
    const Vector3fT FaceNormal  =Polygon.Plane.Normal.AsVectorOfFloat();
    const Vector3fT UxV         =cross(TI.U, TI.V);
    const Vector3fT FaceTangentU=normalizeOr0(TI.U+scale(UxV, -dot(FaceNormal, TI.U)/dot(FaceNormal, UxV)));
    const Vector3fT FaceTangentV=normalizeOr0(TI.V+scale(UxV, -dot(FaceNormal, TI.V)/dot(FaceNormal, UxV)));


    // Übertrage die Patches-Werte zurück in die LightMaps.
    for (unsigned long t=0; t<PatchMesh.Height; t++)
        for (unsigned long s=0; s<PatchMesh.Width; s++)
        {
            const PatchT&  Patch=PatchMesh.GetPatch(s, t);
            const VectorT& RGB  =Patch.TotalEnergy;

            LightMapMan.Bitmaps[LightMapInfo.LightMapNr]->SetPixel(LightMapInfo.PosS+s, LightMapInfo.PosT+t, char(RGB.x+0.49), char(RGB.y+0.49), char(RGB.z+0.49));


            VectorT Dir=normalizeOr0(Patch.EnergyFromDir);

            // Contrary to Bezier Patches, where we need code as shown in the snipped below,
            // there is no need to check Dir to not exceed a maximum angle with regard to face patches,
            // because faces are always planar and thus cannot receive energy from "behind" in the first place.
         // if (dot(Dir, Patch.Normal)<CosMaxAngle)
         // {
         //     // ...
         // }

            // Compute the Implicit Orientation Factor.
            // *** Note that this factor is already (implicitly) contained in the RGB value ***
            // *** above, because CaLight naturally computes the radiosity results so!!!    ***
            // The value is directly scaled from 0..1 to 0..255 range, and converted to int.
            int iof=int(dot(Dir, Patch.Normal)*255.0+0.49);

            if (iof<  1) iof=  1;   // Avoid divisions-by-zero in the MatSys's pixel shaders.
            if (iof>255) iof=255;

            // Transform (rotate) Dir from world-space into tangent-space.
            MatrixT RotMat;

            for (unsigned long i=0; i<3; i++)
            {
                RotMat.m[0][i]=FaceTangentU[i];
                RotMat.m[1][i]=FaceTangentV[i];
                RotMat.m[2][i]=FaceNormal  [i];
            }

            Dir=RotMat.Mul0(Dir);
         // if (Dir.z<0) Dir.z=0;   // Contrary to Bezier Patches, were this can happen and even is in order (and thus must *not* be clamped to 0!), it never occurs with faces, as it is impossible for faces to be reached by energy from behind.
            Dir=normalizeOr0(Dir);

            // Color-encode Dir and scale from 0..1 to 0..255 range.
            Dir=(Dir+VectorT(1, 1, 1))*0.5*255.0;

            LightMapMan.Bitmaps2[LightMapInfo.LightMapNr]->SetPixel(LightMapInfo.PosS+s, LightMapInfo.PosT+t,
                char(Dir.x+0.49), char(Dir.y+0.49), char(Dir.z+0.49), iof);
        }
}
开发者ID:mark711,项目名称:Cafu,代码行数:70,代码来源:FaceNode.cpp


注:本文中的MatrixT::Mul0方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。