Skip to main content

Cell importing cells

2 replies [Last post]
mcgy0072
Offline
Joined: 2008-11-03

Hi, all.
I'm working on creating forest cell which imports terrain cell and tree cell.
I made a terrain cell and tree cell.
Forest cell is suppose to call a terrain cell and some tree cells into that world and set location of each cells.

I found a reference on this issue in this forum (http://forums.java.net/jive/thread.jspa?messageID=374716&#374716).

it suggest to use codes like below;

String className = setup.getServerClassName();
CellMO cellMO = CellMOFactory.loadCellMO(className);
cellMO.setServerState(setup);
WonderlandContext.getCellManager().insertCellInWorld(cellMO)

(I think setup is an instance of a certain CellServerState.)

And, I modifies above code and put into forest cell like below;

String className = "org.jdesktop.wonderland.modules.forestterrain.server.ForestTerrainCellMO";
ForestTerrainCellServerState setup = new ForestTerrainCellServerState();
ForestTerrainCellMO cellMO = (ForestTerrainCellMO)CellMOFactory.loadCellMO(className);
cellMO.setServerState(setup);
WonderlandContext.getCellManager().insertCellInWorld(cellMO);

I edited codes within NetBeans, and compile with ant command.
But, I got some errors like below;

F:\NetBeansProjects\module example\pineforest-module>compile

F:\NetBeansProjects\module example\pineforest-module>ant
Buildfile: F:\NetBeansProjects\module example\pineforest-module\build.xml

-module-ant-task:

-module-init:

-module-compile-common:
[javac] F:\NetBeansProjects\Wonderland\build-tools\build-scripts\build-setup
.xml:37: warning: 'includeantruntime' was not set, defaulting to build.sysclassp
ath=last; set to false for repeatable builds

-module-compile-server:
[javac] F:\NetBeansProjects\Wonderland\build-tools\build-scripts\build-setup
.xml:37: warning: 'includeantruntime' was not set, defaulting to build.sysclassp
ath=last; set to false for repeatable builds

-module-compile-client:
[javac] F:\NetBeansProjects\Wonderland\build-tools\build-scripts\build-setup
.xml:37: warning: 'includeantruntime' was not set, defaulting to build.sysclassp
ath=last; set to false for repeatable builds
[javac] Compiling 1 source file to F:\NetBeansProjects\module example\pinefo
rest-module\build\classes
[javac] F:\NetBeansProjects\module example\pineforest-module\src\classes\org
\jdesktop\wonderland\modules\pineforest\client\jme\cellrenderer\PineForestCellRe
nderer.java:29: package org.jdesktop.wonderland.modules.forestterrain.common doe
s not exist
[javac] import org.jdesktop.wonderland.modules.forestterrain.common.ForestTe
rrainCellServerState;
[javac] ^
[javac] F:\NetBeansProjects\module example\pineforest-module\src\classes\org
\jdesktop\wonderland\modules\pineforest\client\jme\cellrenderer\PineForestCellRe
nderer.java:30: package org.jdesktop.wonderland.server does not exist
[javac] import org.jdesktop.wonderland.server.WonderlandContext;
[javac] ^
[javac] F:\NetBeansProjects\module example\pineforest-module\src\classes\org
\jdesktop\wonderland\modules\pineforest\client\jme\cellrenderer\PineForestCellRe
nderer.java:31: package org.jdesktop.wonderland.server.cell does not exist
[javac] import org.jdesktop.wonderland.server.cell.CellMO;
[javac] ^
[javac] F:\NetBeansProjects\module example\pineforest-module\src\classes\org
\jdesktop\wonderland\modules\pineforest\client\jme\cellrenderer\PineForestCellRe
nderer.java:32: package org.jdesktop.wonderland.server.cell does not exist
[javac] import org.jdesktop.wonderland.server.cell.CellMOFactory;
[javac] ^
[javac] F:\NetBeansProjects\module example\pineforest-module\src\classes\org
\jdesktop\wonderland\modules\pineforest\client\jme\cellrenderer\PineForestCellRe
nderer.java:117: cannot find symbol
[javac] symbol : class CellMO
[javac] location: class org.jdesktop.wonderland.modules.pineforest.client.jm
e.cellrenderer.PineForestCellRenderer
[javac] CellMO cellMO = (CellMO)CellMOFactory.loadCellMO(classNa
me);
[javac] ^
[javac] F:\NetBeansProjects\module example\pineforest-module\src\classes\org
\jdesktop\wonderland\modules\pineforest\client\jme\cellrenderer\PineForestCellRe
nderer.java:117: cannot find symbol
[javac] symbol : class CellMO
[javac] location: class org.jdesktop.wonderland.modules.pineforest.client.jm
e.cellrenderer.PineForestCellRenderer
[javac] CellMO cellMO = (CellMO)CellMOFactory.loadCellMO(classNa
me);
[javac] ^
[javac] F:\NetBeansProjects\module example\pineforest-module\src\classes\org
\jdesktop\wonderland\modules\pineforest\client\jme\cellrenderer\PineForestCellRe
nderer.java:117: cannot find symbol
[javac] symbol : variable CellMOFactory
[javac] location: class org.jdesktop.wonderland.modules.pineforest.client.jm
e.cellrenderer.PineForestCellRenderer
[javac] CellMO cellMO = (CellMO)CellMOFactory.loadCellMO(classNa
me);
[javac] ^
[javac] F:\NetBeansProjects\module example\pineforest-module\src\classes\org
\jdesktop\wonderland\modules\pineforest\client\jme\cellrenderer\PineForestCellRe
nderer.java:119: cannot find symbol
[javac] symbol : variable WonderlandContext
[javac] location: class org.jdesktop.wonderland.modules.pineforest.client.jm
e.cellrenderer.PineForestCellRenderer
[javac] WonderlandContext.getCellManager().insertCellInWorld(cel
lMO);
[javac] ^
[javac] 8 errors

BUILD FAILED
F:\NetBeansProjects\Wonderland\modules\build-tools\build-scripts\module-build.xm
l:94: The following error occurred while executing this line:
F:\NetBeansProjects\Wonderland\build-tools\build-scripts\build-setup.xml:61: The
following error occurred while executing this line:
F:\NetBeansProjects\Wonderland\build-tools\build-scripts\build-setup.xml:37: Com
pile failed; see the compiler error output for details.

Total time: 4 seconds
F:\NetBeansProjects\module example\pineforest-module>

I must be a missing classpath prone-error, but I added other cell's classes path to this cell project.

Could anyone give some advice to fix these errors?

Thanks in advance.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mcgy0072
Offline
Joined: 2008-11-03

Actually, I resolved the compile problem by adding server side classpath to \wonderland\modules\build-tools\build-scripts\module-build.xml at ln:102 like below;

but, I got an error when I insert forest cell into world;

java.lang.NoClassDefFoundError: org/jdesktop/wonderland/server/wfs/importer/CellImporterUtils

Clearly, I tried to use server side method (CellImporterUtils) at client side, and it reached to another dead end.

For client side, there is CellUtils.createCell(CellSeverState), but I'm not sure how to create a CellServerState instance in other cell and how to set classpath for refefred cell to build/run.

mcgy0072
Offline
Joined: 2008-11-03

I follow the way implemented at \wonderland\modules\paletter\..CellPalette.java at ln:244, and resolved the problem.

CellRegistry registry = CellRegistry.getCellRegistry();
Set cellFactories = registry.getAllCellFactories();
List listNames = new LinkedList();

Map cellFactoryMap = new HashMap();
// Loop through each cell factory we find. Insert the cell names
// into a list. Ignore any factories without a cell name.
for (CellFactorySPI cellFactory : cellFactories) {
try {
String name1 = cellFactory.getDisplayName();
if (name1 != null) {
listNames.add(name1);
cellFactoryMap.put(name1, cellFactory);
}
} catch (java.lang.Exception excp) {
// Just ignore, but log a message
System.out.println("No Display Name for Cell Factory " +
cellFactory);
}
}

String cellDisplayName = "ForestTerrain";
CellFactorySPI factory = cellFactoryMap.get(cellDisplayName);
CellServerState setup = factory.getDefaultCellServerState(null);

// Create the new cell at a distance away from the avatar
try {
CellUtils.createCell(setup);
} catch (CellCreationException excp) {
System.out.println("Unable to create cell " +
cellDisplayName + " using palette");
}