-
Notifications
You must be signed in to change notification settings - Fork 65
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
Migrating from 2.01 to 2.03 #78
Comments
After a bit of research i did find this: |
As mentioned in the issue that you linked to: The (An aside: I know that this is a lame excuse for breaking changes. But JglTF is only one of ~50 spare time projects that I'm working on, and if somebody wants 'better engineered' software, then there is a simple solution for that: $$$) However, the So your original code snippet still compiles in the given form: import java.nio.ByteBuffer;
import java.util.List;
import de.javagl.jgltf.impl.v2.MeshPrimitive;
import de.javagl.jgltf.model.GltfConstants;
import de.javagl.jgltf.model.creation.BufferStructureBuilder;
public class JgltfIssue78
{
public void exportJointsAndWeights()
{
BufferStructureBuilder bufferStructureBuilder =
new BufferStructureBuilder();
MeshPrimitive meshPrimitive = new MeshPrimitive();
List<ByteBuffer> buffers = null; // writeJointsAndWeights(bones);
int jointsAccessorIndex = bufferStructureBuilder.getNumAccessorModels();
bufferStructureBuilder.createAccessorModel(
"jointsAccessor_" + jointsAccessorIndex,
GltfConstants.GL_UNSIGNED_SHORT, "VEC4", buffers.get(0));
meshPrimitive.addAttributes("JOINTS_0", jointsAccessorIndex);
bufferStructureBuilder
.createArrayElementBufferViewModel("joints_bufferView");
int weightsAccessorIndex =
bufferStructureBuilder.getNumAccessorModels();
bufferStructureBuilder.createAccessorModel(
"weightsAccessor_" + weightsAccessorIndex, GltfConstants.GL_FLOAT,
"VEC4", buffers.get(1));
meshPrimitive.addAttributes("WEIGHTS_0", weightsAccessorIndex);
bufferStructureBuilder
.createArrayElementBufferViewModel("weights_bufferView");
}
} (I hope that there are no breaking changes in the functionality, but ... you might give it a try...)
The The Here is an example that shows how a "complex, custom" attribute can be added: import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
import de.javagl.jgltf.model.GltfConstants;
import de.javagl.jgltf.model.creation.AccessorModels;
import de.javagl.jgltf.model.creation.MeshPrimitiveBuilder;
import de.javagl.jgltf.model.impl.DefaultAccessorModel;
import de.javagl.jgltf.model.impl.DefaultMeshPrimitiveModel;
import de.javagl.jgltf.model.io.Buffers;
public class JgltfIssue78b
{
public void builderExample()
{
int indices[] = null;
float positions[] = null;
float normals[] = null;
short[] mySpecialAttributeData = null;
// Add the attribute data for the commonly used attributes
// using the convenience methods:
MeshPrimitiveBuilder b = MeshPrimitiveBuilder.create();
b.setIntIndicesAsShort(IntBuffer.wrap(indices));
b.addPositions3D(FloatBuffer.wrap(positions));
b.addNormals3D(FloatBuffer.wrap(normals));
// Handle the 'mySpecialAttribute' data here. Just to have a complex
// example, this is an attribute that contains normalized unsigned
// short 2D vectors....
int componentType = GltfConstants.GL_UNSIGNED_SHORT;
String type = "VEC2";
boolean normalized = true;
ByteBuffer attributeData = Buffers.createByteBufferFrom(
ShortBuffer.wrap(mySpecialAttributeData));
DefaultAccessorModel mySpecialAttribute = AccessorModels.create(
componentType, type, normalized, attributeData);
b.addAttribute("_MY_SPECIAL_ATTRIBUTE", mySpecialAttribute);
DefaultMeshPrimitiveModel meshPrimitiveModel = b.build();
}
} The idea here is, roughly speaking:
Or to put it that way: There certainly wouldn't be a point in adding methods like
to the However, you made a valid point: The I'll consider adding these (and leave this issue open until this was addressed). But I always have to emphasize: All this is not yet 100% settled. Also see the message in this commit - I'd have to invest more time to arrive at a (more) stable solution locally, before publishing it. But at least, this way, I may receive valuable feedback, like the point about joints and weights that you just brought up. |
Using jgltf-model dependency(https://mvnrepository.com/artifact/de.javagl/jgltf-model/2.0.3) like before but just version changed from 2.01 to 2.03 this still does not compile for me (creation package doesn't even exist) unless that's because it's not published yet
Yeah this is exactly what i was trying to say, i agree that adding a bunch of convenience methods like
dam, i was not aware you were working on this many projects, anyway i actually wanted to make a new issue to ask about this but since you already sorta mentioned it, i'll ask it here. |
The I guess the relevant point here is: This library is not part of Try adding the following dependency to your
I haven't looked into the details of possible sponsorship, and somehow doubt that there's soooo much interest in what I'm doing: Nearly everything that I'm doing also exists as a *Script-npm library, often backed by large companies and many contributors (yes, sometimes sponsored). Setting up the infrastructure for sponsoring (including tax forms and whatnot) would probably not be worth the hassle. (I'm a freelancer, though. Wrapping a certain task into a fixed-price, fixed-time work contract could be much easier and goal-oriented...) |
Thanks, everything works exactly as before now.
at least for this project i don't think that's the case as this is the only library i found that allowed me to easily construct glTF models in java from a set of data(positions, vertices, tex coords, joints, weights etc) and reading a glTF was very easy as well |
This is obsolete with the release of 2.0.4. This might also include "breaking changes", but hopefully very few and very narrow ones. (Yeah, I know, proper "semantic vesioning" would be nice. But I'm juggling with time and priorities here...). I started a change log at https://github.com/javagl/JglTF/blob/master/CHANGES.md - maybe that helps for future changes. |
A year ago i started working on a glTF converter tool (custom format -> glTF and vice versa) and it was fairly easy to do using this library, i never fully finished the project and decided to start working on it again now.
Last time i simply referred to jgltf-obj and built it based on that.
However now i decided to upgrade to the latest jgltf model (at least latest in mavenrepository) and seems like a lot has changed.
To be more specific, one specific class
BufferStructureBuilder
which i used heavily no longer exists, so code like this:no longer compiles.
Edit: im aware that
BufferStructureBuilder
was only supposed to be used internally as i remember you mentioning it in an issue i made a while ago: #55 (comment)So i believe my main question is what's the easiest way currently to construct a glTF file from a set of data (vertices, indices, normals, materials, joints/bones etc) as im aware that i probably have to rewrite most of my current code (probably best bet would be to just start from scratch).
I also don't mind using 'non-released modules' like the jgltf-model-builder (at least i didn't find a release of it in maven repo) or any other branches that are more up to date but just isn't released yet as i can just clone these easily rather easily and include in my project if it does make it any easier
The text was updated successfully, but these errors were encountered: