Comments (18)
Hi. If you want to paint yourself the model programmatically, you would have to parse the groups of the model and save it on the Object3DData. Then you will be able to paint them independently, with material or any color.
So, in order to save the groups for later processing, you need at least a structure like this:
IdGroup : gasoline_tank
vertexList:1,2,30,41,1000,etc
IdGroup:. wheels
vertexList:. 23,24,80,2000,etc
With that structure you can populate arrayVertexColorBuffer object.
from android-3d-model-viewer.
Hi, Replace the setColor function in Object3DData.java like this:
public Object3DData setColor(float[] color) {
// color variable when using single color
this.color = color;
// color buffer when using multiple colors
if (this.vertexColorsArrayBuffer != null && this.vertexColorsArrayBuffer.capacity() > 0){
for (int i=0; i<vertexColorsArrayBuffer.capacity(); i+=4){
vertexColorsArrayBuffer.put(i,color[0]);
vertexColorsArrayBuffer.put(i+1,color[1]);
vertexColorsArrayBuffer.put(i+2,color[2]);
vertexColorsArrayBuffer.put(i+3,color[3]);
}
}
return this;
}
Then call
obj.setColor(new float[] { 1f, 0f, 1f, 1f });
from android-3d-model-viewer.
Hi. If you want to paint yourself the model programmatically, you would have to parse the groups of the model and save it on the Object3DData. Then you will be able to paint them independently, with material or any color.
So, in order to save the groups for later processing, you need at least a structure like this:
IdGroup : gasoline_tank vertexList:1,2,30,41,1000,etc IdGroup:. wheels vertexList:. 23,24,80,2000,etc
With that structure you can populate arrayVertexColorBuffer object.
Hi. Ok, so that means i need to modify the WavefrontLoader class in the readModel method for parse the group over 'o' rigth?
from android-3d-model-viewer.
Hi ritup. Are you trying to load ToyPlane.obj from external SD card? If so, please attach the log to see what error you have. KR
from android-3d-model-viewer.
No I am not having error
It shows green color in app & in online site it shows orange color
from android-3d-model-viewer.
from android-3d-model-viewer.
from android-3d-model-viewer.
Hey. Not sure to understand your last question. What API? The different Kd colors are linked to the different parts of the 3d obj file.
In the ToyModel example you have 3 colors only and a texture.
from android-3d-model-viewer.
from android-3d-model-viewer.
hi @ritup22 not sure to understand. are you trying to change the colors of the loaded model in your app?
regards
from android-3d-model-viewer.
from android-3d-model-viewer.
Hey. The change colors feature is not implemented.
If you want to do it yourself, you would have to post process the materials in Object3DData.java
Here is were the colors are generated for 3D Object3DBuilder.java#L515
I am chaning the title of this issue to "Implement API to change model colors"
from android-3d-model-viewer.
Hi,
I am also getting the same issue. When I am loading a model, it's color is changing. The original color of the model is white but when I am loading the model its color is changing to green.
from android-3d-model-viewer.
Hi @andresoviedo,
I am also trying to implement this feature. I founded where can we change the material (in my case) attached to the obj but this is not showing when the object is already created and showing, i guess i need to refresh the scene or something...
How can i re-build or re-read the object to showing the changes?
Regards
from android-3d-model-viewer.
// color buffer when using multiple colors
if (this.vertexColorsArrayBuffer != null && this.vertexColorsArrayBuffer.capacity() > 0){
for (int i=0; i<vertexColorsArrayBuffer.capacity(); i+=4){
vertexColorsArrayBuffer.put(i,color[0]);
vertexColorsArrayBuffer.put(i+1,color[1]);
vertexColorsArrayBuffer.put(i+2,color[2]);
vertexColorsArrayBuffer.put(i+3,color[3]);
}
}
Thanks for the answer. It works fine but this code paint all the object to the specified color. Is there any way to set the color to specified material? This is the code what i've works on
obj.materials.materials["Material.003"]?.kd = WavefrontLoader.Tuple3(0.0f, 0.0f, 0.0f)
obtaining the material and set the color to it.
->
from android-3d-model-viewer.
@sk8dar yes. You would need to:
- extend Object3DData with a Map<String,IntBuffer>
- improve Wavefrontloader to parse groups.
Regards
from android-3d-model-viewer.
API has the method Oject3DData.setColor(float[])
available.
from android-3d-model-viewer.
Hi. If you want to paint yourself the model programmatically, you would have to parse the groups of the model and save it on the Object3DData. Then you will be able to paint them independently, with material or any color.
So, in order to save the groups for later processing, you need at least a structure like this:IdGroup : gasoline_tank vertexList:1,2,30,41,1000,etc IdGroup:. wheels vertexList:. 23,24,80,2000,etc
With that structure you can populate arrayVertexColorBuffer object.
Hi. Ok, so that means i need to modify the WavefrontLoader class in the readModel method for parse the group over 'o' rigth?
Hello you this group of different color inside implements, please can you help me, I need your demo
from android-3d-model-viewer.
Related Issues (20)
- improve demo feature
- implement geometry demo
- rename packages and rebrand to org.the3deer
- F-Droid build failed HOT 5
- How to rotate camera on Y axis by angle (-180 degrees ~ 180 degrees)
- I want to load a single model directly from REPO_URL HOT 1
- Load Texture from picture does not work
- How to display text under each object? I tried many methods but failed
- Load the text record for reference to anyone who encounters the same problem HOT 1
- How to add a sliding buffer effect when the gesture is dragged up HOT 1
- Some GLTF model load failed HOT 1
- lighting effects HOT 2
- How to display in AR?
- Can't build
- Camera lag
- The problem that the bounding box is not drawn
- Can we add jpeg or PNG file on GLTF file on specific position using library settings or functions
- Using android-3D-model-viewer as library
- The loaded 3D model can be deleted and then reloaded with a new one
- How to render the dae object on opengl for ARCore?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-3d-model-viewer.