Skip to content
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

Setting the color of .obj file. #72

Open
abhishek1508 opened this issue Oct 3, 2017 · 6 comments
Open

Setting the color of .obj file. #72

abhishek1508 opened this issue Oct 3, 2017 · 6 comments

Comments

@abhishek1508
Copy link

Hello,

I am new to the field of 3D modeling in android. I am trying to load an .obj file (in this case, it is a car) and try to rotate it 360 degrees. I have been successfully able to do that. Now, I am trying to change the color of the car using the code below to black color.

`public class ObjectRenderer extends RajawaliRenderer {

private DirectionalLight directionalLight;
private Object3D mObjectGroup;
private Animation3D mCameraAnim, mLightAnim;

public ObjectRenderer(Context context) {
    super(context);
}

@Override
protected void initScene() {
    getCurrentScene().setBackgroundColor(1.0f, 1.0f, 1.0f, 1.0f);
    getCurrentCamera().setZ(16);

    LoaderOBJ objParser = new LoaderOBJ(mContext.getResources(), mTextureManager, R.raw.bmw);
    try {
        objParser.parse();
        mObjectGroup = objParser.getParsedObject();
        mObjectGroup.setScale(0.04f);
        mObjectGroup.setPosition(0.0f, -1.5f, 5.0f);
        //mObjectGroup.setColor(Color.BLACK) // I have tried this as well

        Material simple = new Material();
        simple.setColor(Color.BLACK); //I am setting the color here to black
        mObjectGroup.setMaterial(simple);

        getCurrentScene().addChild(mObjectGroup);

        mCameraAnim = new RotateOnAxisAnimation(Vector3.Axis.Y, 360);
        mCameraAnim.setDurationMilliseconds(8000);
        mCameraAnim.setRepeatMode(Animation.RepeatMode.INFINITE);
        mCameraAnim.setTransformable3D(mObjectGroup);
    } catch (ParsingException e) {
        e.printStackTrace();
    }
    getCurrentScene().registerAnimation(mCameraAnim);
    mCameraAnim.play();
}

@Override
public void onOffsetsChanged(float xOffset, float yOffset, float xOffsetStep, float yOffsetStep, int xPixelOffset, int yPixelOffset) {
}

@Override
public void onTouchEvent(MotionEvent event) {
}

}`

The issue is I cannot see the color change on the object. This is what I see no matter what color I add.

screenshot_2017-10-04-06-05-06-197_com application threesixtyrotation

Can please someone tell me if I am missing something.

@jwoolston
Copy link
Member

Before setting the material add sjmple.setColorInfluence(1.0f)

@abhishek1508
Copy link
Author

@jwoolston Thanks for the reply. I added this line of code. It still doesn't work. I also tried to add a texture to the Material. That doesn't work as well.
simple.addTexture(new Texture("texture", R.drawable.checkerboard));

@SenthilPrabhuBose
Copy link

SenthilPrabhuBose commented Jan 7, 2018

@abhishek1508 I am also struck with the same issue. Is there any solution or work around for this issue.

@MrSagarShah
Copy link

@jwoolston
Hi
I am new to this.
As fas as i have read the coloring code for the .obj model is stored in side the .mtl file.
So my question is how can i load .mtl file coded color in my .obj model?
Thanks

@surajappentus
Copy link

Still similar issue facing , please provide solution or (update the library) @jwoolston @abhishek1508 @MrSagarShah @SenthilPrabhuBose @tenaciousRas

Thanks

@surajappentus
Copy link

ss_sofa_non_colored

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants