javafx.scene.shape.Shape3D Java Examples

The following examples show how to use javafx.scene.shape.Shape3D. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScatterPlot.java    From FXyzLib with GNU General Public License v3.0 6 votes vote down vote up
public void setXYZData(List<Double> xData, List<Double> yData, List<Double> zData, List<Color> colors) {
    xAxisData = xData;
    yAxisData = yData;
    zAxisData = zData;
    scatterDataGroup.getChildren().clear();
    //for now we will always default to x axis
    //later we could maybe dynamically determine the smallest axis and then
    //uses 0's for the other axes that are larger.
    for(int i=0;i<xAxisData.size();i++) {
        final Shape3D dataSphere = createDefaultNode(nodeRadius);
        double translateY = 0.0;
        double translateZ = 0.0;            
        if(!yAxisData.isEmpty() && yAxisData.size() > i)
            translateY = yAxisData.get(i);
        if(!zAxisData.isEmpty() && zAxisData.size() > i)
            translateZ = zAxisData.get(i);
        dataSphere.setTranslateX(xAxisData.get(i));
        dataSphere.setTranslateY(translateY);
        dataSphere.setTranslateZ(translateZ);
        dataSphere.setMaterial(new PhongMaterial(colors.get(i)));
        scatterDataGroup.getChildren().add(dataSphere);
    }        
}
 
Example #2
Source File: ScatterPlot.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
private Shape3D createDefaultNode(double radius) {
    switch(defaultNodeType) {
        case SPHERE: return new Sphere(radius);
        case CUBE: return new Box(radius, radius, radius);
        default: return new Box(radius, radius, radius);    
    }
}
 
Example #3
Source File: BillboardBehavior.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Updates the transformation matrix.
 * can change the Translate for fixed distance  
 */
default void updateMatrix(){
    Transform cam  = getOther().getLocalToSceneTransform(),
              self = getBillboardNode().getLocalToSceneTransform();         
            
    Bounds b;
    double cX,
           cY,
           cZ;
    
    if(!(getBillboardNode() instanceof Shape3D)){
        b = getBillboardNode().getBoundsInLocal();
            cX = b.getWidth() / 2;
            cY = b.getHeight() / 2;
            cZ = b.getDepth() / 2;            
    }else{
        cX = self.getTx();
        cY = self.getTy();
        cZ = self.getTz();
    }       
    
    Point3D camPos = new Point3D(cam.getTx(), cam.getTy(), cam.getTz());
            Point3D selfPos = new Point3D(cX, cY, cZ);
            
    Vector3D up = Vector3D.UP,
    forward = new Vector3D(
            (selfPos.getX()) - camPos.getX(),
            (selfPos.getY()) - camPos.getY(),
            (selfPos.getZ()) - camPos.getZ()
    ).toNormal(),
    right = up.crossProduct(forward).toNormal();
    up = forward.crossProduct(right).toNormal();
            
    switch(getBillboardMode()){
        
        case SPHERICAL:                  
            affine.setMxx(right.x); affine.setMxy(up.x); affine.setMzx(forward.x); 
            affine.setMyx(right.y); affine.setMyy(up.y); affine.setMzy(forward.y); 
            affine.setMzx(right.z); affine.setMzy(up.z); affine.setMzz(forward.z);
    
            affine.setTx(cX * (1 - affine.getMxx()) - cY * affine.getMxy() - cZ * affine.getMxz());
            affine.setTy(cY * (1 - affine.getMyy()) - cX * affine.getMyx() - cZ * affine.getMyz());
            affine.setTz(cZ * (1 - affine.getMzz()) - cX * affine.getMzx() - cY * affine.getMzy());                
            break;
            
        case CYLINDRICAL:                
            affine.setMxx(right.x); affine.setMxy(0); affine.setMzx(forward.x); 
            affine.setMyx(0);       affine.setMyy(1); affine.setMzy(0); 
            affine.setMzx(right.z); affine.setMzy(0); affine.setMzz(forward.z);
                            
            affine.setTx(cX * (1 - affine.getMxx()) - cY * affine.getMxy() - cZ * affine.getMxz());
            affine.setTy(cY * (1 - affine.getMyy()) - cX * affine.getMyx() - cZ * affine.getMyz());
            affine.setTz(cZ * (1 - affine.getMzz()) - cX * affine.getMzx() - cY * affine.getMzy());
            break;
    }
    
}