use of org.jwildfire.create.eden.scene.primitive.Mesh in project JWildfire by thargor6.
the class AddSceneObjectsVisitor method addPositionableSceneElement.
private void addPositionableSceneElement(PositionableSceneElement pSceneElement) {
Matrix4 matrix = calcTransform(pSceneElement);
if (pSceneElement instanceof Sphere) {
Sphere sphere = (Sphere) pSceneElement;
if (useMatrix) {
sceneBuilder.addSphere().withShader(sphere.getMaterial()).withTransform().withMatrix(matrix);
} else {
sceneBuilder.addSphere().withShader(sphere.getMaterial()).withTransform().withScaleX(sphere.getSize().getX()).withScaleY(sphere.getSize().getY()).withScaleZ(sphere.getSize().getZ()).withTranslateX(sphere.getPosition().getX()).withTranslateY(sphere.getPosition().getY()).withTranslateZ(sphere.getPosition().getZ());
}
} else if (pSceneElement instanceof Cylinder) {
Cylinder cylinder = (Cylinder) pSceneElement;
if (useMatrix) {
sceneBuilder.addCylinder().withShader(cylinder.getMaterial()).withTransform().withMatrix(matrix);
} else {
sceneBuilder.addCylinder().withShader(cylinder.getMaterial()).withTransform().withScaleX(cylinder.getSize().getX()).withScaleY(cylinder.getSize().getY()).withScaleZ(cylinder.getSize().getZ()).withTranslateX(cylinder.getPosition().getX()).withTranslateY(cylinder.getPosition().getY()).withTranslateZ(cylinder.getPosition().getZ()).withRotateX(cylinder.getOrientation().getAlpha()).withRotateY(cylinder.getOrientation().getBeta()).withRotateZ(cylinder.getOrientation().getGamma());
}
} else if (pSceneElement instanceof Box) {
Box box = (Box) pSceneElement;
if (useMatrix) {
sceneBuilder.addBox().withShader(box.getMaterial()).withTransform().withMatrix(matrix);
} else {
sceneBuilder.addBox().withShader(box.getMaterial()).withTransform().withScaleX(box.getSize().getX()).withScaleY(box.getSize().getY()).withScaleZ(box.getSize().getZ()).withTranslateX(box.getPosition().getX()).withTranslateY(box.getPosition().getY()).withTranslateZ(box.getPosition().getZ()).withRotateX(box.getOrientation().getAlpha()).withRotateY(box.getOrientation().getBeta()).withRotateZ(box.getOrientation().getGamma());
}
} else if (pSceneElement instanceof Mesh) {
Mesh mesh = (Mesh) pSceneElement;
if (useMatrix) {
sceneBuilder.addMesh().withShader(mesh.getMaterial()).withMesh(mesh).withTransform().withMatrix(matrix);
} else {
sceneBuilder.addMesh().withShader(mesh.getMaterial()).withMesh(mesh).withTransform().withScaleX(mesh.getSize().getX()).withScaleY(mesh.getSize().getY()).withScaleZ(mesh.getSize().getZ()).withTranslateX(mesh.getPosition().getX()).withTranslateY(mesh.getPosition().getY()).withTranslateZ(mesh.getPosition().getZ());
}
} else if (pSceneElement instanceof PointLight) {
PointLight light = (PointLight) pSceneElement;
sceneBuilder.addLight().withType(LightType.POINT).withColor(light.getColor().getR(), light.getColor().getG(), light.getColor().getB()).withP(light.getPosition().getX(), light.getPosition().getY(), light.getPosition().getZ()).withPower(light.getIntensity() * 2000000.0);
} else if (pSceneElement instanceof SkyLight) {
SkyLight light = (SkyLight) pSceneElement;
sceneBuilder.addSkyLight().withUp(light.getUp().getX(), light.getUp().getY(), light.getUp().getZ()).withEast(light.getEast().getX(), light.getEast().getY(), light.getEast().getZ()).withSundir(light.getSundir().getX(), light.getSundir().getY(), light.getSundir().getZ()).withTurbidity(light.getTurbidity()).withSamples(light.getSamples());
} else if (pSceneElement instanceof Camera) {
Camera camera = (Camera) pSceneElement;
sceneBuilder.openCamera().withType(CameraType.PINHOLE).withEye(camera.getEye().getX(), camera.getEye().getY(), camera.getEye().getZ()).withTarget(camera.getTarget().getX(), camera.getTarget().getY(), camera.getTarget().getZ()).withUp(camera.getUp().getX(), camera.getUp().getY(), camera.getUp().getZ()).withFov(camera.getFov()).withAspect(camera.getAspect());
} else if (pSceneElement instanceof Scene || pSceneElement instanceof MaterialGroup) {
} else {
System.out.println("Unknown positionable element " + pSceneElement);
}
}
use of org.jwildfire.create.eden.scene.primitive.Mesh in project JWildfire by thargor6.
the class SceneElementGroup method addMesh.
public Mesh addMesh() {
Mesh mesh = new Mesh(this);
elements.add(mesh);
return mesh;
}
use of org.jwildfire.create.eden.scene.primitive.Mesh in project JWildfire by thargor6.
the class FilterKernelVisualisation3dRenderer method addCube.
private void addCube(Scene pScene, double pX, double pY, double pWidth, double pHeight, double pZ, Color pColor) {
Mesh mesh = pScene.addMesh();
List<Point3f> pPoints = mesh.getPoints();
List<Face3i> pFaces = mesh.getFaces();
double z0 = 0;
int idx0 = pPoints.size();
// top points
pPoints.add(new Point3f(pX, pY, pZ));
pPoints.add(new Point3f(pX, pY + pHeight, pZ));
pPoints.add(new Point3f(pX + pWidth, pY + pHeight, pZ));
pPoints.add(new Point3f(pX + pWidth, pY, pZ));
// top 0 1 3/3 1 2
pFaces.add(new Face3i(idx0, idx0 + 1, idx0 + 3));
pFaces.add(new Face3i(idx0 + 3, idx0 + 1, idx0 + 2));
// bottom points
pPoints.add(new Point3f(pX, pY, z0));
pPoints.add(new Point3f(pX, pY + pHeight, z0));
pPoints.add(new Point3f(pX + pWidth, pY + pHeight, z0));
pPoints.add(new Point3f(pX + pWidth, pY, z0));
// front 1 5 2/2 5 6
pFaces.add(new Face3i(idx0 + 1, idx0 + 5, idx0 + 2));
pFaces.add(new Face3i(idx0 + 2, idx0 + 5, idx0 + 6));
// right 2 6 3/3 6 7
pFaces.add(new Face3i(idx0 + 2, idx0 + 6, idx0 + 3));
pFaces.add(new Face3i(idx0 + 3, idx0 + 6, idx0 + 7));
// back 3 7 0/0 7 4
pFaces.add(new Face3i(idx0 + 3, idx0 + 7, idx0));
pFaces.add(new Face3i(idx0, idx0 + 7, idx0 + 4));
// left 0 4 1/1 4 5
pFaces.add(new Face3i(idx0, idx0 + 4, idx0 + 1));
pFaces.add(new Face3i(idx0 + 1, idx0 + 4, idx0 + 5));
}
Aggregations