Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3508 Members - Latest Member: NevilleKemp

26. May 2012, 04:45:18 pm
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)Problem with object disappear
Pages: [1]
Print
Author Topic: Problem with object disappear  (Read 1358 times)
Dori
Enjoying the stay
*
Offline Offline

Posts: 90


View Profile
« on: 16. February 2007, 03:56:28 pm »

After I updated Xith today, I think culling does not work right. Some of my objects disappear from my screen when I move the camera to the side.
This did not happen yesterday.
Logged
'n ddrylliog
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #1 on: 16. February 2007, 04:13:41 pm »

Oh really ? That's won't make Marvin happy.. he has spent so much time debugging Bounds lately...
Logged
Dori
Enjoying the stay
*
Offline Offline

Posts: 90


View Profile
« Reply #2 on: 16. February 2007, 04:19:07 pm »

Well after reading this http://www.xith.org/forum/index.php?topic=113.0 thread I used updateBounds(false) and that did the trick and its OK now, but it is strange that it was OK yesterday
Logged
horati
Global Moderator
Getting respectable
*****
Offline Offline

Posts: 393


View Profile
« Reply #3 on: 16. February 2007, 05:24:00 pm »

That's the flip side of a fast paced project Smiley
Logged

Kevin
"It may not seem like a big deal, but ignorance of character encoding issues leads to insidious code rot akin to y2k."
http://stackoverflow.com/users/3474/sylvarking
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #4 on: 16. February 2007, 05:29:35 pm »

Yeah, Bounds were making me crazy yesterday night. But I thought, everything was working just right now. If you could paste me some test code, so that I could see, if the updateBounds() call could be avoided.

Marvin
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #5 on: 16. February 2007, 06:11:30 pm »

I readded two updateBounds calls in AtomsCollector, that I though were expensive and unnecesary. But in fact they are at least cheap. And their absense could be the cause of your recent problems.

Please check, if it works now. Otherwise, please send me some test code.

Marvin
Logged
Dori
Enjoying the stay
*
Offline Offline

Posts: 90


View Profile
« Reply #6 on: 16. February 2007, 07:54:50 pm »

NO it doesn't work now ether.

Code:
import java.io.File;

import javax.vecmath.Color3f;
import javax.vecmath.Tuple3f;
import javax.vecmath.Vector3f;

import mygame.input.MyInputAdapter;

import org.xith3d.geometry.Line;
import org.xith3d.loaders.texture.TextureLoader;
import org.xith3d.loaders.texture.TextureStreamLocatorFile;
import org.xith3d.render.Canvas3D;
import org.xith3d.render.Canvas3DFactory;
import org.xith3d.render.base.Xith3DEnvironment;
import org.xith3d.render.loop.RenderLoop;
import org.xith3d.scenegraph.BranchGroup;
import org.xith3d.scenegraph.Group;
import org.xith3d.scenegraph.PointLight;
import org.xith3d.scenegraph.View;
import org.xith3d.ui.hud.HUD;
import org.xith3d.ui.hud.listeners.ButtonListener;
import org.xith3d.ui.hud.widgets.Button;

public class Test extends RenderLoop implements ButtonListener {

private Xith3DEnvironment env;
private View view;
private MyInputAdapter myAdapter;
private Tuple3f eyePosition;
private Tuple3f viewFocus;
private Tuple3f vecUp;

private int tileW = 2;

public void onButtonClicked(org.xith3d.ui.hud.widgets.Button button, Object userObject) {
if (userObject.equals("EXIT")) {
this.end();
}
}

private BranchGroup createScene(Xith3DEnvironment env) {
BranchGroup rootBranch = new BranchGroup();
// Let there be light
rootBranch.addChild(new PointLight(0.3f, 0.3f, 0.3f, 20f, 100f, 0f, 0.00001f));

// Draw grid
Tuple3f start = new Vector3f(0, 0.1f, 0);
Tuple3f end = new Vector3f(10, 0.01f, 0);
Color3f color = new Color3f(0.5f, 0.5f, 0.5f);

Group grid = new Group();
start.z = 20 * -1;
end.z =20;
for (int x = 0; x <= 20; x++) {
start.x = (x * tileW) - 20;
end.x = (x * tileW) - 20;
grid.addChild(new Line(start, end, 1f, color));
}
start.x = 20 * -1;
end.x = 20;
for (int z = 0; z <= 20; z++) {
start.z = (z * tileW) - 20;
end.z = (z * tileW) - 20;
grid.addChild(new Line(start, end, 1f, color));
}
// grid.updateBounds(false);
rootBranch.addChild(grid);
return (rootBranch);
}

protected void loopIteration(long gameTime, long frameTime) {
myAdapter.updateView(gameTime, frameTime);
super.loopIteration(gameTime, frameTime);
}

private HUD createHUD(Canvas3D canvas) {
HUD hud = new HUD(canvas, 800, 600, this.getOperationScheduler());

this.getInputManager().registerInputListener(hud);

Button button = new Button(90, 30, "Exit this app");
button.setUserObject("EXIT");
button.addButtonListener(this);
hud.addWidget(button, 10, 10);

return (hud);
}

public Test(String[] args) {
super(128L); // Note: 128 FPS limitation!
eyePosition = new Vector3f(5f, 10f, 5f);
viewFocus = new Vector3f(0.0f, 0.0f, 0.0f);
vecUp = new Vector3f(0.0f, 1.0f, 0.0f);

env = new Xith3DEnvironment(this);
view = env.getView();

// set camera
env.getView().lookAt(eyePosition, viewFocus, vecUp);
Canvas3D canvas;

canvas = Canvas3DFactory.createWindowed(1024, 768, "My Game");
// canvas = Canvas3DFactory.createFullscreen(1024,768);
// canvas = Canvas3DFactory.createFullscreen(1280, 1024);
env.addCanvas(canvas);

canvas.setBackgroundColor(Color3f.CYAN);
TextureLoader.getInstance().addTextureStreamLocator(new TextureStreamLocatorFile(new File("data/textures")));

env.addPerspectiveBranch(createScene(env));
env.addRenderPass(createHUD(canvas).getRenderPass());

this.getInputManager().registerKeyboard(canvas);
this.getInputManager().registerMouse(canvas);

this.myAdapter = new MyInputAdapter(view, canvas, 3.0f);
myAdapter.createDefaultKeyBindings(true);
myAdapter.setFixedPlaneEnabled(true);
this.getInputManager().registerInputListener(myAdapter);

// FirstPersonInputHandler fpHandler = new FirstPersonInputHandler( view,
// canvas, 1.0f, 1.0f, 3.0f );
// fpHandler.createDefaultKeyBindings( true );
// fpHandler.setFixedPlaneEnabled(true);
// // fpHandler.getInputManager().getMouse().setExclusive(false);
// this.getInputManager().addInputHandler( fpHandler );

this.begin();
}

/**
* @param args
*/
public static void main(String[] args) {
new Test(args);
}
}
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #7 on: 17. February 2007, 03:36:27 am »

The Line Shape was a special case. It didn't set the Bounds to dirty when the coordinates are manipulated, which was done in the constructor. I've changed that. Now your test works without the updateBounds() call.

btw. Why did you create your own MyInputAdapter? Does it do anything more than the FirstPersonInputAdapter? Maybe I could integrate your additional functionality, if it is not a special thing for your app.

Marvin
Logged
Dori
Enjoying the stay
*
Offline Offline

Posts: 90


View Profile
« Reply #8 on: 17. February 2007, 11:03:00 am »

Well the lines are fixed now but some of my models are disappearing when I move the camera at the models the disappear. I just send you the hole thing, this code though is just a hack, I'm trying to learn Xith an game development at the same time.

About the MyInputAdapter is just a copy of the old FPSInputAdepter and I removed the mouse rotation. The plan is turn it into a OverviewInputAdepter which WASD and arrow buttons will do what the do now but the mouse wheel will zoom in/out or the will rotate around the X axis and have some key use different camera mode, like close up, semi overview and complete overview. Also when the mouse will go to the edge the screen will follow. But that is for some other day to implement.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #9 on: 17. February 2007, 02:27:22 pm »

Well the lines are fixed now but some of my models are disappearing when I move the camera at the models the disappear. I just send you the hole thing, this code though is just a hack, I'm trying to learn Xith an game development at the same time.

Cool. Thanks. I will what I can do.

Marvin
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #10 on: 19. February 2007, 03:12:16 am »

The new Bounds fix is ready. I hope, everything works now. Please check it out.

Marvin
Logged
Dori
Enjoying the stay
*
Offline Offline

Posts: 90


View Profile
« Reply #11 on: 19. February 2007, 11:25:31 am »

Yes it works now thanks, but the performance hasn't increased anything like they talk about here http://www.xith.org/forum/index.php?topic=168.msg1372;topicseen#msg1372
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #12 on: 19. February 2007, 03:08:49 pm »

Yes it works now thanks, but the performance hasn't increased anything like they talk about here http://www.xith.org/forum/index.php?topic=168.msg1372;topicseen#msg1372

Well, the fix, that was talked about in the linked thread, will boost performance when you have many TransformGroups in your scene, that are constantly manipulated. Your scene is static most of the time, so no TransformGroup is manipulated and you won't gain any boost from the fix.

Marvin
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic