Making a plane with two different tiles

Software: Away3D 4.x

elemmiki, Newbie
Posted: 01 September 2013 01:35 PM   Total Posts: 10

Hello everyone!
I’m trying to make a plane that accepts two different bitmaps and tiles them in a checkerboard style. So, one bitmap would replace the white spots on the board and the other bitmap would replace the black spots.
Is it possible? And could you help me out somehow, cause I have no idea how to start this.
I thought about making a model in Blender and then importing it in Away3D and then texture it, but then I realized that it’s too hard for me to do it since I’m a newbie at this, and I’d like to do everything in AS3 if possible.
Thank you!

   

Avatar
SharpEdge, Member
Posted: 02 September 2013 09:55 AM   Total Posts: 94   [ # 1 ]

I would use a simple texture made of 4 quadrants as the attachment, then enable tiling on the material and you’ve done.

 

   

elemmiki, Newbie
Posted: 02 September 2013 12:17 PM   Total Posts: 10   [ # 2 ]

Thank you for the reply!
I want to be able to change the bitmaps at runtime. If I only make them into one texture and tile it then i won’t be able to change them separately at runtime.
Like so: I click on a plane, a popup shows asking me to choose two bitmaps from a list, i select some random two and it tiles them both in the checkerboard style.

I could make a combination of all the tiles together and then use a variable to determine which combination was chosen and then use that texture, but that seems like a lot of work when you consider having dozens of different bitmaps.
Thank you for your time!

 

   

Avatar
SharpEdge, Member
Posted: 02 September 2013 12:32 PM   Total Posts: 94   [ # 3 ]

oh ok i got it now, so the solution could be generating the bitmap texture each time:

The user select 2 images
Create a new Bitmap (I.E. 1024x1024)
Draw onto it the 2 images like the pattern above
Assign the Bitmap to the material (always with tiling)

If you don’t know how to do it, i’ll write that for you when i go home from work.

 

   

Avatar
dottob, Jr. Member
Posted: 03 September 2013 10:47 AM   Total Posts: 49   [ # 4 ]

Maybe two ways:

1.More planes together to be a checker,

planeA,planeB,planeA…
planeB,planeA,planeB…
palneA,planeB,planeA…

so when click one of them,do your function

2.Do something with a bitmap(your material) use mask,when the plane be clicked,calculate uvs,then do your function

I like 1

 

   

Avatar
SharpEdge, Member
Posted: 03 September 2013 10:51 AM   Total Posts: 94   [ # 5 ]
dottob - 03 September 2013 10:47 AM

Maybe two ways:

1.More planes together to be a checker,

planeA,planeB,planeA…
planeB,planeA,planeB…
palneA,planeB,planeA…

so when click one of them,do your function

2.Do something with a bitmap(your material) use mask,when the plane be clicked,calculate uvs,then do your function

I like 1

N.B. The solution 1 is not efficient because you would have a high number of objects

 

   

Avatar
dottob, Jr. Member
Posted: 03 September 2013 12:37 PM   Total Posts: 49   [ # 6 ]
SharpEdge - 03 September 2013 10:51 AM
dottob - 03 September 2013 10:47 AM

Maybe two ways:

1.More planes together to be a checker,

planeA,planeB,planeA…
planeB,planeA,planeB…
palneA,planeB,planeA…

so when click one of them,do your function

2.Do something with a bitmap(your material) use mask,when the plane be clicked,calculate uvs,then do your function

I like 1

N.B. The solution 1 is not efficient because you would have a high number of objects

With mesh’s clone and material’s clone, i think away3d can do that well.If go far away enough,weld mesh,reused the parts of the mesh,will do it better.

 

   

Avatar
SharpEdge, Member
Posted: 03 September 2013 12:41 PM   Total Posts: 94   [ # 7 ]

i think that’s the solution if he need to differentiate between tiles, but if he don’t needs to know what tile has been clicked it’s better to use a dynamically generated texture.

 

   

Avatar
dottob, Jr. Member
Posted: 03 September 2013 12:52 PM   Total Posts: 49   [ # 8 ]
SharpEdge - 03 September 2013 12:41 PM

i think that’s the solution if he need to differentiate between tiles, but if he don’t needs to know what tile has been clicked it’s better to use a dynamically generated texture.

As your say.^_^

 

   

elemmiki, Newbie
Posted: 06 September 2013 02:27 PM   Total Posts: 10   [ # 9 ]

I’m actually having problems making the popup window, it’s a lot harder than I thought it would be.
Anyways, SharpEdge is right, I don’t need to know which tile has been clicked, I just need to be able to click on the plane and a popup window should ask to select two bitmaps and then tile them across that one plane.
Can a bitmap be tiled with normal maps also?

 

   

Avatar
dottob, Jr. Member
Posted: 07 September 2013 01:51 PM   Total Posts: 49   [ # 10 ]
[Embed(source="assets/a.jpg")]
  
private var bitA:Class;
  
[Embed(source="assets/b.jpg")]
  
private var bitB:Class;
...
var 
sA:Sprite=new Sprite()
   var 
sB:Sprite=new Sprite()
   var 
sC:Sprite=new Sprite()
   var 
sD:Sprite=new Sprite()
   
sA.addChild(new bitA())
   
sB.addChild(new bitB())
   
sC.addChild(new bitB())
   
sD.addChild(new bitA())
   var 
ss:Sprite=new Sprite()
   
ss.addChild(sA)
   
ss.addChild(sB)
   
ss.addChild(sC)
   
ss.addChild(sD)
   
   
sB.x=sD.x=128
   sC
.y=sD.y=128
   
   addChild
(ss)
   
   var 
bmp:BitmapData=new BitmapData(ss.width,ss.height,false,0)
   
bmp.draw(ss)
   
_plane = new Mesh(new PlaneGeometry(700700), new TextureMaterial(Cast.bitmapTexture(bmp)));
... 

I post this,I think if someone posted a way(perhaps it’s not so good).Maybe you can try yourself to find more better way to do what you want.
Don’t be waiting for an answer,open you mind,just do it *^_^*

 

   

Avatar
SharpEdge, Member
Posted: 09 September 2013 10:25 AM   Total Posts: 94   [ # 11 ]

Other way, assuming your images are of correct size (in this case 512x512), otherwise you should also apply a scaling.

NOT TESTED, this is jut to give an idea of what i mean:

public static const SIZE int 1024;
public var 
img1 Bitmap;
public var 
img2 Bitmap;

var 
bmp:BitmapData=new BitmapData(SIZE,SIZE,false,0);
bmp.draw(img1);
bmp.draw(img2, new Matrix(1,0,0,1SIZE/20));
bmp.draw(img1, new Matrix(1,0,0,1SIZE/2SIZE/2));
bmp.draw(img2, new Matrix(1,0,0,10SIZE/2)); 

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X