Recent Posts

Pages: 1 ... 8 9 [10]
91
Support / Re: 3Dto2D
« Last post by aleks1283 on July 25, 2022, 12:01:30 am »
Thanks
92
Support / Re: 3Dto2D
« Last post by AeroShark333 on July 24, 2022, 07:08:03 pm »
I see two possibilities:
1.
I'd first loop over all Object3D's in the world.
Then see which of these Object3D's are in the camera's FOV.
(Easiest way would be to do a dot product with the camera direction and the vector connecting the camera to each Object3D; then let's say > 0 falls in the camera view and < 0 is behind the camera's view.)

Then next, using the Object3D's in the camera's view, you'll be using polygon manager. https://www.jpct.net/jpct-ae/doc/com/threed/jpct/PolygonManager.html
You'll have something like this:
Code: [Select]
final Object3D obj = ...;
PolygonManager objPM = obj.getPolygonManager();
for(int id = 0; id < objPM.getMaxPolygonID(); id++){
if(objPM.getTransformedNormal(id).y > 0){
// ^Check if normal of polygon points up...
// Change if this doesn't work
SimpleVector v1 = objPM.getTransformedVertex(id, 0);
SimpleVector v2 = objPM.getTransformedVertex(id, 1);
SimpleVector v3 = objPM.getTransformedVertex(id, 2);
float maxHeight = Math.max(Math.max(v1.y, v2.y), v3.y);
// Do whatever with the max height of this polygon face
}
}
I sort of assumed here that the camera is looking down in the y-axis...

2. Shoot rays for every pixel on the screen and see with which Object3D and polygon face it interacts with. Then use the PolygonManager again to get the distance to that polygon (by averaging vertices or something)...
Make sure the algorithm is RAY:
https://www.jpct.net/jpct-ae/doc/com/threed/jpct/CollisionEvent.html
Maybe the code in reply #19 can help you with ray-polygon intersection:
https://www.jpct.net/forum2/index.php/topic,4821.msg32989.html#msg32989
It's up to you whether you want the ray to be from the camera's origin or parallel to the camera's direction...
To get the 3D position of the screen plane, I think you should use "reproject2D3DWS" in Interact2D. Then you can shoot a ray with vector "normalize((3D position of screen plane) - (camera position))"...
For ray-polygon picking, I think this might be useful: https://www.jpct.net/wiki/index.php/Picking and https://www.jpct.net/doc/com/threed/jpct/World.html#calcMinDistance(com.threed.jpct.SimpleVector,%20com.threed.jpct.SimpleVector,%20float)

Sorry for this messy explanation; typing on phone isn't ideal...
93
Support / Re: 3Dto2D
« Last post by aleks1283 on July 24, 2022, 11:33:27 am »
Egon where are you? How to get this information??? :) :) :)
94
Support / Re: 3Dto2D
« Last post by aleks1283 on July 24, 2022, 09:07:04 am »
In theory, this information is already somewhere in jpct-ae, since visible points are projected onto the screen, and so on with the calculation of the distance to the points .
95
Support / Re: 3Dto2D
« Last post by aleks1283 on July 24, 2022, 08:56:33 am »
How first find the local position of each visible point on 3D?
96
Support / Re: 3Dto2D
« Last post by MichaelJPCT on July 24, 2022, 07:19:32 am »
the screen is at the camera position in world space.
first find the local position of each point on 3D object, then convert the position into world space, then calc the distance from camera position.
converting involves matrix calculation that you need to know.
97
Support / Re: 3Dto2D
« Last post by aleks1283 on July 23, 2022, 06:15:56 pm »
I would do it through interact3D2D maybe, but how to find the coordinates of all visible surfaces of objects???
98
Support / 3Dto2D
« Last post by aleks1283 on July 23, 2022, 01:40:00 pm »
Hello friends. How to find the distance to each point in 3d space from the screen. I want to make a height map from the 3d world displayed on the screen..
99
Support / Re: How to add more texture maps to obj
« Last post by a8451727 on June 11, 2022, 02:31:39 am »
Thank you. Let me check whether there is a problem with my export
100
Support / Re: How to add more texture maps to obj
« Last post by AeroShark333 on June 10, 2022, 04:31:03 pm »
In Blender, try to import the model.
Then in top-left of your screen, change from Object Mode to Edit Mode.
Press CTRL+T (Triangulate mesh).
And then export this new Mesh as .Obj

(source: https://blender.stackexchange.com/questions/19253/how-to-make-all-polygons-into-triangles)
Pages: 1 ... 8 9 [10]