Spline Mesh
I basically have a hermite curve which I have verified is correct. I have a mesh which I am trying to stretch along the mesh with no avail. If somebody cld help me understand how can I stretch it using openTk that wld be helpful.
35 Replies
what is the original mesh?
can you send a screenshot too?
sure
@Anton
The first screenshot is what I tried and the second is the curve
and what output do you expect?
what does it mean to stretch a mesh along a mesh (you probably meant mesh along a curve or vice versa)
yes the mesh along a curve
what does that mean?
my english aint that good
So i am try my best to explain it
So basically I want the mesh to follow the curve without compressing or expanding
i mean you could also draw what you expect in paint or something
sure
so basially the black line represents the curve while the pruple line represents the mesh which I want to follow the curve
ok got it
so you have a mesh that represents a slice
and you want to repeat this slice mesh at a few points along the curve
connecting consecutive slices between each other to form the outside of this "tunnel"
do I got it right?
ye
well whatever you're doing, first thing I'd recommend is laying out your vertices in memory
you need a struct that represents the layout of a vertex
got it
so you can't accidentally write one of the values at an incorrect index
I see
this will make later discussions way easier
doing some helper methods to set the values is ok too
like, you could take a Span<float> of the current vertex data
and have a method like MyVertex.PositionX(...) that sets the position
that is pretty much equivalent to a struct with explicit layout
ok
how do I actually deform the curve so that the mesh actually follows the curve
have you done the vertex thing?
yes
i saw that i have to do smething with
Frenet–Serret formulas
I don't know what that is
well basically the idea is to make triangles between consecutive layers
also you'll need to rotate your mesh in the direction of the splines tangent
how do I do that
Here's an example of connecting two adjacent copies of a mesh (a triangle)
the blue lines denote the triangles you need to add to the final mesh
It depends how you do it on the way you're going to draw it
but in its simplest form (no index buffer, no triangle strip draw call) you'd have to make a quad out of 2 pairs of vertices
one pair per cosecutive mesh pair
to make a quad you make 2 triangles that make it up
just apply the transformation to the positions of the vertices
multiply by a rotation matrix
the rotation matrix that brings the general normal of you mesh (normally the up vector) to the spline's tangent
it's some form of rotation around an axis
bro istg I am losing brain cells trying to deform this mesh
do you know what a linear transformation is?
not really this is my first time messing with this stuff
I highly recommend watching this
https://youtube.com/playlist?list=PLZHQObOWTQDPD3MizzM2xVFitgF8hE_ab&si=K7g9wReGIc3XrN_w
YouTube
Essence of linear algebra
A free course offering the core concept of linear algebra with a visuals-first approach.
You might also want to learn the basics of homogenous coordinates, though probably not necessary for this problem
I just finished the linear transformaton topic so i think I am a bit familiar with it now
Mathematics Stack Exchange
Calculate Rotation Matrix to align Vector $A$ to Vector $B$ in $3D$?
I have one triangle in $3D$ space that I am tracking in a simulation. Between time steps I have the previous normal of the triangle and the current normal of the triangle along with both the curren...
this is the solution you need to move the normal to the tangent of the curve
do that for each step, and you'll get the consecutive copies of the mesh
aligned correctly at points of the curve
you may want to try and generate that as your mesh first to see if you got it right
and then do this between the consecutive slices