headsUp with a sloping normal face.

Hi.

Im trying to do some math magic and get a model block to create itself and be arranged perpendicular to another model block

I’ve tried:

This is what im trying to reproduce:



My code: (press r to deploy)
http://tauris.the-construct.net/files/test.rar

What picture 4 shows is that the beams lower edges are attached to the pads outer edges.

I was wondering if anyone could provide an easier alternative to what im trying to accomplish that wont result in a thousand lines of hacky code.

Thanks a whole lot!

I can’t run your code without your models and textures, but I could also use some clarification on what you’re trying to do.

I thought you just wanted to get the normal of surface that you were pointing at, but you say you “need corners as well.” What do you mean, exactly?

OP updated

You’re quite right. I started writing my post with that goal in-mind but as it started progressing i changed what i was after. :stuck_out_tongue:

I do apologize for that confusing inconsistency.

.

I’ve been able to do some of the things i’ve set out to do, but it only works on some faces, doing them all would require a ton more code and step-by-step trial-and-error, and i am pretty sure Panda has a much easier solution to what im trying to do.

Plus, i also have no idea how to use headsUp().

Any help is greatly appreciated.

I don’t think Panda3D has any easy way of building objects out of rectangular prisms; it’s a not exactly a standard feature for games.

However, I think you could at least do this with cubes pretty easily:

# collEntry is the CollisionEntry of the cube you clicked on.
clickedCube = collEntry.getIntoNodePath()
normal = collEntry.getSurfaceNormal(render)
cubeCenter = clickedCube.getPos(render)
newCubeCenter = cubeCenter + normal * cubeWidth
# Now make a new cube, and set its Hpr to that of the clicked cube, and its position to newCubeCenter

This is assuming that you are adding the cubes as children of render. You’ll need to adjust the getSurfaceNormal and getPos calls if the cubes have some other parent.

It also gets trickier with non-cubic geometry, since you need to figure out what the orientation should be. If you want to build on top of larger objects, like in your screenshots, I’d recommend tiling the surfaces with invisible squares, and detecting collisions against the squares. Then you just place new objects on top of the square that was clicked.