What's new

xentr_guest_message_title Asian Coderz

xentr_guest_message_description

SF Bone Drawing Function

Status
Not open for further replies.

XorEax

Administrator
Staff member
Administrator
Joined
Dec 8, 2013
Messages
911
Reaction score
2
Points
16
Age
21
Code:
void DrawHead(CActors* Actor, DWORD Color)
{
if (Actor->IsValid())
{
	auto tTopHead = Actor->GetBonePosByName("Bip01 HeadNub");
	auto tBotHead = Actor->GetBonePosByName("Bip01 Head");

	if (W2S(&tTopHead) && W2S(&tBotHead)) {
		D3DXVECTOR3 Box = tBotHead - tTopHead;
		if (Box.y < 0) Box.y *= -1;
		int HeadRadius = (int)Box.y / 2;

		DrawCircle(tBotHead.x, tBotHead.y - HeadRadius, HeadRadius, Color);
	}
}
}

void DrawBone(CActors* Actor, LPCSTR StartBone, LPCSTR EndBone, DWORD Color)
{
if (Actor->IsValid())
{
	auto StartPos = Actor->GetBonePosByName(StartBone);
	auto EndPos = Actor->GetBonePosByName(EndBone);

	if (W2S(&StartPos) && W2S(&EndPos))
		DrawLine(StartPos.x, StartPos.y, EndPos.x, EndPos.y, Color);
}
}

void DrawPlayerBone(CActors* Actor, DWORD Color)
{
DrawHead(Actor, Color);

DrawBone(Actor, "Bip01 Neck", "Bip01 Head", Color);
DrawBone(Actor, "Bip01 Pelvis", "Bip01 Neck", Color);

DrawBone(Actor, "Bip01 L UpperArm", "Bip01 Neck1", Color);
DrawBone(Actor, "Bip01 R UpperArm", "Bip01 Neck1", Color);

DrawBone(Actor, "Bip01 L Hand", "Bip01 L UpperArm", Color);
DrawBone(Actor, "Bip01 R Hand", "Bip01 R UpperArm", Color);

DrawBone(Actor, "Bip01 L Thigh", "Bip01 Pelvis", Color);
DrawBone(Actor, "Bip01 R Thigh", "Bip01 Pelvis", Color);

DrawBone(Actor, "Bip01 L Calf", "Bip01 L Thigh", Color);
DrawBone(Actor, "Bip01 R Calf", "Bip01 R Thigh", Color);

DrawBone(Actor, "Bip01 L Foot", "Bip01 L Calf", Color);
DrawBone(Actor, "Bip01 R Foot", "Bip01 R Calf", Color);
}
 
Status
Not open for further replies.
Top Bottom