void Text3D::UpdateGeometry(const FrameInfo& frame) { if (fontDataLost_) { // Re-evaluation of the text triggers the font face to reload itself UpdateTextBatches(); UpdateTextMaterials(); fontDataLost_ = false; } // In case is being rendered from multiple views, recalculate camera facing & fixed size if (faceCameraMode_ != FC_NONE || fixedScreenSize_) CalculateFixedScreenSize(frame); if (geometryDirty_) { for (unsigned i = 0; i < batches_.Size() && i < uiBatches_.Size(); ++i) { Geometry* geometry = geometries_[i]; geometry->SetDrawRange(TRIANGLE_LIST, 0, 0, uiBatches_[i].vertexStart_, (uiBatches_[i].vertexEnd_ - uiBatches_[i].vertexStart_) / UI_VERTEX_SIZE); } } if ((geometryDirty_ || vertexBuffer_->IsDataLost()) && uiVertexData_.Size()) { unsigned vertexCount = uiVertexData_.Size() / UI_VERTEX_SIZE; if (vertexBuffer_->GetVertexCount() != vertexCount) vertexBuffer_->SetSize(vertexCount, MASK_POSITION | MASK_COLOR | MASK_TEXCOORD1); vertexBuffer_->SetData(&uiVertexData_[0]); } geometryDirty_ = false; }
void BillboardSet::UpdateBatches(const FrameInfo& frame) { // If beginning a new frame, assume no sorting first if (frame.frameNumber_ != sortFrameNumber_) { sortThisFrame_ = false; sortFrameNumber_ = frame.frameNumber_; } Vector3 worldPos = node_->GetWorldPosition(); Vector3 offset = (worldPos - frame.camera_->GetNode()->GetWorldPosition()); // Sort if position relative to camera has changed if (offset != previousOffset_ || frame.camera_->IsOrthographic() != hasOrthoCamera_) { if (sorted_) sortThisFrame_ = true; if (faceCameraMode_ == FC_DIRECTION) bufferDirty_ = true; hasOrthoCamera_ = frame.camera_->IsOrthographic(); } // Calculate fixed screen size scale factor for billboards. Will not dirty the buffer unless actually changed if (fixedScreenSize_) CalculateFixedScreenSize(frame); distance_ = frame.camera_->GetDistance(GetWorldBoundingBox().Center()); // Calculate scaled distance for animation LOD float scale = GetWorldBoundingBox().Size().DotProduct(DOT_SCALE); // If there are no billboards, the size becomes zero, and LOD'ed updates no longer happen. Disable LOD in that case if (scale > M_EPSILON) lodDistance_ = frame.camera_->GetLodDistance(distance_, scale, lodBias_); else lodDistance_ = 0.0f; batches_[0].distance_ = distance_; batches_[0].numWorldTransforms_ = 2; // Billboard positioning transforms_[0] = relative_ ? node_->GetWorldTransform() : Matrix3x4::IDENTITY; // Billboard rotation transforms_[1] = Matrix3x4(Vector3::ZERO, faceCameraMode_ != FC_NONE ? frame.camera_->GetFaceCameraRotation( node_->GetWorldPosition(), node_->GetWorldRotation(), faceCameraMode_, minAngle_) : node_->GetWorldRotation(), Vector3::ONE); }
void BillboardSet::UpdateGeometry(const FrameInfo& frame) { // If rendering from multiple views and fixed screen size is in use, re-update scale factors before each render if (fixedScreenSize_ && viewCameras_.Size() > 1) CalculateFixedScreenSize(frame); // If using camera facing, re-update the rotation for the current view now if (faceCameraMode_ != FC_NONE) { transforms_[1] = Matrix3x4(Vector3::ZERO, frame.camera_->GetFaceCameraRotation(node_->GetWorldPosition(), node_->GetWorldRotation(), faceCameraMode_, minAngle_), Vector3::ONE); } if (bufferSizeDirty_ || indexBuffer_->IsDataLost()) UpdateBufferSize(); if (bufferDirty_ || sortThisFrame_ || vertexBuffer_->IsDataLost()) UpdateVertexBuffer(frame); }
void Text3D::UpdateBatches(const FrameInfo& frame) { distance_ = frame.camera_->GetDistance(GetWorldBoundingBox().Center()); if (faceCameraMode_ != FC_NONE || fixedScreenSize_) CalculateFixedScreenSize(frame); for (unsigned i = 0; i < batches_.Size(); ++i) { batches_[i].distance_ = distance_; batches_[i].worldTransform_ = faceCameraMode_ != FC_NONE ? &customWorldTransform_ : &node_->GetWorldTransform(); } for (unsigned i = 0; i < uiBatches_.Size(); ++i) { if (uiBatches_[i].texture_ && uiBatches_[i].texture_->IsDataLost()) { fontDataLost_ = true; break; } } }