Modify Primitive properties

Started by CarlosMB89, June 27, 2015, 01:01:01 PM

Previous topic - Next topic

CarlosMB89

Hello

I was developing an app for Android with JPCT and I would like to change the height of a cylinder dinamically.

Would it be possible? Because I didn't found any method to do that.

Thanks in advance.

EgonOlsen

The simplest way to do that, is by multiplying the object's rotation matrix with a none-uniform scaling matrix. Something like


Matrix m=new Matrix();
m.set(1,1,2f);
cylinder.getRotation().matMul(m);


However, this affects lighting in a way that might look strange. Just give it a try and see if it's sufficient. If it's not, please report back here and we'll find another solution.

CarlosMB89

Hello Egon, I tried it but the height doesn't change. It has no effect. What could I do then??

Thank you

EgonOlsen

Please double check your code. I don't see any reason why it shouldn't work, unless you are doing something the the objects rotation matrix afterwards.

CarlosMB89

Ok, sorry, I fixed it. The problem was as you said thai I changed the orientation of the object before.
But I still have a problem about the light as you said as well.

When the object grows in the oposite direction, the lights of the object turns off. It has no illumination. How can I fix it?

Thank you

EgonOlsen

What do you mean by 'opposite direction' in this case?

CarlosMB89

This means that my cylinder grows along the positive X axis and then it grows about the negative X axis, but when it grows this way the lights turn off....

EgonOlsen

Yes, because that will invert the normals...I'll try to figure something out...

EgonOlsen

Why does it actually grow along the negative axis? Are you using a negative scale? If that's the case, try to add this:


cyl.invertCulling(scale < 0);


If that's not the case, then I'm not sure if I understand the problem correctly...

EgonOlsen

BTW: Please fix your mail address. I'm getting bounces with "user unknown" each time the forum system tries to send a mail to you.