Results 1 to 1 of 1

Thread: The Way to Set alpha vertex from 0~255

  1. #1
    Lesser Wizard
    Join Date
    Feb 2013
    Posts
    142

    Default The Way to Set alpha vertex from 0~255

    //follow code test good in b3d obj 3ds
    //demo here
    https://plus.google.com/photos/10618...41018774360364

    ////////////////////////////////////////////////////////////////
    IAnimatedMesh* mesh;
    IAnimatedMeshSceneNode* node;
    .
    .
    .
    mesh = smgr->getMesh( memfile );
    node = smgr->addAnimatedMeshSceneNode( mesh );
    node->setMaterialFlag(EMF_LIGHTING, true); // use light is ok~~~
    node->setMaterialFlag(EMF_NORMALIZE_NORMALS, true);

    u32 MyAlpha = 150; //0~255
    u32 MaterialCount = node->getMaterialCount();
    for(u32 i=0; i<MaterialCount; i++)
    {
    video::SMaterial& tex_mat = node->getMaterial(i);
    tex_mat.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
    tex_mat.AmbientColor.setAlpha(MyAlpha);
    tex_mat.DiffuseColor.setAlpha(MyAlpha);
    tex_mat.SpecularColor.setAlpha(MyAlpha);
    tex_mat.EmissiveColor.setAlpha(MyAlpha);
    }


    //this can do or not by ur choice
    for(u32 i=0; i<mesh->getMeshBufferCount(); i++)
    {
    scene::IMeshBuffer* buffer = mesh->getMeshBuffer(i);
    video::S3DVertex* vertex = (video::S3DVertex*)buffer->getVertices();
    for(u32 j=0; j<buffer->getVertexCount(); j++)
    {
    vertex[j].Color.setAlpha(MyAlpha);
    }
    }
    Last edited by feelthat; 02-13-2015 at 03:23 AM.

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •