Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve 3D view (rounded, filled obstacles) #24

Open
armin-reichert opened this issue Dec 11, 2024 · 8 comments
Open

Improve 3D view (rounded, filled obstacles) #24

armin-reichert opened this issue Dec 11, 2024 · 8 comments

Comments

@armin-reichert
Copy link
Owner

3D view should use filled and rounded obstacles.

@Birdasaur
Copy link

You might be able to cheat a little bit to achieve rounded effects by simply inserting a properly sized cylinder object at each corner. By sizing the radius properly you should be able to achieve a rounded effect without z fighting.
Caveat... this will add a bunch more nodes to your scenegraph... but you can mitigate some of the cpu overhead by setting them mouse transparent.

Advantages to this approach over doing a custom rounded wall triangle mesh are simplicity obviously but also style. You could colorize and shade the corners differently than the walls which could get a really cool depth effect. I could also see a new type of game mode where you ONLY apply lighting to the corners. (or at least make the walls very dark). This would give the whole gameboard a black light effect and make it harder to navigate.

Maybe this could be an effect that is triggered randomly or due to a hazard to make it more difficult.
Or you could make it a fog of war mechanic where at the start the user only sees the corner nodes and the other nodes become revealed as the pac man character gets close. You could accomplish it simply by managing which nodes get added to the ambient light scope and when.

You could call it PacMan++ :-)

@armin-reichert
Copy link
Owner Author

Hi Sean,

what an honor to get input from a real JavaFX expert :-)

Thank you for all your ideas, I will think about them.

I admit, the 3D maze always looked a litle bit cheap and I wanted to improve that already since a long time. In the recent months, I was busy adding the Tengen Ms. Pac-Man game variant which offers a large number of new mazes, some of which are really, as their name says, "strange".

After having "completed" that (the 2-player modes are not implemented), I want to come back to finally improving the 3D view. To do so I reworked the representation of the obstacles so it should be no problem at all to replace the 3D corners by something more fancy. What I had in mind was using one of your F(X)yz library shapes, not sure which one would make most sense. That would, however, violate my silent requirement to not use any additional libraries (tinylog doesn't count :-) in my game implementation, just JavaFX out-of-the box.

Of course, a prefabricated 3D model for all the known mazes would easiest to use and would look best, but unfortunately, I am completely untalented in using programs like Blender and the like.

The current solution gives my a generic way of creating the 3D mazes from any (2D) map file and improving this is probably the way to go.

Best regards from Germany

Armin

@Birdasaur
Copy link

Thank you for the compliment.
I really love what you did with this game... I have a special love for taking "simple" retro games and making them 3D while maintaining the simplicity. And it looks really nice as is!

Regarding FXyz... I'd have to think about what would make a good corner shape... but I'm not sure if any one of them will do the job properly.
Maybe the SegmentedSphere or SegmentedTorus? They are designed for the user to control the vertex and face winding so that only parts of the shape are drawn. I bet you could achieve a shape that is rounded on only one side, thereby giving you the effect you need.

You could also make a set of curved face cuboid trianglemeshes. It would be a custom mesh but not complicated... essentially take the cuboid mesh vertices round out one of the corners. (probably need to add several more verts to do this. Then for any corner angle you would simply need to rotate/flip the shapes orientation to make it align properly.
Highly artistic example:
image

This is basically what the SegmentedSphere allows you to do using variables, except that it assumes a spherical interpolation which might not align well with your existing walls. So A third option would be to take the Capsule code in FXyz and modify it to allow for a squared interior.

I still think that using Cylinders at the corners is the way to go. (or capsules I suppose) It would open up a lot of cool stylistic options.

Sean

@armin-reichert
Copy link
Owner Author

In a first try I placed cylinders in the corners and shortened the walls in the corner a bit. This already looks better. However, what I really want to achieve in the future are filled obstacles which look exactly like the 2D obstacles.

@Birdasaur
Copy link

give us some pics fam.... ;-p

@armin-reichert
Copy link
Owner Author

armin-reichert commented Dec 20, 2024

I started by adding cylinders to all corners (as you can e.g. see in the outer walls). This already improved the look a bit.

Then I changed the representation of O-shaped obstacles as you can see in the screenshot. L-shapes and T-shapes will probably also not be a problem.

For creating filled and rounded representations of general polygonal obstacles I probably need to implement some polygon decomposition algorithm like has been done here:

https://github.com/shininglion/rectirization.
rounded-obstacles-first-steps

@Birdasaur
Copy link

I think this looks cool actually! I know you are showing wire frame for debugging purposes but its a cool effect. It would be cool if you had random chaotic effects that kicked in like all the obstacles and characters going wireframe temporarily for like 5 seconds

for the long walls inside the maze, (not the outer walls) are you using a standard Box object?
If so you could possibly replace that with a Capsule from Fxyz would would give you nice rounded barriers.

Another idea would be to make an animated box ... ie... its a custom class that reuses the original Box trianglemesh code but then adds code to animate the texture on the surface. Basically what I'm suggesting is that you could keep the wall structures as is but ALSO add image materials to it that you animate the UV coordinates of to simulate motion or some cool special effect. You could do that special effect only when a ghost or the pacman is near by. Maybe even have different material animations depending on which ghost.

Here is an example I did for an animated box object in my Trinity software:
https://github.com/trinity-xai/Trinity/blob/main/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/AnimatedBox.java

The intent of the effect was that if you double clicked on the box it would rotate the material texture on the box vertically. It's intent was to simulate animated motion on a city street. You can do something fancy like this with your walls or anything you want technically. Or even draw on the texture directly using pixelwriter if you want to get super whiz bang.

@armin-reichert
Copy link
Owner Author

armin-reichert commented Dec 27, 2024

Wow, so much ideas (from your side) and so little knowledge (from my side :-)

But honestly, thank you very much for all your ideas! Will see what I can realize.

Today, I added support for basic L-shapes and T-shapes, see screenshot. Next, I will implement elementary U-shapes and cross-like shapes. I find this a useful path to follow for now. All the 3D shapes are just composed of cylinders and boxes by now.

The internal obstacles you mentioned are also just
composed of boxes and cylinders (inside the corners). This rounds the corners a litte bit, the outer non-closed wall paths are done the same way, there the corner rounding effect is a bit more visible, but it's exactly the same code as for the closed obstacle inside.

rounded-walls-continued

Best regards

@armin-reichert armin-reichert changed the title Improve 3D view Improve 3D view (rounded, filled obstacles) Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants