|
@@ -53,6 +53,7 @@ const char* faceCameraModeNames[] =
|
|
|
"Rotate Y",
|
|
"Rotate Y",
|
|
|
"LookAt XYZ",
|
|
"LookAt XYZ",
|
|
|
"LookAt Y",
|
|
"LookAt Y",
|
|
|
|
|
+ "Rotate Along Direction",
|
|
|
0
|
|
0
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -104,7 +105,7 @@ void BillboardSet::RegisterObject(Context* context)
|
|
|
URHO3D_ACCESSOR_ATTRIBUTE("Sort By Distance", IsSorted, SetSorted, bool, false, AM_DEFAULT);
|
|
URHO3D_ACCESSOR_ATTRIBUTE("Sort By Distance", IsSorted, SetSorted, bool, false, AM_DEFAULT);
|
|
|
URHO3D_ACCESSOR_ATTRIBUTE("Can Be Occluded", IsOccludee, SetOccludee, bool, true, AM_DEFAULT);
|
|
URHO3D_ACCESSOR_ATTRIBUTE("Can Be Occluded", IsOccludee, SetOccludee, bool, true, AM_DEFAULT);
|
|
|
URHO3D_ATTRIBUTE("Cast Shadows", bool, castShadows_, false, AM_DEFAULT);
|
|
URHO3D_ATTRIBUTE("Cast Shadows", bool, castShadows_, false, AM_DEFAULT);
|
|
|
- URHO3D_ENUM_ATTRIBUTE("Face Camera Mode", faceCameraMode_, faceCameraModeNames, FC_ROTATE_XYZ, AM_DEFAULT);
|
|
|
|
|
|
|
+ URHO3D_ENUM_ACCESSOR_ATTRIBUTE("Face Camera Mode", GetFaceCameraMode, SetFaceCameraMode, FaceCameraMode, faceCameraModeNames, FC_ROTATE_XYZ, AM_DEFAULT);
|
|
|
URHO3D_ACCESSOR_ATTRIBUTE("Draw Distance", GetDrawDistance, SetDrawDistance, float, 0.0f, AM_DEFAULT);
|
|
URHO3D_ACCESSOR_ATTRIBUTE("Draw Distance", GetDrawDistance, SetDrawDistance, float, 0.0f, AM_DEFAULT);
|
|
|
URHO3D_ACCESSOR_ATTRIBUTE("Shadow Distance", GetShadowDistance, SetShadowDistance, float, 0.0f, AM_DEFAULT);
|
|
URHO3D_ACCESSOR_ATTRIBUTE("Shadow Distance", GetShadowDistance, SetShadowDistance, float, 0.0f, AM_DEFAULT);
|
|
|
URHO3D_ACCESSOR_ATTRIBUTE("Animation LOD Bias", GetAnimationLodBias, SetAnimationLodBias, float, 1.0f, AM_DEFAULT);
|
|
URHO3D_ACCESSOR_ATTRIBUTE("Animation LOD Bias", GetAnimationLodBias, SetAnimationLodBias, float, 1.0f, AM_DEFAULT);
|
|
@@ -170,8 +171,13 @@ void BillboardSet::UpdateBatches(const FrameInfo& frame)
|
|
|
Vector3 worldPos = node_->GetWorldPosition();
|
|
Vector3 worldPos = node_->GetWorldPosition();
|
|
|
Vector3 offset = (worldPos - frame.camera_->GetNode()->GetWorldPosition());
|
|
Vector3 offset = (worldPos - frame.camera_->GetNode()->GetWorldPosition());
|
|
|
// Sort if position relative to camera has changed
|
|
// Sort if position relative to camera has changed
|
|
|
- if (offset != previousOffset_ & sorted_)
|
|
|
|
|
- sortThisFrame_ = true;
|
|
|
|
|
|
|
+ if (offset != previousOffset_)
|
|
|
|
|
+ {
|
|
|
|
|
+ if(sorted_)
|
|
|
|
|
+ sortThisFrame_ = true;
|
|
|
|
|
+ if(faceCameraMode_ == FC_DIRECTION)
|
|
|
|
|
+ bufferDirty_ = true;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
distance_ = frame.camera_->GetDistance(GetWorldBoundingBox().Center());
|
|
distance_ = frame.camera_->GetDistance(GetWorldBoundingBox().Center());
|
|
|
|
|
|
|
@@ -188,8 +194,11 @@ void BillboardSet::UpdateBatches(const FrameInfo& frame)
|
|
|
// Billboard positioning
|
|
// Billboard positioning
|
|
|
transforms_[0] = relative_ ? node_->GetWorldTransform() : Matrix3x4::IDENTITY;
|
|
transforms_[0] = relative_ ? node_->GetWorldTransform() : Matrix3x4::IDENTITY;
|
|
|
// Billboard rotation
|
|
// Billboard rotation
|
|
|
- transforms_[1] = Matrix3x4(Vector3::ZERO, faceCameraMode_ != FC_NONE ? frame.camera_->GetFaceCameraRotation(
|
|
|
|
|
- node_->GetWorldPosition(), node_->GetWorldRotation(), faceCameraMode_) : node_->GetWorldRotation(), Vector3::ONE);
|
|
|
|
|
|
|
+ if (faceCameraMode_ != FC_DIRECTION)
|
|
|
|
|
+ {
|
|
|
|
|
+ transforms_[1] = Matrix3x4(Vector3::ZERO, faceCameraMode_ != FC_NONE ? frame.camera_->GetFaceCameraRotation(
|
|
|
|
|
+ node_->GetWorldPosition(), node_->GetWorldRotation(), faceCameraMode_) : node_->GetWorldRotation(), Vector3::ONE);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void BillboardSet::UpdateGeometry(const FrameInfo& frame)
|
|
void BillboardSet::UpdateGeometry(const FrameInfo& frame)
|
|
@@ -201,7 +210,7 @@ void BillboardSet::UpdateGeometry(const FrameInfo& frame)
|
|
|
UpdateVertexBuffer(frame);
|
|
UpdateVertexBuffer(frame);
|
|
|
|
|
|
|
|
// If using camera facing, re-update the rotation for the current view now
|
|
// If using camera facing, re-update the rotation for the current view now
|
|
|
- if (faceCameraMode_ != FC_NONE)
|
|
|
|
|
|
|
+ if (faceCameraMode_ != FC_NONE || faceCameraMode_ != FC_DIRECTION)
|
|
|
{
|
|
{
|
|
|
transforms_[1] = Matrix3x4(Vector3::ZERO, frame.camera_->GetFaceCameraRotation(node_->GetWorldPosition(),
|
|
transforms_[1] = Matrix3x4(Vector3::ZERO, frame.camera_->GetFaceCameraRotation(node_->GetWorldPosition(),
|
|
|
node_->GetWorldRotation(), faceCameraMode_), Vector3::ONE);
|
|
node_->GetWorldRotation(), faceCameraMode_), Vector3::ONE);
|
|
@@ -245,6 +254,7 @@ void BillboardSet::SetNumBillboards(unsigned num)
|
|
|
billboards_[i].uv_ = Rect::POSITIVE;
|
|
billboards_[i].uv_ = Rect::POSITIVE;
|
|
|
billboards_[i].color_ = Color(1.0f, 1.0f, 1.0f);
|
|
billboards_[i].color_ = Color(1.0f, 1.0f, 1.0f);
|
|
|
billboards_[i].rotation_ = 0.0f;
|
|
billboards_[i].rotation_ = 0.0f;
|
|
|
|
|
+ billboards_[i].direction_ = Vector3::UP;
|
|
|
billboards_[i].enabled_ = false;
|
|
billboards_[i].enabled_ = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -272,8 +282,19 @@ void BillboardSet::SetSorted(bool enable)
|
|
|
|
|
|
|
|
void BillboardSet::SetFaceCameraMode(FaceCameraMode mode)
|
|
void BillboardSet::SetFaceCameraMode(FaceCameraMode mode)
|
|
|
{
|
|
{
|
|
|
- faceCameraMode_ = mode;
|
|
|
|
|
- MarkNetworkUpdate();
|
|
|
|
|
|
|
+ if((faceCameraMode_ != FC_DIRECTION && mode == FC_DIRECTION) || (faceCameraMode_ == FC_DIRECTION && mode != FC_DIRECTION))
|
|
|
|
|
+ {
|
|
|
|
|
+ faceCameraMode_ = mode;
|
|
|
|
|
+ if(faceCameraMode_ == FC_DIRECTION)
|
|
|
|
|
+ batches_[0].geometryType_ = GEOM_DIRBILLBOARD;
|
|
|
|
|
+ else batches_[0].geometryType_ = GEOM_BILLBOARD;
|
|
|
|
|
+ geometryTypeUpdate_ = true;
|
|
|
|
|
+ bufferSizeDirty_ = true;
|
|
|
|
|
+ Commit();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ faceCameraMode_ = mode;
|
|
|
|
|
+ MarkNetworkUpdate();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void BillboardSet::SetAnimationLodBias(float bias)
|
|
void BillboardSet::SetAnimationLodBias(float bias)
|
|
@@ -310,16 +331,31 @@ void BillboardSet::SetBillboardsAttr(const VariantVector& value)
|
|
|
unsigned numBillboards = index < value.Size() ? value[index++].GetUInt() : 0;
|
|
unsigned numBillboards = index < value.Size() ? value[index++].GetUInt() : 0;
|
|
|
SetNumBillboards(numBillboards);
|
|
SetNumBillboards(numBillboards);
|
|
|
|
|
|
|
|
- for (PODVector<Billboard>::Iterator i = billboards_.Begin(); i != billboards_.End() && index < value.Size(); ++i)
|
|
|
|
|
- {
|
|
|
|
|
- i->position_ = value[index++].GetVector3();
|
|
|
|
|
- i->size_ = value[index++].GetVector2();
|
|
|
|
|
- Vector4 uv = value[index++].GetVector4();
|
|
|
|
|
- i->uv_ = Rect(uv.x_, uv.y_, uv.z_, uv.w_);
|
|
|
|
|
- i->color_ = value[index++].GetColor();
|
|
|
|
|
- i->rotation_ = value[index++].GetFloat();
|
|
|
|
|
- i->enabled_ = value[index++].GetBool();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // Dealing with old billboard format
|
|
|
|
|
+ if(value.Size() == billboards_.Size() * 6 + 1)
|
|
|
|
|
+ for (PODVector<Billboard>::Iterator i = billboards_.Begin(); i != billboards_.End() && index < value.Size(); ++i)
|
|
|
|
|
+ {
|
|
|
|
|
+ i->position_ = value[index++].GetVector3();
|
|
|
|
|
+ i->size_ = value[index++].GetVector2();
|
|
|
|
|
+ Vector4 uv = value[index++].GetVector4();
|
|
|
|
|
+ i->uv_ = Rect(uv.x_, uv.y_, uv.z_, uv.w_);
|
|
|
|
|
+ i->color_ = value[index++].GetColor();
|
|
|
|
|
+ i->rotation_ = value[index++].GetFloat();
|
|
|
|
|
+ i->enabled_ = value[index++].GetBool();
|
|
|
|
|
+ }
|
|
|
|
|
+ // New billboard format
|
|
|
|
|
+ else
|
|
|
|
|
+ for (PODVector<Billboard>::Iterator i = billboards_.Begin(); i != billboards_.End() && index < value.Size(); ++i)
|
|
|
|
|
+ {
|
|
|
|
|
+ i->position_ = value[index++].GetVector3();
|
|
|
|
|
+ i->size_ = value[index++].GetVector2();
|
|
|
|
|
+ Vector4 uv = value[index++].GetVector4();
|
|
|
|
|
+ i->uv_ = Rect(uv.x_, uv.y_, uv.z_, uv.w_);
|
|
|
|
|
+ i->color_ = value[index++].GetColor();
|
|
|
|
|
+ i->rotation_ = value[index++].GetFloat();
|
|
|
|
|
+ i->direction_ = value[index++].GetVector3();
|
|
|
|
|
+ i->enabled_ = value[index++].GetBool();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
Commit();
|
|
Commit();
|
|
|
}
|
|
}
|
|
@@ -337,6 +373,7 @@ void BillboardSet::SetNetBillboardsAttr(const PODVector<unsigned char>& value)
|
|
|
i->uv_ = buf.ReadRect();
|
|
i->uv_ = buf.ReadRect();
|
|
|
i->color_ = buf.ReadColor();
|
|
i->color_ = buf.ReadColor();
|
|
|
i->rotation_ = buf.ReadFloat();
|
|
i->rotation_ = buf.ReadFloat();
|
|
|
|
|
+ i->direction_ = buf.ReadVector3();
|
|
|
i->enabled_ = buf.ReadBool();
|
|
i->enabled_ = buf.ReadBool();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -351,7 +388,7 @@ ResourceRef BillboardSet::GetMaterialAttr() const
|
|
|
VariantVector BillboardSet::GetBillboardsAttr() const
|
|
VariantVector BillboardSet::GetBillboardsAttr() const
|
|
|
{
|
|
{
|
|
|
VariantVector ret;
|
|
VariantVector ret;
|
|
|
- ret.Reserve(billboards_.Size() * 6 + 1);
|
|
|
|
|
|
|
+ ret.Reserve(billboards_.Size() * 7 + 1);
|
|
|
ret.Push(billboards_.Size());
|
|
ret.Push(billboards_.Size());
|
|
|
|
|
|
|
|
for (PODVector<Billboard>::ConstIterator i = billboards_.Begin(); i != billboards_.End(); ++i)
|
|
for (PODVector<Billboard>::ConstIterator i = billboards_.Begin(); i != billboards_.End(); ++i)
|
|
@@ -361,6 +398,7 @@ VariantVector BillboardSet::GetBillboardsAttr() const
|
|
|
ret.Push(Vector4(i->uv_.min_.x_, i->uv_.min_.y_, i->uv_.max_.x_, i->uv_.max_.y_));
|
|
ret.Push(Vector4(i->uv_.min_.x_, i->uv_.min_.y_, i->uv_.max_.x_, i->uv_.max_.y_));
|
|
|
ret.Push(i->color_);
|
|
ret.Push(i->color_);
|
|
|
ret.Push(i->rotation_);
|
|
ret.Push(i->rotation_);
|
|
|
|
|
+ ret.Push(i->direction_);
|
|
|
ret.Push(i->enabled_);
|
|
ret.Push(i->enabled_);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -379,6 +417,7 @@ const PODVector<unsigned char>& BillboardSet::GetNetBillboardsAttr() const
|
|
|
attrBuffer_.WriteRect(i->uv_);
|
|
attrBuffer_.WriteRect(i->uv_);
|
|
|
attrBuffer_.WriteColor(i->color_);
|
|
attrBuffer_.WriteColor(i->color_);
|
|
|
attrBuffer_.WriteFloat(i->rotation_);
|
|
attrBuffer_.WriteFloat(i->rotation_);
|
|
|
|
|
+ attrBuffer_.WriteVector3(i->direction_);
|
|
|
attrBuffer_.WriteBool(i->enabled_);
|
|
attrBuffer_.WriteBool(i->enabled_);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -416,8 +455,18 @@ void BillboardSet::UpdateBufferSize()
|
|
|
{
|
|
{
|
|
|
unsigned numBillboards = billboards_.Size();
|
|
unsigned numBillboards = billboards_.Size();
|
|
|
|
|
|
|
|
- if (vertexBuffer_->GetVertexCount() != numBillboards * 4)
|
|
|
|
|
- vertexBuffer_->SetSize(numBillboards * 4, MASK_POSITION | MASK_COLOR | MASK_TEXCOORD1 | MASK_TEXCOORD2, true);
|
|
|
|
|
|
|
+ if (vertexBuffer_->GetVertexCount() != numBillboards * 4 || geometryTypeUpdate_)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (faceCameraMode_ == FC_DIRECTION)
|
|
|
|
|
+ {
|
|
|
|
|
+ geometry_->SetVertexBuffer(0, vertexBuffer_, MASK_POSITION | MASK_NORMAL | MASK_COLOR | MASK_TEXCOORD1 | MASK_TEXCOORD2 | MASK_TANGENT);
|
|
|
|
|
+ vertexBuffer_->SetSize(numBillboards * 4, MASK_POSITION | MASK_NORMAL | MASK_COLOR | MASK_TEXCOORD1 | MASK_TEXCOORD2 | MASK_TANGENT, true);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ geometry_->SetVertexBuffer(0, vertexBuffer_, MASK_POSITION | MASK_COLOR | MASK_TEXCOORD1 | MASK_TEXCOORD2);
|
|
|
|
|
+ vertexBuffer_->SetSize(numBillboards * 4, MASK_POSITION | MASK_COLOR | MASK_TEXCOORD1 | MASK_TEXCOORD2, true);
|
|
|
|
|
+ }
|
|
|
|
|
+ geometryTypeUpdate_ = false;
|
|
|
|
|
+ }
|
|
|
if (indexBuffer_->GetIndexCount() != numBillboards * 6)
|
|
if (indexBuffer_->GetIndexCount() != numBillboards * 6)
|
|
|
indexBuffer_->SetSize(numBillboards * 6, false);
|
|
indexBuffer_->SetSize(numBillboards * 6, false);
|
|
|
|
|
|
|
@@ -514,56 +563,140 @@ void BillboardSet::UpdateVertexBuffer(const FrameInfo& frame)
|
|
|
if (!dest)
|
|
if (!dest)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
- for (unsigned i = 0; i < enabledBillboards; ++i)
|
|
|
|
|
|
|
+ if(faceCameraMode_ != FC_DIRECTION)
|
|
|
{
|
|
{
|
|
|
- Billboard& billboard = *sortedBillboards_[i];
|
|
|
|
|
-
|
|
|
|
|
- Vector2 size(billboard.size_.x_ * billboardScale.x_, billboard.size_.y_ * billboardScale.y_);
|
|
|
|
|
- unsigned color = billboard.color_.ToUInt();
|
|
|
|
|
-
|
|
|
|
|
- float rotationMatrix[2][2];
|
|
|
|
|
- rotationMatrix[0][0] = Cos(billboard.rotation_);
|
|
|
|
|
- rotationMatrix[0][1] = Sin(billboard.rotation_);
|
|
|
|
|
- rotationMatrix[1][0] = -rotationMatrix[0][1];
|
|
|
|
|
- rotationMatrix[1][1] = rotationMatrix[0][0];
|
|
|
|
|
-
|
|
|
|
|
- dest[0] = billboard.position_.x_;
|
|
|
|
|
- dest[1] = billboard.position_.y_;
|
|
|
|
|
- dest[2] = billboard.position_.z_;
|
|
|
|
|
- ((unsigned&)dest[3]) = color;
|
|
|
|
|
- dest[4] = billboard.uv_.min_.x_;
|
|
|
|
|
- dest[5] = billboard.uv_.min_.y_;
|
|
|
|
|
- dest[6] = -size.x_ * rotationMatrix[0][0] + size.y_ * rotationMatrix[0][1];
|
|
|
|
|
- dest[7] = -size.x_ * rotationMatrix[1][0] + size.y_ * rotationMatrix[1][1];
|
|
|
|
|
-
|
|
|
|
|
- dest[8] = billboard.position_.x_;
|
|
|
|
|
- dest[9] = billboard.position_.y_;
|
|
|
|
|
- dest[10] = billboard.position_.z_;
|
|
|
|
|
- ((unsigned&)dest[11]) = color;
|
|
|
|
|
- dest[12] = billboard.uv_.max_.x_;
|
|
|
|
|
- dest[13] = billboard.uv_.min_.y_;
|
|
|
|
|
- dest[14] = size.x_ * rotationMatrix[0][0] + size.y_ * rotationMatrix[0][1];
|
|
|
|
|
- dest[15] = size.x_ * rotationMatrix[1][0] + size.y_ * rotationMatrix[1][1];
|
|
|
|
|
-
|
|
|
|
|
- dest[16] = billboard.position_.x_;
|
|
|
|
|
- dest[17] = billboard.position_.y_;
|
|
|
|
|
- dest[18] = billboard.position_.z_;
|
|
|
|
|
- ((unsigned&)dest[19]) = color;
|
|
|
|
|
- dest[20] = billboard.uv_.max_.x_;
|
|
|
|
|
- dest[21] = billboard.uv_.max_.y_;
|
|
|
|
|
- dest[22] = size.x_ * rotationMatrix[0][0] - size.y_ * rotationMatrix[0][1];
|
|
|
|
|
- dest[23] = size.x_ * rotationMatrix[1][0] - size.y_ * rotationMatrix[1][1];
|
|
|
|
|
-
|
|
|
|
|
- dest[24] = billboard.position_.x_;
|
|
|
|
|
- dest[25] = billboard.position_.y_;
|
|
|
|
|
- dest[26] = billboard.position_.z_;
|
|
|
|
|
- ((unsigned&)dest[27]) = color;
|
|
|
|
|
- dest[28] = billboard.uv_.min_.x_;
|
|
|
|
|
- dest[29] = billboard.uv_.max_.y_;
|
|
|
|
|
- dest[30] = -size.x_ * rotationMatrix[0][0] - size.y_ * rotationMatrix[0][1];
|
|
|
|
|
- dest[31] = -size.x_ * rotationMatrix[1][0] - size.y_ * rotationMatrix[1][1];
|
|
|
|
|
-
|
|
|
|
|
- dest += 32;
|
|
|
|
|
|
|
+ for (unsigned i = 0; i < enabledBillboards; ++i)
|
|
|
|
|
+ {
|
|
|
|
|
+ Billboard& billboard = *sortedBillboards_[i];
|
|
|
|
|
+
|
|
|
|
|
+ Vector2 size(billboard.size_.x_ * billboardScale.x_, billboard.size_.y_ * billboardScale.y_);
|
|
|
|
|
+ unsigned color = billboard.color_.ToUInt();
|
|
|
|
|
+
|
|
|
|
|
+ float rotationMatrix[2][2];
|
|
|
|
|
+ rotationMatrix[0][0] = Cos(billboard.rotation_);
|
|
|
|
|
+ rotationMatrix[0][1] = Sin(billboard.rotation_);
|
|
|
|
|
+ rotationMatrix[1][0] = -rotationMatrix[0][1];
|
|
|
|
|
+ rotationMatrix[1][1] = rotationMatrix[0][0];
|
|
|
|
|
+
|
|
|
|
|
+ dest[0] = billboard.position_.x_;
|
|
|
|
|
+ dest[1] = billboard.position_.y_;
|
|
|
|
|
+ dest[2] = billboard.position_.z_;
|
|
|
|
|
+ ((unsigned&)dest[3]) = color;
|
|
|
|
|
+ dest[4] = billboard.uv_.min_.x_;
|
|
|
|
|
+ dest[5] = billboard.uv_.min_.y_;
|
|
|
|
|
+ dest[6] = -size.x_ * rotationMatrix[0][0] + size.y_ * rotationMatrix[0][1];
|
|
|
|
|
+ dest[7] = -size.x_ * rotationMatrix[1][0] + size.y_ * rotationMatrix[1][1];
|
|
|
|
|
+
|
|
|
|
|
+ dest[8] = billboard.position_.x_;
|
|
|
|
|
+ dest[9] = billboard.position_.y_;
|
|
|
|
|
+ dest[10] = billboard.position_.z_;
|
|
|
|
|
+ ((unsigned&)dest[11]) = color;
|
|
|
|
|
+ dest[12] = billboard.uv_.max_.x_;
|
|
|
|
|
+ dest[13] = billboard.uv_.min_.y_;
|
|
|
|
|
+ dest[14] = size.x_ * rotationMatrix[0][0] + size.y_ * rotationMatrix[0][1];
|
|
|
|
|
+ dest[15] = size.x_ * rotationMatrix[1][0] + size.y_ * rotationMatrix[1][1];
|
|
|
|
|
+
|
|
|
|
|
+ dest[16] = billboard.position_.x_;
|
|
|
|
|
+ dest[17] = billboard.position_.y_;
|
|
|
|
|
+ dest[18] = billboard.position_.z_;
|
|
|
|
|
+ ((unsigned&)dest[19]) = color;
|
|
|
|
|
+ dest[20] = billboard.uv_.max_.x_;
|
|
|
|
|
+ dest[21] = billboard.uv_.max_.y_;
|
|
|
|
|
+ dest[22] = size.x_ * rotationMatrix[0][0] - size.y_ * rotationMatrix[0][1];
|
|
|
|
|
+ dest[23] = size.x_ * rotationMatrix[1][0] - size.y_ * rotationMatrix[1][1];
|
|
|
|
|
+
|
|
|
|
|
+ dest[24] = billboard.position_.x_;
|
|
|
|
|
+ dest[25] = billboard.position_.y_;
|
|
|
|
|
+ dest[26] = billboard.position_.z_;
|
|
|
|
|
+ ((unsigned&)dest[27]) = color;
|
|
|
|
|
+ dest[28] = billboard.uv_.min_.x_;
|
|
|
|
|
+ dest[29] = billboard.uv_.max_.y_;
|
|
|
|
|
+ dest[30] = -size.x_ * rotationMatrix[0][0] - size.y_ * rotationMatrix[0][1];
|
|
|
|
|
+ dest[31] = -size.x_ * rotationMatrix[1][0] - size.y_ * rotationMatrix[1][1];
|
|
|
|
|
+
|
|
|
|
|
+ dest += 32;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else
|
|
|
|
|
+ {
|
|
|
|
|
+ for (unsigned i = 0; i < enabledBillboards; ++i)
|
|
|
|
|
+ {
|
|
|
|
|
+ Billboard& billboard = *sortedBillboards_[i];
|
|
|
|
|
+
|
|
|
|
|
+ Vector2 size(billboard.size_.x_ * billboardScale.x_, billboard.size_.y_ * billboardScale.y_);
|
|
|
|
|
+ unsigned color = billboard.color_.ToUInt();
|
|
|
|
|
+
|
|
|
|
|
+ float rot2D[2][2];
|
|
|
|
|
+ rot2D[0][0] = Cos(billboard.rotation_);
|
|
|
|
|
+ rot2D[0][1] = Sin(billboard.rotation_);
|
|
|
|
|
+ rot2D[1][0] = -rot2D[0][1];
|
|
|
|
|
+ rot2D[1][1] = rot2D[0][0];
|
|
|
|
|
+
|
|
|
|
|
+ dest[0] = billboard.position_.x_;
|
|
|
|
|
+ dest[1] = billboard.position_.y_;
|
|
|
|
|
+ dest[2] = billboard.position_.z_;
|
|
|
|
|
+ dest[3] = billboard.direction_.x_;
|
|
|
|
|
+ dest[4] = billboard.direction_.y_;
|
|
|
|
|
+ dest[5] = billboard.direction_.z_;
|
|
|
|
|
+ ((unsigned&)dest[6]) = color;
|
|
|
|
|
+ dest[7] = billboard.uv_.min_.x_;
|
|
|
|
|
+ dest[8] = billboard.uv_.min_.y_;
|
|
|
|
|
+ dest[9] = -size.x_ * rot2D[0][0] + size.y_ * rot2D[0][1];
|
|
|
|
|
+ dest[10] = -size.x_ * rot2D[1][0] + size.y_ * rot2D[1][1];
|
|
|
|
|
+ dest[11] = frame.camera_->GetNode()->GetWorldPosition().x_;
|
|
|
|
|
+ dest[12] = frame.camera_->GetNode()->GetWorldPosition().y_;
|
|
|
|
|
+ dest[13] = frame.camera_->GetNode()->GetWorldPosition().z_;
|
|
|
|
|
+ dest[14] = 1.0f;
|
|
|
|
|
+
|
|
|
|
|
+ dest[15] = billboard.position_.x_;
|
|
|
|
|
+ dest[16] = billboard.position_.y_;
|
|
|
|
|
+ dest[17] = billboard.position_.z_;
|
|
|
|
|
+ dest[18] = billboard.direction_.x_;
|
|
|
|
|
+ dest[19] = billboard.direction_.y_;
|
|
|
|
|
+ dest[20] = billboard.direction_.z_;
|
|
|
|
|
+ ((unsigned&)dest[21]) = color;
|
|
|
|
|
+ dest[22] = billboard.uv_.max_.x_;
|
|
|
|
|
+ dest[23] = billboard.uv_.min_.y_;
|
|
|
|
|
+ dest[24] = size.x_ * rot2D[0][0] + size.y_ * rot2D[0][1];
|
|
|
|
|
+ dest[25] = size.x_ * rot2D[1][0] + size.y_ * rot2D[1][1];
|
|
|
|
|
+ dest[26] = frame.camera_->GetNode()->GetWorldPosition().x_;
|
|
|
|
|
+ dest[27] = frame.camera_->GetNode()->GetWorldPosition().y_;
|
|
|
|
|
+ dest[28] = frame.camera_->GetNode()->GetWorldPosition().z_;
|
|
|
|
|
+ dest[29] = 1.0f;
|
|
|
|
|
+
|
|
|
|
|
+ dest[30] = billboard.position_.x_;
|
|
|
|
|
+ dest[31] = billboard.position_.y_;
|
|
|
|
|
+ dest[32] = billboard.position_.z_;
|
|
|
|
|
+ dest[33] = billboard.direction_.x_;
|
|
|
|
|
+ dest[34] = billboard.direction_.y_;
|
|
|
|
|
+ dest[35] = billboard.direction_.z_;
|
|
|
|
|
+ ((unsigned&)dest[36]) = color;
|
|
|
|
|
+ dest[37] = billboard.uv_.max_.x_;
|
|
|
|
|
+ dest[38] = billboard.uv_.max_.y_;
|
|
|
|
|
+ dest[39] = size.x_ * rot2D[0][0] - size.y_ * rot2D[0][1];
|
|
|
|
|
+ dest[40] = size.x_ * rot2D[1][0] - size.y_ * rot2D[1][1];
|
|
|
|
|
+ dest[41] = frame.camera_->GetNode()->GetWorldPosition().x_;
|
|
|
|
|
+ dest[42] = frame.camera_->GetNode()->GetWorldPosition().y_;
|
|
|
|
|
+ dest[43] = frame.camera_->GetNode()->GetWorldPosition().z_;
|
|
|
|
|
+ dest[44] = 1.0f;
|
|
|
|
|
+
|
|
|
|
|
+ dest[45] = billboard.position_.x_;
|
|
|
|
|
+ dest[46] = billboard.position_.y_;
|
|
|
|
|
+ dest[47] = billboard.position_.z_;
|
|
|
|
|
+ dest[48] = billboard.direction_.x_;
|
|
|
|
|
+ dest[49] = billboard.direction_.y_;
|
|
|
|
|
+ dest[50] = billboard.direction_.z_;
|
|
|
|
|
+ ((unsigned&)dest[51]) = color;
|
|
|
|
|
+ dest[52] = billboard.uv_.min_.x_;
|
|
|
|
|
+ dest[53] = billboard.uv_.max_.y_;
|
|
|
|
|
+ dest[54] = -size.x_ * rot2D[0][0] - size.y_ * rot2D[0][1];
|
|
|
|
|
+ dest[55] = -size.x_ * rot2D[1][0] - size.y_ * rot2D[1][1];
|
|
|
|
|
+ dest[56] = frame.camera_->GetNode()->GetWorldPosition().x_;
|
|
|
|
|
+ dest[57] = frame.camera_->GetNode()->GetWorldPosition().y_;
|
|
|
|
|
+ dest[58] = frame.camera_->GetNode()->GetWorldPosition().z_;
|
|
|
|
|
+ dest[59] = 1.0f;
|
|
|
|
|
+
|
|
|
|
|
+ dest += 60;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
vertexBuffer_->Unlock();
|
|
vertexBuffer_->Unlock();
|