Get the center between normals

Hi, my stupid question is:



How can I get the center of "square" between normals in the scenario of my game? :?



Thx a lot!!!


If you mean how to compute the center of a square that is spanned by two orthogonal, normalized vectors v1 and v2 that is really easy:

center = v10.5 + v20.5



But I guess you mean something else . . .


Hi irrisor!

I want get the center of any normals in my floor...I want construct a TriMesh with the coord of the four vertex.



Thank you! And sorry my english cann not me explain more

hehe, ok - my next guess :): you simply need the center of the four vertices the normals belong to?



Do you already know the vertice data/indices? If yes, you only have to decide whether you need the geometric center or the point between the four vertices that is exactly on your terrain (yes, that's a difference).

The latter can be queried from the terrain classes, iirc - I've read a post about someone correcting it. Can anyone tell the method name? (maybe you can even find it yourself)

hehehe

What do you have to identify them? An area on the screen? A 3D location? A list of normals? (in the latter case where did you get them from?)

Hi irrisor!



I want 3D location…

I want create a TriMesh by the verteices of floor…





Thank you!!!

Ok, but what do you already have?

Hi irrisor!!!



My real problem is:



I create a single scenario on blender and my problem is get the Y position on the floor when my character walk. I want create a method like in the TestThirdPersonController that control the Y position of my character…something like this:



float characterMinHeight = page.getHeight(m_character

                .getLocalTranslation())+((BoundingBox)m_character.getWorldBound()).yExtent;

        if (!Float.isInfinite(characterMinHeight) && !Float.isNaN(characterMinHeight)) {

            m_character.getLocalTranslation().y = characterMinHeight;

        }



But the TriMesh dont have a method like TerrainPage (getHeight())…So, I GUESS, that if I create a footsteps(I guess that in english is it - like image below) with TriMeshs solve my problem because I can create a collision with each square. Now I know like the JME load the vertex (second image)…But If have another way to control the Y position using the a terrain model…please, show me…I

I think there is an easier way to achieve that then. First, I once again repeat what I think you want:


  • you have the x and z coordinate of your character
  • you have an arbitrary mesh that represents your terrain
  • you want to compute the y coordinate of your character to avoid terrain penetration



    My proposal:
  1. use picking with a ray to find the triangle of interest

          - create a ray that starts slightly above the probable new charcter position e.g. (newX, oldY + 0.5, newZ) with a direction straight down

          - triangle pick your terrain mesh(es)
  2. call intersectWhere of the ray with that found triangle

          - you get an exact distance
  3. compute the new character position as (newX, startOfTheRay.z + intersectDistance, newZ )



    If you can't get it to work quickly, try to implement it in steps. First do only the triangle picking and visualize the picked triangle like in TestOBBPick. Then vizualze the computed distance…

Nice!!!



Thank you irrisor!!!