Why do we need a mesh to render a geometry

Software: Away3D 4.x

Avatar
ganesh, Member
Posted: 09 September 2012 12:23 PM   Total Posts: 54

This is the simplest code to add a geometry into a scene and render it.
This is the modifed version of Basic_view tutorial from away gold src lesson.

package
{

import flash.display.Sprite;
import flash.events.Event;

import away3d.containers.*;
import away3d.primitives.*;
import away3d.entities.*;
import away3d.materials.*;

public class SimpleGeometry extends Sprite
{
  private var _view:View3D;
  private var _sphere:SphereGeometry;
  private var _mesh:Mesh;

  public function SimpleGeometry()
  {

  _view = new View3D();
  _mesh = new Mesh(new SphereGeometry(100), new ColorMaterial(0x6666FF,1))
 
  _view.scene.addChild(_mesh);
  addChild(_view);
 
  addEventListener(Event.ENTER_FRAME, _onEnterFrame);
  }


  private function _onEnterFrame(e:Event):void
  {

  _view.render();
  }


}

}

—————————————————-
When I add mesh into the scene and render it, it works. But when I add geometry directly to the scene and render it , it throws error. Do I need mesh always to render a scene, cant I add geometry directly?

_view.scene.addChild(_mesh);  // works
_view.scene.addChild(_sphere);// does not work

 

 

   

Avatar
80prozent, Sr. Member
Posted: 09 September 2012 03:47 PM   Total Posts: 430   [ # 1 ]

hi

you allways need a mesh to render a geometry.

a mesh is whats being processed on rendertime (as it extends Entity) and it defines the material of the Geometry.

this way you can have one Geometry-Object, but several meshobjects with different materials applied, all referencing the same Geometry-Object.

a mesh should have one submesh for each of the subgeometries inside of the meshes Geometry object. this way you can apply different materials to the submeshes and theire corresponding subgeometries.

hope that makses sense

 Signature 

sorry…i hope my actionscript is better than my english…

   

Avatar
ganesh, Member
Posted: 09 September 2012 06:46 PM   Total Posts: 54   [ # 2 ]

Thanks, nicely understood.
Now one Q. coming to my mind, I understood that we can apply image color or any material in a geometry, but I also know that these geometry actually consists of a wireframe, so can we filter materials in such a way that it lookes like geometry structure is overlying the material(image) or the image is residing inside the geometry cage? just asking.

   

Avatar
80prozent, Sr. Member
Posted: 09 September 2012 07:39 PM   Total Posts: 430   [ # 3 ]

i am not shure if i understand your question.

you can imagine the meshdata as wieframes, for your own understanding, but the meshdata itself is nohing more than just some lists of Numbers or inds, that tell the gpu where and how to render a face.

a shader programm is whats telling the gpu how to use the given data to render the face.

a wireframe (segmentSet) is a special kind of mesh, that uses a shader progamm thats drawing lines between the given vertexpoints. these drawn lines again are nothing else than two triangles, working together as one line (2 triangles = 1 rectangle).
as far as i know, he gpu can only render triangles, no points or lines.

to display the wireframe of a mesh, you could create a segmentset containing a linesegment for each line you want to draw, or you could use the WireframeMapGenerator.as wich will create a bitmap showing the uv-wireframes of your mesh and can be used as texture on the mesh.
the first method would need much more memory than the secound, but results in nicer quality, since with the secound method your stuck with the quality defined by the bitmaps dimensions.

again
hope that makes sense

 Signature 

sorry…i hope my actionscript is better than my english…

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X