Player Indicator now working OK. Scaling depending on how far away you are makes the Indicator to hide players head behind it. Shields are making indicators to disappear.
This commit is contained in:
@@ -1,7 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
<Indicator xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Indicator.xsd">
|
<Indicator xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Indicator.xsd">
|
||||||
<MaxDistance>10</MaxDistance>
|
<MinScale>10</MinScale>
|
||||||
<MinDistance>10</MinDistance>
|
|
||||||
<MinDistance>1</MinDistance>
|
|
||||||
<MaxDistance>1</MaxDistance>
|
|
||||||
</Indicator>
|
</Indicator>
|
||||||
@@ -9,14 +9,7 @@
|
|||||||
</xs:annotation>
|
</xs:annotation>
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:all>
|
<xs:all>
|
||||||
<xs:element name="MaxDistance" type="t:double" minOccurs="0">
|
|
||||||
<xs:annotation><xs:documentation>After this distance between the camera and the sprite, the sprite will not get any smaller on the screen</xs:documentation></xs:annotation>
|
|
||||||
</xs:element>
|
|
||||||
<xs:element name="MinDistance" type="t:double" minOccurs="0">
|
|
||||||
<xs:annotation><xs:documentation>Smaller distance between the camera and the sprite, the sprite will not get any bigger on the screen</xs:documentation></xs:annotation>
|
|
||||||
</xs:element>
|
|
||||||
<xs:element name="MinScale" type="t:double" minOccurs="0"/>
|
<xs:element name="MinScale" type="t:double" minOccurs="0"/>
|
||||||
<xs:element name="MaxScale" type="t:double" minOccurs="0"/>
|
|
||||||
</xs:all>
|
</xs:all>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|||||||
@@ -349,7 +349,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Animation>
|
<c:Animation>
|
||||||
<AnimationName1>Idle</AnimationName1>
|
<AnimationName1>Idle</AnimationName1>
|
||||||
<Time1>0.30516549779527224</Time1>
|
<Time1>1.9902125899398158</Time1>
|
||||||
<Speed1>1</Speed1>
|
<Speed1>1</Speed1>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
@@ -370,8 +370,8 @@
|
|||||||
<Transparent>true</Transparent>
|
<Transparent>true</Transparent>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0.120430455" Y="-0.232123077" Z="-0.181454748"/>
|
<Position X="0.120430678" Y="-0.228444964" Z="-0.181454539"/>
|
||||||
<Orientation X="0.010404747" Y="-0.00268168887" Z="0.0428438447"/>
|
<Orientation X="0.0104046883" Y="-0.00268161646" Z="0.0428441353"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children>
|
<Children>
|
||||||
@@ -477,7 +477,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Animation>
|
<c:Animation>
|
||||||
<AnimationName1>Idle</AnimationName1>
|
<AnimationName1>Idle</AnimationName1>
|
||||||
<Time1>1.9204144556290004</Time1>
|
<Time1>1.7887947062665859</Time1>
|
||||||
<Speed1>1</Speed1>
|
<Speed1>1</Speed1>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:AnimationOffset>
|
<c:AnimationOffset>
|
||||||
@@ -501,8 +501,8 @@
|
|||||||
<Resource>Models/Weapons/Blue/AssaultWeaponBlue.mesh</Resource>
|
<Resource>Models/Weapons/Blue/AssaultWeaponBlue.mesh</Resource>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0.157390118" Y="1.03132391" Z="-0.215858489"/>
|
<Position X="0.158748239" Y="1.02847004" Z="-0.215365171"/>
|
||||||
<Orientation X="-0.0626512468" Y="-0.0318936296" Z="0.120511964"/>
|
<Orientation X="-0.0626733601" Y="-0.0367665328" Z="0.120039687"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children>
|
<Children>
|
||||||
@@ -575,7 +575,7 @@
|
|||||||
<Entity name="Indicator">
|
<Entity name="Indicator">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Indicator>
|
<c:Indicator>
|
||||||
<MaxDistance>30</MaxDistance>
|
<MinScale>80</MinScale>
|
||||||
</c:Indicator>
|
</c:Indicator>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Icons/Arrow.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Icons/Arrow.png</DiffuseTexture>
|
||||||
@@ -585,7 +585,7 @@
|
|||||||
<c:HiddenForLocalPlayer/>
|
<c:HiddenForLocalPlayer/>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="1.69509101" Z="0"/>
|
<Position X="0" Y="1.69509101" Z="0"/>
|
||||||
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
|
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children/>
|
<Children/>
|
||||||
|
|||||||
@@ -349,7 +349,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Animation>
|
<c:Animation>
|
||||||
<AnimationName1>Idle</AnimationName1>
|
<AnimationName1>Idle</AnimationName1>
|
||||||
<Time1>0.73262309029003347</Time1>
|
<Time1>1.5972608217572741</Time1>
|
||||||
<Speed1>1</Speed1>
|
<Speed1>1</Speed1>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
@@ -370,8 +370,8 @@
|
|||||||
<Transparent>true</Transparent>
|
<Transparent>true</Transparent>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0.120430365" Y="-0.24209328" Z="-0.181454867"/>
|
<Position X="0.12043044" Y="-0.234334946" Z="-0.181454733"/>
|
||||||
<Orientation X="0.0104046632" Y="-0.0026818295" Z="0.0428442396"/>
|
<Orientation X="0.0104046538" Y="-0.00268155546" Z="0.0428440906"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children>
|
<Children>
|
||||||
@@ -477,7 +477,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Animation>
|
<c:Animation>
|
||||||
<AnimationName1>Idle</AnimationName1>
|
<AnimationName1>Idle</AnimationName1>
|
||||||
<Time1>0.031207590802594609</Time1>
|
<Time1>1.0291785284465931</Time1>
|
||||||
<Speed1>1</Speed1>
|
<Speed1>1</Speed1>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:AnimationOffset>
|
<c:AnimationOffset>
|
||||||
@@ -501,8 +501,8 @@
|
|||||||
<Resource>Models/Weapons/Red/AssaultWeaponRed.mesh</Resource>
|
<Resource>Models/Weapons/Red/AssaultWeaponRed.mesh</Resource>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0.157017991" Y="1.03271544" Z="-0.216204733"/>
|
<Position X="0.163536936" Y="1.02330899" Z="-0.215455115"/>
|
||||||
<Orientation X="-0.0626475811" Y="-0.0306777786" Z="0.120614327"/>
|
<Orientation X="-0.0631270558" Y="-0.0581946671" Z="0.118220322"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children>
|
<Children>
|
||||||
@@ -575,7 +575,7 @@
|
|||||||
<Entity name="Indicator">
|
<Entity name="Indicator">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Indicator>
|
<c:Indicator>
|
||||||
<MaxDistance>30</MaxDistance>
|
<MinScale>80</MinScale>
|
||||||
</c:Indicator>
|
</c:Indicator>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Icons/Arrow.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Icons/Arrow.png</DiffuseTexture>
|
||||||
@@ -584,7 +584,7 @@
|
|||||||
<c:HiddenForLocalPlayer/>
|
<c:HiddenForLocalPlayer/>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="1.69500005" Z="0"/>
|
<Position X="0" Y="1.69500005" Z="0"/>
|
||||||
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
|
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children/>
|
<Children/>
|
||||||
|
|||||||
@@ -67,16 +67,26 @@ void RenderSystem::fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, Worl
|
|||||||
fillColor = (glm::vec4)fillComponent["Color"];
|
fillColor = (glm::vec4)fillComponent["Color"];
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 modelMatrix = glm::mat4(1);
|
glm::mat4 modelMatrix;
|
||||||
|
|
||||||
bool isIndicator = false;
|
bool isIndicator = false;
|
||||||
if (world->HasComponent(entity.ID, "Indicator") || entity.FirstParentWithComponent("Indicator").Valid())
|
if (world->HasComponent(entity.ID, "Indicator") || entity.FirstParentWithComponent("Indicator").Valid())
|
||||||
{
|
{
|
||||||
|
EntityWrapper EntityWithIndicator;
|
||||||
|
if (world->HasComponent(entity.ID, "Indicator")) {
|
||||||
|
EntityWithIndicator = entity;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
EntityWithIndicator = entity.FirstParentWithComponent("Indicator");
|
||||||
|
}
|
||||||
|
auto indicator = EntityWithIndicator["Indicator"];
|
||||||
|
|
||||||
|
float minScale = (float)(double)indicator["MinScale"];
|
||||||
isIndicator = true;
|
isIndicator = true;
|
||||||
glm::vec3 pos = Transform::AbsolutePosition(entity);
|
glm::vec3 pos = Transform::AbsolutePosition(entity);
|
||||||
|
|
||||||
|
|
||||||
// Code for shcneking if sprite is inside or outside of screen
|
// Code for check if sprite is inside or outside of screen
|
||||||
//glm::vec4 projectedPos = m_Camera->ProjectionMatrix() * m_Camera->ViewMatrix() * glm::vec4(pos, 1.0f);
|
//glm::vec4 projectedPos = m_Camera->ProjectionMatrix() * m_Camera->ViewMatrix() * glm::vec4(pos, 1.0f);
|
||||||
//projectedPos /= projectedPos.w;
|
//projectedPos /= projectedPos.w;
|
||||||
//// Check if inside of outside of screen.
|
//// Check if inside of outside of screen.
|
||||||
@@ -89,6 +99,13 @@ void RenderSystem::fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, Worl
|
|||||||
|
|
||||||
glm::vec3 zAxis = glm::vec3(0.0f, 1.0f, 0.0f);
|
glm::vec3 zAxis = glm::vec3(0.0f, 1.0f, 0.0f);
|
||||||
glm::vec3 normal = pos - m_Camera->Position();
|
glm::vec3 normal = pos - m_Camera->Position();
|
||||||
|
|
||||||
|
//float distance = glm::length(normal);
|
||||||
|
//if (distance < minDistance) {
|
||||||
|
// pos = pos - glm::normalize(normal) * (distance - minDistance);
|
||||||
|
//} else if (distance > maxDistance) {
|
||||||
|
// pos = pos - glm::normalize(normal) * (distance - maxDistance);
|
||||||
|
//}
|
||||||
normal.y = 0;
|
normal.y = 0;
|
||||||
normal = glm::normalize(normal);
|
normal = glm::normalize(normal);
|
||||||
glm::vec3 right = glm::cross(normal, zAxis);
|
glm::vec3 right = glm::cross(normal, zAxis);
|
||||||
@@ -97,21 +114,34 @@ void RenderSystem::fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, Worl
|
|||||||
modelMatrix[0][0] = right.x;
|
modelMatrix[0][0] = right.x;
|
||||||
modelMatrix[0][1] = right.y;
|
modelMatrix[0][1] = right.y;
|
||||||
modelMatrix[0][2] = right.z;
|
modelMatrix[0][2] = right.z;
|
||||||
|
modelMatrix[0][3] = 0.0f;
|
||||||
|
|
||||||
modelMatrix[1][0] = zAxis.x;
|
modelMatrix[1][0] = zAxis.x;
|
||||||
modelMatrix[1][1] = zAxis.y;
|
modelMatrix[1][1] = zAxis.y;
|
||||||
modelMatrix[1][2] = zAxis.z;
|
modelMatrix[1][2] = zAxis.z;
|
||||||
|
modelMatrix[1][3] = 0.0f;
|
||||||
|
|
||||||
modelMatrix[2][0] = normal.x;
|
modelMatrix[2][0] = normal.x;
|
||||||
modelMatrix[2][1] = normal.y;
|
modelMatrix[2][1] = normal.y;
|
||||||
modelMatrix[2][2] = normal.z;
|
modelMatrix[2][2] = normal.z;
|
||||||
|
modelMatrix[2][3] = 0.0f;
|
||||||
|
|
||||||
modelMatrix[3][0] = pos.x;
|
modelMatrix[3][0] = pos.x;
|
||||||
modelMatrix[3][1] = pos.y;
|
modelMatrix[3][1] = pos.y;
|
||||||
modelMatrix[3][2] = pos.z;
|
modelMatrix[3][2] = pos.z;
|
||||||
|
modelMatrix[3][3] = 1.0f;
|
||||||
|
|
||||||
modelMatrix = modelMatrix * glm::scale(Transform::AbsoluteScale(entity));
|
glm::mat4 tranformationMatrix = modelMatrix * glm::scale(Transform::AbsoluteScale(entity));
|
||||||
|
glm::vec4 tmp = tranformationMatrix * glm::vec4(glm::vec3(0.5, 0.5, 0), 1.0f);
|
||||||
|
glm::vec2 projectedTopRight = m_Camera->WorldToScreen(glm::vec3(tmp), m_Renderer->GetViewportSize());
|
||||||
|
tmp = tranformationMatrix * glm::vec4(glm::vec3(-0.5, -0.5, 0), 1.0f);
|
||||||
|
glm::vec2 projectedBottomLeft = m_Camera->WorldToScreen(glm::vec3(tmp), m_Renderer->GetViewportSize());
|
||||||
|
|
||||||
|
float diag = glm::length(projectedBottomLeft - projectedTopRight);
|
||||||
|
if (diag < minScale) {
|
||||||
|
tranformationMatrix = tranformationMatrix * glm::scale(glm::vec3(minScale / diag, minScale / diag, minScale / diag));
|
||||||
|
}
|
||||||
|
modelMatrix = tranformationMatrix;
|
||||||
} else {
|
} else {
|
||||||
modelMatrix = Transform::ModelMatrix(entity.ID, world);
|
modelMatrix = Transform::ModelMatrix(entity.ID, world);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user