-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New RectangleMesh shape class #1701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This RectangleMesh class was created based on the idea proposed at https://hub.jmonkeyengine.org/t/next-release-of-the-engine/44988/170
jme3-core/src/main/java/com/jme3/scene/shape/RectangleMesh.java
Outdated
Show resolved
Hide resolved
jme3-core/src/main/java/com/jme3/scene/shape/RectangleMesh.java
Outdated
Show resolved
Hide resolved
|
This is better. There might be advantages in adding methods to the |
|
Also ... thinking ahead to how we might test I encourage you to modify these apps (and others) to use |
|
Yes, a Anyway, I am going to open a new PR to add Also, I'll take a look at the examples and modify them to use |
|
Normals (of rectangles) are used to calculate distances and for other purposes that have nothing to do with meshes. So a method to calculate the normal would have broad application, in my opinion. One tricky thing about normals is documenting how the sign of the normal is determined... |
|
P.S.: Note that the |
|
I moved the I used this PR to make the changes in |
|
It's okay to make both changes in the same PR, since they're so closely related. However, I think it's unwise to change the semantics of |
|
The thing is if you do the math you won't find the fourth point of the rectangle with that formula. Instead, you will find a point outside the rectangle area. I don't know where the original developers of |
|
The old formula assumes that the order of the vertices (as you follow the rectangle's perimeter) is A-B-D-C. This isn't the usual labeling used in math textbooks (which favor A-B-C-D). It was careless of Mark and Joshua to use a non-standard vertex ordering without documenting it, but I wouldn't call it a bug. I'm very reluctant to change the vertex order. After 12+ years of telling developers that D = (B + C) - A, it's very likely someone used that formula, even if it wasn't coded into jme3-core. The best we can do is document the gotchas, including this one. |
|
I Understand. Back to the original formula. I documented the order of the vertices in the first javadoc entry of |
Modified to use RectangleMesh instead of Quad.
Modified to use RectangleMesh instead of Quad.
Modified to use RectangleMesh instead of Quad.
Modified to use RectangleMesh instead of Quad.
|
Though I still wonder how many of these 'new' shape classes could be replaced by a couple of static methods that operate on any mesh. |
Operating on any mesh is a tall order, since JME meshes are extremely flexible: animated/morphing/non-animated, indexed/non-indexed, 9 mesh modes, 9 buffer formats, and all with/without binormals/normals/tangents/UVs/colors, All this flexibility is great for writing importers and generating custom meshes, not so good if you want to manipulate meshes in a general way. I've been writing mesh-edit utilities for years, but I still don't grok all the options. So you write a simple utility to translate the vertex positions, but you forget to update the bounds. Or you forget to translate the bind positions of an animated mesh. Then someone finds a mesh with a double-precision position buffer. Or throws interleaved data at it. |
|
You know what I meant. Certainly, the dozens of custom shape objects folks are about to make just to offset this or twist that are all going to use the position buffer, normal buffer, etc.. Two or three static methods and a Quad would have been fine. Then you get the added benefit that those static methods would work for box, sphere, <insert any mesh with a Position, Normal, Tangent, etc. buffer here>. "Write a new shape class every time we want to center a thing" doesn't seem like the right answer. |
|
While I certainly agree we should be cautious about adding While not perfect, I believe this PR is ready to be integrated. @fba-rio I'd like to document a few caveats and other details. Would it be OK for me to make last-minute changes to the javadoc before integration? |
Sure, go ahead! |
|
While writing javadoc, I noticed a few issues:
float x = b.x + c.x - a.x;
float y = b.y + c.y - a.y;
float z = b.z + c.z - a.z;
return new Vector3f(x, y, z);
What do you think? |
Changed the access modifier of updateMesh() from public to protected.
Shouldn't the responsibility to provide a valid vector lie with the developer who calls this method? If not, what do you think should be done in this case?
Good point. I made the necessary change.
It is protected now.
You're right. Renamed. I think you've made a mistake in the javadoc of |
It's not that simple. For any particular parallelogram, there are 2 plausible normal vectors. For instance, a square in the X-Y plane could have normals of either +Z or -Z. I think the most likely use for I see many possible solutions. One would be to update the winding order in An even simpler possibility would be to just get rid of |
|
What does |
|
This is the down side to all-in-one classes versus utility methods. Always one more edge case instead of letting the user just pick the behavior they want. |
My bad. I used a seamless texture in my tests and ended up neglecting the texture on |
|
How would you like to resolve this issue? |
|
Sorry, I missed 1f20015 for some reason, so ignore my last comment. I'm still concerned about Please describe what |
|
I've rewritten the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should do it! Thanks for your patience.
|
Thanks for your contribution to the project, Francivan! I enjoyed collaborating with you. |
|
My pleasure! |
This RectangleMesh class was created based on the idea proposed at https://hub.jmonkeyengine.org/t/next-release-of-the-engine/44988/170