first, I would apologize for my bad english.
I'm pretty bad in coding, soo i apologize too if my problem
come from a big mistake.
I'm programming an interface for modeling a 2D figure using
Jreality but I have to face a problem. i choose to use Jreality
although it's for modeling in 2D because there are
great documentation&tutorial.
I create a square using the indexesFaceFactory but
in reduction the dimension to 2 [code1],
then I incorporate your drag method issu from
DragEventTool1.java to give the possibility to modelize the square.
I modify it a bit for not considerate the third dimension [code2]
I also desactivate the rotateTool.
After incorporate the whole thing in a frame, it give a square.
When i move the first and third vertex in the inside of the
square, all is alright, i can merge the two vertices and have a sort of
V with only the edges visible,
but when i try this modification with the second and the last,
i can't create something smaller than a triangle, i.e. i can't create angle bigger
than 180° if the vertex is the second ( index 0) or the fourth( index 2).
I also try to draw another object instead of a indexedFaceSet, a quad mesh with
your quadMeshExample.
I try this time in 3D , and it seems that the problem could be with the dragging
and the third dimension, but I thought that my code deal with this dimension.
But maybe it's not a problem of dimension?
Here is my code.
Of course i try without the modifications about the third dimension,
but it still doesn't work as i wish.
Edit :
i have another question,
is it possible to add a vertex to a face already draw without
redrawing it? i mean, in the case of i want to add a vertex on a edge,
then move the vertex ; creating from this edge two edges.
Code 1
Code: Select all
[...]
SceneGraphComponent myComponent = new SceneGraphComponent();
IndexedFaceSetFactory ifsf = new IndexedFaceSetFactory();
double[][] vertices = new double[][] { { 0, 0, 0 }, { 3, 0, 0 },{ 3, 3, 0 }, { 0, 3, 0 } };
int[][] faceIndices = new int[][] { { 0, 1, 2, 3 } };
ifsf.setVertexCount(vertices.length);
ifsf.setVertexCoordinates(vertices);
ifsf.setFaceCount(faceIndices.length);
ifsf.setFaceIndices(faceIndices);
[...]
Code: Select all
public void pointDragged(PointDragEvent e) {
PointSet pointSet = e.getPointSet();
double[][] points = new double[pointSet.getNumPoints()][];
pointSet.getVertexAttributes(Attribute.COORDINATES).toDoubleArrayArray(points);
double[] positionWithoutDepth = e.getPosition();
positionWithoutDepth[2] = 0;
points[e.getIndex()] = positionWithoutDepth; //e.getPosition();
pointSet.setVertexAttributes(Attribute.COORDINATES,StorageModel.DOUBLE_ARRAY.array(3).createReadOnly(
points));
viewer.render();
}