instantreality forum
news: Welcome to the instantreality forums!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 26, 2018, 02:49:55 am


Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Replace USE (option U) in aopt leads to model without shadows  (Read 5148 times)
JLummer
Newbie
*
Posts: 8


View Profile
« on: March 07, 2014, 07:39:59 pm »

Hi,

I want to use aopt to replace parts with the USE attribute (option U). This generally works fine. However, the model I get has no shadows but is completely white. I found out that the values in "Coordinate point" and "Normal vector" are not comma seperated anymore which leads to the explained behaviour. I load the models in x3dom afterwards.

Is there a way to get round this problem? Is this a known issue?

I'm using Windows with the latest aopt version.

Best regards.
J.
Logged
yjung
Administrator
Sr. Member
*****
Posts: 260


View Profile
« Reply #1 on: March 07, 2014, 09:30:31 pm »

Spaces and commas are both treated as whitespace, that is not the problem. When the appearance is totally white, then usually the reason is that there is no material and/or no appearance node in the shape. The spec is strange in that the object is rendered white then:
http://www.web3d.org/files/specifications/19775-1/V3.3/Part01/components/lighting.html#Lightingoff
Maybe during conversion somehow the appearance got lost or couldn't be resolved.
Logged
JLummer
Newbie
*
Posts: 8


View Profile
« Reply #2 on: March 11, 2014, 10:30:19 am »

Hi,

unfortunately, the commas are indeed the problem because before using aopt they are there. When aopt gives back my file they are gone. Putting them back manually, everything works fine again with shadows.

The appearance and material is defined in the following way:
 
<Appearance DEF='2'>
     <Material/>
</Appearance>

...

<Appearance USE="2"/>

This is what I get when I convert a STEP file from CAD software into an x3d file. So I can't change the x3d structure manually in every file.

Hmmm, what to do?

Best regards.
J.
Logged
yjung
Administrator
Sr. Member
*****
Posts: 260


View Profile
« Reply #3 on: March 11, 2014, 10:33:50 am »

Do you export to an HTML file? If so, you can't use self-closing tags, which means that appearance and so on has to be defined like follows:

<Appearance DEF='two'>
     <Material></Material>
</Appearance>

...

<Appearance USE='two'></Appearance>
Logged
JLummer
Newbie
*
Posts: 8


View Profile
« Reply #4 on: March 11, 2014, 11:27:38 am »

I do use the file in html by inserting it via x3dom's Inline. There is no problem with self-closing tags as long as there are commas in the mentioned "Coordinate point" and "Normal vector".
Logged
yjung
Administrator
Sr. Member
*****
Posts: 260


View Profile
« Reply #5 on: March 11, 2014, 11:35:04 am »

This is strange, could you please open an issue at x3dom's bugtracker (prefarably with test): https://github.com/x3dom/x3dom/issues

However, I'd recommend using BinaryGeometry instead, which is more efficient, here is a tutorial: http://x3dom.org/docs/dev/tutorial/aopt.html
Logged
JLummer
Newbie
*
Posts: 8


View Profile
« Reply #6 on: March 11, 2014, 12:12:29 pm »

Oh, I checked the file again and you are right. The problem is not the commas which I assumed at first, but is indeed the appearance node which aopt deletes.

Before my file looked like this:

<Shape>
            <Appearance USE="2"/>
            <IndexedFaceSet ...
...

After the aopt tool has applied the U option it looks like this:

<Shape>
            <IndexedFaceSet ...
...

The same happens for the BinaryGeometry.

Sorry for the hassle.

J.

Logged
yjung
Administrator
Sr. Member
*****
Posts: 260


View Profile
« Reply #7 on: March 11, 2014, 12:17:20 pm »

And now I see your problem: you mixed up the -u and -U options. These are case sensitive. You might want to use u instead?
Logged
JLummer
Newbie
*
Posts: 8


View Profile
« Reply #8 on: March 11, 2014, 01:16:51 pm »

No, I really want to use U, but now it gets tricky. I want to replace models which use USE by their real definition, e.g. if there are two cubes, at first described by DEF and USE they should be two independent geometries after conversion. The aim is to be able to access them separately in x3dom (see my e-mail to the x3dom mailing list, "Replacing DEF USE"). I thought that aopt can help me on this topic. But now it seems there is a conflict of interests if the appearance node will disappear if it uses USE.

Obstacles you would never think of ...  Smiley.
Logged
JLummer
Newbie
*
Posts: 8


View Profile
« Reply #9 on: March 15, 2014, 11:43:19 am »

Hi,

I just wanted to state that the conversion to BinaryGeometry creates objects  without shadows as well although this should have nothing to do with replacement of DEF and USE. This happens no matter whether I load it as inline element in HTML or in Instant Player.

Best regards.
J.
Logged
yjung
Administrator
Sr. Member
*****
Posts: 260


View Profile
« Reply #10 on: March 15, 2014, 08:07:28 pm »

Hi, you really mean shadows? Those have to be enabled. And I used BinGeos several times together with shadows enabled. Could you provide a test case where it doesn't work?
Logged
JLummer
Newbie
*
Posts: 8


View Profile
« Reply #11 on: March 15, 2014, 10:15:15 pm »

I converted the attached file in aopt as described:

mkdir bingeo
aopt -i [input.foo] -G "bingeo/:is" -x [output].x3d

Then I get:

<Scene>
    <Transform>
      <Group DEF='Bevel gear'>
        <Transform DEF='Gear1.1' rotation='0.995732 0.0652637 -0.0652637 1.57507' translation='-5.15143e-017 -0.0127043 0.0205659'>
          <Group DEF='Gear1'>
            <Group>
              <Shape DEF='SP_0'>
                <Appearance>
                  <Material/>
                </Appearance>
                <BinaryGeometry DEF='BG_0' solid='false' vertexCount='70' primType='"TRIANGLESTRIP"' position='-0.00551091600209 0.00551045034081 -0.00441519264132' size='0.00163195421919 0.001631942112 0.00111740874127' index='testBG/BG_0_indexBinary.bin' coord='testBG/BG_0_coordBinary.bin' normal='testBG/BG_0_normalBinary.bin'/>
              </Shape>
              <Shape DEF='SP_1'>
                <BinaryGeometry DEF='BG_1' solid='false' vertexCount='24' primType='"TRIANGLESTRIP"' position='-0.00757330143824 0.00620307214558 -0.00154041755013' size='0.00328990537673 0.00301718572155 0.00502459751442' index='testBG/BG_1_indexBinary.bin' coord='testBG/BG_1_coordBinary.bin' normal='testBG/BG_1_normalBinary.bin'/>
              </Shape>
...

I guess it has something to do with 'Appearance' again. Or do I have to include BinaryGeometry x3d files (as Inline) in another way as normal x3d files in HTML?

Thanks.
J.
Logged
JLummer
Newbie
*
Posts: 8


View Profile
« Reply #12 on: March 15, 2014, 10:20:02 pm »

Ah, by "without shadows" I mean that the object is white instead of with grey shadows, see attachments.
Logged
mlimper
Administrator
Newbie
*****
Posts: 7


View Profile
« Reply #13 on: March 28, 2014, 10:33:20 am »

Okay, I think there are, in general, two problems:

1.) X3DOM does not provide functionality to identify (=> usually: to pick) USEd parts. There is an open X3DOM issue for that:
https://github.com/x3dom/x3dom/issues/220

2.) The USEd Appearance, somehow, does not work

The second point seems to be a problem with AOPT and your DEF="2" - if you replace it by DEF="TWO", it seems to work (at least InstantPlayer displays the correct result then).

We'll probably have to check whether this is expected behavior for X3D (if pure numbers are allowed as identifiers), or whether this is a bug in AOPT (or some related library).

Thanks for reporting this.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.15 | SMF © 2011, Simple Machines