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


C++ NxScene::raycastAllShapes方法代码示例

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


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

示例1: MsgReceive

hsBool plLOSDispatch::MsgReceive(plMessage* msg)
{

    plLOSRequestMsg* requestMsg = plLOSRequestMsg::ConvertNoRef(msg);
    if (requestMsg)
    {
        plProfile_BeginTiming(LineOfSight);

        plSimulationMgr* sim = plSimulationMgr::GetInstance();

        plKey worldKey = requestMsg->fWorldKey;
        if (!worldKey)
        {
            plArmatureMod* av = plAvatarMgr::GetInstance()->GetLocalAvatar();
            if ( av && av->GetController() )
                worldKey = av->GetController()->GetSubworld();
        }

        hsPoint3 from = requestMsg->fFrom;
        hsPoint3 at = requestMsg->fTo;

        // requests are always sent in world space, but they might
        // need to be converted to subworld space
        hsMatrix44 l2w, w2l;
        if (worldKey)
        {
            plSceneObject* so = plSceneObject::ConvertNoRef(worldKey->ObjectIsLoaded());
            if (so)
            {
                l2w = so->GetLocalToWorld();
                w2l = so->GetWorldToLocal();
                from = w2l * from;
                at = w2l * at;
            }
        }
        else
        {
            l2w.Reset();
            w2l.Reset();
        }

        NxScene* scene = sim->GetScene(worldKey);

        gMyReport.InitCast(requestMsg->GetRequestType(), requestMsg->GetTestType());

        hsVector3 norm = hsVector3(at - from);
        float dist = norm.Magnitude();
        norm.Normalize();

        NxRay worldRay;
        worldRay.dir = plPXConvert::Vector(norm);
        worldRay.orig = plPXConvert::Point(from);
        //PhysX will complain to log if ray distance is less than or equal to Zero, besides shouldn't  bother throwing 
        // a point, and if we have negative we have some serious problems
        if(dist>0.0f)
        {
            scene->raycastAllShapes(worldRay, gMyReport, NX_ALL_SHAPES, 0xffffffff, dist, NX_RAYCAST_DISTANCE | NX_RAYCAST_IMPACT | NX_RAYCAST_NORMAL);
        }
        else{
            SimLog("%s sent out a LOS request with a ray length of %d.", requestMsg->GetSender()->GetName().c_str(), dist);
        }
        if (gMyReport.GotHit())
        {
            // We got a hit, save off the info
            plMessage* hitMsg = ICreateHitMsg(requestMsg, l2w);

            if (requestMsg->GetCullDB() != plSimDefs::kLOSDBNone)
            {
                // If we have a cull db, adjust the length of the raycast to be from the
                // original point to the object we hit.  If we find anything from the cull
                // db in there, the cast fails.
                float dist = gMyReport.GetDistance();
                if(dist!=0.0)
                {
                    gMyReport.InitCast(requestMsg->GetCullDB(), plLOSRequestMsg::kTestAny);
                    scene->raycastAllShapes(worldRay, gMyReport, NX_ALL_SHAPES, 0xffffffff, dist, NX_RAYCAST_DISTANCE | NX_RAYCAST_IMPACT | NX_RAYCAST_NORMAL);

                    if (gMyReport.GotHit())
                    {
                        delete hitMsg;
                        hitMsg = nil;

                        if (requestMsg->GetReportType() == plLOSRequestMsg::kReportMiss ||
                            requestMsg->GetReportType() == plLOSRequestMsg::kReportHitOrMiss)
                        {
                            ICreateMissMsg(requestMsg)->Send();
                        }
                    }
                }
                else// we are right on top of the object I assume that means we hit it
                {// since PhysX would have complained we will log it anyways. Just so we have a better idea, where this
                    //was happening previously
                    SimLog("%s sent out a LOS request. The second cast for culling was of length 0. ABORTING and assuming hit.", requestMsg->GetSender()->GetName().c_str());
                }

            }

            if (hitMsg &&
                (requestMsg->GetReportType() == plLOSRequestMsg::kReportHit ||
                requestMsg->GetReportType() == plLOSRequestMsg::kReportHitOrMiss))
//.........这里部分代码省略.........
开发者ID:cwalther,项目名称:Plasma-nobink-test,代码行数:101,代码来源:plLOSDispatch.cpp


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