Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Pignic

#1
Support / Export Object3D into a .obj file
September 12, 2014, 05:50:37 PM
Hi,

Is it possile to create a .obj file and write some Object3D in it ?

Thanks.
#2
Support / Re: Applet Render Hardware Windows vs Mac
September 12, 2014, 05:42:47 PM
Hi,

I have updated the Mac to the Maverick version and everithing works well now (just some issues on some font but easy to solve)

Thank you.
#3
Support / Re: Applet Render Hardware Windows vs Mac
July 25, 2014, 04:52:58 PM
Hi,

I don't really understand what you mean by : "On Windows, one can tweak the Java2d pipeline by some system parameters to either use D3D, OpenGL or software".
Is it a parameter to add in the applet tag ?

Thanks
#4
Support / Re: Applet Render Hardware Windows vs Mac
July 11, 2014, 11:29:29 AM
Hi,
First of all, thank you for your quick reactivity.
I've don't run the app in a standalone version but if I try to run it with the appletViewer of Eclipse, it works well. I have made a comparison of the classPath and others parameter with visualVM to reproduce the same environment but nothing to do... I don't know very well the Mac's world and I've tried for a year to solve this problem. I solve just one thing : I deactivate the shadow helper because it cause a black canvas on mac (I've passed 3 month to find this, maybe is was a bad use or anything but I don't want to use more time for this (my boss doesn't want to pay me for this :)...))
If you want, you can chek the app on http://www.easygreen.pro/pages/designer

Thanks for your help !
Nicolas
#5
Support / Applet Render Hardware Windows vs Mac
July 10, 2014, 09:49:03 AM
Hi,

I’ve created an Applet using JPCT. This work well on Windows but I have some troubles with Mac.
When I'm using Windows, I’ve got this:



And on Mac, I’ve got this:



But on the initialization of the applet, I've got a white screen (normal) and then this :



Before that the canvas appear and the menu goes black...

I have this since the beginning of the project (2 years) and I don’t have any clues on how to solve it.

I see briefly the swing part but it disappears when the canvas appear. I can continue to use the buttons in the menu and the cursor change well when i go in/out the canvas.

What can I post to you to help me with this ?

Best regards,
Nicolas
#6
Support / Re: Texture mapping issue
November 15, 2012, 10:50:26 AM
There is the code to generate a parallelepiped with a good uv mapping :


public Object3D createBox(final float width, final float depth,
final float height, final int textureId) {
final Object3D box = new Object3D(12);

final float x = width / 2;
final float y = depth / 2;
final float z = height / 2;

final int textureFactor = 64;

final SimpleVector upperLeftFront = new SimpleVector(-x, -y, -z);
final SimpleVector upperRightFront = new SimpleVector(x, -y, -z);
final SimpleVector lowerLeftFront = new SimpleVector(-x, y, -z);
final SimpleVector lowerRightFront = new SimpleVector(x, y, -z);

final SimpleVector upperLeftBack = new SimpleVector(-x, -y, z);
final SimpleVector upperRightBack = new SimpleVector(x, -y, z);
final SimpleVector lowerLeftBack = new SimpleVector(-x, y, z);
final SimpleVector lowerRightBack = new SimpleVector(x, y, z);

// Upper
box.addTriangle(lowerLeftFront, x / textureFactor, 0, lowerRightFront,
0, 0, upperLeftFront, x / textureFactor, y / textureFactor,
textureId);
box.addTriangle(lowerRightFront, 0, 0, upperRightFront, 0, y
/ textureFactor, upperLeftFront, x / textureFactor, y
/ textureFactor, textureId);

// Lower
box.addTriangle(upperLeftBack, x / textureFactor, 0, upperRightBack, 0,
0, lowerLeftBack, x / textureFactor, z / textureFactor,
textureId);
box.addTriangle(upperRightBack, 0, 0, lowerRightBack, 0, z
/ textureFactor, lowerLeftBack, x / textureFactor, z
/ textureFactor, textureId);

// Front
box.addTriangle(upperLeftFront, x / textureFactor, z / textureFactor,
upperRightBack, 0, 0, upperLeftBack, x / textureFactor, 0,
textureId);
box.addTriangle(upperLeftFront, x / textureFactor, z / textureFactor,
upperRightFront, 0, z / textureFactor, upperRightBack, 0, 0,
textureId);

// Back
box.addTriangle(lowerLeftBack, x / textureFactor, 0, lowerRightBack, 0,
0, lowerLeftFront, x / textureFactor, z / textureFactor,
textureId);
box.addTriangle(lowerRightBack, 0, 0, lowerRightFront, 0, z
/ textureFactor, lowerLeftFront, x / textureFactor, z
/ textureFactor, textureId);

// Left
box.addTriangle(lowerRightBack, y / textureFactor, 0, upperRightBack,
0, 0, lowerRightFront, y / textureFactor, z / textureFactor,
textureId);
box.addTriangle(upperRightBack, 0, 0, upperRightFront, 0, z
/ textureFactor, lowerRightFront, y / textureFactor, z
/ textureFactor, textureId);

// Right
box.addTriangle(upperLeftBack, y / textureFactor, 0, lowerLeftBack, 0,
0, upperLeftFront, y / textureFactor, z / textureFactor,
textureId);
box.addTriangle(lowerLeftBack, 0, 0, lowerLeftFront, 0, z
/ textureFactor, upperLeftFront, y / textureFactor, z
/ textureFactor, textureId);

return box;
}

#7
Support / Lighting problem on 2 Object3D side by side
November 15, 2012, 10:40:55 AM
Hello,

I have a strange light effect when I place two objects side by side as in this image :



My light source :

final Light sun = new Light(world);
sun.setIntensity(50, 55, 60);
sun.setDiscardDistance(3000);
sun.setPosition(new SimpleVector(500, 500, 2700));


My config of lights :

Config.lightMul = 1;
Config.fadeoutLight = false;
world.getLights().setRGBScale(Lights.RGB_SCALE_2X);
world.setAmbientLight(131, 138, 154);
world.getLights().setOverbrightLighting(Lights.OVERBRIGHT_LIGHTING_DISABLED);


What I put on all the objects to have a lighting effetc :

wall.build();
wall.setSpecularLighting(true);
wall.setLighting(Object3D.LIGHTING_ALL_ENABLED);


On this image, there are 6 objects : 3 angles and 3 walls.

Can anyone help me or tell me if I forgot some parameters ?

Thanks and best regards.
#8
Support / Re: Generate a plan from model
November 05, 2012, 05:56:14 PM
I created a fairly simple algorithm to answer my question.
I don't think it is very efficient but it works pretty well.
I think the functions that I have added can be bypassed by JPCT functions easier to use.

The class is called ModelComposerImpl.

The main function :

public static Object3D generateFlatModel(final List<Object3D> inPoints,
final float height, final int groundTextureId,
final int roofTextureId) {
final Object3D plan = new Object3D(1000);
final List<Object3D> points = new ArrayList<Object3D>(inPoints);
int i = 0;
// The angle to know if a corner is in or out the shape.
final float innerAngle = ModelComposerImpl.calcInnerAngle(inPoints);
// The vector to lift the plan by the given value.
final SimpleVector liftVector = new SimpleVector(0, 0, -(inPoints
.get(0).getOrigin().z - height));
final float textureRatio = 128;
// While we can make triangles
while (points.size() > 2) {
final int size = points.size();
// Get the angle of the corner
final float angle = ModelComposerImpl.getAngle(points.get(i % size)
.getOrigin(), points.get((i + 1) % size).getOrigin(),
points.get((i + 2) % size).getOrigin());
// If the corner is an obtuse angle
if (angle <= 0 && innerAngle > 0 || angle >= 0 && innerAngle < 0) {
++i;
continue;
}
boolean intersected = false;
// Check if the triangle overlaps another side of the shape
for (int j = 0; j < inPoints.size() && !intersected; ++j) {
intersected = ModelComposerImpl.isLineCrossing(
points.get(i % size).getOrigin(),
points.get((i + 2) % size).getOrigin(),
inPoints.get(j % inPoints.size()).getOrigin(), inPoints
.get((j + 1) % inPoints.size()).getOrigin());
}
// If the triangle does not overlaps another side of the shape,
// create the triangle.
if (!intersected) {
final SimpleVector point1 = points.get((i + 2) % size)
.getOrigin().calcAdd(liftVector);
final SimpleVector point2 = points.get((i + 1) % size)
.getOrigin().calcAdd(liftVector);
final SimpleVector point3 = points.get(i % size).getOrigin()
.calcAdd(liftVector);
// Upper face
plan.addTriangle(point1, point1.x / textureRatio, point1.y
/ textureRatio, point2, point2.x / textureRatio,
point2.y / textureRatio, point3, point3.x
/ textureRatio, point3.y / textureRatio,
innerAngle > 0 ? groundTextureId : roofTextureId);
// Lower face
plan.addTriangle(point3, point3.x / textureRatio, point3.y
/ textureRatio, point2, point2.x / textureRatio,
point2.y / textureRatio, point1, point1.x
/ textureRatio, point1.y / textureRatio,
innerAngle > 0 ? roofTextureId : groundTextureId);
points.remove((i + 1) % size);
} else {
++i;
}
}
return plan;
}


The function to get the an angle between two vectors (it's to bad that I don't found a simple method to get an oriented angle so I do it manualy) :


public static float getAngle(final SimpleVector side1,
final SimpleVector center, final SimpleVector side2) {
final SimpleVector side1Vector = side1.calcSub(center);
final SimpleVector side2Vector = side2.calcSub(center);
float angle = side1.calcSub(center).calcAngle(side2.calcSub(center));
// If the angle is an obtuse angle, subtract PI to the angle
if (side1Vector.x < side2Vector.x && side1Vector.y > side2Vector.y
&& side1Vector.y > 0 && side2Vector.x > 0) {
angle -= Math.PI;
}
if (side1Vector.x < side2Vector.x && side1Vector.y < side2Vector.y
&& side1Vector.x < 0 && side2Vector.y > 0) {
angle -= Math.PI;
}
if (side1Vector.x > side2Vector.x && side1Vector.y < side2Vector.y
&& side1Vector.y < 0 && side2Vector.x < 0) {
angle -= Math.PI;
}
if (side1Vector.x > side2Vector.x && side1Vector.y > side2Vector.y
&& side1Vector.x > 0 && side2Vector.y < 0) {
angle -= Math.PI;
}
return angle;
}


The function to check if two segments are crossing (return false if the segments get a same point)
I think this function can be replaced by a jpct's function but I don't find it.

public static boolean isLineCrossing(final SimpleVector line1Origin,
final SimpleVector line1End, final SimpleVector line2Origin,
final SimpleVector line2End) {
// If the lines have a same point , return false.
if (line1Origin.distance(line2Origin) == 0
|| line1Origin.distance(line2End) == 0
|| line1End.distance(line2Origin) == 0
|| line1End.distance(line2End) == 0) {
return false;
}
double sx;
double sy;
if (line1Origin.x == line1End.x) {
if (line2Origin.x == line2End.x) {
return false;
} else {
final double pCD = (line2Origin.y - line2End.y)
/ (line2Origin.x - line2End.x);
sx = line1Origin.x;
sy = pCD * (line1Origin.x - line2Origin.x) + line2Origin.y;
}
} else {
if (line2Origin.x == line2End.x) {
final double pAB = (line1Origin.y - line1End.y)
/ (line1Origin.x - line1End.x);
sx = line2Origin.x;
sy = pAB * (line2Origin.x - line1Origin.x) + line1Origin.y;
} else {
final double pCD = (line2Origin.y - line2End.y)
/ (line2Origin.x - line2End.x);
final double pAB = (line1Origin.y - line1End.y)
/ (line1Origin.x - line1End.x);
if (pAB == pCD) {
// If the vectors are collinear, we don't need to consider that they colliding.
return false;
}
final double oCD = line2Origin.y - pCD * line2Origin.x;
final double oAB = line1Origin.y - pAB * line1Origin.x;
sx = (oAB - oCD) / (pCD - pAB);
sy = pCD * sx + oCD;
}
}
// if sx and sy are not in the lines, return false.
if ((sx < line1Origin.x && sx < line1End.x)
| (sx > line1Origin.x && sx > line1End.x)
| (sx < line2Origin.x && sx < line2End.x)
| (sx > line2Origin.x && sx > line2End.x)
| (sy < line1Origin.y && sy < line1End.y)
| (sy > line1Origin.y && sy > line1End.y)
| (sy < line2Origin.y && sy < line2End.y)
| (sy > line2Origin.y && sy > line2End.y)) {
return false;
}
return true;
}


The function to get the inner angle of the shape :

public static float calcInnerAngle(final List<Object3D> points) {
float angle = 0;
final int size = points.size();
for (int i = 0; i < points.size(); ++i) {
angle += ModelComposerImpl.getAngle(points.get(i).getOrigin(),
points.get((i + 1) % size).getOrigin(),
points.get((i + 2) % size).getOrigin());
}
return angle / 4;
}


And then :


Thanks EgonOlsen for your reactivity !

Best regards.
#9
Support / Re: Generate a plan from model
October 31, 2012, 06:02:40 PM
Or most easily, how to generate a flat model with a list of points in the same plan ?

Thanks.
#10
Support / Generate a plan from model
October 31, 2012, 05:43:47 PM
Hi,
I am looking for a simple way to get a shape that represent a plain slice of a model.
For example : if I have the walls of a house, I want to be able to get the ground inside the house as a model.
Are those kinds of uses are native in jpct? or will I explode my brain on tons of big algorythm ?

Thanks and best regards,

Nicolas.