0.6 Adding another sprite

By Jim Sager, james_sager3@yahoo.com.

Here is the standard code for adding a sprite:

iMeshWrapper* sprite = engine->CreateMeshWrapper (imeshfact, "MySprite", room, csVector3 (-3, 5, 3));

To create a duplicate sprite, copy the above code. Here is the rest of the code from Simple2

csMatrix3 m; m.Identity (); m *= 2.;
sprite->GetMovable ()->SetTransform (m);
sprite->GetMovable ()->UpdateMove ();
iSprite3DState* spstate = SCF_QUERY_INTERFACE (sprite->GetMeshObject (), iSprite3DState);
spstate->SetAction ("default");
imeshfact->DecRef ();
spstate->DecRef ();

// The following two calls are not needed since CS_ZBUF_USE and
// Object render priority are the default but they show how you
// can do this.
sprite->SetZBufMode (CS_ZBUF_USE);
sprite->SetRenderPriority (engine->GetObjectRenderPriority ());

Take the copied code, and paste it here, right below the SetRenderPriority (). The name sprite should be changed to sprite2, since this is a new sprite, and move this new sprite a bit by changing the 5 in its csVector3 to a 6, so that it isn't obscured by the other. Here is what your code should look like:

iMeshWrapper* sprite2 = engine->CreateMeshWrapper (imeshfact, "MySprite2", room, csVector3 (-3, 6, 3));

NOW compile it :) You might get some compiler warnings; who cares? You should have a 2nd cube floating above the first. This new cube is size 1, and has no textures on it. Want to make a cube identical to the 2nd? Just copy that code again, and rename it sprite3 )(Note that this sprite has been moved):

iMeshWrapper* sprite3 = engine->CreateMeshWrapper (imeshfact, "MySprite3", room, csVector3 (-3, 4, 3));

Now you'll have 3 blocks :) Two black and one textured.