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


C++ g3d::Ray类代码示例

本文整理汇总了C++中g3d::Ray的典型用法代码示例。如果您正苦于以下问题:C++ Ray类的具体用法?C++ Ray怎么用?C++ Ray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: intersectRay

bool ModelInstance::intersectRay(const G3D::Ray& pRay, float& pMaxDist,
		bool pStopAtFirstHit) const {
	if (!iModel) {
		//std::cout << "<object not loaded>\n";
		return false;
	}
	float time = pRay.intersectionTime(iBound);
	if (time == G3D::inf()) {
//            std::cout << "Ray does not hit '" << name << "'\n";

		return false;
	}
//        std::cout << "Ray crosses bound of '" << name << "'\n";
	/*        std::cout << "ray from:" << pRay.origin().x << ", " << pRay.origin().y << ", " << pRay.origin().z
	 << " dir:" << pRay.direction().x << ", " << pRay.direction().y << ", " << pRay.direction().z
	 << " t/tmax:" << time << "/" << pMaxDist;
	 std::cout << "\nBound lo:" << iBound.low().x << ", " << iBound.low().y << ", " << iBound.low().z << " hi: "
	 << iBound.high().x << ", " << iBound.high().y << ", " << iBound.high().z << std::endl; */
	// child bounds are defined in object space:
	Vector3 p = iInvRot * (pRay.origin() - iPos) * iInvScale;
	Ray modRay(p, iInvRot * pRay.direction());
	float distance = pMaxDist * iInvScale;
	bool hit = iModel->IntersectRay(modRay, distance, pStopAtFirstHit);
	if (hit) {
		distance *= iScale;
		pMaxDist = distance;
	}
	return hit;
}
开发者ID:rexy,项目名称:ArkCORE,代码行数:29,代码来源:ModelInstance.cpp

示例2: intersectRay

    bool ModelInstance::intersectRay(const G3D::Ray& pRay, float& pMaxDist, bool pStopAtFirstHit) const
    {
        if (!iModel)
        {
#ifdef VMAP_DEBUG
            DEBUG_LOG("<object not loaded>");
#endif
            return false;
        }
        float time = pRay.intersectionTime(iBound);
        if (time == G3D::inf())
        {
#ifdef VMAP_DEBUG
            DEBUG_LOG("Ray does not hit '%s'", name.c_str());
#endif
            return false;
        }
        // child bounds are defined in object space:
        Vector3 p = iInvRot * (pRay.origin() - iPos) * iInvScale;
        Ray modRay(p, iInvRot * pRay.direction());
        float distance = pMaxDist * iInvScale;
        bool hit = iModel->IntersectRay(modRay, distance, pStopAtFirstHit);
        if(hit)
        {
            distance *= iScale;
            pMaxDist = distance;
        }
        return hit;
    }
开发者ID:Agustinls,项目名称:Radical,代码行数:29,代码来源:ModelInstance.cpp

示例3: IntersectTriangle

    bool IntersectTriangle(const MeshTriangle& tri, std::vector<Vector3>::const_iterator points, const G3D::Ray& ray, float& distance)
    {
        static const float EPS = 1e-5f;

        // See RTR2 ch. 13.7 for the algorithm.

        const Vector3 e1 = points[tri.idx1] - points[tri.idx0];
        const Vector3 e2 = points[tri.idx2] - points[tri.idx0];
        const Vector3 p(ray.direction().cross(e2));
        const float a = e1.dot(p);

        if (abs(a) < EPS)
        {
            // Determinant is ill-conditioned; abort early
            return false;
        }

        const float f = 1.0f / a;
        const Vector3 s(ray.origin() - points[tri.idx0]);
        const float u = f * s.dot(p);

        if ((u < 0.0f) || (u > 1.0f))
        {
            // We hit the plane of the m_geometry, but outside the m_geometry
            return false;
        }

        const Vector3 q(s.cross(e1));
        const float v = f * ray.direction().dot(q);

        if ((v < 0.0f) || ((u + v) > 1.0f))
        {
            // We hit the plane of the triangle, but outside the triangle
            return false;
        }

        const float t = f * e2.dot(q);

        if ((t > 0.0f) && (t < distance))
        {
            // This is a new hit, closer than the previous one
            distance = t;

            /* baryCoord[0] = 1.0 - u - v;
            baryCoord[1] = u;
            baryCoord[2] = v; */

            return true;
        }
        // This hit is after the previous hit, so ignore it
        return false;
    }
开发者ID:Sar777,项目名称:server,代码行数:52,代码来源:WorldModel.cpp

示例4: intersect

 void ModelContainer::intersect(const G3D::Ray& pRay, float& pMaxDist, bool pStopAtFirstHit, G3D::Vector3& /*pOutLocation*/, G3D::Vector3& /*pOutNormal*/) const
 {
     IntersectionCallBack<SubModel> intersectCallback;
     NodeValueAccess<TreeNode, SubModel> vna = NodeValueAccess<TreeNode, SubModel>(getTreeNodes(), iSubModel);
     Ray relativeRay = Ray::fromOriginAndDirection(pRay.origin() - getBasePosition(), pRay.direction());
     iTreeNodes[0].intersectRay(pRay, intersectCallback, pMaxDist, vna, pStopAtFirstHit, false);
 }
开发者ID:3raZar3,项目名称:fucked,代码行数:7,代码来源:ModelContainer.cpp

示例5: mdl_box

/*
{
    ModelList::const_iterator it = model_list.find(info.Displayid);
    if (it == model_list.end())
        return false;

    G3D::AABox mdl_box(it->second.bound);
    // ignore models with no bounds
    if (mdl_box == G3D::AABox::zero())
    {
        VMAP_ERROR_LOG("misc", "GameObject model %s has zero bounds, loading skipped", it->second.name.c_str());
        return false;
    }

    iModel = ((VMAP::VMapManager2*)VMAP::VMapFactory::createOrGetVMapManager())->acquireModelInstance(sWorld->GetDataPath() + "vmaps/", it->second.name);

    if (!iModel)
        return false;

    name = it->second.name;
    //flags = VMAP::MOD_M2;
    //adtId = 0;
    //ID = 0;
    iPos = Vector3(go.GetPositionX(), go.GetPositionY(), go.GetPositionZ());
    iScale = go.GetObjectScale();
    iInvScale = 1.f / iScale;

    G3D::Matrix3 iRotation = G3D::Matrix3::fromEulerAnglesZYX(go.GetOrientation(), 0, 0);
    iInvRot = iRotation.inverse();
    // transform bounding box:
    mdl_box = AABox(mdl_box.low() * iScale, mdl_box.high() * iScale);
    AABox rotated_bounds;
    for (int i = 0; i < 8; ++i)
        rotated_bounds.merge(iRotation * mdl_box.corner(i));

    this->iBound = rotated_bounds + iPos;
#ifdef SPAWN_CORNERS
    // test:
    for (int i = 0; i < 8; ++i)
    {
        Vector3 pos(iBound.corner(i));
        if (Creature* c = const_cast<GameObject&>(go).SummonCreature(24440, pos.x, pos.y, pos.z, 0, TEMPSUMMON_MANUAL_DESPAWN))
        {
            c->setFaction(35);
            c->SetObjectScale(0.1f);
        }
    }
#endif

    return true;
}

GameObjectModel* GameObjectModel::Create(const GameObject& go)
{
    const GameObjectDisplayInfoEntry* info = sGameObjectDisplayInfoStore.LookupEntry(go.GetDisplayId());
    if (!info)
        return NULL;

    GameObjectModel* mdl = new GameObjectModel();
    if (!mdl->initialize(go, *info))
    {
        delete mdl;
        return NULL;
    }

    return mdl;
}
*/
bool GameObjectModel::intersectRay(const G3D::Ray& ray, float& MaxDist, bool StopAtFirstHit) const
{
    float time = ray.intersectionTime(iBound);
    if (time == G3D::inf())
        return false;

    // child bounds are defined in object space:
    Vector3 p = iInvRot * (ray.origin() - iPos) * iInvScale;
    Ray modRay(p, iInvRot * ray.direction());
    float distance = MaxDist * iInvScale;
    bool hit = iModel->IntersectRay(modRay, distance, StopAtFirstHit);
    if (hit)
    {
        distance *= iScale;
        MaxDist = distance;
    }
    return hit;
}
开发者ID:aikon-com-cn,项目名称:Infinity-Core,代码行数:86,代码来源:GameObjectModel.cpp

示例6: intersectRay

bool ModelInstance::intersectRay(const G3D::Ray& pRay, float& pMaxDist, bool pStopAtFirstHit) const
{
    if (!iModel)
        return false;

    float time = pRay.intersectionTime(iBound);
    if (time == G3D::inf())
        return false;

    // child bounds are defined in object space:
    Vector3 p = iInvRot * (pRay.origin() - iPos) * iInvScale;
    Ray modRay(p, iInvRot * pRay.direction());
    float distance = pMaxDist * iInvScale;
    bool hit = iModel->IntersectRay(modRay, distance, pStopAtFirstHit);
    if (hit)
    {
        distance *= iScale;
        pMaxDist = distance;
    }
    return hit;
}
开发者ID:Phentora,项目名称:OregonCore,代码行数:21,代码来源:ModelInstance.cpp

示例7: intersectRay

bool GameObjectModel::intersectRay(G3D::Ray const& ray, float& maxDist, bool stopAtFirstHit, PhaseShift const& phaseShift, VMAP::ModelIgnoreFlags ignoreFlags) const
{
    if (!isCollisionEnabled() || !owner->IsSpawned())
        return false;

    if (!owner->IsInPhase(phaseShift))
        return false;

    float time = ray.intersectionTime(iBound);
    if (time == G3D::finf())
        return false;

    // child bounds are defined in object space:
    Vector3 p = iInvRot * (ray.origin() - iPos) * iInvScale;
    Ray modRay(p, iInvRot * ray.direction());
    float distance = maxDist * iInvScale;
    bool hit = iModel->IntersectRay(modRay, distance, stopAtFirstHit, ignoreFlags);
    if (hit)
    {
        distance *= iScale;
        maxDist = distance;
    }
    return hit;
}
开发者ID:welder1976,项目名称:TrinityCore,代码行数:24,代码来源:GameObjectModel.cpp


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