本文整理汇总了C++中Sphere::SetRadius方法的典型用法代码示例。如果您正苦于以下问题:C++ Sphere::SetRadius方法的具体用法?C++ Sphere::SetRadius怎么用?C++ Sphere::SetRadius使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sphere
的用法示例。
在下文中一共展示了Sphere::SetRadius方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetContainerBoundingSphere
void SNPointLight::GetContainerBoundingSphere(Sphere &cSphere)
{
// The sphere has always the 'range' as radius
cSphere.SetRadius(m_fRange);
// The sphere is always within the scene node origin
cSphere.SetPos(GetTransform().GetPosition());
}
示例2: CalculateSphere
/**
* @brief
* Calculates the sphere surrounding the enclosed area
*/
void PlaneSet::CalculateSphere(Sphere &cSphere) const
{
// Init sphere
cSphere.SetPos();
cSphere.SetRadius();
// Find all plane intersection points
Vector3 vD;
Array<Vector3> lstPoints;
for (uint32 nP1=0; nP1<m_lstPlane.GetNumOfElements(); nP1++) {
const Plane &cP1 = m_lstPlane[nP1];
for (uint32 nP2=0; nP2<m_lstPlane.GetNumOfElements(); nP2++) {
const Plane cP2 = m_lstPlane[nP2];
if (nP2 != nP1) {
for (uint32 nP3=0; nP3<m_lstPlane.GetNumOfElements(); nP3++) {
const Plane &cP3 = m_lstPlane[nP3];
if (nP3 != nP1 && nP3 != nP2) {
Vector3 vRes;
if (Intersect::PlanePlanePlane(cP1, cP2, cP3, vRes)) {
lstPoints.Add(vRes);
vD += vRes;
}
}
}
}
}
}
// Get sphere position and radius
if (lstPoints.GetNumOfElements()) {
vD /= static_cast<float>(lstPoints.GetNumOfElements());
cSphere.SetPos(vD);
float fMaxLength = 0.0f;
for (uint32 i=0; i<lstPoints.GetNumOfElements(); i++) {
const Vector3 &vP = lstPoints[i];
const float fLength = (vP-vD).GetLength();
if (fLength > fMaxLength)
fMaxLength = fLength;
}
cSphere.SetRadius(fMaxLength);
}
}
示例3: Render
void FlyingLayer::Render(TimeDelta real_time_delta) const {
// Draw joystick
m_Shader->Bind();
const Vector3f desiredLightPos(0, 10, -10);
const Vector3f lightPos = m_EyeView.transpose()*desiredLightPos + m_EyePos;
const int lightPosLoc = m_Shader->LocationOfUniform("lightPosition");
glUniform3f(lightPosLoc, lightPos[0], lightPos[1], lightPos[2]);
Sphere sphere;
sphere.SetRadius(0.3f);
sphere.Translation() = (m_EyeView.transpose()*Vector3f(0, 0, 1.25) + m_EyePos).cast<double>();
sphere.SetDiffuseColor(Color(1.0f, 0.5f, 0.4f, m_Alpha));
sphere.SetAmbientFactor(0.3f);
PrimitiveBase::DrawSceneGraph(sphere, m_Renderer);
m_Shader->Unbind();
glBegin(GL_LINES);
glVertex3fv(Vector3f::Zero().eval().data());
glVertex3fv(m_Velocity.eval().data());
glEnd();
//glMatrixMode(GL_MODELVIEW);
Vector3f centerpoint = m_EyePos - m_GridCenter;
//glScalef(2.0f, 2.0f, 2.0f);
glMultMatrixf(m_GridOrientation.eval().data());
glTranslatef(m_GridCenter.x(), m_GridCenter.y(), m_GridCenter.z());
int xShift = 2.0f*static_cast<int>(0.5f*centerpoint.x() + 0.5f);
int yShift = 20.0f*static_cast<int>(0.05f*centerpoint.y() + 0.5f);
int zShift = 2.0f*static_cast<int>(0.5f*centerpoint.z() + 0.5f);
glLineWidth(m_LineThickness);
glBegin(GL_LINES);
for (int i = -60 + xShift; i < 60 + xShift; i+=2) {
for (int j = -50 + yShift; j < 70 + yShift; j+=20) {
for (int k = -60 + zShift; k < 60 + zShift; k+=2) {
Vector3f a(static_cast<float>(i), static_cast<float>(j), static_cast<float>(k));
Vector3f b(static_cast<float>(i + 2), static_cast<float>(j), static_cast<float>(k));
//Vector3f c(static_cast<float>(i), static_cast<float>(j + 2), static_cast<float>(k));
Vector3f d(static_cast<float>(i), static_cast<float>(j), static_cast<float>(k + 2));
float aColor = std::min(1.0f, static_cast<float>(m_GridBrightness)/(20.0f + (a - centerpoint).squaredNorm()));
float bColor = std::min(1.0f, static_cast<float>(m_GridBrightness)/(20.0f + (b - centerpoint).squaredNorm()));
//float cColor = std::min(1.1f9 100.02/(10.0f + (c - centerpoint).squaredNorm()));
float dColor = std::min(1.0f, static_cast<float>(m_GridBrightness)/(20.0f + (d - centerpoint).squaredNorm()));
glColor4f(1.0f, 1.0f, 1.0f, m_Alpha*aColor);
glVertex3fv((a).eval().data());
glColor4f(1.0f, 1.0f, 1.0f, m_Alpha*bColor);
glVertex3fv((b).eval().data());
//glColor4f(1.0f, 1.0f, 1.0f, aColor);
//glVertex3fv((a).eval().data());
//glColor4f(1.0f, 1.0f, 1.0f, cColor);
//glVertex3fv((c).eval().data());
glColor4f(1.0f, 1.0f, 1.0f, m_Alpha*aColor);
glVertex3fv((a).eval().data());
glColor4f(1.0f, 1.0f, 1.0f, m_Alpha*dColor);
glVertex3fv((d).eval().data());
}
}
}
glEnd();
}
示例4: CheckLoS
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CheckLoS(): This function looks at the player and sees if the player is in range and in line of sight.
//
// Returns: bool = true if the player is in line of sight
//
// Mod. Name: Josh Morgan
// Mod. Date:8/14/12
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool CSlimeMonsterIdleAI::CheckLoS(void)
{
//creating the sound sphere
Sphere LoSRadius;
LoSRadius.SetRadius(LOS_BUBBLE);
LoSRadius.SetCenter(m_pParentObject->GetWorldPos());
CSceneObject LoSSphere;
LoSSphere.SetCollidableObject(&LoSRadius);
// create a return vector to hold all the objects the kd tree returns
std::vector <CSceneObject*> ReturnVector;
// create a unsigned int that will tell the kd tree what you want put in the return vector
// this uses bit wise operations so you can have more then one object returned
// use the return flags enum from the kd tree so you know what you can get back
int ReturnParams = 0;
int ReturnBody = 0;
int ReturnObjects = 1<<OBJ_PLAYER | 1<<OBJ_WORLD_COLLISION;
CKdTree::GetNearObjects(&LoSSphere, PSFLAG_SPHERE, ReturnParams, ReturnVector, ReturnBody, ReturnObjects);
//bool for checking if there's the player, and the position of the player
bool bPlayerInRange = false;
vec3f tPlayerPos = vec3f(0.0f, 0.0f, 0.0f);
for(unsigned int i = 0; i < ReturnVector.size(); i++)
{
IBaseObject* pObject = ((IBaseObject*)ReturnVector[i]);
if(pObject->GetType() == OBJ_PLAYER)
{
bPlayerInRange = true;
tPlayerPos = pObject->GetWorldPos();
break;
}
}
if(!bPlayerInRange)
{
return false;
}
//we make a line to the player since he's in aggro range
CSceneObject soLineSceneObject;
Line LineToPlayer;
LineToPlayer.SetVolumeType(VMT_LINE);
LineToPlayer.SetStartPoint(vec3f(m_pParentObject->GetWorldPos().x, m_pParentObject->GetWorldPos().y + 100.0f, m_pParentObject->GetWorldPos().z));
LineToPlayer.SetEndPoint(vec3f(tPlayerPos.x, tPlayerPos.y + 100.0f, tPlayerPos.z));
soLineSceneObject.SetCollidableObject(&LineToPlayer);
CKdTree::GetNearObjects(&soLineSceneObject, PSFLAG_LINE, ReturnParams, ReturnVector, ReturnBody, ReturnObjects);
soLineSceneObject.SetCollidableObject(nullptr);
//loop through all the return objects again and check collision with them.
for(unsigned int i = 0; i < ReturnVector.size(); ++i)
{
IBaseObject* pObject = ((IBaseObject*)ReturnVector[i]);
if(pObject->GetType() == OBJ_WORLD_COLLISION)
{
//check to see if our line to the player is obstructed by this ocject
vec3f Intersection = vec3f(FLT_MAX, FLT_MAX, FLT_MAX);
if(LineToPlayer.LineToAABB(*((AABB*)pObject->GetCollidableObject()), Intersection))
{
//D3DXMATRIX mat;
//D3DXMatrixIdentity(&mat);
//mat._41 = Intersection.x;
//mat._42 = Intersection.y;
//mat._43 = -500;
//DebugShapes::RenderSphere(mat);
//we see that there's something between us so I don't have line of sight
return false;
}
}
}
//set the slime monster to face the player
matrix4f _localMat = (*m_pParentObject->GetLocalMat());
matrix4f rotationMatrix;
vec2f DtoP = LineToPlayer.GetEndPoint2D() - LineToPlayer.GetStartPoint2D();
if(DtoP.x <= 0.0f)
{
//spawn facing left
rotationMatrix.make_rotation_y( D3DXToRadian(90) );
}
else
{
//spawn to face right
rotationMatrix.make_rotation_y( D3DXToRadian(-90) );
}
rotationMatrix.axis_pos = _localMat.axis_pos;
//.........这里部分代码省略.........
示例5: DivideTriangle
void SoftBodyNode::DivideTriangle(TDVertexContainer& Vertices,
TDConnectContainer& Connections,
TDConnectContainer::iterator itFace)
{
TDConnect::iterator itIdx = itFace->begin();
TDConnect::size_type nIdxA = *itIdx;
TDConnect::size_type nIdxB = *(itIdx + 1);
TDConnect::size_type nIdxC = *(itIdx + 2);
TDConnect::size_type nIdxD = -1;
TDConnect::size_type nIdxE = -1;
TDConnect::size_type nIdxF = -1;
TDVertex A(m_Vertices[nIdxA]);
TDVertex B(m_Vertices[nIdxB]);
TDVertex C(m_Vertices[nIdxC]);
TDVertex AB(B-A);
TDVertex AC(C-A);
TDVertex BC(C-B);
//TDVertex Normal(AB.Cross(AC));
//normals of the edges - I don't know if this idea makes sense - I've never come
//across an edge normal before in computer graphics literature. In this program I've defined the normal of
//an edge to be the sum of the normals of the adjoining vertices. This is not true in general.
//It should be the sum of the normals of the adjoining faces, ie the faces that the edge border,
//but in this case because the kernel polyhedron is an octahedron, we may be able to get away with it.
TDVertex NormalAB(*(m_Normals[nIdxA]) + *(m_Normals[nIdxB]));
TDVertex NormalAC(*(m_Normals[nIdxA]) + *(m_Normals[nIdxC]));
TDVertex NormalBC(*(m_Normals[nIdxB]) + *(m_Normals[nIdxC]));
NormalAB = 1.0f/bnu::norm_2(NormalAB) * NormalAB;
NormalAC = 1.0f/bnu::norm_2(NormalAC) * NormalAC;
NormalBC = 1.0f/bnu::norm_2(NormalBC) * NormalBC;
TDVertex MidAB(A + 0.5*AB);
TDVertex MidAC(A + 0.5*AC);
TDVertex MidBC(B + 0.5*BC);
Sphere BoundSphere;
bnu::vector<double> Center(3);
Center[0] = 0.0; Center[1] = 1.0; Center[2] = 0.0;
BoundSphere.SetCenter(Center);
BoundSphere.SetRadius(0.5);
Ray Ray;
Ray.SetOrigin(MidAB);
Ray.SetDirection(NormalAB);
TDVertexContainer Points;
FindIntersection(Ray, BoundSphere, Points);
assert(Points.size() == 1);
TDVertex D(Points[0]);
Ray.SetOrigin(MidBC);
Ray.SetDirection(NormalBC);
FindIntersection(Ray, BoundSphere, Points);
assert(Points.size()== 1);
TDVertex E(Points[0]);
Ray.SetOrigin(MidAC);
Ray.SetDirection(NormalAC);
FindIntersection(Ray, BoundSphere, Points);
assert(Points.size()== 1);
TDVertex F(Points[0]);
TDVertexContainer::iterator itVec;
if ((itVec = find_if(Vertices.begin(), Vertices.end(), bind(Equal<TDVertex>(), _1, D))) == Vertices.end())
{
Vertices.push_back(D);
nIdxD = Vertices.size() - 1;
}
else
{
nIdxD = Vertices.size() - (Vertices.end() - itVec);
}
if ((itVec = find_if(Vertices.begin(), Vertices.end(), bind(Equal<TDVertex>(), _1, E))) == Vertices.end())
{
Vertices.push_back(E);
nIdxE = Vertices.size() - 1;
}
else
{
nIdxE = Vertices.size() - (Vertices.end() - itVec);
}
if ((itVec = find_if(Vertices.begin(), Vertices.end(), bind(Equal<TDVertex>(), _1, F))) == Vertices.end())
{
Vertices.push_back(F);
nIdxF = Vertices.size() - 1;
}
else
{
nIdxF = Vertices.size() - (Vertices.end() - itVec);
}
vector<unsigned> vecFace;
vecFace.push_back(nIdxA);
vecFace.push_back(nIdxD);
vecFace.push_back(nIdxF);
Connections.push_back(vecFace);
vecFace.clear();
vecFace.push_back(nIdxD);
vecFace.push_back(nIdxB);
//.........这里部分代码省略.........
示例6: parseSceneXML
//.........这里部分代码省略.........
XMFLOAT3 scale(1.f, 1.f, 1.f);
XMFLOAT3 target = translate;
XMFLOAT3 rotateAxis(0.f, 0.f, 1.f);
float rotateDegrees = 0.f;
while(elementInfo != NULL) {
std::string info = elementInfo->Name();
if(info == "translate") {
elementInfo->QueryFloatAttribute("x", &translate.x);
elementInfo->QueryFloatAttribute("y", &translate.y);
elementInfo->QueryFloatAttribute("z", &translate.z);
} else if(info == "color") {
elementInfo->QueryFloatAttribute("r", &color.x);
elementInfo->QueryFloatAttribute("g", &color.y);
elementInfo->QueryFloatAttribute("b", &color.z);
} else if(info == "rotate") {
elementInfo->QueryFloatAttribute("axisX", &rotateAxis.x);
elementInfo->QueryFloatAttribute("axisY", &rotateAxis.y);
elementInfo->QueryFloatAttribute("axisZ", &rotateAxis.z);
elementInfo->QueryFloatAttribute("degrees", &rotateDegrees);
} else if(info == "scale") {
elementInfo->QueryFloatAttribute("x", &scale.x);
elementInfo->QueryFloatAttribute("y", &scale.y);
elementInfo->QueryFloatAttribute("z", &scale.z);
} else {
std::cout << __LINE__ << " -- boom\n";
}
elementInfo = elementInfo->NextSiblingElement();
}
//create sphere
Sphere* sphere = new Sphere();
sphere->SetRadius(radius);
sphere->setPosition(translate);
sphere->setRotation(rotateAxis, rotateDegrees);
sphere->setScale(scale);
sphere->color = color;
//add sphere to scene
scene->addPrimitive(sphere);
} else if(elementType == "cube") {
XMLElement* elementInfo = sceneElement->FirstChildElement();
float edgelen = sceneElement->FloatAttribute("edgelen");
XMFLOAT3 translate(0.f, 0.f, 0.f);
XMFLOAT3 color(1.f, 1.f, 1.f);
XMFLOAT3 scale(1.f, 1.f, 1.f);
XMFLOAT3 target = translate;
XMFLOAT3 rotateAxis(0.f, 0.f, 1.f);
float rotateDegrees = 0.f;
while(elementInfo != NULL) {
std::string info = elementInfo->Name();
if(info == "translate") {
elementInfo->QueryFloatAttribute("x", &translate.x);
elementInfo->QueryFloatAttribute("y", &translate.y);
elementInfo->QueryFloatAttribute("z", &translate.z);
} else if(info == "color") {
elementInfo->QueryFloatAttribute("r", &color.x);
elementInfo->QueryFloatAttribute("g", &color.y);
elementInfo->QueryFloatAttribute("b", &color.z);
} else if(info == "rotate") {