Author Topic: Modify Primitive properties  (Read 3817 times)

Offline CarlosMB89

  • byte
  • *
  • Posts: 15
    • View Profile
Modify Primitive properties
« 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Modify Primitive properties
« Reply #1 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.

Offline CarlosMB89

  • byte
  • *
  • Posts: 15
    • View Profile
Re: Modify Primitive properties
« Reply #2 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Modify Primitive properties
« Reply #3 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.

Offline CarlosMB89

  • byte
  • *
  • Posts: 15
    • View Profile
Re: Modify Primitive properties
« Reply #4 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Modify Primitive properties
« Reply #5 on: July 09, 2015, 05:28:52 pm »
What do you mean by 'opposite direction' in this case?

Offline CarlosMB89

  • byte
  • *
  • Posts: 15
    • View Profile
Re: Modify Primitive properties
« Reply #6 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....

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Modify Primitive properties
« Reply #7 on: July 15, 2015, 12:33:06 pm »
Yes, because that will invert the normals...I'll try to figure something out...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Modify Primitive properties
« Reply #8 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...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Modify Primitive properties
« Reply #9 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.