jPCT - a 3d engine for Java > Support

How to create an Applet

(1/3) > >>

Scalpweb:
Hello,

First, excuse me for my english, I'm a french developper. ^^

I just find out the jpct 3D engine, and I want to create a basic applet : I just want to create a scene where I can see a 3DSmax object. I want to use hardware rendering (OpnGl).

But, unfortunatelly, I can't find any tutorial or exemple for this... So, for exemple, if I want to convert the "fps" demo in a Applet, how can I do that ?

Thanks,
Scalp

paulscode:
I have a simple applet that should help you get started.  It demonstrates how to load and set up 3DS models, how to use hardware rendering in an applet, and how to switch between hardware and software rendering modes on the fly.

Here is a link to the source code:
http://www.paulscode.com/demos/jpct/jPCTGears/jPCTGearsSource.zip

To use hardware rendering in an applet, you must load it with the lwjgl applet loader, which you can download from:
http://www.lwjgl.org


Here are some instructions for using the applet loader, in case you have problems figuring out how to make it work:

You must place the following files (plus your program jar) somewhere online:

--- Code: ---jpct.jar
lzma.jar
lwjgl_util_applet.jar
lwjgl.jar.pack.lzma
lwjgl_util.jar.pack.lzma
jinput.jar.pack.lzma
res.jar.lzma
windows_natives.jar.lzma
linux_natives.jar.lzma
macosx_natives.jar.lzma
solaris_natives.jar.lzma
--- End code ---
Plus the two loader image files (in this example I am using paulscodelogo.png and paulscodeprogress.gif)

Next you need to create an html file to load the applet.  Here is the html I used in the gears demo example:

--- Code: ---<html><body>
    <applet code="org.lwjgl.util.applet.AppletLoader"
        archive="http://www.paulscode.com/libs/lwjgl/JARs/lwjgl_util_applet.jar,
            http://www.paulscode.com/libs/lwjgl/JARs/lzma.jar"
            codebase="." width="640" height="480">
            <param name="al_title" value="jPCTGears">
            <param name="al_main" value="jPCTGears">
            <param name="al_logo" value="http://www.paulscode.com/libs/lwjgl/paulscodelogo.png">
            <param name="al_progressbar" value="http://www.paulscode.com/libs/lwjgl/paulscodeprogress.gif">
            <param name="al_jars"
            value="http://www.paulscode.com/demos/jpct/jPCTGears/jPCTGears.jar,
            http://www.paulscode.com/libs/jpct/jpct.jar,
            http://www.paulscode.com/libs/lwjgl/JARs/lwjgl.jar.pack.lzma,
            http://www.paulscode.com/libs/lwjgl/JARs/jinput.jar.pack.lzma,
            http://www.paulscode.com/libs/lwjgl/JARs/lwjgl_util.jar.pack.lzma,
            http://www.paulscode.com/libs/lwjgl/JARs/res.jar.lzma">
            <param name="al_windows" value="http://www.paulscode.com/libs/lwjgl/JARs/windows_natives.jar.lzma">
            <param name="al_linux" value="http://www.paulscode.com/libs/lwjgl/JARs/linux_natives.jar.lzma">
            <param name="al_mac" value="http://www.paulscode.com/libs/lwjgl/JARs/macosx_natives.jar.lzma">
            <param name="al_solaris" value="http://www.paulscode.com/libs/lwjgl/JARs/solaris_natives.jar.lzma">
            <param name="al_version" value="1.0">
    </applet>
</body></html>
--- End code ---

Just substitute your own files and class names.

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.

Edit the file you created, with notepad or other text editor.  Add the line:
AddType application/x-lzma .lzma

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.  Let me know if you need any further clarification.

And for reference, here is a link to the working gears demo applet:
http://www.paulscode.com/demos/jpct/jPCTGears/

.jayderyu:
hey Paul. I think you should put together a comprehensive jpct + applets post|tutorial. Then ask Egon for it to be stickied.

paulscode:

--- Quote from: .jayderyu on November 29, 2008, 12:54:34 am ---hey Paul. I think you should put together a comprehensive jpct + applets post|tutorial. Then ask Egon for it to be stickied.

--- End quote ---
This thread would work fine for that.

Johnston:
U can use Eclipse as IDE it's a good IDE and u can found more than java editor. u can also write the java applet in a bloc note and name the file the same name as the class in(extension .java)
and then compile this file using javac to have the compiled (extension .class)
which u can run using java program
exp:
suppose the name of the first file is myclass.java
u can in command line in the fiolder containing this file write :
javac myclass.java
u will have myclass.class
u can use java to run it if it' defined as application (using main method):
java myclass.class
if ur file is an applet (using paint method) :
u will create a html page that contains the class created by javac using the applet tag as bellow :

<APPLET code="myclass.class" width="500" height="200">
myfirst applet
</APPLET>

here bellow an applet structure:


import java.applet.*;
import java.awt.*;

public class myclass extends Applet
{
public void paint(Graphics g)
{
g.drawString("Hi to all !!!", 30, 30);
}
}

Navigation

[0] Message Index

[#] Next page

Go to full version