Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - paulscode

Pages: 1 ... 5 6 [7] 8 9 ... 58
91
Support / Re: CameraMovement
« on: October 15, 2010, 11:27:55 am »
What happens if you make slowCamMovement smaller, like say 5.0f?  Also, make sure all your variables are either floats or type-cast as floats in your "speed=" algorithm (so Java doesn't try to do integer division and round to zero).

92
Support / Re: [HOW-TO??] make reflective a simple Object3D (like a cube)
« on: October 10, 2010, 02:52:35 pm »
For those who can't see the images again, here are the links from the page source:
http://www.fileden.com/files/2008/10/14/2142989/improv.tiff
and:
http://www.fileden.com/files/2008/10/14/2142989/nasty.tiff

Might I suggest using a format more common on the web, like jpg?

In regards to your question, I am not sure what direction you are looking at the cube from in the second picture.  Are you looking directly toward a corner or toward a face?  If you are looking toward a face and getting this effect, then it is probably because the face is made up of four triangles with a central vertex.  Since shading on polygons start from the vertices, and since the light source is over that central vertex, you get the effect in your second image.

If that is the case, I would reduce the number of triangles you are using on that face.  There is no reason for a face to have four triangles instead of two.  I'm assuming you created this cube using jPCT's Primitives.getCube method, which has four triangles on at least two of the sides for some reason.  You could try building your cube manually, only using two polys per side.  Something like this should work (untested, but you get the general idea):
Code: [Select]
    // Creates a cube of the specified color
    private Object3D coloredCube( float scale, Color color )
    {
        TextureManager.getInstance().addTexture( "CubeClr",
                                               new Texture( 4, 4, color) );

        // 'offset' is simply half the length of the cube's side:
        float offset = 0.5f * scale;

        // Create a new object with the proper number of polys:
        Object3D obj = new Object3D( 12 );
        // Define the object's polys:
        obj.addTriangle( new SimpleVector( -offset, -offset, -offset ), 0, 0,
                         new SimpleVector( -offset, offset, -offset ), 0, 1,
                         new SimpleVector( offset, offset, -offset ), 1, 1,
                         TextureManager.getInstance().getTextureID( "CubeClr" ) );
        obj.addTriangle( new SimpleVector( offset, offset, -offset ), 1, 1,
                         new SimpleVector( offset, -offset, -offset ), 1, 0,
                         new SimpleVector( -offset, -offset, -offset ), 0, 0,
                         TextureManager.getInstance().getTextureID( "CubeClr" ) );
        obj.addTriangle( new SimpleVector( offset, -offset, offset ), 0, 0,
                         new SimpleVector( offset, offset, offset ), 0, 1,
                         new SimpleVector( -offset, offset, offset ), 1, 1,
                         TextureManager.getInstance().getTextureID( "CubeClr" ) );
        obj.addTriangle( new SimpleVector( -offset, offset, offset ), 1, 1,
                         new SimpleVector( -offset, -offset, offset ), 1, 0,
                         new SimpleVector( offset, -offset, offset ), 0, 0,
                         TextureManager.getInstance().getTextureID( "CubeClr" ) );
        obj.addTriangle( new SimpleVector( -offset, -offset, offset ), 0, 0,
                         new SimpleVector( -offset, offset, offset ), 0, 1,
                         new SimpleVector( -offset, offset, -offset ), 1, 1,
                         TextureManager.getInstance().getTextureID( "CubeClr" ) );
        obj.addTriangle( new SimpleVector( -offset, offset, -offset ), 1, 1,
                         new SimpleVector( -offset, -offset, -offset ), 1, 0,
                         new SimpleVector( -offset, -offset, offset ), 0, 0,
                         TextureManager.getInstance().getTextureID( "CubeClr" ) );
        obj.addTriangle( new SimpleVector( offset, -offset, -offset ), 0, 0,
                         new SimpleVector( offset, offset, -offset ), 0, 1,
                         new SimpleVector( offset, offset, offset ), 1, 1,
                         TextureManager.getInstance().getTextureID( "CubeClr" ) );
        obj.addTriangle( new SimpleVector( offset, offset, offset ), 1, 1,
                         new SimpleVector( offset, -offset, offset ),1, 0,
                         new SimpleVector( offset, -offset, -offset ), 0, 0,
                         TextureManager.getInstance().getTextureID( "CubeClr" ) );
        obj.addTriangle( new SimpleVector( -offset, -offset, offset ), 0, 0,
                         new SimpleVector( -offset, -offset, -offset ), 0, 1,
                         new SimpleVector( offset, -offset, -offset ), 1, 1,
                         TextureManager.getInstance().getTextureID( "CubeClr" ) );
        obj.addTriangle( new SimpleVector( offset, -offset, -offset ), 1, 1,
                         new SimpleVector( offset, -offset, offset ), 1, 0,
                         new SimpleVector( -offset, -offset, offset ), 0, 0,
                         TextureManager.getInstance().getTextureID( "CubeClr" ) );
        obj.addTriangle( new SimpleVector( -offset, offset, -offset ), 0, 0,
                         new SimpleVector( -offset, offset, offset ), 0, 1,
                         new SimpleVector( offset, offset, offset ), 1, 1,
                         TextureManager.getInstance().getTextureID( "CubeClr" ) );
        obj.addTriangle( new SimpleVector( offset, offset, offset ), 1, 1,
                         new SimpleVector( offset, offset, -offset ), 1, 0,
                         new SimpleVector( -offset, offset, -offset ), 0, 0,
                         TextureManager.getInstance().getTextureID( "CubeClr" ) );
        obj.build();
        return obj;
    }

93
Support / Re: [HOW-TO??] make reflective a simple Object3D (like a cube)
« on: October 09, 2010, 10:56:06 pm »
Well, I haven't a clue what "Clojure side" means, but I can tell you that a point light of color 0,0,0 is like having no light at all.  Also, setAdditionalColor acts the same as making the ambient light brighter on whatever object it is applied to.  Ambient light alone without a point light source makes the entire object all the same shade, which is exactly the effect that you are seeing.  Make your point light brighter and reduce the brightness of whatever value you are sending to the setAdditionalColor method (or remove the call to that method entirely), and you should achieve the effect you are after.

94
Support / Re: [HOW-TO??] make reflective a simple Object3D (like a cube)
« on: October 09, 2010, 06:18:28 pm »
A code sample would be helpful, but my first impression is that you have the ambient light up too high.  Try adjusting the brightness of both the ambient light and the point light source.

On a separate note, for some reason, your pictures didn't show up in my browser (Firefox 3.6.10, Ubuntu Lucid 64-bit).  I had to grab the links from the page source.  I'm guessing it is due to the fact that they are in .tiff format.  In case anyone else has the same issue, the links are:
http://www.fileden.com/files/2008/10/14/2142989/no_ref.tiff
and:
http://www.fileden.com/files/2008/10/14/2142989/reflecting.tiff

95
Projects / Re: Projects anyone?
« on: October 06, 2010, 10:07:21 pm »
I've got nothing yet, but should have a couple small games in the near future.  I'm trying to come up with a good joystick-like user interface for the touch-screen, which I'll write into the games and have folks comment on how well it works, suggestions, etc.

96
Support / Re: Max Camera Matrix to JPCT
« on: September 29, 2010, 01:43:59 pm »
Ok, give this a try (to see if my logic about flipping x and z in camera space to rotate the scene properly is incorrect).  Set up your scene as you did earlier where you can see the characters from looking sideways at the scene (i.e. comment out matrix thing, FOV to 45, position of camera -y/z flipped and camera.lookAt to the position of Max's camera's target).  Then call the following method:

Code: [Select]
    public void rotateScene90( Object3D[] sceneObjects, SimpleVector lookTarget, Camera camera )
    {
        SimpleVector sourcePosition, targetPosition, translation;
        for( int x = 0; x < sceneObjects.length; x++ )
        {
            // convert object's position into camera space:
            sourcePosition = new SimpleVector( sceneObjects[x].getTransformedCenter() );
            sourcePosition = sourcePosition.calcSub( camera.getPosition() );
            sourcePosition.matMul( camera.getBack() );
            // determine the new position (in camera space):
            targetPosition = new SimpleVector(sourcePosition.z, sourcePosition.y, sourcePosition.x );
            // convert new position into world space:
            targetPosition.matMul( camera.getBack().invert3x3() );
            targetPosition.add( camera.getPosition() );
            // translate to the new position:
            sceneObjects[x].translate( targetPosition.calcSub( sceneObjects[x].getTransformedCenter() ) );
        }

        // convert the look-target into camera space:
        sourcePosition = new SimpleVector( lookTarget );
        sourcePosition = sourcePosition.calcSub( camera.getPosition() );
        sourcePosition.matMul( camera.getBack() );
        // determine the new look-target (in camera space):
        targetPosition = new SimpleVector(sourcePosition.z, sourcePosition.y, sourcePosition.x );
        // convert the new look-target into world space:
        targetPosition.matMul( camera.getBack().invert3x3() );
        targetPosition.add( camera.getPosition() );

        // look toward the new look-target:
        SimpleVector look = targetPosition.calcSub( camera.getPosition() ).normalize();
        SimpleVector up = camera.getYAxis();
        up.scalarMul( -1 );  // Bug fix, shouldn't be necessary?  Try removing if scene is upside-down
        camera.setOrientation( look, up );
    }

Notice the bug fix for the setOrientation issue.  Depending on the scene, the call to up.scalarMul( -1 ) may or may not be necessary (remove it if the scene winds up upside-down).

97
Support / Camera space to world space?
« on: September 29, 2010, 03:45:41 am »
What is the correct method for converting from camera space into world space?  I thought it was this:
Code: [Select]
vector.matMul( camera.getBack().invert3x3() );
vector.add( camera.getPosition() );

I am getting an unexpected result with this.  In the case where I set the camera position and orientation as:
Code: [Select]
        camera.setPosition( 0, 50, 0 );
        camera.setOrientation( new SimpleVector( 0, -1, 0 ), new SimpleVector( 0, 0, -1 ) );

Then try to convert the following vector:
Code: [Select]
SimpleVector vector = new SimpleVector( 50, 0, 0 );
vector.matMul( camera.getBack().invert3x3() );
vector.add( camera.getPosition() );

I get a resulting vector of (-50.0, 50.0, 0.0).  But shouldn't it be (50.0, 50.0, 0.0)?  Am I incorrect about what the result should be, or am I doing the conversion incorrectly?

To visualize the problem, this is the result I am expecting to see:

98
Support / Re: Max Camera Matrix to JPCT
« on: September 29, 2010, 12:05:54 am »
That is very strange.  I can't imagine a scenario where you can see something then flipping the x and z coordinates in camera space of that thing plus the x and z values of the camera's look direction in camera space and no longer being able to see the thing - seems like that should always result in the equivalent of rotating the thing 90 degrees around its y-axis.  Obviously such a scenario exists in your case, so I guess it is just a limitation of my imagination..

99
Support / Re: Max Camera Matrix to JPCT
« on: September 28, 2010, 10:52:56 pm »
I flipped the values now and, unfortunately, no cigar. I see nothing on screen.
Is camera at 0,0,0?  If not, you'll need to subtract it from the converted vectors.  Also try reversing the sign of x, z, or both.

100
Support / Re: Max Camera Matrix to JPCT
« on: September 28, 2010, 10:34:08 pm »
Well, jPCT's up axis is -y, whereas worldspace up for max is +z. I accounted for that. Or do you mean something else?

No, I mean more like the x-axis you are using is equivalent to jPCT's z-axis.

101
Support / Re: Max Camera Matrix to JPCT
« on: September 28, 2010, 10:22:01 pm »
When I commented-out the entire matrix thing and set the FOV to 45 (as it is in Max), and entered the position of the camera (-y/z flipped) and set camera.lookAt to the position of Max's camera's target, I got a camera looking sideways at the scene (as if it had been jpctY-rotated 90 around the center of the scene). But I got to see the characters (the height was right). Bizarre, right?
This sounds like you have the wrong coordinate system.  The fact that you see the characters should mean that the target position is in the same coordinate system as the camera lookAt position, but the fact that in jPCT's coordinate system everything is rotated and you are looking from the side could mean that the entire scene (including the lookAt vector you are using) is rotated 90 around the jPCT camera's y-axis.  You should be able to just flip the x and z coordinates (in camera space) for the object positions and the camera lookAt vector (leave the camera in the position you have it), to have everything oriented properly.

Question: is the up-vector just, say, a (0, 1, 0)-type of vector? Meaning are there only three (or six with negative values) possibilities for it?
Correct as long as the camera is aligned with the cardinal directions.

102
Currently, there is no method for creating an empty/black texture of a specified size with alpha, something like this:

Code: [Select]
myTexture = new Texture( width, height, true );
This would be useful for cases where a texture's contents are generated entirely through an ITextureEffect implementation where alpha is used (i.e. if there is no "initial" frame to use when instantiating the Texture).  This is not high-priority for me, though.  I came up with a workaround that seems to function the same way:

Code: [Select]
BufferedImage image = new BufferedImage( width, height, BufferedImage.TYPE_4BYTE_ABGR );
myTexture = new Texture( image, true );

103
Support / Re: lighting mode and ambient light
« on: September 26, 2010, 01:34:48 am »
Right, but jPCT doesn't use the rotation pivot for the billboard effect.  Instead, it uses the object's center-of-mass, which is apparently calculated when the object is built.  This can be changed either by making the object have more volume by adding polys or by translating the mesh after building.

For the color settings, you would need to somehow specify negative values for the additive transparency mode - you want to add some green after subtracting a bit of red and blue, so the resulting effect is brighter than the initial colors, but not in a way that makes it look white.  I'm not sure if there is a one-step way to do that.

104
Support / Re: lighting mode and ambient light
« on: September 25, 2010, 03:35:39 am »
One billboard quad could be the child of a second billboard quad, both with the same center/pivot.  The polys of the outer layer would consist of vertices with lower values for z (or higher, depending on which side billboarding points toward the camera in jPCT) than those of the inner layer.  Then you would give the parent object normal transparency and the child object additive transparency.

--EDIT--
I should point out in case you haven't noticed already, jPCT automatically calculates the center/pivot of a quad to have the same z-value as the polys when the object is built.  One work-around to "trick" jPCT into using a different center is to add two additional back-faced polys (on the other side of the imaginary "cube").  In my above scenario you could leave the parent object as 2 polys and just add a the extra polys to the child object.  An alternative to adding polys is with translateMesh, I believe, however as I recall it will just revert back if you call build or buildAll afterwards.

105
Support / Re: lighting mode and ambient light
« on: September 25, 2010, 02:15:39 am »
The reason for this problem, of course, is that with additive color you are adding the color of the transparent image to the existing color, so even a dark color causes the area to approach white very quickly when the color you are adding it to is already bright to begin with.  Another thing you could try is two layers for your glow effect.  The first you would use normal transparency mode to shade the area closer to the target color.  Then placing the texture with additive transparency over that won't require as much additional color to reach your target color, so hopefully it won't end up looking as bright/white.

Pages: 1 ... 5 6 [7] 8 9 ... 58