IndexedFaceSet creates extra faces in x3d file - x3d

I have created an x3d file using x3dom. Following is the structure of the file. Copy the following code into text editor and save it as .x3d file. For imgage texture you can consider any jpg file and place it at the same location as x3d.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN"
"http://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D profile='Interchange' version='3.0'
xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'
xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.0.xsd'>
<Scene>
<NavigationInfo type='"EXAMINE" "WALK" "FLY" "ANY"'/>
<DirectionalLight intensity="0.8" direction="0 1 0"/>
<DirectionalLight intensity="0.9" direction="0 -1 0"/>
<DirectionalLight intensity="0.6" direction="1 0 -1"/>
<DirectionalLight intensity="0.6" direction="-1 0 -1"/>
<DirectionalLight intensity="0.6" direction="-1 0 1"/>
<DirectionalLight intensity="0.6" direction="1 0 1"/>
<Shape>
<Appearance>
<Material ambientIntensity="0.2" diffuseColor="0.004 0.004 0.004" emissiveColor="0 0 0" shininess="0.2" specularColor="0 0 0" transparency="0"/>
<ImageTexture url="Penguins.jpg"/>
</Appearance>
<IndexedFaceSet convex="true" coordIndex="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 -1 " ccw="true">
<Coordinate point="132.2349 0 329.9732 123.0347 0 336.9273 109.9391 0 350.0229 102.985 0 359.223 82.26761 0 386.6317 69.30841 0 436.438 74.03987 0 470.4683 78.77134 0 504.4987 104.8261 0 548.8805 132.2349 0 569.598 191.8598 0 569.598 191.8598 0 689.9727 911.8589 0 689.9727 1032.234 0 569.598 1032.234 0 270.3483 852.2339 0 270.3483 852.2339 0 210.7232 371.8596 0 210.7232 371.8596 0 329.9732"/>
</IndexedFaceSet>
</Shape>
<Viewpoint description="Center of Space" fieldOfView="0.785" position="553.1368 60 450.348"/>
</Scene>
</X3D>
Looking it from the top view the 3D object looks like this,
enter image description here
And from the bottom view it looks like this,
enter image description here
I have checked all the points and they are in proper sequence but not sure why these two extra faces are created. Anything I am doing wrong here?

You draw a non-convex shape, therefor you need to set convex to false, in addition if you want to see your shape from "behind" you need to set solid to false.
This works:
<IndexedFaceSet convex="false" solid="false" coordIndex="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 -1">
(you dont need ccw, its true by default)

Related

unable to use svg in react

I am using a svg image by importing that from a folder but its showing empty then I tried ti give path directly but it does not solve the problem.
image.svg
<svg xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 480 360">
<defs><linearGradient id="a" x1="19.5%" x2="77.5%" y1="71.8%" y2="16.7%">
<stop offset="0%" stop-color="#00AB55"/><stop offset="100%" stop-color="#00AB55" stop-opacity="0"/>
</linearGradient></defs>
<path fill="url(#a)" d="M0 198.8c0 41.4 15 79.2 39.5 107.8A151.3 151.3 0 0 0 154.3 360a148.4 148.4 0 0
0 56.5-11c9-3.7 19.1-3.3 28 1a75.8 75.8 0 0 0 33.9 8 75.9 75.9 0 0 0 50.8-19.3 34.4 34.4 0 0 1 22.9-8.4h.1a129
129 0 0 0 74.5-23.7c19-13.4 34.5-31.7 44.9-53.3 9-18.7 14.1-40 14.1-62.3
0-77-59.8-139.3-133.5-139.3-7.5 0-14.9.6-22 1.9a107 107 0 0 0-92-53.6 103.7 103.7 0 0 0-45.9 10.7c-13.2 6.4-25
15.7-34.6 26.9-32.7.5-63 11.7-87.7 30.3C25.3 97.2 0 144.9 0 198.8z" opacity=".2"/><image height="300" x="322"
y="30" href="/assets/illustrations/characters/character_2.png"/><path fill="url(#b)" d="M216.3 138v108.3a4 4 0
0 1-4 4H195a4 4 0 0 1-4-4V138a4 4 0 0 1 4-4h17.3a4 4 0 0 1 4 4zm-55-68H144a4 4 0 0 0-4 4v176.3a4 4 0 0 0
4 4h17.3a4 4 0 0 0 4-4V74a4 4 0 0 0-4-4zm102 93H246a4 4 0 0 0-4 4v75.7a4 4 0 0 0 4 4h17.3a4 4 0 0 0 4-4V167a4
4 0 0 0-4-4z"/><path fill="#005249" d="M359.2 253.4a207 207 0 0 1-3.7 9.7l-15.2.4c-3.3.1-6.9.2-9.6 2.1-5.2 3.6-.7
6.1-1.3 9.6-.7 4.2-4.9 5.1-9 5.1-14.1.1-27.7 4.6-41.5 7.3s-28.9 3.5-41.2-3.4c-.8-.5-1.7-1-2-2-.6-1.6.9-3.2 2.3-4.2
3.2-2.2 6.7-3.7 10.5-4.5 2.2-.5 4.5-.8 6.5-2 1.9-1.2 3.3-3.7 2.3-5.8-32.1 2-64.1 4.8-96 8.4-41.1 4.8-81.8 12.9-123
15.9h-.4c-2.9-2.9-5.5-6-7.9-9.3l.6-.7c2-2.2 5-3.2 7.8-4.1 15.9-4.9 32.4-7.4 48.8-9.9 81.6-12.3 164.2-21.1 246.8-15.3a359
359 0 0 1 25.2 2.7z" opacity=".2"/><path fill="#DFE3E8" d="m81.7 204.2 74 11v60.7h8.5v3.6h-19.5v-2.3h8.7v-50.3l-70-13.
5v49h9.7v1.7H73.6V262h8.2v-57.8h-.1z"/><path fill="#C4CDD5" d="m80.6 204.2 74 11v60.7h8.5v3.6h-19.5v-2.3h8.7v-50.3l-70-13.
5v49H92v1.7H72.4V262h8.2v-57.8z"/><defs>
<linearGradient id="b" x1="140" x2="276.5" y1="98" y2="312.5" gradientUnits="userSpaceOnUse"><stop stop-color="#C8FACD"/>
<stop offset="1" stop-color="#007B55"/></linearGradient></defs></svg>
first I imported that image when it doesnot work I gave direct path in src,
// import { girlFlyIcon } from '../../utils/appSvg';
<Grid item>
<img src='../../svg/image.svg'
style={{
opacity: '0.8',
zIndex: '999'
}} alt='' />
</Grid>
How to resolve this....Thanks in advance...
use require in src prop of img like this
<img
src={require('../../svg/image.svg')}
... />
Instead of using image, try to use svg as component
import {ReactComponent as ImageSVG} from '../../svg/image.svg'
...
<ImageSVG/>

Tinymce toolbar icons sometimes do not display

I'm using timymce with react.js. It works fine, but once in a while the toolbar icons don't display, and instead, I get some characters displayed. I'm assuming that it can't reach the server to get the icons. I want to create a local copy of the icons. I read that I should add:
import "tinymce/icons/default";
but when I do that, I get the error message:
ReferenceError: tinymce is not defined
./node_modules/tinymce/icons/default/icons.js
C:/react/andiamo-web/node_modules/tinymce/icons/default/icons.js:1
1 | tinymce.IconManager.add('default', {
2 | icons: {
3 | 'accessibility-check': '<svg width="24" height="24"><path d="M12 2a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2c0-1.1.9-2 2-2zm8 7h-5v12c0 .6-.4 1-1 1a1 1 0 01-1-1v-5c0-.6-.4-1-1-1a1 1 0 00-1 1v5c0 .6-.4 1-1 1a1 1 0 01-1-1V9H4a1 1 0 110-2h16c.6 0 1 .4 1 1s-.4 1-1 1z" fill-rule="nonzero"/></svg>',
4 | 'action-next': '<svg width="24" height="24"><path fill-rule="nonzero" d="M5.7 7.3a1 1 0 00-1.4 1.4l7.7 7.7 7.7-7.7a1 1 0 10-1.4-1.4L12 13.6 5.7 7.3z"/></svg>',
Any ideas?
EDIT: Once in a while, tinymce does not display at all (not just the toolbar, but the whole component). Maybe I need to look into hosting my own copy and not rely on the online version?
Thanks
Tom

Replacing specific elements in a table with a specific element from a range in APLX

I'm learning a spread of programming languages in a class, and we're working on an APLX project at the moment. A restriction we have to work around is we cannot use If, For, While, etc. No loops or conditionals. I have to be able to take a plane of numbers, ranging 0-7, and replace each number 2 or greater into the depth of that number, and, ideally, change the 1's to 0's. For example:
0100230 => 0000560
I have no idea how I'm supposed to do the replacement with depth aspect, though the change from ones to zeros is quite simple. I'm able to produce the set of integers in a table and I understand how to replace specific values, but only with other specific values, not values that would have to be determined during the function. The depth should be the row depth, rather than the multi-dimensional depth.
For the record this is not the whole of the program, the program itself is a poker dealing and scoring program. This is a specific aspect of the scoring methodology that my professor recommended I use.
TOTALS„SCORE PHAND;TYPECOUNT;DEPTH;ISCOUNT;TEMPS;REPLACE
:If (½½PHAND) = 0
PHAND„DEAL PHAND
:EndIf
TYPECOUNT„CHARS°.¹PHAND
DEPTH„2Þ(½TYPECOUNT)
REPLACE „ 2 3 4 5 6 7
ISCOUNT „ +/ TYPECOUNT
ISCOUNT „ ³ISCOUNT
((1=,ISCOUNT)/,ISCOUNT)„0
©((2=,ISCOUNT)/,ISCOUNT)„1
©TEMPS „ ISCOUNT
Œ„ISCOUNT
Œ„PHAND
You may have missed the first lessons of your prof and it might help to look at at again to learn about vectors and how easy you can work with them - once you unlearned the ideas of other programming languages ;-)
Assume you have a vector A with numbers from 1 to 7:
A←⍳7
A
1 2 3 4 5 6 7
Now, if you wanted to search for values > 3, you'd do:
A>3
0 0 0 1 1 1 1
The result is a vector, too, and you can easily combine the two in lots of operations:
multiplication to only keep values > 0 and replace others with 0:
A×A>3
0 0 0 4 5 6 7
or add 500 to values >3
A+500×A>3
1 2 3 504 505 506 507
or, find the indices of values > 3:
(A>3)×⍳⍴A
0 0 0 4 5 6 7
Now, looking at your q again, the word 'depth' has a specific meaning in APL and I guess you meant something different. Do I understand correctly that you want to replace values > 2 with the ' indices' of these values?
Well, with what I've shown before, this is easy:
A←0 1 0 0 2 3 0
(A≥2)×⍳⍴A
0 0 0 0 5 6 0
edit: looking at multi-dimensional arrays:
let's look into this example:
A←(⍳5)∘.×⍳10
A
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
Now, which numbers are > 20 and < 30?
z←(A>20)∧A<30
z
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 1 1 0
0 0 0 0 0 1 1 0 0 0
0 0 0 0 1 0 0 0 0 0
Then, you can multiply the values with that boolean result to filter out only the ones satisfying the condition:
A×z
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 21 24 27 0
0 0 0 0 0 24 28 0 0 0
0 0 0 0 25 0 0 0 0 0
Or, perhaps you're interested in the column-index of the values?
z×[2]⍳¯1↑⍴z
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 7 8 9 0
0 0 0 0 0 6 7 0 0 0
0 0 0 0 5 0 0 0 0 0
NB: this statement might not work in all APL-dialects. Here's another way to formulate this:
z×((1↑⍴z)⍴0)∘.+⍳¯1↑⍴z
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 7 8 9 0
0 0 0 0 0 6 7 0 0 0
0 0 0 0 5 0 0 0 0 0
I hope this gives you some ideas to play with. In general, using booleans to manipulate arrays in mathematical operations is an extremely powerful idea in APL which will take you loooooong ways ;-)
Also, if you'd like to see more of the same, have a look at the FinnAPL Idioms - some useful shorties grown over the years ;-)
edit re. "maintaining untouched values":
going back to example array A:
A←(⍳5)∘.×⍳10
A
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
Replacing values between 20 and 30 with the power 2 of these values, keeping all others unchanged:
touch←(A>20)∧A<30
(touch×A*2)+A×~touch
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 441 576 729 30
4 8 12 16 20 576 784 32 36 40
5 10 15 20 625 30 35 40 45 50
I hope you get the idea...
Or better: ask a new q, as otherwise this would truly take epic dimensions, whereas the idea of stackoverflow is more like "one issue - one question"...

Draw a 3d rectangular box(rectangular prism ?) in wpf

I am using the following code to form a cube. It uses triangles for each face. How can I make a rectangular box by modifying its values. I dont have much idea on the indices property used here.
<GeometryModel3D.Geometry>
<MeshGeometry3D
Positions = "-1,-1,1 1,-1,1 1,1,1 -1,1,1"
TriangleIndices = "0 1 2 2,3,0"
TextureCoordinates="0,1 1,1 1,0 0,0"
/>
</GeometryModel3D.Geometry>
here you go
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions = "0 0 0 1 0 0 0 1 0 1 1 0 0 0 1 1 0 1 0 1 1 1 1 1"
TriangleIndices = "2 3 1 2 1 0 7 1 3 7 5 1 6 5 7 6 4 5 6 2 0 2 0 4 2 7 3 2 6 7 0 1 5 0 5 4"/>
</GeometryModel3D.Geometry>
this will produce a cube geometry
I would suggest you to understand how it work so you can make other objects too
here is a nice tutorial on WPF 3D
http://www.codeproject.com/Articles/24727/WPF-D-Part-of-n

X3D - How to color polygon faces in X3D

How do I color a polygon face - as in just color 1 face all red for example. I don't want linear interpolation occuring when I move on to color a neighboring face. I am able to color it with the following codes but the colors merge. When I turn colorPerVertex to false, the coloring looks weird. Please advice. Thank you.
<X3D>
<Scene>
<Shape>
<IndexedFaceSet solid="false" colorPerVertex="true"
coordIndex="0 3 4 1 -1
1 4 5 2 -1
3 6 7 4 -1
4 7 8 5 -1">
<Coordinate
point= "0 0 0, 1 0 0, 2 0 0
0 0 1, 1 3 1, 2 0 1
0 0 2, 1 0 2, 2 0 2" />
<Color color= "0 0 0, 1 0 0, 2 0 0
0 0 1, 1 3 1, 2 0 1
0 0 2, 1 0 2, 2 0 2" />
</IndexedFaceSet>
<Appearance>
<Material diffuseColor='1 0 0' />
</Appearance>
</Shape>
</Scene>
</X3D>
If colorPerVertex is FALSE AND the colorIndex field is not empty, then one colour is applied for each face of the IndexedFaceSet.
Therefore if you set colorPerVertex to FALSE in your example you should NOT have color interpolation between faces (tested).

Resources