Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11855 Posts in 1569 Topics- by 3055 Members - Latest Member: TipEpismKeype

11. February 2012, 01:22:07 PM
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)Render Pass and Widget3D
Pages: [1]
Print
Author Topic: Render Pass and Widget3D  (Read 545 times)
elijah
Enjoying the stay
*
Offline Offline

Posts: 72


View Profile
« on: 29. July 2010, 11:28:06 AM »

Can somebody help me on this ? When I do this

RenderPassTextureDesign test = new RenderPassTextureDesign();
test.setEnabled(true);
w3D = new Widget3D( 300, 300, test.getConfig() );

The widget3D is displayed but no shape is being shown. But when I

RenderPassTextureDesign test = new RenderPassTextureDesign();
test.setEnabled(true);

ENVIRONMENT.add( test );

the renderpass is shown.

I want the renderpass to be dispalyed in the Widget3D. How to do this ?

Code:
public class RenderPassTextureDesign extends RenderPass {
private static final String ID = RenderPassTextureDesign.class.getName();
private static BaseRenderPassConfig RENDER_PASS_CONFIG = new BaseRenderPassConfig();

protected static final BranchGroup      RENDER_PASS_BRANCH_GROUP = new BranchGroup();
protected TransformGroup    TRANSFORM_GROUP_FOR_THE_MAIN_SCENE;

protected int  VIEWPORT_X = 0, VIEWPORT_Y=500, VIEWPORT_WIDTH=250, VIEWPORT_HEIGHT=300;

public RenderPassTextureDesign( ){
super( RENDER_PASS_BRANCH_GROUP, RENDER_PASS_CONFIG );
CreateXithAxis();
SetupViewTransform();
SetupViewport();
System.out.println("x = " + VIEWPORT_X + " y = " + VIEWPORT_Y + " width = " + VIEWPORT_WIDTH + " height = " + VIEWPORT_HEIGHT );
}

private void CreateXithAxis(){
Material mat;
XithAxis axis;
Transform3D t3d;
Shape3D Shape;

Shape = new Cube( 3.0f , Colorf.RED);
t3d = new Transform3D();
t3d.setIdentity();

        mat = new Material();
        mat.setAmbientColor( Colorf.GRAY25 );
        mat.setLightingEnabled( true );

Shape.getAppearance(true).setMaterial(mat);

TRANSFORM_GROUP_FOR_THE_MAIN_SCENE = new TransformGroup();
TRANSFORM_GROUP_FOR_THE_MAIN_SCENE.setTransform(t3d);
TRANSFORM_GROUP_FOR_THE_MAIN_SCENE.addChild( Shape );

RENDER_PASS_BRANCH_GROUP.addChild( TRANSFORM_GROUP_FOR_THE_MAIN_SCENE );
        RENDER_PASS_BRANCH_GROUP.addChild( new AmbientLight( true, Colorf.BLUE ));

//RENDER_PASS_BRANCH_GROUP.addChild( axis.getShape3D() );

}

private void SetupViewport() {
Rect2i viewport;

viewport = new Rect2i( VIEWPORT_X, VIEWPORT_Y, VIEWPORT_WIDTH, VIEWPORT_WIDTH );
createPerspective(RENDER_PASS_BRANCH_GROUP);
RENDER_PASS_CONFIG.setViewport( viewport );

}

private void SetupViewTransform(){
Transform3D trans;
    trans = new Transform3D();
    trans.setIdentity();
    trans.setTranslation( 5.0f, 5.0f, 20f);
    RENDER_PASS_CONFIG.setViewTransform( trans );

}
   
public TransformGroup getTransformGroup(){       
        return TRANSFORM_GROUP_FOR_THE_MAIN_SCENE;
}
}

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

Posts: 4337


May the 4th, be with you...


View Profile
« Reply #1 on: 29. July 2010, 12:53:27 PM »

The RenderPass needs to be attached to both the environment and the Widget3D.

I have committed a little patch to Xith3D to apply the initial location of the Widget3D to the RenderPass and modified WidgetsTest1 to show a little Widget3D.

Marvin
Logged
elijah
Enjoying the stay
*
Offline Offline

Posts: 72


View Profile
« Reply #2 on: 29. July 2010, 01:18:58 PM »

Thanks
Logged
elijah
Enjoying the stay
*
Offline Offline

Posts: 72


View Profile
« Reply #3 on: 30. July 2010, 08:17:41 AM »

Marvin,

I have tried the examples in xith-tk. There are still some problems.

1. When attaching the Widget3D directly into a Panel , make sure to call setNoBackground() and attached it directly to the hud. This will work.

2. For Frames it does not work. I think this is because it has no setNoBackground().
Logged
elijah
Enjoying the stay
*
Offline Offline

Posts: 72


View Profile
« Reply #4 on: 05. August 2010, 12:24:09 PM »

Can somebody help me on this ? I have created a RenderPass with RenderPass.createPerspective(BranchGroup branchGroup) . The problem is I do not want it to see the background of the underlying scene/shapes that is available on the main hud. What is the best way to achieved this ? I tried creating a Sphere to block out the background but it does not always work.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Online Online

Posts: 4337


May the 4th, be with you...


View Profile
« Reply #5 on: 05. August 2010, 06:25:25 PM »

I'm not sure, if I get, what you mean. Well, I have applied another little patch to the Widget3D to track the parent Window's location to apply it to the RenderPass when the Window is moved. But the rest seems to work.

I have modified the WidgetTest1 in the following way to test it and it works.
Code:
Frame f2 = new Frame( 256, 256 * 3 / 4, "test" );

Widget3D w3d = new Widget3D( 256, 256 * 3 / 4, td.getConfig() );
w3d.setBorder( new ColoredBorder( 2, Colorf.YELLOW ) );
//contentPane.addWidget( w3d, 500, 330 );
f2.getContentPane().setNoBackground();
f2.getContentPane().setLayout( new FillLayout() );
f2.getContentPane().addWidget( w3d );

hud.addWindow( f2, 100, 100 );

Does this help you?

Marvin
Logged
elijah
Enjoying the stay
*
Offline Offline

Posts: 72


View Profile
« Reply #6 on: 05. August 2010, 07:32:47 PM »

I have tried that also. Sorry my English is not good. I have managed to get the RenderPass with Perspective running in the Widget3D. Let say you have a lot of shapes in the background and decide to create a widget3D in a panel like a pop up dialog. You do not want the background shapes to appear in the widget3D. I have look at the source code.

So I did a little testing. I created a myWidget3D extends BackgroundSettableWidget and copied all the code from Widget3D class and do a setBackgroundColor() color. The background of the myWidget3D appears to what ever color I have set but it also wipes out the shapes that are in the renderPass and also the background of all the other shapes.

The problem is at the BackgroundSettableWidget.java drawBackground() Function. Somewhere in the function it calls

DrawUtils.clearImage( getBackgroundColor(), getBackgroundTexture(), getBackgroundTileMode(), texCanvas, offsetX, offsetY, width, height ); and you lose the Shapes that are in the RenderPass.

I have a solution to this. The user must create a Sphere big enough to cover the display area of the Widget3D and move the viewport inside the Sphere and display all the shapes need in the renderpass. So all the background shapes will not be displayed.

I wasted 3 weeks of trial and error in using a cube and it does not work but must be a sphere.

Marvin is there any plans to port Xith3D to the andriod platform. I know that JME is starting to port to the andriod platform.

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

Posts: 4337


May the 4th, be with you...


View Profile
« Reply #7 on: 05. August 2010, 10:19:59 PM »

Ok, I see. The problem is not the background of the Widget. A Widget's background will always overpaint the scene behind it. This also includes the RenderPass attached to the Widget3D. You would need to clear the viewport before the attached RenderPass is rendered. This is currently not supported, but could be quite simply added. I will see, if I can find the time to do this over the weekend. But I cannot promise that.

Marvin is there any plans to port Xith3D to the andriod platform. I know that JME is starting to port to the andriod platform.

Definitely not (by me). I don't have the time for that. Of course you're invited to do that, if you want.

Marvin
« Last Edit: 06. August 2010, 07:34:08 AM by Marvin Fröhlich » Logged
elijah
Enjoying the stay
*
Offline Offline

Posts: 72


View Profile
« Reply #8 on: 06. August 2010, 04:05:04 AM »

It would be good to have both options in the Widget3D. ie allows to used to select weather they want to see the background or not.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Online Online

Posts: 4337


May the 4th, be with you...


View Profile
« Reply #9 on: 06. August 2010, 07:36:09 AM »

This is not possible. The HUD is rendered on top of the 3D scene. You cannot render the panel's background behind the scene.

Marvin
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic