Professional Web Applications Themes

Using text as a texture issues - Macromedia Director 3D

Recently I was working on using text (members) as textures in my 3d member (users can enter their name ingame). It was working, but horribly slow and unpredictable. I didn't find any good solutions or tips on this, so I ended up coding a simple copypixels solution and this worked much faster and better than I expected. However, what is the correct way of setting up text(members) as textures without all the problems?...

  1. #1

    Default Using text as a texture issues

    Recently I was working on using text (members) as textures in my 3d member
    (users can enter their name ingame). It was working, but horribly slow and
    unpredictable. I didn't find any good solutions or tips on this, so I ended up
    coding a simple copypixels solution and this worked much faster and better than
    I expected.
    However, what is the correct way of setting up text(members) as textures
    without all the problems?

    PpHammer Guest

  2. #2

    Default Re: Using text as a texture issues

    Yes, taking the image of a text member is probably best. Here's an example
    script I clipped from my projects (took out some pieces so check it if you try
    to use it). The handler formats the passed string and returns a custom
    "nametag" texture. You'd format the text size, etc to however it best fit what
    you're doing:


    -- some property definitions here...
    pMemForNametagName = member("NametagFormatText") -- text member used to format
    the name string.
    pMemForNametagBmp = member("NametagBackingBmp") -- bitmap member used for
    nametag ** width and height must be power of 2 **
    pUniqueNametagCt = 0 -- nametag textures must have unique names. use this
    counter.

    on createNametagTexture me, vName
    -- test the length of the name string. size the text according to how many
    chars in the string
    len = vName.chars.count
    if (len <= 6) then
    vTextSize = 24
    else
    vTextSize = 14
    end if
    case (len) of
    7: vTextSize = 20
    8: vTextSize = 18
    9: vTextSize = 16
    10, 11, 12: vTextSize = 14
    end case
    -- put the name string into the text member, size it, then take its image
    pMemForNametagName.fontSize = vTextSize
    pMemForNametagName.text = vName.char[1..12] -- max _ chars in name
    vImgName = pMemForNametagName.image.duplicate()
    -- matte the name image onto the middle of a preformatted nametag image
    vImgNametag = pMemForNametagBmp.image.duplicate()
    -- determine the destination rect used for copypixels
    a = (vImgNametag.width - vImgName.width) / 2 -- left
    b = (vImgNametag.height - vImgName.height) / 2 -- top
    c = vImgNametag.width - a -- right
    d = vImgNametag.height - b -- bottom
    vDestRect = rect(a, b, c, d)
    vImgNametag.copypixels(vImgName, vDestRect, vImgName.rect)
    pUniqueNametagCt = pUniqueNametagCt + 1
    vTextureName = "Nametag_" & pMemForNametagName.text & pUniqueNametagCt
    t = gScene.newTexture(vTextureName, #fromImageObject, vImgNametag)
    t.renderFormat = #rgba8880 --
    t.quality = #high --
    t.nearfiltering = TRUE

    return t
    end createNametag

    tedalde2 Guest

  3. #3

    Default Re: Using text as a texture issues

    Hi tedalde2,

    Thanks for your reply. Your script is surely more advanced then mine currently
    ;)
    The current solution i have now works perfectly. So I like to wait with
    implementing an other solution. However I definetely will keep this for future
    reference! I get it from your reply you don't have any good experience with
    getting a texture from a textmember directly either. How did you test and try
    this initially?
    Anybody else with their experiences?


    PpHammer Guest

  4. #4

    Default Re: Using text as a texture issues

    That's the only way to get text members into textures; simply take the image of
    the text member and create a texture with it. Perhaps #fromCastMember works
    with text members, but I haven't tried it. My handler is just longer due to
    some formatting and creating the "nametag" matte.

    I'd test the bitmap/image results by putting my results into test bitmap
    members: member("someBmpMem").image = vImgNametag.duplicate() etc... To test
    applying the texture to a shaderlist and model, I'd just look at the model and
    use 3DPI to adjust the texture. 3DPI is a must-have for creating advanced 3D
    scenes.

    tedalde2 Guest

Similar Threads

  1. PDF to Text conversion issues
    By Jay_Shakir@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 26
    Last Post: October 16th, 01:03 PM
  2. Text Wrapping Issues
    By jhgd143@adobeforums.com in forum Adobe Indesign Macintosh
    Replies: 5
    Last Post: October 4th, 01:58 PM
  3. Text Issues
    By EmmaLawrence in forum Macromedia Dynamic HTML
    Replies: 10
    Last Post: January 23rd, 07:09 PM
  4. Unicode Text Issues with ASP/ADO
    By Oleg in forum ASP Database
    Replies: 2
    Last Post: June 3rd, 10:46 PM
  5. Alias text issues in 2004 Pro
    By domconlon webforumsuser@macromedia.com in forum Macromedia Flash Sitedesign
    Replies: 0
    Last Post: January 27th, 11:05 AM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139