www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: CarlosMB89 on June 27, 2015, 01:01:01 pm

Title: Modify Primitive properties
Post by: CarlosMB89 on June 27, 2015, 01:01:01 pm
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.
Title: Re: Modify Primitive properties
Post by: EgonOlsen on June 27, 2015, 08:53:00 pm
The simplest way to do that, is by multiplying the object's rotation matrix with a none-uniform scaling matrix. Something like

Code: [Select]
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.
Title: Re: Modify Primitive properties
Post by: CarlosMB89 on July 09, 2015, 09:03:19 am
Hello Egon, I tried it but the height doesn't change. It has no effect. What could I do then??

Thank you
Title: Re: Modify Primitive properties
Post by: EgonOlsen on July 09, 2015, 09:10:37 am
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.
Title: Re: Modify Primitive properties
Post by: CarlosMB89 on July 09, 2015, 05:25:12 pm
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
Title: Re: Modify Primitive properties
Post by: EgonOlsen on July 09, 2015, 05:28:52 pm
What do you mean by 'opposite direction' in this case?
Title: Re: Modify Primitive properties
Post by: CarlosMB89 on July 15, 2015, 10:56:34 am
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....
Title: Re: Modify Primitive properties
Post by: EgonOlsen on July 15, 2015, 12:33:06 pm
Yes, because that will invert the normals...I'll try to figure something out...
Title: Re: Modify Primitive properties
Post by: EgonOlsen on July 15, 2015, 01:04:36 pm
Why does it actually grow along the negative axis? Are you using a negative scale? If that's the case, try to add this:

Code: [Select]
cyl.invertCulling(scale < 0);

If that's not the case, then I'm not sure if I understand the problem correctly...
Title: Re: Modify Primitive properties
Post by: EgonOlsen on July 15, 2015, 01:06:46 pm
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.