Main Menu
Menu

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.

Show posts Menu

Topics - paulscode

#21
I have tracked the invisible Object3D problem down to whenever the Object3D in question is billboarded and is the child of an Object3D.createDummyObj().  Problem only occurrs in the latest beta version of jPCT.  Should be simple to replicate, but if you need a test case I can post one.
#22
Support / Destroying an Object3D
December 29, 2008, 02:14:50 AM
In an applet I am working on, I got the following messages, which I haven't seen before:
Additional visibility list (2) created with size: 10000
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at com.threed.jpct.World.renderScene(Unknown Source)
at C3.JupiterDefense.paint(JupiterDefense.java:166)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


The applet is a target shooter which generates a lot of bullets, each having two Object3Ds (a box and a billboarded quad), so I am thinking that perhaps the problem is that I am not disposing of all these Object3Ds properly.  When I am finished with each bullet, I am running the following method:
    public void remove()
    {
        world.removeObject( object3D );
        if( childrenObjects != null )
        {
            for( int i = 0; i < childrenObjects.length; i++ )
            {
                world.removeObject( childrenObjects[i] );
            }
        }
    }


Is there something else I need to be doing in addition to calling removeObject()?

At this point, I don't really know if it is related to too many Object3Ds or what.  I will try and replicate a simple test case if possible - the project is quite large atm.  I thought in the mean time, someone might recognize that message (or why might the message "Additional visibility list (2) created with size: 10000" be generated?)

--EDIT--
Oh, I forgot to mention, I have the following line in the applet's init() method, which is where the number "10000" is coming from:
Config.maxPolysVisible = 10000;
I suppose a posibility is that the applet is running out of memory, but in that case I would expect to receive some kind of "out of memory" message instead.  I'll try and run this program as an application and see if the problem still exists.
#23
Support / Translating Child Object3D
December 28, 2008, 10:29:45 PM
I have noticed that translating a child Object3D does not take the parent's rotations into account.  Is this a bug, or do I just need to account for parent rotations "manually"?
#24
Support / 2D foreground in hardware rendering mode
December 15, 2008, 01:15:02 AM
Here's another question that's probably been asked a hundred times:

Is there a way to get a Graphics context to draw on when using hardware rendering mode?  I can't use getGraphics() since, as the Javadoc states, "when using OpenGL support, this value is rather meaningless".

I suppose I could draw my layer onto an Image, and use that to create a Texture to use in the blit() method.  I'd have to rethink how I handle images that change dynamically (since I wouldn't want to create a new texture every frame).  Also, is a texture's alpha information taken into account by blit()?  If not, is there another way to draw simi-transparent 2D stuff on top of the rendered scene?

--EDIT-- I see that one of the blit() methods has the ability to set an additional color.  I'll play around with this to see if I can get the results I'm looking for.
#25
Support / Converting world-space coordinates
December 10, 2008, 03:33:42 AM
What would be a good way to convert a SimpleVector in world-space into one in camera-space (i.e. the look-direction +z axis, up-direction -y axis, etc)?
#26
Bugs / Billboarding ignores parent rotations
December 06, 2008, 10:23:58 PM
I don't know if this is a bug or if it is intentional, but I thought I would point it out just in case.  Billboarding does not take an Object3D's parents' rotations into account (i.e. when rotating the parent, the child Object3D behaves as if it were BILLBOARDING_DISABLED).  Subsequent movements of the camera then result in the object auto-aligning to a direction other than the camera.
#27
Support / How to make things glow
December 05, 2008, 04:31:01 AM
I was wondering what might be the best way to make something appear to glow (such as a lightbulb).  The idea I had would be to strategically place a few light sources right outside the surface of the object (maybe only one light source would be needed if viewing the object from just one side).  More would be needed for different shapes, such as for cylinders.

Is this a good idea for making an object glow, or is this normally done a different way that I haven't considered?

Also, how much do multiple light sources affect performance (i.e., is there a general rule of thumb for how many would be the maximum number one should use)?

Thanks in advance!
#28
Support / Building a Terrain Object3D from scratch
October 18, 2008, 04:59:08 PM
I have a couple more questions related to building a terrain Object3D.

My first question is why does building an Object3D increase its vertice count?  Building the following square Object3D increases its vertice count from 4 to 12 ???
        Object3D terrain = new Object3D( 2 );
        SimpleVector bottomLeft = new SimpleVector( 0, 0, 0 );
        SimpleVector bottomRight = new SimpleVector( 5, 0, 0 );
        SimpleVector topRight = new SimpleVector( 5, 0, 5 );
        SimpleVector topLeft = new SimpleVector( 0, 0, 5 );
       
        int triangle1 = terrain.addTriangle( topLeft, 0, 0,
                                             bottomLeft, 0, 1,
                                             bottomRight, 1, 1 );
        int triangle2 = terrain.addTriangle( bottomRight, 1, 1,
                                             topRight, 1, 0,
                                             topLeft, 0, 0 );

        System.out.println( "Unique Vertice count before build: " + terrain.getMesh().getUniqueVertexCount() );
        System.out.println( "    Triangles: " + terrain.getMesh().getTriangleCount() );
        terrain.build();
        System.out.println( "Unique Vertice count after build: " + terrain.getMesh().getUniqueVertexCount() );
        System.out.println( "    Triangles: " + terrain.getMesh().getTriangleCount() );

Strangely, the number of triangles remains 2 even though the number of vertices triples.  What is causing this, and how do I prevent it from happening?

My second question is what is the best way to determine a polyID given a triangle number.  I don't suppose they are the same, are they?

My last question is about OcTree's.  The JavaDoc states that the best maxPoly value to use for an OcTree depends on the object and its usage.  Unfortunately, I don't know enough to know what the best value to use for my situation might be.  What would you recommend for terrain objects that are 32X32 grids with two triangles per square?
#29
Support / Textures on a Terrain
October 16, 2008, 11:57:17 PM
Another question about terrains.  It looks as though only one texture can be assigned to an Object3D at any given time, so what is the best way to texture a terrain that has many different graphics on it, like grass, dirt, roads, etc?  My thought was to create a texture that is say 1024 width and a super huge height that has all the texture graphics on it, then do a UV map for each polygon to the desired graphic.  I'm not sure what method to use for this though.  PolygonManager.setPolygonTexture( int polyID, TextureInfo tInf ) looks like it will do the job, but I just wanted to make sure that will work in both software and OpenGL modes (assuming I use a single texture that is).
#30
There are a couple of ways I am considering to interact with a terrain via the mouse:

The first way would be to make each square of the terrain its own individual Object3D, and use the World.checkCollision( SimpleVector, SimpleVector, float ) method to determine which grid square of the terrain that the user clicked on.

The second way would be to place the entire terrain into a single Object3D, and generate an actual collision event, then call the CollisionEvent.getPolygonIDs() method.  This could be used to determine which grid square of the terrain was clicked on by searching all polygons in the terrain for a match.

Is there likely to be a significant performance difference with either method, or is there a different way all-together to accomplish this?
#31
Support / Interact2D
October 15, 2008, 02:52:53 AM
Another question related to rotations.  I am planning to use Interact2D.reproject2D3D(Camera camera, FrameBuffer buffer, int x, int y, float z) for interacting with the world via the mouse.  I assume the returned SimpleVector is in Camera space, so I would need to apply the camera's rotations (inverted I assume) and translations to it to get a SimpleVector in world space.  Translations are a simple matter of addition, but what methods do I use for rotations?  I'm guessing I would start with this:

Matrix m = myCamera.getBack().cloneMatrix().invert3x3();

Then what method do I use to apply this matrix to the SimpleVector?

Thanks for the help, BTW.  I know I am asking questions that have been asked before.  I just have trouble finding things in the forums occasionally.
#32
Support / Setting a Camera's orientation
October 13, 2008, 01:03:46 AM
What is the best way to set a camera's orientation?  I can use the lookAt() method to tell the camera which direction to point, but I am having a little trouble figuring out a simple way to set the camera's up direction.
#33
I am sure this question has been answered before, but I am having trouble locating a previous thread about it.  I am generating a terrain which is made up of a grid of squares.  Each square consists of two polygons and four vertices:

(1)---------(3)
| \              |
|     \          |
|         \      |
|             \  |
(2)---------(0)

(the numbers represent the index of each vertex).

Each square in the terrain has its own GridVertexController (which extends GenericVertexController and implements IVertexController).  The GridVertexController class has four SimpleVectors:
    SimpleVector vertex0, vertex1, vertex2, vertex3;

My program changes these four SimpleVectors to represent the new values for the square's vertices.

In the apply() method, I update the getDestinationMesh() array, and then attempt to update the getDestinationNormals() array:


    public void apply()
    {
        SimpleVector dstVertex[] = getDestinationMesh();
        SimpleVector dstNormal[] = getDestinationNormals();
        SimpleVector A, B, C, D;
       
        dstVertex[0].set( vertex0 );
        dstVertex[1].set( vertex1 );
        dstVertex[2].set( vertex2 );
        dstVertex[3].set( vertex3 );
       
        A = vertex1.calcSub( vertex2 );
        B = vertex0.calcSub( vertex2 );
        C = A.calcCross( B ).normalize();
        dstNormal[2].set( C );
       
        A = vertex0.calcSub( vertex3 );
        B = vertex1.calcSub( vertex3 );
        D = A.calcCross( B ).normalize();
        dstNormal[3].set( D );
       
        D.add( C );
        D = D.normalize();
        dstNormal[0].set( D );
        dstNormal[1].set( D );
    }


The vertices are changed correctly, but there seems to be a problem in the algorithm I'm using to calculate the normals, because lighting on the terrain is not correct.  For example, if I generate a flat terrain on the x/z plane with a light source directly overhead, the terrain still appears dark.
#34
Projects / Robot Builder
September 21, 2008, 12:50:23 AM
-- This slot is reserved for resources, links, and screen shots --

 

Robot Builder 2D  (Unfinished)
My original 2D version of Robot Builder.

3D Robot Viewer
Applet I created to test my 3D robot.


Robot Odyssey  (Wikipedia)
The inspiration for Robot Builder

The Robot Odyssey Resource
AppleWin emulator and Robot Odyssey disk images
#35
I noticed that returned vectors for the Camera's default orientation are:

getDirection() returns: (0, 0, 1)
getUpVector() returns: (0, 1, 0)

This should mean the camera is facing into the screen and upside down (since -y is "up" in jPCT).  I am not sure if this is a bug or not, but I thought I would bring it up just in case.  It seems possible that the returned y-coordinate for the camera's up-vector is signed incorrectly.  Reason I say that is because when converting the returned values for direction and up into OpenAL coordinates, sounds are playing backwards (i.e. coordinates for an Object3D to the left create sources to the right when the listener's orientation is synced with the camera).  This is what one would expect if the listener were facing the same direction but upside down in relation to the camera.  Of course the most likely cause for this odd behavior is a bug in my code and not a bug in jPCT, but it does seem possible that the camera's actual default up-vector is really (0,-1,0) and the method Camera.getUpVector() is somehow returning an incorrectly signed value for y.
#36
The new LWJGL 2.0 Beta 1 was released on April 20, 2008.  As you all probably know, jPCT uses LWJGL for the hardware rendering mode, and in an applet this generally requires using LWJGL's AppletLoader.

Then biggest change in this release (from an AppletLoader perspective) is that it now has support for lzma and pack200.  I had some time today to work with the new AppletLoader.  Usage is similar to previous releases, but most of the files have been changed from JAR's to LZMA's.  There is a problem, though.  If you try loading an applet over the internet with it, you will receive the following error:
Fatal error occured (4): Could not verify signing in resource: lwjgl.jar.pack.lzma

The problem is not mentioned in the included documentation, and the bundle does not come with JAR's to use instead of the LZMA's.  I posted the problem on the LWJGL forums, and was informed that it is related to the following bug:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6697988

Until this bug is fixed, you can use the following work-around:

1) Create a text file named ".htaccess".
If you are running Windows, it will complain, because that is not a valid filename, according to Bill.  You'll have to name it something like ".htaccess.txt", then rename it later after uploading it.

2) Edit the file you created with a text editor, like notepad.  Add the line:
AddType application/x-lzma .lzma

3) Save your file, and FTP it to wherever lwjgl_util_applet.jar and lzma.jar are located.  If necessary, rename your file ".htaccess" (remove the ".txt" extension)
Make sure you are allowed to use .htaccess before doing this!  Some of the things that .htaccess is able to do can compromise a server configuration.  For this reason, some web hosting companies may require them to be set up by an admin, so don't get in trouble.  You should CHMOD your .htaccess file to 644 (RW-R--R--) to prevent people from messing with it

That's it.  Hope you find this helpful!
#37
Projects / jPCT Birthday E-Card
April 22, 2008, 09:34:42 PM
My wife's birthday is in a couple of weeks (May 3).  She likes personalized things like home-made cards, crafts, etc.  She prefers gifts that you have to spend a little time to make, rather than taking the easy way out and buying her something.  So I decided to make her sort of a 3D "E-Card" using jPCT.  (She never reads these forums, so it's safe to talk here ;D)  I'm thinking a 3D animation of a guy and a girl who embrace, music in the background, and a message popping up.  I've already finished the man character and am almost done with the woman character.  I am using photos of my wife and me to texture them.  They don't look a lot like us, but it is an acceptable approximation.  I'll post my progress here, as well as the finished applet (after her birthday, of course, so she sees it first).  Any ideas are welcome, although I may not be able to implement them since I have a pretty tight deadline for this project.
#38
Support / Character Poly Number
April 18, 2008, 01:42:56 AM
I am sure there are a range of opinions on this issue, but I was wondering what some of you think is a reasonable number of polys that a character should have in a MMORPG?  There isn't really a right or wrong answer here, I just want to get a feel for what some more experienced game developers think.
#39
Support / Character Animations
April 11, 2008, 02:11:21 AM
This question is not about a particular problem, but more for some general advice.  I've gone through the tutorials in Autodesk 3DS Max for modeling biped humanoids and animating them, and I believe I now have a pretty good grasp on how to model and animate characters from within the Autodesk program.  My question now is, what is the next step?  How do I take this new knowledge and begin animating a 3D character in a jPCT program?  I'd like to start with something simple like a walking animation or waving or something like that.  I know that a few of you have character animation experience.  Do you happen to have any good pointers for someone like me who is just starting out?  Thanks in advance!
#40
Support / Thread-safe question
March 23, 2008, 10:44:56 PM
This is a basic question more related to Java, I think, than jPCT.  I am rather new to threads, so I want to make sure I using good programming technique.  My question is: Is it is safe to call the following methods from a seperate thread (I am checking if the objects are null immediately before calling the methods):

Camera:
    getPosition()
    getDirection()
    getYAxis()
Object3D:
    getTransformedCenter()

I suppose it could be possible that the instance in question could have been changed or deleted during the nanosecond between when the "if" statement checks if the object is null and when one of these methods gets called.  How likely is that scenario, and other than that, is it likely that calling any of these methods from a seperate thread might lead to other exceptions/errors?