javagl / obj Goto Github PK
View Code? Open in Web Editor NEWA simple Wavefront OBJ file loader
License: Other
A simple Wavefront OBJ file loader
License: Other
Hey, I'm trying to debug this one... I've got an obj that I loaded from Google Poly where the faces aren't being drawn quite right. I think it has to do with the complex faces that it defines. If I find the fix I'll send a pull request but I figured you should know about it.
model.zip
Can I use this library for load obj and mtl files in Android for vuforia?
If yes can you please suggest a way ?
Thanks
Hi, I have been trying to learn to work with 3d rendering and was trying to load an obj file with your loader but it loads strangely. This is what it looks like when I render it.
I tried to render the same by breaking it into material groups and looping it. Now it's close to the real thing.It's still not perfect though.
when i load only one material group, the center oval should look like this,
but instead it looks like this. Do you have Any idea why this could be happening?
The method Obj#setActiveGroupNames()
fails with a NullPointerException
if used on a collection generated by Set.of()
or List.of()
. This is because those collections throw an exception if you try to test if they contain null
, which you do when in the block:
else if (groupNames.contains(null))
{
throw new NullPointerException("The groupNames contains null");
}
This is pretty annoying because if you're trying to add a face to only one group, that's what you'll be using 90% of the time.
Hey, I'm not really sure this belongs in this library but I don't have a much better way to communicate with you. I found a model https://poly.google.com/view/eydI4__jXpi that does not contain normal vectors for one of the material groups. This makes the model render all black when computing the diffuse color since it's multiplied by the dot product of the face normal and the light direction.
This can be computed by calculating the normal of every face that a vertex is a part of and taking the average of these as the vertex normal. I added code to ObjUtils.convertToRenderable
that does this but it's slow (about 21.5 seconds on a Pixel phone), even then I clearly did something wrong because the color isn't quite right (I'm still getting some black spots). Here's the commit to my branch where I added the code to inject normals: GoMeta@aefde24
Do you know if there's a better way to make sure that all the faces/vertices have the appropriate normals?
Hi,
thank you for your Loader. Works fine,
but:
maybe you have an idea why my model stands head.
I am using the plain arrays from the ObjFile.
Another question would be: the parameter dimensions in the ObjData.getTexCoordArrays(obj, dimension) is for the format of my Texture Coordinates (in my case 2).
Thank you very much!
I have working ar-core android sample using your library to read obj files and render in opengl es.I have 200mb obj file its not read by simple wavefront loader library it causes the java.lang.OutOfMemoryError.But 110 obj files were read perfectly.is any to solve this problem?
Version 0.3.0, class MtlReader
, line 160-161:
String mapKd = line.substring("map_Kd".length()).trim();
currentMtl.setMapKd(mapKd);
If line is "\tmap_Kd wood.jpg"
, we will get mapKd String value as a "d wood.jpg"
.
We must also cut "d "
On package de.javagl.jgltf.obj.model;
public class ObjGltfModelCreator
Method: public GltfModel create(URI objUri) throws IOException
String mtlFileName = baseName + ".mtl";
URI mtlUri = IO.makeAbsolute(baseUri, mtlFileName);
Obj obj = readObj(objUri);
if (IO.existsUnchecked(mtlUri))
may i know if this tool can convert osm file(open street map file) to obj?
In 0.3.0 supported mtl attributes are:
Ka - Ambient component
Ks - Specular component
Kd - Diffuse component
map_Kd - Diffuse map
Ns - Shininess
D - Opacity
can we introduce more support to mtl attribute, such as pbr attributes:
Pr/map_Pr # roughness
Pm/map_Pm # metallic
Ps/map_Ps # sheen
Pc # clearcoat thickness
Pcr # clearcoat roughness
Ke/map_Ke # emissive
aniso # anisotropy
anisor # anisotropy rotation
norm # normal map (RGB components represent XYZ components of the surface normal)
btw, I'ved add these attribute locally since I was developing a ar demo, and I'm willing to share my solution and create a mr, if possible.
is there any coverage standard or requirement if I want to contribute my solution.
Thanks
Found a small bug when a friend sent me a material file with the following:
newmtl mat18
Ka 0.00 0.00 0.00
Kd 0.00 0.00 0.00
map_Kd TextureFile.png
This resulted in a DefaultMtl
object with name tl_mat18
and mapKd p_Kd TextureFile.png
Hai iam working ar-core augment reality in android.Rendering object using opengl es and reading obj and mtl file using simple Wavefront OBJ file loader library.I want to know how to get transparency factor from mtl file using this library and apply to the object using opengl es.
Is really need the initial value (kd, ks, ka) of DefaultMtl ?
I think it should be possible to determine the case where no value is specified.
Current codes
DefaultMtl(String name)
{
this.name = name;
ka = new DefaultFloatTuple(0,0,0);
kd = new DefaultFloatTuple(0,0,0);
ks = new DefaultFloatTuple(0,0,0);
ns = 100.0f;
d = 1.0f;
}
private final DefaultFloatTuple ka;
private final DefaultFloatTuple kd;
private final DefaultFloatTuple ks;
java.lang.NullPointerException: Attempt to invoke virtual method 'void de.javagl.DefaultMtl.setKd(float, float, float)' on a null object reference
Tried loading it with input stream as well as with reader instance
nothing happend lel
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.