Hi Rayan,
I think you should extend your vehicle class from BranchGroup class.
I guess that this class will be abstract and include parameters like position
and others that are related to your types of vehicle in general.
You can then extend that Vehicle class in Car, Truck or whatever you want.
Each vehicle created can then be added to a BranchGroup name VehiclesGroup
for example; this will help you to track your objects.

This is an illustration I have implemented with general avatars
that can then be bipedes, multipedes or something else.


public abstract class Avatar3D extends BranchGroup
{

   ...............
    protected TransformGroup baseTransformGroup=null;
    protected Transform3D baseTransformation = null;
    ..............

    public Avatar3D(int type, int simID)
    {

        String modelName;

        setType(type);
        simulationId=simID;

        this.setCapability(Group.ALLOW_CHILDREN_READ);
        this.setCapability(Group.ALLOW_CHILDREN_WRITE);
        this.setCapability(Group.ALLOW_CHILDREN_EXTEND);

        baseTransformGroup= new TransformGroup();
        baseTransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
        baseTransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

        baseTransformation = new Transform3D();
        baseTransformGroup.setTransform(baseTransformation);

        this.addChild(baseTransformGroup);

        .........................

        }

       public Avatar3D(int type, int simID, float x, float y, float z, float r)
      {
          this(type,simID);

          // translation
          baseTransformation.setTranslation(new Vector3f(x,y,z));

          // rotation around Y axis
          baseTransformation.setRotation(new AxisAngle4f(0,1,0,r));

          baseTransformGroup.setTransform(baseTransformation);
        }

       public void setPosition(float px, float py, float pz)
      {

            baseTransformation.x = px;
            baseTransformation.y = py;
            baseTransformation.z = pz;

            baseTransformGroup.setTransform(baseTransformation);
       }

      public void setRotation(float rt)
      {
          baseTransformation.rotY(rt);
          baseTransformGroup.setTransform(baseTransformation);
      }
        ......................
    }


    public class Bipede extends Avatar3D
    {

    .................

    public Bipede(String name,
                          int type,
                          int simID,
                          float COGHeight,
                          float headHeight,
                          float shoulderHeight,
                          float shoulderWidth,
                          float feetWidth,
                          float lowerArmLenght,
                          float upperArmLenght,
                          float lowerLegLenght,
                          float upperLegLenght )

    {
        super(type, simID);

        ......................
    }

    ........................
  }

    Hope this answers your question.

   Regards,
   Pascal.

---------------------------------------------------------------------------------

Pascal Debarge / Computer Graphics Engineer / Animation Sience
tel: (408) 543 1615
e-mail: [EMAIL PROTECTED]



Rayan Jreije wrote:

> Maybe i'll have to clarify one point.
> I want to create my own Primitive "Classes"  and not "Objects".
> I want to create  a new class let's say called "Vehicule" which is a
> specific group of shapes, whose size and positions are parametrized.
>
> What's the best to do?
> Should vehicule extend Group?
> Should it Extend Transform group?
> or Should It extend Shape3d?
> (Note that Vehicule is a complex shape and thus can't be just one simple
> Quad Array or Triangular array)
>
> I hope this illustration makes my question clearer.
> Cheers,
>
> -----Original Message-----
> From: Ronnachai Chinowutthichai [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 19, 1999 6:53 AM
> To: Rayan Jreije
> Cc: Java 3D Interest Group (E-mail)
> Subject: Re: [java3d] Creating my Own Primitives
>
> I'm not very good at explaining this but I'll give it a shot.
> Firstly, Primitive class is a com.sun extension, it is not part of Java3D
> core api. You can create your own primitives by creating your own Shape3D
> object and group them together. (ie. a cylinder is made up of top, bottom
> and the side). To create a Shape3D object you will have to use one of the
> GoemetryArray classes to specify all vertices and other info. So really,
> you can create any type of primitives you want.
>
> About the TransformGroup and Group, I'm not sure why but it's probably a
> cleaner implementation for such utility class.
>
> hope that helps,
> rOnn c.
>
> On Thu, 18 Feb 1999, Rayan Jreije wrote:
>
> > Hi All-
> > I am trying to create my own primitives to be used in java 3D.
> > I looked at the primitives provided in the utils package,
> > And they don't have enough functionality. I feel they are just there for
> > compliance reasons and ease of use for people who are used to VRML.
> > They are not extendable because they were coded in a way
> > just to fit the needs of the five possible primitives needed (Box,
> Cylinder,
> > sphere...)
> >
> > Can anybody tell me why primitive extends Group and not Transform group?
> > If anyway it will be used in  a scenegraph with a Transform Group, why not
> > letting it extend transform Group immediately? is it because of storage
> > optimisation reasons or there are other concerns here?
> >
> > Does the primitive package now ship with java 3D or it is justa n addition
> > that is not an essential  part of Java3D?
> > Thanks for replying..
> > Cheers,
> >
> >
> > Rayan Jreije (Ms Eng)
> > Consolidated Contractors Int'l Company
> > Kiffisias 62B, Amaroussion 15110
> > Athens, Greece
> > Tel +30-16 182 132
> > Fax +30-16 182 199
> > Cell +30-932-415158
> >
> >
> > =====================================================================
> > To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
> > Java 3D Home Page: http://java.sun.com/products/java-media/3D/
> >
> =====================================================================
> To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
> Java 3D Home Page: http://java.sun.com/products/java-media/3D/

=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/

Reply via email to