So I’ve been trying to give physics to objects made with Custom Geometry (Same as DynamicGeometry sample) but when I do
node->CreateComponent<ur::RigidBody>()->SetMass(1.0f);
ur::CollisionShape *shape= node->CreateComponent<ur::CollisionShape>();
shape->SetTriangleMesh(object->GetModel(), 0);
It throws an exception, around the shape->SetTriangleMesh part.
I’ve also tried using the actual model variable but that throws an exception, too.
Here’s how the model is made
ur::SharedPtr<ur::Model> model(new ur::Model(context_));
ur::SharedPtr<ur::VertexBuffer> vb(new ur::VertexBuffer(context_));
ur::SharedPtr<ur::IndexBuffer> ib(new ur::IndexBuffer(context_));
ur::SharedPtr<ur::Geometry> geom(new ur::Geometry(context_));
ur::PODVector<ur::VertexElement> elements;
elements.Push(ur::VertexElement(ur::TYPE_VECTOR3, ur::SEM_POSITION));
elements.Push(ur::VertexElement(ur::TYPE_VECTOR3, ur::SEM_NORMAL));
elements.Push(ur::VertexElement(ur::TYPE_VECTOR3, ur::SEM_COLOR));
elements.Push(ur::VertexElement(ur::TYPE_VECTOR2, ur::SEM_TEXCOORD));
elements.Push(ur::VertexElement(ur::TYPE_VECTOR4, ur::SEM_TANGENT));
vb->SetShadowed(true);
vb->SetSize(numVertices, elements);
vb->SetData(vertexData);
ib->SetSize(36, false);
ib->SetData(indexData);
geom->SetVertexBuffer(0, vb);
geom->SetIndexBuffer(ib);
geom->SetDrawRange(TRIANGLE_LIST, 0, numVertices);
model->SetNumGeometries(1);
model->SetGeometry(0, 0, geom);
model->SetBoundingBox({min, min + max});
Any clue?