Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3509 Members - Latest Member: lioneltenel

26. May 2012, 09:26:33 pm
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)Q about materialless objects
Pages: [1]
Print
Author Topic: Q about materialless objects  (Read 1070 times)
autophile
Just dropped in

Offline Offline

Posts: 16


View Profile Email
« on: 06. April 2007, 05:27:51 pm »

Hi all,

I'm struggling to come up with an explanation for why a shape looks white in a scene with a red ambient light and without the shape having any material or texture (source attached). Any ideas?

Thanks,

--Rob
Logged
Patheros
Getting respectable
***
Offline Offline

Posts: 267


Dead Dolphin


View Profile WWW Email
« Reply #1 on: 06. April 2007, 08:50:46 pm »

I took a look at your source, you need to enable light. this is how I do it
Code:
      RenderOptions options = new RenderOptions();
options.setOption(Option.USE_LIGHTING,true);
env.getCanvas().setRenderOptions(options);
Make sure you do this after
Code:
env.addCanvas(Canvas3DFactory
                .createWindowed(800, 600, "My empty scene"));

I did that to your code and uncommitted the appearance section and it seemed to work. I don't know why the default material doesn't appear to be lite properly.
Logged

"I like my method, what was my method again?" - Jon
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #2 on: 06. April 2007, 11:01:36 pm »

Strange, that that helped. Lighting is enabled by default.

And ti is a good habit to not create a new instance of RenderOptions, but to resuse the existing one. Maybe the instance has been modified somewhere. So, if lighting is not enabled for some reason, enable it like this:

Code:
canvas.getRenderOptions().setOption( Option.USE_LIGHTING, true );

Or even better:

Code:
canvas.enableLighting();

Marvin

PS. Unfortunately I have no time today to have a look at your source. But I will do tomorrow.
Logged
autophile
Just dropped in

Offline Offline

Posts: 16


View Profile Email
« Reply #3 on: 06. April 2007, 11:08:16 pm »

Sorry all, I should have been more explicit -- I'd like to know why OpenGL renders the cube as white (1) without a light, and (2) with a red light.

--Rob
Logged
'n ddrylliog
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #4 on: 07. April 2007, 03:15:38 pm »

Sorry all, I should have been more explicit -- I'd like to know why OpenGL renders the cube as white (1) without a light, and (2) with a red light.

--Rob
Simple : your Shape3D needs an Appearance with a Material with lightingEnabled = true to be affected by the lighting :
Code:
shape.getAppearance(true).setMaterial(new Material(true));

Enjoy !

Amos
Logged
autophile
Just dropped in

Offline Offline

Posts: 16


View Profile Email
« Reply #5 on: 07. April 2007, 07:58:47 pm »

Okay, I understand that, now. So.. why does the object appear white instead of black or invisible when it does not have a material?

Thanks!

--Rob
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #6 on: 07. April 2007, 08:23:57 pm »

Okay, I understand that, now. So.. why does the object appear white instead of black or invisible when it does not have a material?

That's simply, how OpenGL handles this case.

Marvin
Logged
'n ddrylliog
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #7 on: 07. April 2007, 10:01:18 pm »

Yep :
- The object is white so it won't appear black since its basic color never gets modified during the rendering
- It won't be invisible : that would need an Appearance + TransparencyAttributes
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic