[Bf-cycles] Assign shader to a mesh
haggi krey
haggi at haggi.de
Sat Nov 14 14:43:32 CET 2015
Hi,
following the standalone xml reader, I tried to create a shader and
assign it to my mesh.
Is it correct that I add the index of the shader in the scene->shaders
array to the mesh and to the created triangle?
For some reason I get an vector error in util_vector.h if I do it this
way. ShaderId is set to my self created shader which can be found in the
scene at index 4:
Mesh *mesh = new Mesh();
scene->meshes.push_back(mesh);
Object *object = new Object();
object->mesh = mesh;
Transform tfm = transform_identity();
object->tfm = tfm;
scene->objects.push_back(object);
mesh->used_shaders.push_back(shaderId);
vector<float3> P;
float3 p0 = { -1, -1, 0 };
float3 p1 = { -1, 1, 0 };
float3 p2 = { 1, 1, 0 };
P.push_back(p0);
P.push_back(p1);
P.push_back(p2);
mesh->verts = P;
mesh->add_triangle(0, 1, 2, shaderId, true);
Any idea what could be wrong here?
haggi
More information about the Bf-cycles
mailing list