I’ve started to develop a Chess Game in 3d with this amazing engine. I’ve made a board with Boxes and used the test models as pieces and that’s all i have achieved.
Thing is i want to be able to highlight both (box and model) when the center of the camera points at either one. With a ray i can detect collisions on models to make them “shiny” by adding/removing an ambient Light to them on the update method. The very same doesn’t apply to my boxes, they collide but they don’t shine. Besides i can’t seem to find a proper way to find out which box has the model i select with the crosshair and viceversa.
Perhaps i should have designed a different node hierarchy? I have three nodes attached to the rootNode, the one with the board and two for the pieces owned by each chess player.
One way of doing this is to use a filter… in postQueue render a GeometryList containing the chess piece + board cube using a forced material and then blend the output of that frame buffer back into the scene.
There are multiple ways of determining which box has the selected piece… but I would think you would know already simply due to the nature of chess. If the game isn’t this far alone just worry about highlighting the piece for now… and snag the board geometry later.
A second thought would be to use a single geometry for the board and projective texturing to show the piece that is currently active (or a combo of the above idea and this.
But basically, I shoot a ray, when it intersects the board I take the world coordinates X,Z and since I know how large my “tiles” are I just divide to get the correct tile.
@Empire Phoenix @jmaasing Are you guys serious? Would u actually take this approach considering the game is CHESS and it is an ABSOLUTE REQUIREMENT to know what piece reside where on the board. Why would u loop over the entire board when you HAVE to know that pawn3 is on a5 just to write the logic portion of the game.
This isn’t trying to be offensive, I’m actually curious… would you do this?
but the chess pieces are game objects and not scene objects and so have their own board data structure that they use. At least if things are done right. So then “picking” a piece is just a matter of division.
But my “spatials are not game objects” recording is getting kind of worn through at the moment.
but the chess pieces are game objects and not scene objects and so have their own board data structure that they use. At least if things are done right. So then “picking” a piece is just a matter of division.
But my “spatials are not game objects” recording is getting kind of worn through at the moment.
No they are not, but you have to have some sort of linkage between your visual representation and game objects if you want the user to be able to interact via the spatials… and in this case, the rules have been setup for the OP far before we had computers to simulate the game. I was just curious what the reasoning behind a blind sweep of spatials was all about when the game requires knowing this information to write any form of AI for a computer based opponent… actually… screw the AI… board setup requires specifying where to place the pieces. /boggle
<cite>pspeedsaid:</cite>
but the chess pieces are game objects and not scene objects and so have their own board data structure that they use. At least if things are done right. So then "picking" a piece is just a matter of division.
Which is precisely what the code I shared do for picking a tile, It does not pick a chess piece.
For determining what game object/chess piece lives in a specific tile, that has nothing to do with the scene graph. That is a model of the game that lives outside the scene graph and that can be solved in different ways. Like pspeed already said
I’m sorry for being so late. I’ve learned two things here : that the community is cooler than what i would have imagined and that my game needs to be re-engineered.
I’m going to download jmaasing’s code, i was in need of a proper guidance as it’s very hard for me to learn both jME and game development’s good practices.
The loop was the simplest approach, it’s not bad but i was aiming for the best approach with my question.