Author Topic: Merging Primitive planes  (Read 2734 times)

Offline jpro

  • byte
  • *
  • Posts: 20
    • View Profile
Merging Primitive planes
« on: December 01, 2010, 08:37:25 pm »
Is there any reason I shouldn't do:

Code: [Select]
Object3D plane1 = Primitives.getPlane(1, 10f);
Object3D plane2 = Primitives.getPlane(1, 10f);
plane2.rotateX((float) Math.toRadians(90));

Object3D merged = Object3D.mergeObjects(plane1, plane2);
world.addObject(merged);
world.buildAllObjects();

When I do so only one plane is visible.

Offline Nick

  • byte
  • *
  • Posts: 8
    • View Profile
Re: Merging Primitive planes
« Reply #1 on: December 01, 2010, 11:49:55 pm »
Hey jpro,

Maybe the camera is set up so you're looking to a plane from behind or from the side. You must mention that when creating planes you can only display one side. I think this is the reason for your problem, so you could just try to rotate the other plane or the camera. Maybe that helps?

Offline jpro

  • byte
  • *
  • Posts: 20
    • View Profile
Re: Merging Primitive planes
« Reply #2 on: December 01, 2010, 11:56:17 pm »
A decent guess, but it's not visible from any angle. Camera is in fly mode and I have checked it from below, above, left, right, etc.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Merging Primitive planes
« Reply #3 on: December 02, 2010, 08:02:55 am »
You are rotating via matrix transform only this way. Add a

Code: [Select]
plane2.rotateMesh();
plane2.clearRotation();

after the rotateX to make it permanent and see if that helps.

Offline jpro

  • byte
  • *
  • Posts: 20
    • View Profile
Re: Merging Primitive planes
« Reply #4 on: December 02, 2010, 04:23:26 pm »
That worked. Thank you. :)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Merging Primitive planes
« Reply #5 on: December 02, 2010, 04:34:21 pm »
If you are doing this only to work around backface culling, then Object3D.setCulling(false); does the same thing without duplicating the geometry. If lighting is an issue, it might be useful to double the plane as you do though.