Creating a maze by from 2d matrix


#1

Hey, I am entirely new to Panda3d and I have no prior experience working with a 3D Engine whatsoever, what I want to do is give a 2d matrix input of 0s and 1s and construct a 3d maze out of it, with 1s as walls and 0s as movable and then use it for maneuvering a vehicle in it.

How do I get started??


#2

You can take a look at Procedurally Generating 3D Models section of the manual. Another option is to convert the matrix into a heightmap/heightfield that can be used for rendering (e.g., GeoMipMapTerrain, ShadderTerrainMesh) and physics (e.g., BulletHeightfieldShape).


#3

Would you happen to know how to create just a plain surface with a cube on it, I will probably be able to reverse engineer my way from there


#4

I would recommend going through the hello world example from the manual.


#5

I know but there are way too many components to go through all of them, I mean isn’t there just a simple code that just models a cube or something at a certain point


#6

Yes, there is. Check out the “Procedural Cube” sample program included in the samples folder of the SDK.


#7

I have some code that takes a black and white image and creates a 3D maze (with collisions) from it using just a floor, a wall and a column model.

I can share the code if that’s something along the lines of what you need (I just need to find it - may take a day or two).


#8

That would be really helpful mate, I am trying to set a simulator for a deep RL problem


#9

Ok, so from what I have read( and hopefully understood) I will need to use a bullet world for the physics and everything.Lets break down the problem into sub-parts, so the first thing that I would would want is a plane surface on which on place things. How do I do that?


#10

Ok so from what I have understood you can create a plane following the example code like this:

shape = BulletPlaneShape(Vec3(0, 0, 1), 1)
node = BulletRigidBodyNode('Ground')
node.addShape(shape)
np = render.attachNewNode(node) 
np.setPos(0, 0, -2)
world.attachRigidBody(node)

But how exactly should I make it visible possibly with some texture?


#11

You can’t create visible geometry from a physics shape; you usually create the physics shape to match the physical geometry.

You should probably think about creating your models and your visible geometry first, and think about physics later. You may actually not even need a physics engine; the built-in collision engine may suffice depending on your needs.

You could generate a plane shape using CardMaker, or you could load in a model of a plane that you created using a program like Blender.


#12

Examples would really help, like how do you get the CardMaker to do it, and how do I combine it with the plane


#13

Oh now I get it thanks, I was not able to use CardMaker, but using Blender with Chicken did the trick


#14

Here’s the code I wrote about earlier.
Screen:

Code:
https://drive.google.com/file/d/12OwbS4Q1IauQ7WxaXxcgyqBFsO6Jl_qY/view?usp=sharing