本文整理汇总了C++中Vec4函数的典型用法代码示例。如果您正苦于以下问题:C++ Vec4函数的具体用法?C++ Vec4怎么用?C++ Vec4使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Vec4函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: backward
//.........这里部分代码省略.........
if (_vertexBuffer == nullptr)
{
CCLOG("PUParticle3DBoxRender::render create vertex buffer failed");
return;
}
_vertexBuffer->retain();
_vertices.resize(8 * particleSystem->getParticleQuota());
_indexBuffer = IndexBuffer::create(IndexBuffer::IndexType::INDEX_TYPE_SHORT_16, 36 * particleSystem->getParticleQuota());
if (_indexBuffer == nullptr)
{
CCLOG("PUParticle3DBoxRender::render create index buffer failed");
return;
}
_indexBuffer->retain();
_indices.resize(36 * particleSystem->getParticleQuota());
reBuildIndices(particleSystem->getParticleQuota());
}
unsigned int vertexindex = 0;
unsigned int index = 0;
Mat4 texRot;
Vec3 val;
for (auto iter : particlePool.getActiveDataList())
{
auto particle = static_cast<PUParticle3D *>(iter);
float halfHeight = particle->height * 0.5f;
float halfWidth = particle->width * 0.5f;
float halfDepth = particle->depth * 0.5f;
Mat4::createRotation(backward, particle->zRotation, &texRot);
val = texRot * Vec3(0.0f, 0.75f, 0.0);
_vertices[vertexindex + 0].position = particle->position + Vec3(-halfWidth, -halfHeight, halfDepth);
_vertices[vertexindex + 0].color = particle->color;
_vertices[vertexindex + 0].uv.x = val.x;
_vertices[vertexindex + 0].uv.y = val.y;
val = texRot * Vec3(0.0f, 0.25f, 0.0);
_vertices[vertexindex + 1].position = particle->position + Vec3(halfWidth, -halfHeight, halfDepth);
_vertices[vertexindex + 1].color = particle->color;
_vertices[vertexindex + 1].uv.x = val.x;
_vertices[vertexindex + 1].uv.y = val.y;
val = texRot * Vec3(0.5f, 0.25f, 0.0);
_vertices[vertexindex + 2].position = particle->position + Vec3(halfWidth, halfHeight, halfDepth);
_vertices[vertexindex + 2].color = particle->color;
_vertices[vertexindex + 2].uv.x = val.x;
_vertices[vertexindex + 2].uv.y = val.y;
val = texRot * Vec3(0.5f, 0.75f, 0.0);
_vertices[vertexindex + 3].position = particle->position + Vec3(-halfWidth, halfHeight, halfDepth);
_vertices[vertexindex + 3].color = particle->color;
_vertices[vertexindex + 3].uv.x = val.x;
_vertices[vertexindex + 3].uv.y = val.y;
val = texRot * Vec3(0.0f, 0.0f, 0.0);
_vertices[vertexindex + 4].position = particle->position + Vec3(halfWidth, -halfHeight, -halfDepth);
_vertices[vertexindex + 4].color = particle->color;
_vertices[vertexindex + 4].uv.x = val.x;
_vertices[vertexindex + 4].uv.y = val.y;
val = texRot * Vec3(0.0f, 1.0f, 0.0);
_vertices[vertexindex + 5].position = particle->position + Vec3(-halfWidth, -halfHeight, -halfDepth);
_vertices[vertexindex + 5].color = particle->color;
_vertices[vertexindex + 5].uv.x = val.x;
_vertices[vertexindex + 5].uv.y = val.y;
val = texRot * Vec3(0.5f, 1.0f, 0.0);
_vertices[vertexindex + 6].position = particle->position + Vec3(-halfWidth, halfHeight, -halfDepth);
_vertices[vertexindex + 6].color = particle->color;
_vertices[vertexindex + 6].uv.x = val.x;
_vertices[vertexindex + 6].uv.y = val.y;
val = texRot * Vec3(0.5f, 0.0f, 0.0);
_vertices[vertexindex + 7].position = particle->position + Vec3(halfWidth, halfHeight, -halfDepth);
_vertices[vertexindex + 7].color = particle->color;
_vertices[vertexindex + 7].uv.x = val.x;
_vertices[vertexindex + 7].uv.y = val.y;
vertexindex += 8;
index += 36;
}
if (!_vertices.empty() && !_indices.empty()) {
_vertexBuffer->updateVertices(&_vertices[0], vertexindex/* * sizeof(_posuvcolors[0])*/, 0);
_indexBuffer->updateIndices(&_indices[0], index/* * sizeof(unsigned short)*/, 0);
GLuint texId = (_texture ? _texture->getName() : 0);
_stateBlock->setBlendFunc(_particleSystem->getBlendFunc());
_meshCommand->init(0,
texId,
_glProgramState,
_stateBlock,
_vertexBuffer->getVBO(),
_indexBuffer->getVBO(),
GL_TRIANGLES,
GL_UNSIGNED_SHORT,
index,
transform,
Node::FLAGS_RENDER_AS_3D);
_meshCommand->setSkipBatching(true);
_meshCommand->setTransparent(true);
_glProgramState->setUniformVec4("u_color", Vec4(1,1,1,1));
renderer->addCommand(_meshCommand);
}
}
示例2: cry_strcpy
//--------------------------------------------------------------------------------------------------
// Name: Initialise
// Desc: Initialises post effect activation system from data
// Uses the xml node name for the post effect, and activeValue and nonActiveValue attributes
//--------------------------------------------------------------------------------------------------
void CPostEffectActivationSystem::Initialise(const IItemParamsNode* postEffectListXmlNode)
{
if(postEffectListXmlNode)
{
const IItemParamsNode* postEffectXmlNode = NULL;
SPostEffectParam* param = NULL;
int childCount = postEffectListXmlNode->GetChildCount();
int postEffectCount = childCount;
const IItemParamsNode* vecsXmlNode = postEffectListXmlNode->GetChild("vecs");
if(vecsXmlNode)
{
postEffectCount--;
}
m_postEffectParam.resize(postEffectCount);
int paramIndex=0;
for(int c=0; c<childCount; c++)
{
postEffectXmlNode = postEffectListXmlNode->GetChild(c);
if(postEffectXmlNode && postEffectXmlNode != vecsXmlNode)
{
param = &m_postEffectParam[paramIndex];
cry_strcpy(param->name, postEffectXmlNode->GetName());
postEffectXmlNode->GetAttribute("activeValue",param->activeValue);
postEffectXmlNode->GetAttribute("nonActiveValue",param->nonActiveValue);
int forceValue = 0;
postEffectXmlNode->GetAttribute("forceValue",forceValue);
param->forceValue = (forceValue) ? true : false;
paramIndex++;
}
}
if(vecsXmlNode)
{
SPostEffectParamVec* paramVec = NULL;
const int vecCount = vecsXmlNode->GetChildCount();
m_postEffectParamVec.resize(vecCount);
for(int i=0; i<vecCount; i++)
{
postEffectXmlNode = vecsXmlNode->GetChild(i);
paramVec = &m_postEffectParamVec[i];
cry_strcpy(paramVec->name, postEffectXmlNode->GetName());
Vec3 vecValue(0.0f,0.0f,0.0f);
float wValue = 0.0f;
postEffectXmlNode->GetAttribute("activeVec3",vecValue);
postEffectXmlNode->GetAttribute("activeW",wValue);
paramVec->activeValue = Vec4(vecValue,wValue);
postEffectXmlNode->GetAttribute("nonActiveVec3",vecValue);
postEffectXmlNode->GetAttribute("nonActiveW",wValue);
paramVec->nonActiveValue = Vec4(vecValue,wValue);
int forceValue = 0;
postEffectXmlNode->GetAttribute("forceValue",forceValue);
paramVec->forceValue = (forceValue) ? true : false;
}
}
}
}//-------------------------------------------------------------------------------------------------
示例3: Vec4
Vec4 Vec4::operator+(const Vec4& v) { return Vec4(this->x + v.x, this->y + v.y, this->z + v.z, this->w + v.w); }
示例4: JointPositionIsValid
void FilterDoubleExponential::Update( const SKinSkeletonRawData& pSkeletonData, uint32 i, const KIN_TRANSFORM_SMOOTH_PARAMETERS& smoothingParams )
{
Vec4 vPrevRawPosition;
Vec4 vPrevFilteredPosition;
Vec4 vPrevTrend;
Vec4 vRawPosition;
Vec4 vFilteredPosition;
Vec4 vPredictedPosition;
Vec4 vDiff;
Vec4 vTrend;
Vec4 vLength;
float fDiff;
BOOL bJointIsValid;
const Vec4* __restrict pJointPositions = pSkeletonData.vSkeletonPositions;
vRawPosition = pJointPositions[i];
vPrevFilteredPosition = m_History[i].m_vFilteredPosition;
vPrevTrend = m_History[i].m_vTrend;
vPrevRawPosition = m_History[i].m_vRawPosition;
bJointIsValid = JointPositionIsValid(vRawPosition);
// If joint is invalid, reset the filter
if (!bJointIsValid)
{
m_History[i].m_dwFrameCount = 0;
}
// Initial start values
if (m_History[i].m_dwFrameCount == 0)
{
vFilteredPosition = vRawPosition;
vTrend = Vec4(0,0,0,0);
m_History[i].m_dwFrameCount++;
}
else if (m_History[i].m_dwFrameCount == 1)
{
vFilteredPosition = (vRawPosition + vPrevRawPosition) * 0.5f;
vDiff = vFilteredPosition - vPrevFilteredPosition;
vTrend = (vDiff * smoothingParams.m_fCorrection) + (vPrevTrend * (1.0f - smoothingParams.m_fCorrection));
m_History[i].m_dwFrameCount++;
}
else
{
// First apply jitter filter
vDiff = vRawPosition - vPrevFilteredPosition;
fDiff = fabs(vDiff.GetLength());
if (fDiff <= smoothingParams.m_fJitterRadius)
{
vFilteredPosition = vRawPosition * (fDiff/smoothingParams.m_fJitterRadius) + vPrevFilteredPosition * (1.0f - fDiff/smoothingParams.m_fJitterRadius);
}
else
{
vFilteredPosition = vRawPosition;
}
// Now the double exponential smoothing filter
vFilteredPosition = vFilteredPosition * (1.0f - smoothingParams.m_fSmoothing) + (vPrevFilteredPosition + vPrevTrend) * smoothingParams.m_fSmoothing;
vDiff = vFilteredPosition - vPrevFilteredPosition;
vTrend = vDiff * smoothingParams.m_fCorrection + vPrevTrend * (1.0f - smoothingParams.m_fCorrection);
}
// Predict into the future to reduce latency
vPredictedPosition = vFilteredPosition + (vTrend * smoothingParams.m_fPrediction);
// Check that we are not too far away from raw data
vDiff = vPredictedPosition - vRawPosition;
fDiff = fabs(vDiff.GetLength());
if (fDiff > smoothingParams.m_fMaxDeviationRadius)
{
vPredictedPosition = vPredictedPosition * smoothingParams.m_fMaxDeviationRadius/fDiff + vRawPosition * (1.0f - smoothingParams.m_fMaxDeviationRadius/fDiff);
}
// Save the data from this frame
m_History[i].m_vRawPosition = vRawPosition;
m_History[i].m_vFilteredPosition = vFilteredPosition;
m_History[i].m_vTrend = vTrend;
// Output the data
m_FilteredJoints[i] = vPredictedPosition;
m_FilteredJoints[i].w = 1.0f;
}
示例5: Vec4
void PhysicsDebugDraw::drawSphere(const btVector3& p, btScalar radius, const btVector3& color)
{
debugRenderer->drawSphere(Vec3(p.getX(), p.getY(), p.getZ()), radius, Vec4(color.getX(), color.getY(), color.getZ(), 1.f));
}
示例6: GetTab
void tcOptionsView::Draw()
{
static unsigned int drawCount = 0;
std::string activeTab = GetTab();
StartDraw();
wxASSERT(mpOptions);
UpdateButtonInfo();
std::vector<tcOptions::OptionInfo>& optionList = mpOptions->maOptionInfo;
for(size_t k=0; k<buttonInfo.size(); k++)
{
if (!buttonInfo[k].isSlider)
{
int optionIdx = buttonInfo[k].optionIdx;
int valueIdx = buttonInfo[k].valueIdx;
tcString sText = optionList[optionIdx].mzCaption[valueIdx];
float x = (float)buttonInfo[k].textX;
float y = (float)buttonInfo[k].textY;
DrawText(sText.c_str(), x, y, defaultFont.get(),
Vec4(0.86f, 0.86f, 1.0f, 1.0f), fontSize, LEFT_CENTER);
if (optionList[optionIdx].mnValue == valueIdx)
{
DrawButton(buttonInfo[k].buttonX, buttonInfo[k].buttonY, 1);
}
else
{
DrawButton(buttonInfo[k].buttonX, buttonInfo[k].buttonY, 0);
}
}
else
{
int optionIdx = buttonInfo[k].optionIdx;
tcString sText = optionList[optionIdx].mzCaption[0];
bool thisSliderActive = sliderDragActive && (sliderIdx == k);
float sliderVal = thisSliderActive ?
sliderDragValue : optionList[optionIdx].floatVal;
float sliderMin = optionList[optionIdx].floatMin;
float sliderMax = optionList[optionIdx].floatMax;
float sliderFraction = (sliderVal - sliderMin) / (sliderMax - sliderMin);
float xText = (float)buttonInfo[k].textX;
float yText = (float)buttonInfo[k].textY;
float xBar = (float)buttonInfo[k].buttonX;
float yBar = (float)buttonInfo[k].buttonY;
DrawText(sText.c_str(), xText, yText, defaultFont.get(),
Vec4(0.86f, 0.86f, 1.0f, 1.0f), fontSize, LEFT_CENTER);
float xThumb = xBar + sliderFraction*sliderBarWidth;
tcRect thumbRect(xThumb-2.0f, xThumb+2.0f, yBar-8.0f, yBar+8.0f);
buttonInfo[k].thumbRect = thumbRect;
// draw slider here
DrawSlider(xBar, yBar, thumbRect, sliderVal, thisSliderActive);
}
}
FinishDraw();
}
示例7: setSunLightPosition
void OsgViewerBase::setSunLightPosition( const Vec3d& position )
{
_sunLight->setPosition(Vec4(position.x(), position.y(), position.z(), 0.0f));
}
示例8: getStartTime
//==============================================================================
void FollowPathEvent::update(F32 prevUpdateTime, F32 crntTime)
{
MoveComponent& move = movableSceneNode->getComponent<MoveComponent>();
I pointA = 0;
I pointB = 0;
// Calculate the current distance. Clamp it to max distance
F32 crntDistance = distPerTime * (crntTime - getStartTime());
ANKI_ASSERT(crntDistance >= 0.0);
crntDistance = std::min(crntDistance, path->getDistance());
const I pointsCount = path->getPoints().size();
ANKI_ASSERT(pointsCount > 1);
// Find the points that we lie between
for(I i = 1; i < pointsCount; i++)
{
const PathPoint& ppa = path->getPoints()[i - 1];
const PathPoint& ppb = path->getPoints()[i];
if(crntDistance > ppa.getDistanceFromFirst()
&& crntDistance <= ppb.getDistanceFromFirst())
{
pointA = i - 1;
pointB = i;
break;
}
}
ANKI_ASSERT(pointA < pointsCount && pointB < pointsCount);
I preA = std::max((I)0, pointA - 1);
I postB = std::min(pointsCount - 1, pointB + 1);
/*I pminus2 = std::max((I)0, pointA - 2);
I pminus1 = std::max((I)0, pointA - 1);*/
// Calculate the u [0.0, 1.0]
F32 u = path->getPoints()[pointB].getDistance() + getEpsilon<F32>();
ANKI_ASSERT(u != 0.0);
const F32 c = crntDistance
- path->getPoints()[pointA].getDistanceFromFirst();
u = c / u;
// Calculate and set new position and rotation for the movable
/*Vec3 newPos = cubicInterpolate(
path->getPoints()[preA].getPosition(),
path->getPoints()[pointA].getPosition(),
path->getPoints()[pointB].getPosition(),
path->getPoints()[postB].getPosition(),
u);*/
Vec3 newPos = interpolate(
path->getPoints()[pointA].getPosition(),
path->getPoints()[pointB].getPosition(),
u);
{
F32 u2 = u * u;
Vec4 us(1, u, u2, u2 * u);
F32 t = 0.7;
Mat4 tentionMat(
0.0, 1.0, 0.0, 0.0,
-t, 0.0, t, 0.0,
2.0 * t, t - 3.0, 3.0 - 2.0 * t, -t,
-t, 2.0 - t, t - 2.0, t);
Vec4 tmp = us * tentionMat;
Mat4 posMat;
posMat.setRows(
Vec4(path->getPoints()[preA].getPosition(), 1.0),
Vec4(path->getPoints()[pointA].getPosition(), 1.0),
Vec4(path->getPoints()[pointB].getPosition(), 1.0),
Vec4(path->getPoints()[postB].getPosition(), 1.0));
Vec4 finalPos = tmp * posMat;
newPos = finalPos.xyz();
}
Quat newRot = path->getPoints()[pointA].getRotation().slerp(
path->getPoints()[pointB].getRotation(),
u);
F32 scale = move.getLocalTransform().getScale();
Transform trf;
trf.setOrigin(newPos);
trf.setRotation(Mat3(newRot));
trf.setScale(scale);
move.setLocalTransform(trf);
}
示例9: Vec4
void Flow::SelfEquilibrium()
{
Vec4 sum = fvec.ltf +
fvec.rtf +
fvec.ldf +
fvec.rdf +
fvec.ltb +
fvec.rtb +
fvec.ldb +
fvec.rdb;
sum = Vec4(sum.m_x/8.0f, sum.m_y/8.0f, sum.m_z/8.0f);
fvec.ltf = Vec4(Vec4(fvec.ltf.m_x + sum.m_x,
fvec.ltf.m_y + sum.m_y,
fvec.ltf.m_z + sum.m_z)
* m_equilibrium_factor) + (fvec.rtf * fvec.rtf.dot(sum) * m_equilibrium_factor);
// m_equilibrium_factor;
fvec.rtf = Vec4(Vec4(fvec.rtf.m_x + sum.m_x,
fvec.rtf.m_y + sum.m_y,
fvec.rtf.m_z + sum.m_z)
* m_equilibrium_factor) + (fvec.rtf * fvec.rtf.dot(sum)* m_equilibrium_factor);
//* m_equilibrium_factor);
fvec.ldf = Vec4(Vec4(fvec.ldf.m_x + sum.m_x,
fvec.ldf.m_y + sum.m_y,
fvec.ldf.m_z + sum.m_z)
* m_equilibrium_factor) + (fvec.ldf * fvec.ldf.dot(sum)* m_equilibrium_factor);
//m_equilibrium_factor);
fvec.rdf = Vec4(Vec4(fvec.rdf.m_x + sum.m_x,
fvec.rdf.m_y + sum.m_y,
fvec.rdf.m_z + sum.m_z)
* m_equilibrium_factor) + (fvec.rdf * fvec.rdf.dot(sum)* m_equilibrium_factor);
// * m_equilibrium_factor);
fvec.ltb = Vec4(Vec4(fvec.ltb.m_x + sum.m_x,
fvec.ltb.m_y + sum.m_y ,
fvec.ltb.m_z + sum.m_z )
* m_equilibrium_factor) + (fvec.ltf * fvec.ltb.dot(sum)* m_equilibrium_factor);
// * m_equilibrium_factor);
fvec.rtb = Vec4(Vec4(fvec.rtb.m_x + sum.m_x,
fvec.rtb.m_y + sum.m_y,
fvec.rtb.m_z + sum.m_z )
* m_equilibrium_factor) + (fvec.rtf * fvec.rtb.dot(sum));
// * m_equilibrium_factor);
fvec.ldb = Vec4(Vec4(fvec.ldb.m_x + sum.m_x,
fvec.ldb.m_y + sum.m_y,
fvec.ldb.m_z + sum.m_z)
* m_equilibrium_factor) + (fvec.ldf / fvec.rdb.dist(sum));
//* m_equilibrium_factor);
fvec.rdb = Vec4(Vec4(fvec.rdb.m_x + sum.m_x,
fvec.rdb.m_y + sum.m_y,
fvec.rdb.m_z + sum.m_z)
* m_equilibrium_factor) + (fvec.rdf / fvec.ldb.dist(sum));
//* m_equilibrium_factor);
}
示例10: buildAtlas
/* Assembles atlas from tileset and autotile bitmaps */
void buildAtlas()
{
updateAutotileInfo();
TileAtlas::BlitVec blits = TileAtlas::calcBlits(atlas.efTilesetH, atlas.size);
/* Clear atlas */
FBO::bind(atlas.gl.fbo, FBO::Draw);
glState.clearColor.pushSet(Vec4());
glState.scissorTest.pushSet(false);
FBO::clear();
glState.scissorTest.pop();
glState.clearColor.pop();
/* Blit autotiles */
for (size_t i = 0; i < atlas.usableATs.size(); ++i)
{
const uint8_t atInd = atlas.usableATs[i];
Bitmap *autotile = autotiles[atInd];
int blitW = std::min(autotile->width(), atAreaW);
int blitH = std::min(autotile->height(), atAreaH);
FBO::bind(autotile->getGLTypes().fbo, FBO::Read);
if (blitW <= autotileW && tiles.animated)
{
/* Static autotile */
for (int j = 0; j < 4; ++j)
FBO::blit(0, 0, autotileW*j, atInd*autotileH, blitW, blitH);
}
else
{
/* Animated autotile */
FBO::blit(0, 0, 0, atInd*autotileH, blitW, blitH);
}
}
/* Blit tileset */
if (tileset->megaSurface())
{
/* Mega surface tileset */
FBO::unbind(FBO::Draw);
TEX::bind(atlas.gl.tex);
SDL_Surface *tsSurf = tileset->megaSurface();
for (size_t i = 0; i < blits.size(); ++i)
{
const TileAtlas::Blit &blitOp = blits[i];
GLMeta::subRectImageUpload(tsSurf->w, blitOp.src.x, blitOp.src.y,
blitOp.dst.x, blitOp.dst.y, tsLaneW, blitOp.h, tsSurf, GL_RGBA);
}
GLMeta::subRectImageFinish();
}
else
{
/* Regular tileset */
FBO::bind(tileset->getGLTypes().fbo, FBO::Read);
for (size_t i = 0; i < blits.size(); ++i)
{
const TileAtlas::Blit &blitOp = blits[i];
FBO::blit(blitOp.src.x, blitOp.src.y, blitOp.dst.x, blitOp.dst.y, tsLaneW, blitOp.h);
}
}
}
示例11: color
void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
if (_skeleton)
_skeleton->updateBoneMatrix();
Color4F color(getDisplayedColor());
color.a = getDisplayedOpacity() / 255.0f;
//check light and determine the shader used
const auto& lights = Director::getInstance()->getRunningScene()->getLights();
bool usingLight = false;
for (const auto light : lights) {
usingLight = ((unsigned int)light->getLightFlag() & _lightMask) > 0;
if (usingLight)
break;
}
if (usingLight != _shaderUsingLight)
genGLProgramState(usingLight);
int i = 0;
for (auto& mesh : _meshes) {
if (!mesh->isVisible())
{
i++;
continue;
}
auto programstate = mesh->getGLProgramState();
auto& meshCommand = mesh->getMeshCommand();
#if (!defined NDEBUG) || (defined CC_MODEL_VIEWER)
GLuint textureID = 0;
if(mesh->getTexture())
{
textureID = mesh->getTexture()->getName();
}else
{ //let the mesh use a dummy texture instead of the missing or crashing texture file
auto texture = getDummyTexture();
mesh->setTexture(texture);
textureID = texture->getName();
}
#else
GLuint textureID = mesh->getTexture() ? mesh->getTexture()->getName() : 0;
#endif
float globalZ = _globalZOrder;
bool isTransparent = (mesh->_isTransparent || color.a < 1.f);
if (isTransparent && Camera::getVisitingCamera())
{ // use the view matrix for Applying to recalculating transparent mesh's Z-Order
const auto& viewMat = Camera::getVisitingCamera()->getViewMatrix();
globalZ = -(viewMat.m[2] * transform.m[12] + viewMat.m[6] * transform.m[13] + viewMat.m[10] * transform.m[14] + viewMat.m[14]);//fetch the Z from the result matrix
}
meshCommand.init(globalZ, textureID, programstate, _blend, mesh->getVertexBuffer(), mesh->getIndexBuffer(), mesh->getPrimitiveType(), mesh->getIndexFormat(), mesh->getIndexCount(), transform);
meshCommand.setLightMask(_lightMask);
auto skin = mesh->getSkin();
if (skin)
{
meshCommand.setMatrixPaletteSize((int)skin->getMatrixPaletteSize());
meshCommand.setMatrixPalette(skin->getMatrixPalette());
}
//support tint and fade
meshCommand.setDisplayColor(Vec4(color.r, color.g, color.b, color.a));
meshCommand.setTransparent(isTransparent);
renderer->addCommand(&meshCommand);
}
}
示例12: Vec4
void FloatsToVec4Node::Operate() {
mValue = Vec4(mX.Get(), mY.Get(), mZ.Get(), mW.Get());
}
示例13: sizeof
//.........这里部分代码省略.........
}
Vec3 halfwidth = particle->width * 0.5f * right;
Vec3 halfheight = particle->height * 0.5f * up;
Vec3 offset = halfwidth * offsetX + halfheight * offsetY;
//transform.transformPoint(particle->position, &position);
position = particle->position;
if (_rotateType == TEXTURE_COORDS) {
float costheta = cosf(-particle->zRotation);
float sintheta = sinf(-particle->zRotation);
Vec2 texOffset = 0.5f * (particle->lb_uv + particle->rt_uv);
Vec2 val;
val.set((particle->lb_uv.x - texOffset.x), (particle->lb_uv.y - texOffset.y));
val.set(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
fillVertex(vertexindex, (position + (-halfwidth - halfheight + offset)), particle->color, val + texOffset);
val.set(particle->rt_uv.x - texOffset.x, particle->lb_uv.y - texOffset.y);
val.set(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
fillVertex(vertexindex + 1, (position + (halfwidth - halfheight + offset)), particle->color, val + texOffset);
val.set(particle->lb_uv.x - texOffset.x, particle->rt_uv.y - texOffset.y);
val.set(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
fillVertex(vertexindex + 2, (position + (-halfwidth + halfheight + offset)), particle->color, val + texOffset);
val.set(particle->rt_uv.x - texOffset.x, particle->rt_uv.y - texOffset.y);
val.set(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
fillVertex(vertexindex + 3, (position + (halfwidth + halfheight + offset)), particle->color, val + texOffset);
} else {
Mat4::createRotation(backward, -particle->zRotation, &pRotMat);
fillVertex(vertexindex , (position + pRotMat * (- halfwidth - halfheight + offset)), particle->color, particle->lb_uv);
fillVertex(vertexindex + 1, (position + pRotMat * (halfwidth - halfheight + offset)), particle->color, Vec2(particle->rt_uv.x, particle->lb_uv.y));
fillVertex(vertexindex + 2, (position + pRotMat * (-halfwidth + halfheight + offset)), particle->color, Vec2(particle->lb_uv.x, particle->rt_uv.y));
fillVertex(vertexindex + 3, (position + pRotMat * (halfwidth + halfheight + offset)), particle->color, particle->rt_uv);
}
fillTriangle(index, vertexindex, vertexindex + 1, vertexindex + 3);
fillTriangle(index + 3, vertexindex, vertexindex + 3, vertexindex + 2);
//_posuvcolors[vertexindex].position = (position + (- halfwidth - halfheight + halfwidth * offsetX + halfheight * offsetY));
//_posuvcolors[vertexindex].color = particle->color;
//_posuvcolors[vertexindex].uv.set(val.x + texOffset.x, val.y + texOffset.y);
//val.set(particle->rt_uv.x - texOffset.x, particle->lb_uv.y - texOffset.y);
//val.set(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
//_posuvcolors[vertexindex + 1].position = (position + (halfwidth - halfheight + halfwidth * offsetX + halfheight * offsetY));
//_posuvcolors[vertexindex + 1].color = particle->color;
//_posuvcolors[vertexindex + 1].uv.set(val.x + texOffset.x, val.y + texOffset.y);
//
//val.set(particle->lb_uv.x - texOffset.x, particle->rt_uv.y - texOffset.y);
//val.set(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
//_posuvcolors[vertexindex + 2].position = (position + (- halfwidth + halfheight + halfwidth * offsetX + halfheight * offsetY));
//_posuvcolors[vertexindex + 2].color = particle->color;
//_posuvcolors[vertexindex + 2].uv.set(val.x + texOffset.x, val.y + texOffset.y);
//
//val.set(particle->rt_uv.x - texOffset.x, particle->rt_uv.y - texOffset.y);
//val.set(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
//_posuvcolors[vertexindex + 3].position = (position + (halfwidth + halfheight + halfwidth * offsetX + halfheight * offsetY));
//_posuvcolors[vertexindex + 3].color = particle->color;
//_posuvcolors[vertexindex + 3].uv.set(val.x + texOffset.x, val.y + texOffset.y);
//
//
//_indexData[index] = vertexindex;
//_indexData[index + 1] = vertexindex + 1;
//_indexData[index + 2] = vertexindex + 3;
//_indexData[index + 3] = vertexindex;
//_indexData[index + 4] = vertexindex + 3;
//_indexData[index + 5] = vertexindex + 2;
index += 6;
vertexindex += 4;
}
_vertices.erase(_vertices.begin() + vertexindex, _vertices.end());
_indices.erase(_indices.begin() + index, _indices.end());
if (!_vertices.empty() && !_indices.empty()) {
_vertexBuffer->updateVertices(&_vertices[0], vertexindex/* * sizeof(_posuvcolors[0])*/, 0);
_indexBuffer->updateIndices(&_indices[0], index/* * sizeof(unsigned short)*/, 0);
_stateBlock->setBlendFunc(particleSystem->getBlendFunc());
GLuint texId = (_texture ? _texture->getName() : 0);
_meshCommand->init(0,
texId,
_glProgramState,
_stateBlock,
_vertexBuffer->getVBO(),
_indexBuffer->getVBO(),
GL_TRIANGLES,
GL_UNSIGNED_SHORT,
index,
transform,
Node::FLAGS_RENDER_AS_3D);
_meshCommand->setSkipBatching(true);
_meshCommand->setTransparent(true);
_glProgramState->setUniformVec4("u_color", Vec4(1,1,1,1));
renderer->addCommand(_meshCommand);
}
}
示例14: Vec4
Vec4 operator^(const Vec4 &l, const Vec4 &r) {
float x = l.coord[1] * r.coord[2] - l.coord[2] * r.coord[1];
float y = l.coord[2] * r.coord[0] - l.coord[0] * r.coord[2];
float z = l.coord[0] * r.coord[1] - l.coord[1] * r.coord[0];
return Vec4(x, y, z, 0);
}
示例15: Vec4
Vec4 Matrix4x4::getRotationSeted()
{
return Vec4(rotx,roty,rotz);
}