Hi! And you looked sample 34_DynamicGeometry ?
I recently did something like this,dynMesh with my material(alpha texture) but w/o rigidbody, I think for him to need the right boundbox or something else.
default line of trianles_strip in start proc of script
typedef struct DYN_VERTEX
{
Vector3 p;
Vector3 n;
Vector2 uv;
} DYN_VERTEX;
void LineGenerator::Start()
{
ResourceCache* cache = GetSubsystem<ResourceCache>();
tailLength_ = 20;
fromScratchModel = new Model(context_);
vb = new VertexBuffer(context_);
ib = new IndexBuffer(context_);
geom = new Geometry(context_);
const unsigned numVertices = tailLength_* 4;
PODVector<DYN_VERTEX> vertexData;
vertexData.Resize(numVertices);
PODVector<unsigned short> indexData;
indexData.Resize(numVertices);
Vector3 xstep = Vector3(1.0f, 0.0f, 0.0f);
Vector3 ystep = Vector3(0.0f, 1.0f, 0.0f);
Vector3 curPos = Vector3(0,0.0f,0);
for (int i =0; i < (numVertices); i += 4)
{
vertexData[i].p = curPos;
curPos += ystep;
vertexData[i+1].p = curPos;
curPos += xstep;
curPos -= ystep;
vertexData[i+2].p = curPos;
curPos += ystep;
vertexData[i+3].p = curPos;
curPos -= ystep;
vertexData[i].n = Vector3::UP;
vertexData[i+1].n = Vector3::UP;
vertexData[i+2].n = Vector3::UP;
vertexData[i+3].n = Vector3::UP;
vertexData[i].uv = Vector2(0.0f, 0.0);
vertexData[i+1].uv = Vector2(0.0f, 1.0f);
vertexData[i+2].uv = Vector2(1.0f, 0.0f);
vertexData[i+3].uv = Vector2(1.0f, 1.0f);
}
//indexes
for (int i =0; i < numVertices; ++i)
{
indexData[i]=i;
}
//vb->SetShadowed(true);
vb->SetSize(numVertices, MASK_POSITION|MASK_NORMAL|MASK_TEXCOORD1);
vb->SetData(&vertexData[0]);
ib->SetShadowed(true);
ib->SetSize(numVertices, false);
ib->SetData(&indexData[0]);
geom->SetVertexBuffer(0, vb);
geom->SetIndexBuffer(ib);
geom->SetDrawRange(TRIANGLE_STRIP, 0, numVertices);
fromScratchModel->SetNumGeometries(1);
fromScratchModel->SetGeometry(0, 0, geom);
fromScratchModel->SetBoundingBox(BoundingBox(Vector3(-5.0f, -5.0f, -5.0f), Vector3(5.0f, 5.0f, 5.0f)));
dynNode_ = GetNode()->GetScene()->CreateChild("dynNode", LOCAL);
StaticModel* object = dynNode_->CreateComponent<StaticModel>();
object->SetModel(fromScratchModel);
object->SetMaterial(cache->GetResource<Material>("Materials/LineGenerator.xml"));
}
Completely all, you can save through a blender or AssetImporter, then read vertex buffer from model and modify it as needed in code.
Save from maya to some format for example obj and open with blender and reexport to *.mdl with individuale frefab options in exporter.
And of course you will need add-on for blender install, befor this all.