Add a picking example
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Documentation
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- cpp
- Domain
- computer-graphics
Research direction
The issue names DirectXTK::BoundingSphere, SimpleMath::Matrix, and the view, projection, and world matrices, but no repository files or tests. Start by locating existing examples and the bounding-volume or picking APIs, then determine how translated objects should be handled. Done means a documented picking example that addresses the reported translation case.
Written by the indexing model from the issue text.
Description
It would help to have a picking method.
I'm trying to make my own, it doesn't work fully, what if the object is translated.
std::shared_ptr<item> Pick(float mouseX,float mouseY)
{
// Right Hand conversion
float pointX = (((2.0f * (float)mouseX) / (float)wi) - 1.0f) * -1.0f;
float pointY = (((2.0f * (float)mouseY) / (float)he) - 1.0f);
Vector3 origin = Vector3(pointX, pointY, 0);
Vector3 farx = Vector3(pointX, pointY, 1);
for (auto& m : models)
{
DirectXTK::BoundingSphere b = m->get_bounding_sphere(); // uses DirectXTK
SimpleMath::Matrix worldMatrix = m->world; // how to use this?
auto m1 = m_view * m_proj;
Matrix m2;
m1.Invert(m2);
// Now transform the ray origin and the ray direction from view space to world space.
auto rayOrigin = XMVector3TransformCoord(origin, m2);
auto rayend = XMVector3TransformCoord(farx, m2);
// Normalize the ray direction.
auto rayDirection = XMVector3Normalize(rayend - rayOrigin);
float radius = 0;
bool intersect = b.Intersects(rayOrigin, rayDirection, radius);
if (intersect == true)
return m;
}
return nullptr;
}
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 538
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 5
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/DirectXTK
-
Question about mesh bounding box center discrepancy for powerplant model in ModelLoadSDKMESH.cpp Openquestion
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Project feedback Open
Difficulty 5/5 Over a week Newbie friendliness 15/100
-
documentation
-
math proposal
Difficulty 5/5 Over a week Newbie friendliness 25/100
All issues in microsoft/DirectXTK
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100