Author Topic: How to change texture after pick up a object  (Read 1132 times)

Offline hoangitk

  • byte
  • *
  • Posts: 8
    • View Profile
How to change texture after pick up a object
« on: February 28, 2011, 01:51:06 am »
Dear all,

I would like to change the texture of picked object.
I have tried:
Code: [Select]
.....
if (event.getAction() == MotionEvent.ACTION_UP) {

if (System.currentTimeMillis() - time < 1000) {
Object3D clickedObj = renderer.PickObj(xpos, ypos);

if (clickedObj != null) {
// set prevClickedObj for tracking
if(prevClickedObj == null || !clickedObj.equals(prevClickedObj)) {
prevClickedObj = clickedObj;
}

statusInfo.setText(clickedObj.getName());
clickedObj.setTexture("textureSelectedLocation");

} else {
// uncheck clicked object
if(prevClickedObj != null) {
prevClickedObj.setTexture("textureLocation");
}
}
}
....

With purpose highlight a picked object.
But it is not effect.

Please kindly advise!

Thank you so much!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: How to change texture after pick up a object
« Reply #1 on: February 28, 2011, 07:32:07 am »
Is clickedObject ever !=null? What does renderer.PickObj(xpos, ypos) do?

Offline hoangitk

  • byte
  • *
  • Posts: 8
    • View Profile
Re: How to change texture after pick up a object
« Reply #2 on: February 28, 2011, 08:26:14 am »
Dear Mr.EgonOlsen,

I found out why.

Because I forgot changing texture name between "textureLocation" and "textureSelectedLocation".

Best regards!