Author Topic: Glass Effect  (Read 4161 times)

Offline san14

  • int
  • **
  • Posts: 60
    • View Profile
Glass Effect
« on: July 16, 2007, 08:38:26 am »
HI
   
    I have fps type example. Which contains some objects of glass. I have given transparency to those object in MAX. I want it to appear as glass when I load it to jpct.  How do i handle it. Can any one help me for same. or any eacmples.

I tried to put glass texture to those object's, but did not serve the purpose.

With Regards
San14
San14

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Glass Effect
« Reply #1 on: July 16, 2007, 05:25:16 pm »
You somehow have to identity transparent objects in the Object3D[]-array that the loader returns (for example based on the object's name or its texture), set it to transparent in jPCT (and don't merge it with the rest in case you are doing so, because transparency is object based) and you are done.

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Glass Effect
« Reply #2 on: July 16, 2007, 07:53:41 pm »
you cant have refraction efect on jpct! You can apply transparency, texture or even a mini reflection efect.

for just giving the object a transparency efect you have to get the glass objects and apply to them the setTransparency value, but dont merge them with other non transparent objects.
Nada por ahora

Offline san14

  • int
  • **
  • Posts: 60
    • View Profile
Re: Glass Effect
« Reply #3 on: July 17, 2007, 01:49:14 pm »
 
 Hi
    Do i need to load glass object separately.
    My object name is Box62 But it is one of The part of entire room in max file
    I tried in this way.
 
 
   Object3D[] levelParts = Loader.load3DS("3ds" + File.separator + "Full_final_Light.3DS", 0.02f);   
   
    level = new Object3D(0);

    for (int i = 0; i < levelParts.length; i++) {
      Object3D part = levelParts [ i ];
 
      part.setCenter(SimpleVector.ORIGIN);
      part.rotateX( (float) - Math.PI / 2);
      part.rotateMesh();
      part.setRotationMatrix(new Matrix());
     
      level = Object3D.mergeObjects(level, part);
     
      Object3D part2 = levelParts[582]
      part2.setTransparency(155);
     
    }
With Regards
San14
« Last Edit: July 17, 2007, 04:05:08 pm by san14 »
San14

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Glass Effect
« Reply #4 on: July 17, 2007, 05:35:27 pm »
Code: [Select]

Object3D[] levelParts = Loader.load3DS("3ds" + File.separator + "Full_final_Light.3DS", 0.02f);   
   
    level = new Object3D(0);
    glass = new Object3D(0);

    for (int i = 0; i < levelParts.length; i++) {
      Object3D part = levelParts [ i ];
 
      part.setCenter(SimpleVector.ORIGIN);
      part.rotateX( (float) - Math.PI / 2);
      part.rotateMesh();
      part.setRotationMatrix(new Matrix());
     
      if (!part.getName ().startswith ("Box62"))
           level = Object3D.mergeObjects(level, part);
     else
           glass = Object3D.mergeObjects(glass, part);
 
    }
     glass.setTransparency (1);

Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Glass Effect
« Reply #5 on: July 17, 2007, 08:03:54 pm »
And don't do something like part2.setTransparency(155); as it won't be transparent anymore. 0 is the lowest possible value (i.e. the most transparent...how transparent can be tweaked in Config). 155 is...well, not transparent at all.

Offline san14

  • int
  • **
  • Posts: 60
    • View Profile
Re: Glass Effect
« Reply #6 on: July 18, 2007, 10:43:56 am »
HI

    Thanks A lot EgonOlsen and Melssj5 It worked.  :D
    Can I Increase Reflection on Those glass Object


With Regards

San14
« Last Edit: July 18, 2007, 01:29:05 pm by san14 »
San14

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Glass Effect
« Reply #7 on: July 18, 2007, 08:42:14 pm »
mmm, put it an enviroment map! but it will result more like plastic than like a window. Have a look at the car.zip file on the download section, there is demostrated how to load something like a reflection over an object3D! this is avaible only on the beta release of jpct becausse Egon made some changes. There is thread on the support section called "Reflection effect"
Nada por ahora

Offline san14

  • int
  • **
  • Posts: 60
    • View Profile
Re: Glass Effect
« Reply #8 on: July 19, 2007, 09:15:25 am »
HI

    Thanks Melssj5 It worked It gave some reflection effecte to glass.
    Can we have some thing like Mirror effect. Where user can see him self. In the Mirror ?
     

      Object3D[] levelParts = Loader.load3DS("3ds" + File.separator + "Full_final_Light.3DS", 0.02f);     
       
      level = new Object3D(0);
      glass = new Object3D(0);
   
      for (int i = 0; i < levelParts.length; i++) {
         Object3D part = levelParts;
     
         part.setCenter(SimpleVector.ORIGIN);
         part.rotateX( (float) - Math.PI / 2);
         part.rotateMesh();
         part.setRotationMatrix(new Matrix());
     
      if (!part.getName ().startsWith("Glass"))
          level = Object3D.mergeObjects(level, part);
           
      else {
          glass = Object3D.mergeObjects(glass, part);
            
         }
      }
       
       glass.setTransparency (1);

   
       glass.createTriangleStrips(2);
       glass.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
       glass.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
   
       glass.setTexture("envmap");
       glass.setEnvmapped(Object3D.ENVMAP_ENABLED);
       glass.setEnvmapMode(Object3D.ENVMAP_WORLDSPACE);
     
       theWorld.addObject(glass);
     

     


With Regards
San14
« Last Edit: July 19, 2007, 09:24:54 am by san14 »
San14

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Glass Effect
« Reply #9 on: July 19, 2007, 09:25:53 am »
Not really. You can play around with render to texture effects and render the scene twice, but i consider this to be overkill in this case. It's also quite complicated to make it look good/real.