How to warp a plane to fit 3D model

Software: Away3D 4.x

dubletar, Member
Posted: 10 August 2013 06:36 PM   Total Posts: 73

Hi,

Im making a mini game and I had a question, ‘how would I warp a plane to fit the shape of a 3d mesh’?

The game has a map with a texture for land.  Im trying to fit a plane over areas to represent zones of control, which would be highlighted when the player hovers over it. Is there anyway to warp a plane to fit a 3D object?

   

dubletar, Member
Posted: 13 August 2013 06:37 PM   Total Posts: 73   [ # 1 ]

Can anyone help with this?

 

   

Avatar
Fabrice Closier, Administrator
Posted: 13 August 2013 07:38 PM   Total Posts: 1265   [ # 2 ]

There are many ways to do this. but you need be more precise. Send some sketches to show the wanted result.

for instance building a plane with same amount of indices as the destination mesh, and interpolate the values is one way to proceed.
Ignoring details, for instance like a cloth falling onto an object would require other approach like using convex hulls, altering the plane with mesh normals,
you could project the plane vertices onto the mesh and let it act as a decal etc…

 

   

dubletar, Member
Posted: 11 March 2014 03:16 AM   Total Posts: 73   [ # 3 ]

Thanks for the response Fabrice.

Here is the image:
http://xeipstudios.com/images/warp_land.png

Basically I have an extrude. What I’m trying to figure out is how I can have a plane, filled with hexagons, warp to fit the terrain exactly. The hexagons will later highlight on mouseover.

Does the image above help better?

Can anyone help with this?

 

   

dubletar, Member
Posted: 12 March 2014 02:46 AM   Total Posts: 73   [ # 4 ]

Just to clarify, I’m trying to get the plane to warp to the shape of the terrain. This is a new type of manipulation for me.

Can anyone help?

 

   

dubletar, Member
Posted: 13 March 2014 04:21 AM   Total Posts: 73   [ # 5 ]

bump

anyone?

 

   

dubletar, Member
Posted: 13 March 2014 04:33 AM   Total Posts: 73   [ # 6 ]

Actually, if someone can point me in the right direction on copying vertices from the 3D object that would be helpful?

 

   

dubletar, Member
Posted: 13 March 2014 05:16 AM   Total Posts: 73   [ # 7 ]

Ok, so I am going one step at a time… did a lot of digging.

The goal is to make a plane that is shaped exactly as a 3d mesh (extrude) I have existing.

terrain == the extrude.

What I am doing is:
1. Creating a plane.
2. Trying to change the geometry/vertices(?) to fit the 3d mesh (extrude).

public function CreatePlane():void
  {
   
var v:Vector.<Number> = SubGeometry(terrain.geometry.subGeometries[0]).vertexData;
   
   if (
leplane == false)
   
{
    
// Create the plane if it doesnt exist
    
var bmd:BitmapData = new BitmapData(terrain.widthterrain.widthtrue0x000000);
    
//bmd.draw(text, null, null, null, null, true);
    
var bmt:BitmapTexture = new BitmapTexture(bmd);
     
    var 
textMat:TextureMaterial = new TextureMaterial(bmt);
    
textMat.bothSides false;
    
    var 
planeMesh:PlaneGeometry = new PlaneGeometry(terrain.widthterrain.width);
    
planeMesh.doubleSided false;
    
    
leplane = new Mesh(planeMeshtextMat);
    
SubGeometry(leplane.geometry.subGeometries[0].updateVertexData(v));
    
addChild(leplane);
   
}
   
else
   
{
    
// update the plane
    //SubGeometry(leplane.geometry.subGeometries[0].updateVertexData(v));
   
}
   
   
  } 

However, I am experiencing an error from this code:
“exception, information=RangeError: Error #3669: Bad input size.”

SubGeometry(leplane.geometry.subGeometries[0].updateVertexData(v)); 

Can anyone assist with this? I would greatly appreciate it.

 

   

dubletar, Member
Posted: 13 March 2014 05:55 AM   Total Posts: 73   [ # 8 ]

Scratch that, I was able to get passed the error.

However, I have a new problem.

I copied the vertices from the extrude which was successful.

However, I want the plane to never go below “0” on the Y axis. So, it can go up, but never lower than 0 on the Y axis.

Is this possible? How would I check for that?

 

   

dubletar, Member
Posted: 13 March 2014 06:37 AM   Total Posts: 73   [ # 9 ]

Wow!

I solved it!

I looped through the vertex data, seeing that it was organized in (x,y,z). I checked the y coordinate and set it to above zero if it was less than zero.

It worked!

This is my first time dealing with vertices and uvdata! This is awesome!

 

   
   
‹‹ VideoTexture Mobile

X

Away3D Forum

Member Login

Username

Password

Remember_me



X