本文整理汇总了C++中Float3函数的典型用法代码示例。如果您正苦于以下问题:C++ Float3函数的具体用法?C++ Float3怎么用?C++ Float3使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Float3函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetModelName
Air::U1 Actor::Create()
{
if (m_Info.strModelName.empty() || m_Info.pSection == NULL)
{
return false;
}
m_pNode = m_Info.pSection->GetActorNode()->CreateChildSceneNode();
SetModelName(m_Info.strModelName);
Physics::Object::Info poInfo;
poInfo.fMass = 1;
poInfo.uiShapeCount = 1;
poInfo.pShapeArray[0].SetCylinder(Float3(0,0,0),0.5,1);
m_pHitShape = PhysicsSystem::GetSingleton()->CreateProduct<Physics::Object>(m_strProductName+"_CD",&poInfo);
m_pHitShape->SetUserData(this);
m_pNode->attachObject(m_pHitShape);
return true;
}
示例2: Float3
void RenderSetSorted::AddRenderNodeSolution(RenderNode *nodePtr)
{
static bool added = false;
if(!added)
{
PrintConsole::GetReference().AddSolution(L"ED2", "Sorting & Hierarchy", Float3(1.0f, 0.0f, 0.0f),
L"RenderSetSorted::AddRenderNodeSolution");
added = true;
}
RenderShape *pShape = (RenderShape *)nodePtr;
// Empty list
if (0 == headPtr)
{
tailPtr = pShape;
tailPtr->SetNext(0);
headPtr = pShape;
}
else
{
RenderShape *pPrevious = 0;
RenderShape *pCurrent = (RenderShape *)headPtr;
// Check if this node is first
if(!SortFunc(pCurrent, pShape))
{
pPrevious = pCurrent;
pCurrent = (RenderShape *)pCurrent->GetNext();
// Find where this node goes
while(pCurrent && !SortFunc(pCurrent, pShape))
{
pPrevious = pCurrent;
pCurrent = (RenderShape *)pCurrent->GetNext();
}
pPrevious->SetNext(pShape);
}
else
headPtr = pShape;
pShape->SetNext(pCurrent);
if(!pCurrent)
tailPtr = pShape;
}
}
示例3: acos
Float3 MlRachis::matchNormal(const Vector3F & wv, const Matrix33F & space)
{
Vector3F ov = space.transform(wv);
Vector3F va = ov;
va.y = 0.f;
va.z -= 0.05f;
va.normalize();
float a = acos(Vector3F::XAxis.dot(va));
if(va.z > 0.f) a = -a;
Vector3F vb = ov;
vb.z = 0.f;
vb.normalize();
float b = acos(Vector3F::XAxis.dot(vb));
if(vb.y < 0.f) b = -b;
return Float3(a, b, 0.f);
}
示例4: Float3
void Frustum::BuildPlane(){
Float3 dir,nc,fc,X,Y,Z;
Z = Float3(-m_vDirection.x,-m_vDirection.y,-m_vDirection.z);
Z.Normalize();
X = m_vUp.Cross(Z);
X.Normalize();
Y = Z.Cross(X);
nc = m_vPosition - Z * m_fNear;
fc = m_vPosition - Z * m_fFar;
Float3 ntl,ntr,nbl,nbr,ftl,ftr,fbl,fbr;
float nw,nh,fw,fh;
float tang = (float)tan(m_fAngle * 0.5f) ;
nh = m_fNear * tang;
nw = nh * m_fAspect;
fh = m_fFar * tang;
fw = fh * m_fAspect;
ntl = nc + Y * nh - X * nw;
ntr = nc + Y * nh + X * nw;
nbl = nc - Y * nh - X * nw;
nbr = nc - Y * nh + X * nw;
ftl = fc + Y * fh - X * fw;
ftr = fc + Y * fh + X * fw;
fbl = fc - Y * fh - X * fw;
fbr = fc - Y * fh + X * fw;
m_vecPlane[enFS_Top].SetVertex(ntr,ntl,ftl);
m_vecPlane[enFS_Bottom].SetVertex(nbl,nbr,fbr);
m_vecPlane[enFS_Left].SetVertex(ntl,nbl,fbl);
m_vecPlane[enFS_Right].SetVertex(nbr,ntr,fbr);
m_vecPlane[enFS_Near].SetVertex(ntl,ntr,nbr);
m_vecPlane[enFS_Far].SetVertex(ftr,ftl,fbl);
}
示例5: Float2
LoaderFbxTextureDesc::LoaderFbxTextureDesc()
{
textureName_ = "Unknown";
fileName_ = "Unknown";
scale_ = Float2(0.0f, 0.0f);
translation_ = Float2(0.0f, 0.0f);
rotation_ = Float3(0.0f, 0.0f, 0.0f);
swap_ = false;
alphaSource_ = 0;
croppingLeft_ = 0;
croppingTop_ = 0;
croppingRight_ = 0;
croppingBottom_ = 0;
mappingType_ = 0;
planarMappingNormal_ = 0;
blendMode_ = 0;
defaultAlpha_ = 0.0f;
materialUse_ = 0;
textureUse_ = 0;
}
示例6: OnUpdate
virtual void OnUpdate()
{
float k = Root::Instance()->GetTime();
float r = 3.0f;
float x = Math::Cos(k) * r;
float z = Math::Sin(k) * r;
gBillboard->SetPosition(Float3(x, 5, z));
gLightDir->SetPosition(Float3(x, 5, z));
gLightDir->SetDirection(-Float3(x, 0, z));
gLightPoint->SetPosition(Float3(x, 5, z));
gLightPoint->SetDirection(-Float3(x, 0, z));
gLightSpot->SetPosition(Float3(x, 5, z));
gLightSpot->SetDirection(-Float3(x, 0, z));
}
示例7: rectangle
void ImGui::beginContainer(int left, int right, int bottom, int top, Container *container)
{
if (left > right or bottom > top)
{
Command command;
command.type = Command::PushScissor;
command.scissor.left = 0;
command.scissor.right = 0;
command.scissor.bottom = 0;
command.scissor.top = 0;
commands.append(command);
return;
}
rectangle(left, right+10, bottom-10, top, 0.44f, 1.0f, 0.0f, 1.0f, Float3(1.0f), Float4(0.0f));
Command command;
command.type = Command::PushScissor;
command.scissor.left = left;
command.scissor.right = right;
command.scissor.bottom = bottom;
command.scissor.top = top;
commands.append(command);
scrollX = container->scrollX;
scrollY = container->scrollY;
containerLeft = left;
containerRight = right;
containerTop = top;
containerBottom = bottom;
container->left = left;
container->right = right;
container->bottom = bottom;
container->top = top;
}
示例8: ParamsFindP
//==================================================================
bool ParamsFindP( ParamList ¶ms,
const SymbolList &globalSymbols,
Float3 *pOut_vectorP,
int expectedN,
int fromIdx )
{
bool gotP = false;
for (size_t i=fromIdx; i < params.size(); i += 2)
{
DASSERT( params[i].type == Param::STR );
const Symbol* pSymbol = globalSymbols.FindSymbol( params[i] );
if ( pSymbol && pSymbol->IsName( "P" ) )
{
DASSTHROW( (i+1) < params.size(), "Invalid number of arguments" );
const FltVec &fltVec = params[ i+1 ].NumVec();
DASSTHROW( (int)fltVec.size() == 3 * expectedN,
"Invalid number of arguments."
" Expecting %i but it's %u", 3 * expectedN, fltVec.size() );
DASSTHROW( (int)(fltVec.size() % 3) == 0,
"Invalid number of arguments."
" Should be multiple of 3 but it's %u", fltVec.size() );
size_t srcN = fltVec.size();
for (size_t si=0, di=0; si < srcN; si += 3, di += 1)
pOut_vectorP[ di ] = Float3( &fltVec[ si ] );
return true;
}
}
return false;
}
示例9: VertexBuffer
//----------------------------------------------------------------------------
TriMesh* RoughPlaneSolidBox::CreateRamp ()
{
float x = 8.0f;
float y = 8.0f;
float z = y*Mathf::Tan((float)mModule.Angle);
VertexFormat* vformat = VertexFormat::Create(2,
VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0);
int vstride = vformat->GetStride();
VertexBuffer* vbuffer = new0 VertexBuffer(6, vstride);
VertexBufferAccessor vba(vformat, vbuffer);
vba.Position<Float3>(0) = Float3(-x, 0.0f, 0.0f);
vba.Position<Float3>(1) = Float3(+x, 0.0f, 0.0f);
vba.Position<Float3>(2) = Float3(-x, y, 0.0f);
vba.Position<Float3>(3) = Float3(+x, y, 0.0f);
vba.Position<Float3>(4) = Float3(-x, y, z);
vba.Position<Float3>(5) = Float3(+x, y, z);
vba.TCoord<Float2>(0, 0) = Float2(0.25f, 0.0f);
vba.TCoord<Float2>(0, 1) = Float2(0.75f, 0.0f);
vba.TCoord<Float2>(0, 2) = Float2(0.0f, 1.0f);
vba.TCoord<Float2>(0, 3) = Float2(1.0f, 1.0f);
vba.TCoord<Float2>(0, 4) = Float2(0.25f, 1.0f);
vba.TCoord<Float2>(0, 5) = Float2(0.75f, 1.0f);
IndexBuffer* ibuffer = new0 IndexBuffer(18, sizeof(int));
int* indices = (int*)ibuffer->GetData();
indices[ 0] = 0; indices[ 1] = 1; indices[ 2] = 4;
indices[ 3] = 1; indices[ 4] = 5; indices[ 5] = 4;
indices[ 6] = 0; indices[ 7] = 4; indices[ 8] = 2;
indices[ 9] = 1; indices[10] = 3; indices[11] = 5;
indices[12] = 3; indices[13] = 2; indices[14] = 4;
indices[15] = 3; indices[16] = 4; indices[17] = 5;
TriMesh* ramp = new0 TriMesh(vformat, vbuffer, ibuffer);
std::string path = Environment::GetPathR("Metal.wmtf");
Texture2D* texture = Texture2D::LoadWMTF(path);
ramp->SetEffectInstance(Texture2DEffect::CreateUniqueInstance(texture,
Shader::SF_LINEAR, Shader::SC_REPEAT, Shader::SC_REPEAT));
return ramp;
}
示例10: mCategory
SLSound::SLSound()
: mCategory(0)
, mFlags(0)
{
mBQObjectI = NULL;
mBQPlayI = NULL;
mVolumeI = NULL;
mBQBufferQueueI = NULL;
mBQEffectSendI = NULL;
mPosition = Float3(0, 0, 0);
mVolume = 1;
mAttenStart = mAttenEnd = 0;
mInvAttenDist = 1;
mPlayTime = 0;
mPlayOffset = 0;
mPlayEnd = FALSE;
mFadeMode = 0;
mFadeTime = SL_FADETIME;
i_thread = NULL;
}
示例11: Float3
// extents, renderable, nearDistance, depth, nearPlaneArea
void Camera::SetLODSolution(IRenderer* renderable, float maxExtent, float nearDistance,
float depth, float minArea)
{
static bool added = false;
if(!added)
{
PrintConsole::GetReference().AddSolution(L"ED2", "LOD", Float3(1.0f, 0.0f, 0.0f),
L"Camera::SetLODSolution");
added = true;
}
unsigned int numLODs = renderable->GetNumLODs();
if( numLODs != 1 )
{
float projectedRadius = (nearDistance * maxExtent) / depth;
float projectedArea = (float)M_PI * projectedRadius * projectedRadius;
float areaOccupiedRatio = min( 1.0f, projectedArea / minArea );
renderable->SetCurrentLOD( (unsigned int)((numLODs-1) * areaOccupiedRatio) );
}
}
示例12: OnInit
virtual void OnInit()
{
SetupUI();
// Create Mesh
MeshSourcePtr pMeshSource = MeshManager::Instance()->LoadMesh("Mesh/fox.mesh");
gMesh = new Mesh;
gMesh->SetSource(pMeshSource);
gMesh->LoadAnimation("Idle1", "Mesh/fox_idle1.anim");
gMesh->SetLighting(true);
gMesh->PlayAnimation("Idle1");
LookMesh(gMesh);
// Setup Main Light
World::Instance()->MainLight()->SetDirection(Float3(-1, 0, 1));
World::Instance()->MainLight()->SetAmbient(Float3(0.2f, 0.2f, 0.2f));
World::Instance()->MainLight()->SetDiffuse(Float3(0.2f, 0.2f, 0.2f));
// Create Lights
gLightDir = new Light(eLightType::DIRECTION);
gLightPoint = new Light(eLightType::POINT);
gLightSpot = new Light(eLightType::SPOT);
gLightDir->SetDiffuse(Float3(1, 0, 0));
gLightPoint->SetDiffuse(Float3(0, 1, 0));
gLightSpot->SetDiffuse(Float3(0, 0, 1));
gLightDir->SetVisible(true);
gLightPoint->SetVisible(false);
gLightSpot->SetVisible(false);
// Create Billboard
gBillboard = new Billboard;
gBillboard->SetSize(Float2(1, 1));
gBillboard->SetTexture("flare.png");
gBillboard->GetMaterial()->blendMode = eBlendMode::ADD;
}
示例13: Float3
U1 Resource::CreateHardwareBuff( MeshHDBuffer* pOutBuff,CalCoreMesh* pInMesh ){
std::vector<ABuff> vertexData;
std::vector<UInt> indexData;
SInt iMeshCount = pInMesh->getCoreSubmeshCount();
SInt iVertexCount = 0;
SInt iIndexCount = 0;
//首先计算顶点数 和 索引数
for(SInt i=0;i<iMeshCount;i++){
CalCoreSubmesh* pSubMesh = pInMesh->getCoreSubmesh(i);
iVertexCount += pSubMesh->getVectorVertex().size();
iIndexCount += pSubMesh->getFaceCount()*3;
}
if( iVertexCount == 0 ||
iIndexCount == 0)
{
return false;
}
//分配空间
vertexData.resize(iVertexCount);
indexData.resize(iIndexCount);
SInt iV = 0;
SInt iI = 0;
for(SInt i=0;i<iMeshCount;i++){
CalCoreSubmesh* pSubMesh = pInMesh->getCoreSubmesh(i);
//计算切线
pSubMesh->enableTangents(0,true);
std::vector<CalCoreSubmesh::Vertex>& lstVector = pSubMesh->getVectorVertex();
std::vector<std::vector<CalCoreSubmesh::TangentSpace> >& lstTangent = pSubMesh->getVectorVectorTangentSpace();
std::vector<std::vector<CalCoreSubmesh::TextureCoordinate> >& lstTexcoord = pSubMesh->getVectorVectorTextureCoordinate();
std::vector<CalCoreSubmesh::Face>& lstFace = pSubMesh->getVectorFace();
SInt iFaceCount = lstFace.size();
//索引缓冲
for(SInt j=0;j<iFaceCount;j++){
indexData[iI] = lstFace[j].vertexId[0] + iV;
indexData[iI+1] = lstFace[j].vertexId[1] + iV;
indexData[iI+2] = lstFace[j].vertexId[2] + iV;
iI += 3;
}
//顶点缓冲数据
for(SInt j=0;j<iVertexCount;j++){
CalCoreSubmesh::Vertex& ver = lstVector[j];
CalCoreSubmesh::TangentSpace tang = lstTangent[0][j];
CalCoreSubmesh::TextureCoordinate uv = lstTexcoord[0][j];
//位置
vertexData[iV].Position = Float3(ver.position.x,ver.position.y,ver.position.z);
SInt iBoneCount = ver.vectorInfluence.size();
for(SInt k=0;k<4;k++){
if(k<iBoneCount){
vertexData[iV].BoneWeight[k] = ver.vectorInfluence[k].weight*255.0f;
//如果只传递自己需要的矩阵
//骨骼索引变成0~n
vertexData[iV].BoneIndex[k] = ver.vectorInfluence[k].boneId;
}else{
vertexData[iV].BoneWeight[k] = 0;
vertexData[iV].BoneIndex[k] = 0;
}
}
//法线
vertexData[iV].Normal = Float3(ver.normal.x,ver.normal.y,ver.normal.z);
//UV
vertexData[iV].UV.x = uv.u;
vertexData[iV].UV.y = uv.v;
//切线
vertexData[iV].Tangent.x = tang.tangent.x;
vertexData[iV].Tangent.y = tang.tangent.y;
vertexData[iV].Tangent.z = tang.tangent.z;
iV++;
}
AString strName = m_strProductName + pInMesh->getName();
Render::Vertex::IDeclare::Info dInfo;
dInfo.SetPNTT_Animation();
pOutBuff->pVertexDeclare = Render::System::GetSingleton()->CreateProduct<Render::Vertex::IDeclare>("PNTTANIM",&dInfo);
Render::Buffer::Info vInfo;
vInfo.SetVertexBuffer(iVertexCount,52);
vInfo.InitData = &vertexData[0];
pOutBuff->pVertexBuff = Render::System::GetSingleton()->CreateProduct<Render::Buffer>(strName+"VB",&vInfo);
vInfo.SetIndexBuffer32(iFaceCount*3);
vInfo.InitData = &indexData[0];
pOutBuff->pIndexBuff = Render::System::GetSingleton()->CreateProduct<Render::Buffer>(strName+"IB",&vInfo);
}
return true;
}
示例14: Float3
Float3<T> Float3<T>::operator -() const
{
return Float3(-this->x, -this->y, -this->z);
}
示例15: switch
void PhysicsComponent::onEvent(Event* e)
{
EventType type = e->getType();
switch(type)
{
case EVENT_ATTRIBUTE_UPDATED: //Removes physics objects when the corresponding physics attribute is removed
{
Event_AttributeUpdated* attributeUpdated = static_cast<Event_AttributeUpdated*>(e);
int attributeIndex = attributeUpdated->index;
if(attributeUpdated->attributeEnum == ATTRIBUTE_PHYSICS)
{
if(attributeUpdated->isDeleted)
{
if(attributeIndex < physicsObjects_->size() && physicsObjects_->at(attributeIndex) != nullptr)
{
dynamicsWorld_->removeRigidBody(physicsObjects_->at(attributeIndex));
delete physicsObjects_->at(attributeIndex);
physicsObjects_->at(attributeIndex) = nullptr;
}
else
{
DEBUGPRINT("Mismatch when synchronizing deletion of physics objects with physics attributes");
}
}
else if(attributeUpdated->isCreated)
{
}
else
{
itrPhysics.at(attributeIndex)->reloadDataIntoBulletPhysics = true;
}
}
/*else if(attributeUpdated->attributeEnum == ATTRIBUTE_CAMERA)
{
if(attributeUpdated->isDeleted)
{
dynamicsWorld_->removeRigidBody(frustumPhysicsObjects_->at(attributeIndex));
delete frustumPhysicsObjects_->at(attributeIndex);
frustumPhysicsObjects_->at(attributeIndex) = nullptr;
}
}*/
break;
}
case EVENT_MODIFY_PHYSICS_OBJECT:
{
Event_ModifyPhysicsObject* modifyPhysicsObject = static_cast<Event_ModifyPhysicsObject*>(e);
int physicsAttributeIndex = modifyPhysicsObject->ptr_physics.index();
if(physicsAttributeIndex < physicsObjects_->size() && physicsAttributeIndex > -1)
{
PhysicsObject* physicsObject = physicsObjects_->at(physicsAttributeIndex);
if(physicsObject != NULL)
{
//Cast void pointer sent in Event_ModifyPhysicsObject to its expected data type and modify physics object accordingly
switch(modifyPhysicsObject->modifyWhatDataInPhysicsObjectData)
{
case XKILL_Enums::ModifyPhysicsObjectData::GRAVITY:
{
Float3* gravity = static_cast<Float3*>(modifyPhysicsObject->data);
physicsObject->setGravity(btVector3(gravity->x, gravity->y, gravity->z));
break;
}
case XKILL_Enums::ModifyPhysicsObjectData::VELOCITY:
{
Float3* velocity = static_cast<Float3*>(modifyPhysicsObject->data);
physicsObject->setLinearVelocity(btVector3(velocity->x, velocity->y, velocity->z));
break;
}
case XKILL_Enums::ModifyPhysicsObjectData::VELOCITYPERCENTAGE:
{
Float3* velocityPercentage = static_cast<Float3*>(modifyPhysicsObject->data);
btVector3 currentLinearVelocity = physicsObject->getLinearVelocity();
physicsObject->setLinearVelocity(btVector3(currentLinearVelocity.x()*velocityPercentage->x, currentLinearVelocity.y()*velocityPercentage->y, currentLinearVelocity.z()*velocityPercentage->z));
break;
}
case XKILL_Enums::ModifyPhysicsObjectData::FLAG_STATIC:
{
bool* staticPhysicsObject = static_cast<bool*>(modifyPhysicsObject->data);
if(*staticPhysicsObject == true)
{
physicsObject->setCollisionFlags(physicsObject->getCollisionFlags() | btCollisionObject::CF_STATIC_OBJECT);
}
else if(*staticPhysicsObject == false)
{
physicsObject->setCollisionFlags(physicsObject->getCollisionFlags() & ~ btCollisionObject::CF_STATIC_OBJECT);
}
break;
}
case XKILL_Enums::ModifyPhysicsObjectData::COLLISIONFILTERMASK:
{
/*In order to modify "collisionFilterMask", a physics objects needs to be removed from the Bullet Physics dynamics world and then readded using "addRigidBody", where "collisionFilterMask" is passed as argument.
Write physics object data to physics attribute, modify "collisionFilterMask", and set the "reloadDataIntoBulletPhysics" flag, and this class will handle the removal and addition of the physics object.*/
short* collisionFilterMaskFromEvent = static_cast<short*>(modifyPhysicsObject->data);
AttributePtr<Attribute_Physics> ptr_physics = itrPhysics.at(physicsAttributeIndex);
//.........这里部分代码省略.........