Professional Web Applications Themes

Reuse texture in proportion - Macromedia Director 3D

Hello, Can someone give me a clue on how to approach this, I've been trying and trying but I just can't seem to work it out. I have a texture bitmap of a woodgrain surface, which I want to use on different planes with different sizes, while keeping the same proportions (i.e. the woodgrain detail has to look the same size on each plane). The whole model is created dynamically using Lingo, so no importing from third party 3D software. In some cases the texture is smaller than the plane so it should be tiled, in other cases the texture ...

  1. #1

    Default Reuse texture in proportion

    Hello,

    Can someone give me a clue on how to approach this, I've been trying and
    trying but I just can't seem to work it out.

    I have a texture bitmap of a woodgrain surface, which I want to use on
    different planes with different sizes, while keeping the same proportions (i.e.
    the woodgrain detail has to look the same size on each plane). The whole model
    is created dynamically using Lingo, so no importing from third party 3D
    software.

    In some cases the texture is smaller than the plane so it should be tiled, in
    other cases the texture is (much) larger than the plane so only part of it
    should be seen on the plane. I am now leaning towards imaging Lingo but surely
    there must be an easier way?!

    Help is really really really appreciated!

    Wriker Guest

  2. #2

    Default Re: Reuse texture in proportion

    You should take a look at 'texturetransformlist' and change the 'scale'.

    This could be done like this (behavior used with empty 3D member):



    on beginsprite me

    pmember=sprite(me.spritenum).member
    pmember.resetworld()

    --## new modelresource of a box
    res01=pmember.newmodelresource("res01", #box, #front)

    --## new model from created from the modelresource
    model01=pmember.newmodel("model01", res01)

    --## new texture created from a imported image with the name "texture01"
    tex01=pmember.newtexture("tex01", #fromcastmember, member("texture01"))

    --## new shader that will be used on the box
    shader01=pmember.newshader("shader01", #standard)

    --## use the texture in the shader
    shader01.texturelist[1]=tex01

    --## scale the texture to what ever you like
    shader01.texturetransformlist[1].scale=vector(0.2, 0.2, 1)

    --## use the shader on all six faces of the box
    model01.shaderlist=shader01
    end

    hondo3000 Guest

  3. #3

    Default Re: Reuse texture in proportion

    Is there no simple way to just say "don't scale" the texture? So it tiles if the texture is smaller than the face and crops if it is larger?
    Wriker Guest

  4. #4

    Default Re: Reuse texture in proportion

    >Is there no simple way to just say "don't scale" the texture? So it tiles if
    the texture is 

    No, you have to write a script to do this. But this is not that complicated,
    you only need to calculate the texture-scale in conjunction to the models
    scale. Even if you do not use the 'scale' to change the size of the model, you
    can calculate the texture-scale depending on a given scaling factor.

    You can see how it works in the "on enterframe" part:

    property shader01, model01, n

    on beginsprite me

    pmember=sprite(me.spritenum).member
    pmember.resetworld()

    --## new modelresource of a plane
    res01=pmember.newmodelresource("res01", #plane, #both)
    res01.width=100
    res01.length=100


    --## new model from created from the modelresource
    model01=pmember.newmodel("model01", res01)

    --## new texture created from a imported image with the name "texture01"
    --tex01=pmember.newtexture("tex01", #fromcastmember, member("texture01"))

    --## new shader that will be used on the box
    shader01=pmember.newshader("shader01", #standard)

    --## use the shader on all six faces of the box
    model01.shaderlist=shader01

    end

    on enterframe me

    --## calculating a sinewave to scale the model and the texture
    n=n+2
    n= n mod 360

    --## ms=model scale (will be a value between 1 and -1 because it is a simple
    sine-wave)
    ms=(sin((n*pi)/180))+1.1

    --## scaling the model
    model01.transform.scale=vector(ms,ms,ms)


    --## ts=texture scale (it's 1/scale)
    ts=(1).float/ms

    --## scaling the texture
    shader01.texturetransformlist[1].scale=vector(ts, ts, ts)

    --## rotating the model just for fun
    model01.rotate(vector(0,0,0))

    end



    on exitframe me
    go the frame
    end

    hondo3000 Guest

Similar Threads

  1. minus sign proportion to + sign in bold
    By Weintraub in forum Macromedia Freehand
    Replies: 7
    Last Post: August 2nd, 03:39 PM
  2. Unable to resize object in proportion by holding shift key
    By JamesLJohnson@adobeforums.com in forum Adobe Illustrator Macintosh
    Replies: 6
    Last Post: June 14th, 02:55 PM
  3. how to reuse sub
    By perl@swanmail.com in forum PERL Beginners
    Replies: 9
    Last Post: October 8th, 01:44 PM
  4. Size and Proportion of Pictures
    By Wm. James Johnson in forum Adobe Photoshop Elements
    Replies: 6
    Last Post: August 23rd, 12:24 AM
  5. Hola! proportion problem
    By Odysseus in forum Macromedia Freehand
    Replies: 0
    Last Post: August 7th, 01:13 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