Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

import 3D model using javafx

elattarAug 14 2016 — edited Aug 21 2016

I'm currently working on importing a 3D model (obj file) using JavaFX.

first, i read the obj file and save its content in float arrays (vertices, normals, textures) and integer array for (faces).

for example:

In vertices the file contains:

v 3.227124 -0.065127 -1.000000

v 3.227124 -0.065127 1.000000

i save them in array like that: [3.227124,-0.065127,-1.000000,3.227124,-0.065127,1.000000].

and same for textures and normals.

while for faces: the file contains:

f 509/413/144 91/405/139 94/409/143

f 508/410/3 95/408/142 96/407/141

i save them in integer array as [509,413,144,91,405,139,94,409,143,508,410,3,95,408,142,96,407,141]

Now, i used javafx to draw the model using trianglemshes, but unfortunately the scene is empty and nothing is drawn.

would anybody help me to solve this problem and suggest for me a solution or links for a tutorial or a book.

This is the Code:

public class TriangleMeshes extends Application
{
  
private PerspectiveCamera camera;
  
private final double sceneWidth = 1000;
  
private final double sceneHeight = 700;
  
private double scenex, sceney = 0;
  
private double fixedXAngle, fixedYAngle = 0;
  
private final DoubleProperty angleX = new SimpleDoubleProperty(0);
  
private final DoubleProperty angleY = new SimpleDoubleProperty(0);
  
private double anchorAngleX = 0;
  
private double anchorAngleY = 0;

  
@Override
  
public void start(Stage primaryStage) throws Exception
  
{
  
// Build the Scene and Camera
  
Group sceneRoot = new Group();
  
Scene scene = new Scene(sceneRoot, sceneWidth, sceneHeight);
  
//scene.setFill(Color.BLACK);

  
PerspectiveCamera camera = new PerspectiveCamera(true);
  camera
.setNearClip(0.1);
  camera
.setFarClip(10000.0);
  camera
.setTranslateZ(-1000);
  scene
.setCamera(camera);

  primaryStage
.setTitle("Model 3D Object");
  primaryStage
.setScene(scene);
  primaryStage
.show();

  
// Create the object with a color and add it to the Scene
  
Group obj = buildObject(Color.RED, false, false);
  obj
.setRotationAxis(Rotate.Y_AXIS);
  obj
.setRotate(45);
  obj
.setTranslateX(-100);

  
Group objectGroup = new Group(obj);

  
// Add a Mouse Handler for Rotation
  
Rotate xRotate = new Rotate(0, Rotate.X_AXIS);
  
Rotate yRotate = new Rotate(0, Rotate.Y_AXIS);
  objectGroup
.getTransforms().addAll(xRotate,yRotate);

  
// Use Binding so your rotation doesn't have to be recreated
  xRotate
.angleProperty().bind(angleX);
  yRotate
.angleProperty().bind(angleY);

  
// Tracking mouse movements only when a button is pressed
  scene
.setOnMousePressed(event -> {
  scenex
= event.getSceneX();
  sceney
= event.getSceneY();
  anchorAngleX
= angleX.get();
  anchorAngleY
= angleY.get();
  
});

  
// change angle when the button is pressed
  scene
.setOnMouseDragged(event -> {
  angleX
.set(anchorAngleX - (scenex - event.getSceneY()));
  angleY
.set(anchorAngleY + sceney - event.getSceneX());
  
});

  sceneRoot
.getChildren().addAll(objectGroup);
  
}
  
private Group buildObject(Color color, boolean ambient, boolean fill) throws IOException
  
{
  
// Create object from ObjLoader class to create model containing vertices, normals, textures, and faces
  
ObjLoader ol = new ObjLoader();
  
Model m = ol.loadModel("stall");
  
final TriangleMesh mesh = new TriangleMesh();

  mesh
.getPoints().addAll(m.getVertices()); // [3.227124,-0.065127,-1.000000,3.227124,-0.065127,1.000000, ...]
  mesh
.getTexCoords().addAll(m.getTextures());
  mesh
.getFaces().addAll(m.getFaces()); // [509,413,144,91,405, ...]
  
//mesh.getNormals().addAll(m.getNormals());

  
MeshView meshView = new MeshView(mesh);
  meshView
.setDrawMode(DrawMode.LINE);
  meshView
.setCullFace(CullFace.BACK);

  
Group objGroup = new Group();
  objGroup
.getChildren().add(meshView);

  
if(null != color)
  
{
  
PhongMaterial material = new PhongMaterial(color);
  meshView
.setMaterial(material);
  
}
  
if(ambient)
  
{
  
AmbientLight light = new AmbientLight(Color.WHITE);
  light
.getScope().add(meshView);
  objGroup
.getChildren().add(light);
  
}
  
if(fill)
  
{
  meshView
.setDrawMode(DrawMode.FILL);
  
}

  
return objGroup;
  
}

  
public static void main(String[] args)
  
{
  launch
(args);
  
}

}

Thanks in advance.

Comments

Nikolay Savvinov
Hi,

1) unless index is in an invalid or unusable state, it is very unlikely that it would ever need a rebuild
http://richardfoote.files.wordpress.com/2007/12/index-internals-rebuilding-the-truth.pdf

2) ANALYZE is obsolete, don't use it anymore
3) DBMS_STATS is the way to go (you don't necessarily have to call GATHER_INDEX_STATS explicitly, you can also use CASCADE=>true option in GATHER_TABLE_STATS)

Best regards,
Nikolay
user4295847
Thank for your reply.

Please explain me Index Rebuild ONLINE
and what is the functionality for the DBMS_STATS.GATHER_INDEX and when we need to use ?
unknown-698157
Why are you asking to rephrase what is already explained in the online documentation?

-----------
Sybrand Bakker
Senior Oracle DBA
saratpvv
Please explain me Index Rebuild ONLINE
Jonathan sir have written good article on this have a look.
http://jonathanlewis.wordpress.com/2009/06/05/online-rebuild/
Nikolay Savvinov
Hi
user4295847 wrote:
Thank for your reply.
Please explain me Index Rebuild ONLINE
and what is the functionality for the DBMS_STATS.GATHER_INDEX and when we need to use ?
Why don't we go another way: you spend a few days working through the links and online documentation, and then if you have any questions left, you ask them here.


Best regards,
Nikolay
user4295847
Yes Understand the index rebuild oniline from your link..

Please explain more about DBMS_STATS.GATHER_INDEX_STATS and when we can use ?
Fran
check:
http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_stats.htm#i1036276
user4295847
Hi ,

I am able to understand the DBMS_STATS from this link.

Could you please give me 2 lines answers for what are the advantages if we use DBMS_STATS
Fran
Answer
In order to make good use of the cost based optimizer, you need to create statistics for the data in the database.
Marked as Answer by user4295847 · Sep 27 2020
user4295847
Thanks Fran..
1 - 10
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Sep 18 2016
Added on Aug 14 2016
1 comment
2,120 views