How to render 3D text in JavaFX? - javafx

I'm making my first JavaFX project and I need to render some 3D text. I already put a PerspectiveCamera and I display a text node but it has a Z-dimension of 0 and I don't know how to change this.
Thanks in advance!

Have a look at the FXyz project. It already contains a Text3DMesh class that will allow you generating a 3D mesh for any string and font you need.
Under the hood there is a complex process of converting (2D) Text to Path, Delaunay triangulation and mesh extrusion.
As a result, you have a 3D mesh that can be easily rendered and textured (solid color, density map, images).
Have a look at the sample to get you started.

Related

3D models for React App Dynamically Generated

I need to create a 3D box (transparent) and put inside of it another 3D shapes, such as cylinders and boxes. All of them need to be rendered dynamically based on data fetched from a Data Base. The 3D shapes inside need to respect the edges of the main box and their positions will be determinate by de data which cames from the DB. Any collision must be avoided and the 3D box must be allowed a rotation interaction to allow a visualization from different point of views. When rotated, all the 3D shapes inside must obay the perspective of the main box and their initial positions.
In this perspective, I need help to identify: What is the best and light way to do this for a React application?
I tried CSS 3D Transforms. However, it is not easy to put all the 3D geometric shapes together without any collision or did not see problems when all the set of shapes are rotated. This is the link that I am following: https://3dtransforms.desandro.com/box, to give one idea of what I am searching.
Thanks in advance!
UPDATE: This is some of pictures of what I am trying to do with CSS 3D transform. However, the geometric coordinates is not organized to allow the identification of a pattern to generate the shapes automatically. Besides,the position of inner shapes is not good for all the points of view, as it possible to see in bottom point of view.

Blender 3d sphere material to 2d map

So I've been able to generate a 3d material for a sphere object in Blender. The material is based on the video found here which uses a combination of nodes with the cycles renderer to generate a dynamic material. Although the finished product looks wonderful, I can't find a way to take this material and convert it to a png image. I'm not trying to render the image; I've already rendered an image of the object. I just want to take this generated planet and create a 2D map in the same way you might look at an image of the Earth that includes all surface area in one image.
Can someone help me create a png/jpeg of the 2D map or point me in the right direction?

How to draw or plot a mesh using the mouse in JavaFX which can then be textured and deformed?

I am trying to implement a tool into my application. the tool would allow the user to plot a triangle meshes using the mouse. I have looked everywhere for a way to do this, tutorials, examples, etc and have not been successful. I have seen the FXyz library but that does not really simulate What I am trying to accomplish. The goal of the program looks as follows:
Use Case Sequence:
The user adds a png image to the 3D scene or drags it into the 3D scene using the mouse.
Once the image is being displayed the user would then be able to plot a mesh around the image.
Once the user has finished plotting the mesh. There would have to be a way to add the image being overlayed by the mesh as a texture to the mesh. The image should look the same after being added as a texture. Is this too hard or beyond the scope of what can be achieve in JavaFX?
Theoretically It would then be possible to drag the vertices of the mesh at draggable points and successfully applying transformations to the texture. Would this be possible?
Images showing what I am trying to achieve
As you can see maybe after plotting the mesh the points connecting the vertices can be dragged in order to manipulate or transform the shape of the mesh. If the mesh has a texture over it. would the image then also transform ?
Would this be possible with the TriangleMesh class that JavaFX has which by the way there is very little out there which explains how to use it and how the points, face points and texture points work. Very confusing =(.
Target End Result
My question is would the type of manipulation shown in the image above be possible in JavaFX? Can this sort of functionality be achieved using the TriangleMesh class or other similar class in JavaFX ? As you can see what I am trying to achieve is really image manipulation I would appreciate knowing if there is another better way to do this.
I unfortunately do not have any code I can share. I just cant seem to produce any regarding this task. I am not asking to be given code or for someone to solve the problem for me. I just want to see examples be guided into the right direction on how to do this and to know if it is even possible or should I just give up on it!
If you have read this far Thank you so much for your time I really appreciate it.
I have read your question till the end :-) In contrast to many people here you are at least providing a clear description of what you want to achieve. According to my own experience I would say that what you want to do is easily possible with JavaFX and the MeshView is the way to go here.
You can use your image as the texture for this mesh and you can distort the image by manipulating the vertices of this mesh. I have implemented part of your functionality myself for a project so I know that it works.

Is there a better way to create a button in AFrame?

I've seen this answer to how to create a 3-dimensional button in AFrame, but I was wondering if there was a better way to accomplish this. If there isn't, could somebody please clarify how the rotation/position attributes for the text work (e.g. where the axis of rotation is, where the position is based around relative to the cube, etc.). Thanks!
Depends on which implementation of text you are using. WebGL has no inherent concept of layout like the 2D web. There are upcoming implementations of text which will make it easier to layout and size.
For now, if a text implementation doesn't have any concept of layout, I would use the A-Frame Inspector (<ctrl> + <alt> + i) to manually place your text.
If you want automatic layout in relations to a mesh, you could also try computing the bounding box of the mesh and the text, and automatically centering/aligning the text.

SCNNode material scale

I have an SCNNode that has its geometry populated from a collada file (.dae) and displays correctly on screen. I can apply materials to the geometry easily enough, however I'd like to change the scale of the material.
I currently populate it with
nodeArray[0].geometry?.firstMaterial!.diffuse.contents="wood.png"
but the scale of the material is too small. While I can edit the png in GIMP or something similar and import it as wood2.png is there any way I can set the material scale programatically?
what do you mean by "too small" ?
Geometries are made of different sources such as the vertices' positions, but also their texture coordinates. These texture coordinates (they belong in [0,1]x[0,1]) are specified per vertex and indicate where to look in the texture.
In your 3D modeler please check that your texture coordinates match what you want (i.e. they cover the whole image i.e. they go from 0 to 1 in very direction), and make sure that your image has no extra transparent margin or other wasted space.
You can have a look at SCNMaterialProperty's contentsTransform property. But please check your model and texture before using it.
You need to open your UV snapshot in an image editing software like Photoshop, scale the wood texture in Photoshop over your UV's, then resave your PNG/JPG, move PNG/JPG back to Xcode

Resources