I need a help :-)

Started by DrUiD, June 04, 2005, 10:32:18 PM

Previous topic - Next topic

DrUiD

Hey!!

I need help!!! I wrote swing application, when jPCT is used for rendering scene to canvas component. But I get this strange error message:


[ Sat Jun 04 22:30:16 CEST 2005 ] - ERROR: Can't do portal rendering without a main world being defined!
[ Sat Jun 04 22:30:16 CEST 2005 ] - ERROR: Passed an Object3D to getCurrentSector that isn't defined as main!


--

DrUiD

This is my class. What's wrong ??



package src;

// *** Imports ***
import java.io.*;

import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;

import com.threed.jpct.*;
import com.threed.jpct.util.*;


// *** Class definition ***
public class ModelView extends Canvas
{
// *** Methods ***

// constructor
public ModelView(  int x, int y, int w, int h )
{
// copy values
this.x = x;
this.y = y;
this.w = w;
this.h = h;

// Set max visible polygons
Config.maxPolysVisible = 10000;
   
// Initialize the World instance and get the TextureManager (a singleton)
theWorld = new World();
texMan = TextureManager.getInstance();

   // Setup the lighting. We are not using overbright lighting because the OpenGL
   // renderer can't do it, but we are using RGB-scaling. Some hardware/drivers
   // for OpenGL don't support this (but most do)
Config.fadeoutLight = false;
theWorld.getLights().setOverbrightLighting( Lights.OVERBRIGHT_LIGHTING_DISABLED );
theWorld.getLights().setRGBScale( Lights.RGB_SCALE_2X );
theWorld.setAmbientLight( 25, 30, 30 );

// Place the light sources
theWorld.addLight( new SimpleVector( 0, -150, 0), 25, 22, 19 );
theWorld.addLight( new SimpleVector( -1000, -150, 1000), 22, 5, 4 );
//theWorld.addLight( new SimpleVector( 1000, -150, -1000), 4, 2, 22 );

// Fog
theWorld.setFogging( World.FOGGING_ENABLED );
theWorld.setFogParameters( 1200, 0, 0, 0 );
Config.farPlane = 1200;

// Textures
   Texture rocks = new Texture( "rc/rocks.jpg" );
   texMan.addTexture( "rocks", rocks );
   
   // Load terrain
   Object3D[] objs = Loader.load3DS( "rc/plant.3ds", 10 );
   if ( objs.length > 0 )
   {
    terrain = objs[0];
    terrain.setTexture( "rocks" );
   }

   // add them to world
   terrain.enableLazyTransformations();
   theWorld.addObject( terrain );
   
     /**
      * The terrain isn't located where we want it to, so we take
      * care of this here:
      */
     SimpleVector pos=terrain.getCenter();
     pos.scalarMul(-1f);
     terrain.translate(pos);
     terrain.rotateX((float)-Math.PI/2f);
     terrain.translateMesh();
     terrain.rotateMesh();
     terrain.setTranslationMatrix(new Matrix());
     terrain.setRotationMatrix(new Matrix());


   // The game entities are building themselves, so we only have to build
   // the terrain here
   terrain.build();
   theWorld.buildAllObjects();
   
   // octree
   OcTree oc=new OcTree( terrain, 50, OcTree.MODE_OPTIMIZED );
   terrain.setOcTree( oc );
   
   // Place the camera at the starting position.
   camera=theWorld.getCamera();
   camera.setPosition(0,-2500,-1500);
   camera.lookAt( new SimpleVector( 0, 0, 0) );
   
   // additional setup
   Config.tuneForIndoor();
   
   World.setDefaultThread( Thread.currentThread() );
   
   // setup frame buffer
   buffer = new FrameBuffer( w, h, FrameBuffer.SAMPLINGMODE_NORMAL );
   buffer.enableRenderer( IRenderer.RENDERER_SOFTWARE );
   buffer.setBoundingBoxMode( FrameBuffer.BOUNDINGBOX_NOT_USED );
   buffer.optimizeBufferAccess();
   
reshape( x, y, w, h );
}

// Paint actual
public void paint( Graphics g )
{
       buffer.clear();
       theWorld.renderScene( buffer );
       theWorld.draw( buffer );
       buffer.update();
       buffer.display( g, x, y );
}

// *** Attibutes ***
private int x, y, w, h;
private FrameBuffer buffer = null;
private World theWorld = null;
private TextureManager texMan = null;
private Camera camera = null;

private Object3D terrain = null;
private Texture numbers=null;
}



Thx 4 help!!

DrUiD

I solved this problem, by adding this line in constructor:


theWorld.setMainObjectID( terrain.getID() );


--
DrUiD of HaCra Team
Mysterious World Project
Nautilus.org

EgonOlsen

While that may work, it's actually a workaround and i don't recommend it. It will bite you sooner or later. Your actual problem is, that you are calling Config.tuneForIndoor(), which itself enables portal rendering. But you are not using portal rendering and i don't recommend on doing so, so the best solution is to turn it off after calling tuneFor... To do this, simply set Config.doPortalHsr to false. You can then remove the call to setMainObjectId() and it should work fine.