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.


Topics - Tornado7

Pages: [1]
1
Support / Relationship between Object3D & texture
« on: October 13, 2004, 03:10:58 pm »
Hi Egon,

I'm writing a rapport about my simulator and I'm writing the chapter about jPCT structure... in your notes you draw, using a solid line, that an Object3D has to have a texture.... but, I've used objs in my applet in which I've applied just simple material without textures, so I'm not pretty sure to understand this necessary relation.....

Bye and thanks

2
Support / Loading textures problem in a web server context
« on: September 08, 2004, 12:35:27 pm »
Hi Egon,

I've to move my jPCT applet in a web server (EasyPHP) context; in my current version I load my textures giving to it a path in my local drive:

Code: [Select]

File dir_texture=new File("C:/Programmi/Java_SDK/bin/textures");        String[] files_texture=dir_texture.list();
       for (int i=0; i<files_texture.length; i++) {
           
            String name_texture=files_texture[i];          
            if (name_texture.endsWith(".jpg")) {          
                texMan.addTexture(name_texture, new Texture(getDocumentBase(),"textures/"+name_texture));             }
         
       }


Running the applet with the web server the Java Console obviously says:

Code: [Select]

java.security.AccessControlException: access denied (java.io.FilePermission textures read)

at java.security.AccessControlContext.checkPermission(AccessControlContext.java:270)

at java.security.AccessController.checkPermission(AccessController.java:401)

at java.lang.SecurityManager.checkPermission(SecurityManager.java:542)

at java.lang.SecurityManager.checkRead(SecurityManager.java:887)

at java.io.File.list(File.java:912)

at ThreeDSimApplet.init(ThreeDSimApplet.java:336)

at sun.applet.AppletPanel.run(AppletPanel.java:348)

at java.lang.Thread.run(Thread.java:536)



exist a way to load the textures in this new context considering that I've to load them automatically, I mean, loading them using a loop as in the current version?

Bye and thanks

3
Support / 3D Objects & IDs
« on: June 28, 2004, 11:17:50 am »
Hi Egon,

I'm here again... I'd ask you in which way, if it's possible, I can express a 3D Object using is ID instead of is name; i.e.:

something like Object3D(ID).animate instead of animateMe.animate

It's possible to force a 3D Object to get a specific id (I've just find out a method to set the id of the next obj)?

Bye and thanks

4
Support / Animation
« on: June 16, 2004, 06:03:19 pm »
Another task: Animation. I have to start an object animation when something happens. First consideration, even if I problably I already know the answer: is it possible to import a keyframed animation created in Maya/3D Studio into jPCT? If, as I suppose, the answer is no let try to see if I have understood that way to create animations in jPCT: I load a 3ds file in which I’ve created variuos poses of my obj to animate (every pose corresponds to a keyframe); I load this file as usual, i.e.:
Code: [Select]

Object3D[] animArray=Loader.load3DS(getDocumentBase(),"3ds/ferito_anim.3ds", 20f);

every element of the array animArray is one of my poses (I guess), so after defining and instanciating an animation:
Code: [Select]

Animation anim;  
anim=new Animation(n);

where  n is the number of keyframes (poses) that I want to use. What is pretty cloudy to me is the way to use mesh (that I’ve to pass to the method addKeyFrame), in your documentation you say:
“Mesh can't be instantiated directly”, so in which way can I use them? After adding all my keyframes to the animation, it simply starts when I start the applet? In which you use the interpolation attributes?

Thanks a thousand of times

5
Support / Displaying Objs Problem
« on: June 16, 2004, 01:46:08 pm »
Hi Egon,

as you know I’m using a config file where an operator can decide how many objs to load and where to place them;  for instance:
Code: [Select]

ferito1=(-591,-74,-90)
ferito2=(-766,-82,246)

my init() is:
Code: [Select]

public void init() {

      theWorld=new World();
 
       String param = getParameter("FileToRead");
       
       if ( param != null){
      FileToRead = new String(param);
       }
       
       // Now read the file.
       readConfigFile();
.
.
.

theWorld.addObject(mondo);
theWorld.addObject(ferito);


where readConfigFile() is method that scans the config file; when it find out a line having the word “ferito”, it passes to a method loadFerito that name (completed with 1 or 2) and his coordinate:
Code: [Select]


public void loadFerito(String name, float x, float y, float z){
     
      texMan=TextureManager.getInstance();
      texMan.addTexture(name+".jpg",new      Texture(getDocumentBase(),"textures/feriti/"+name+".jpg"));
      Object3D[] feritoArray=Loader.load3DS(getDocumentBase(),"3ds/"+name+".3ds", 20f);
      ferito=new Object3D(0);
      ferito=feritoArray[0];
      ferito.setCenter(SimpleVector.ORIGIN);
      ferito.translate (x, y+50, z);
      ferito.rotateX((float)-Math.PI/2);
      ferito.rotateMesh();
      ferito.setRotationMatrix(new Matrix());
     
      ferito.createTriangleStrips(2);
      ferito.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
      ferito.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
     
      ferito.enableLazyTransformations();      
     

  }



Even if the two 3ds object are correctly loaded:

Code: [Select]

Loading Texture...textures/feriti/ferito1.jpg
Loading file 3ds/ferito1.3ds
File 3ds/ferito1.3ds loaded...55321 bytes
Processing new material 1.Mat0Tex1!
Processing object from 3DS-file: polySur
Object 'polySur_jPCT0' created using 694 polygons and 354 vertices.
Created 183 triangle-strips for polySur_jPCT0 in 1 pass(es)
Loading Texture...textures/feriti/ferito2.jpg
Loading file 3ds/ferito2.3ds
File 3ds/ferito2.3ds loaded...54631 bytes
Processing new material 1.Mat0Tex1!
Processing object from 3DS-file: polySur
Object 'polySur_jPCT4' created using 706 polygons and 360 vertices.
Created 178 triangle-strips for polySur_jPCT4 in 1 pass(es)


It’s displayed just the one in the last line of the config file. I guess this behavior is dued by the fact that
Code: [Select]
theWorld.addObject(ferito) is outside loadFerito() and so it passes just the last value of ferito to init(). So I’ve tried to move
Code: [Select]
theWorld.addObject(ferito) in the last line of the loadFerito method (and even
Code: [Select]
theWorld=new World() to avoid a null exception) to try to add an obj to the world for every ferito’s occurance, but nothing changes... Any suggestion.....Bye and thanks  :)

6
Support / Camera position object3D position mismatching
« on: June 14, 2004, 05:51:01 pm »
Hi Egon,

I’ve to implement the following capability: I need to place some objects in the world using custom coordinate. So, for decide where place objects I’ve to move myself in the world (by the camera) and, where I decide to place an object, pressing the right click, my applet has to pass the camera’s coordinate to a html page. I’ve created this feature in this way:

Code: [Select]

if (event.getButton()==MouseEvent.BUTTON3) {
    cameraPosition=camera.getPosition();
    cameraX=(int)cameraPosition.x;
    cameraY=(int)cameraPosition.y;
    cameraZ=(int)cameraPosition.z;
                 clicked=true;
                 rightClick=true;
}


then I’ve created a function that creates and places the object using the camera’s coordinates:

Code: [Select]

public void loadFerito(String name, float x, float y, float z){
     
      texMan=TextureManager.getInstance();
      texMan.addTexture(name+".jpg",new  Texture(getDocumentBase(),"textures/feriti/"+name+".jpg"));
      Object3D[] ferito1Array=Loader.load3DS(getDocumentBase(),"3ds/"+name+".3ds", 20f);
      ferito1=new Object3D(0);
      ferito1=ferito1Array[0];
      ferito1.setCenter(SimpleVector.ORIGIN);
      ferito1.translate (x, y+109, z);
      ferito1.rotateX((float)-Math.PI/2);
      ferito1.rotateMesh();
      ferito1.setRotationMatrix(new Matrix());
     
      ferito1.createTriangleStrips(2);
      ferito1.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
      ferito1.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
     
      ferito1.enableLazyTransformations();
     

  }


My problem is that the object in placed in a different position compared to the camera position where I’ve taken the camera’s coordinates. I guess the resulting camera’s coordinates don’t match the object coordinates method. Exist a way to make a matching?

Bye and thanks

7
Support / A texture error…
« on: June 11, 2004, 04:40:48 pm »
Hi Egon,

another question/problem….. I’m loading textures in a generic way as follow:

Code: [Select]

File dir=new File("C:/Programmi/Java_SDK/bin/textures");    
       String[] files=dir.list();

        for (int i=0; i<files.length; i++) {
         String name=files[i];
         if (name.endsWith(".jpg")) {
            texMan.addTexture(name, new Texture(getDocumentBase(),"textures/"+name));
         }
       }


in init() method. In my previous version I’ve loaded some objs separately from my world in init() method too, as follow:
Code: [Select]

      Object3D[] ferito1Array=Loader.load3DS(getDocumentBase(),"3ds/ferito1.3ds", 20f);
      ferito1=new Object3D(0);
      ferito1=ferito1Array[0];
      ferito1.setCenter(SimpleVector.ORIGIN);
      ferito1.rotateX((float)-Math.PI/2);
      ferito1.rotateMesh();
      ferito1.setRotationMatrix(new Matrix());
     
      ferito1.createTriangleStrips(2);
      ferito1.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
      ferito1.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
     
      ferito1.enableLazyTransformations();


Now, I’m using a config file where I can decide to load or not the above obj, so I’ve decide to move the above code in another method, defined  by myself named loadFerito(). The problem is that when I perform this, the Sun Java Console says:

Code: [Select]
ERROR: A texture with the name 'ferito1.jpg' has been declared twice!

where ferito1.jpg is the texture associated with ferito1.3ds and the obj in the applet is obviously white.
If I move back the loading/defition obj code into the init() method everything works fine. Any explanation ? Bye and thanks

8
Support / Loading generic texture in an Applet
« on: June 08, 2004, 11:32:42 am »
Hi Egon,

as you know I’m loading texture in this way:

Code: [Select]
texMan.addTexture("car1.jpg",new Texture(getDocumentBase(),"textures/car1.jpg"));

in my applet context. Considering that I’m using now a certificate, so I can access to the local filesystem, I’d like to load texture in a generic way using a for cycle (as you do in fps) :

Code: [Select]

File dir=new File("textures");
       String[] files=dir.list();
        for (int i=0; i<files.length; i++) {
         String name=files[i];
         if (name.endsWith(".jpg")) {
            texMan.addTexture(name, new Texture("textures"+File.separator+name));
         }
       }


but, when I run the applet the Java console says:

Code: [Select]

java.lang.NullPointerException
at ThreeDSimApplet.init(ThreeDSimApplet.java:238)
at sun.applet.AppletPanel.run(AppletPanel.java:348)
at java.lang.Thread.run(Thread.java:536)


there’s another way to load texture in a generic way in my context? Bye and thanks

9
Support / Loading texture problem while using certificate
« on: June 04, 2004, 05:20:48 pm »
Hi Egon,

I’ve to improve my applet defining a config file where someone can decide what world or another object to load without handling java’s code… I’ve created a config file and I’ve added this code to my applet:
Code: [Select]

    String line;
    String worldValue;
    String tempFile;
    char checkStart;
    File f = null;
    BufferedReader br = null;
   
   
    public void init() {

   
       tempFile="ThreeDSim.cfg";
       f = new File(tempFile);
       
       try{
       
           br = new BufferedReader(new FileReader(f));
           
       }catch(FileNotFoundException fnfe){
        System.out.println("File not found...");        
        fnfe.printStackTrace();
       
        }
       
       try {
           while ((line = br.readLine()) != null) {

         if (line.length()>0) {
           checkStart = line.charAt(0);
   
                  if (checkStart != '*') {
                 
             if (line.startsWith("world")) {
               worldValue=line.substring(6);
                   }
                   
               }
     
           }

    }
   
       } catch (IOException e) {
    e.printStackTrace();
         }

.
.
.


Obviously, when I open my html page the applet doesn’t load because I’m trying to access a file in an applet context. So, I’ve defined a certificate to let the applet to access the file…. using the certificate I can now access the file and reading informations without problems…. But, the problem now is that no texture is visible in my applet (as you know, I’m loading texture one by one in this way:
Code: [Select]
texMan.addTexture("car1.jpg",new Texture(getDocumentBase(),"textures/car1.jpg"));). If is remove the certificate, textures become visible.... but I can’t access the file…. There’s an explanation for this behaviour?

Bye and thanks

10
Support / A javascript listening problem
« on: May 20, 2004, 12:08:11 pm »
Hi, I hope this is my last problem….. After I’ve got the obj ID, I need to pass this value to a javascript that displays this value in the other side of my web page. So I’ve written the following code:
Code: [Select]


<html>
<head>
<title>ThreeDSim</title>
</head>
<body bgcolor="#000000" text="#FFFFFF" topmargin=0 rightmargin=0 leftmargin=0 marginheight=0 marginwidth=0>
<table>
<tr>
<td>&</td></tr>
<tr>
<td valign="middle" align="left">
<font size="5" face="arial">Road Accident Area</font><br>
<applet name="ThreeDSim"  code="ThreeDSimApplet" width="640" height="480"></applet>
<br>
</td></tr>
<tr>
<td>
 <script type="text/javascript">
    <!--
    var temp = document.applets[0].feritoID;
    document.writeln(temp);
   // -->
  </script>
</td>
</tr>
</table>
</body>
</html>


and it works…. The problem is that the javascript obviously reads the feritoID value just when it’s loaded instead I need that the javascript reads this value whenever I make a click on the applet and so, this value changes. Exist a way to perform this task?

Bye and thanks

11
Support / Interact2D behaviour
« on: May 19, 2004, 02:54:11 pm »
Hi, I’m here again to waste your time… but I’ve another question. I’ve implemented the selection objects function, as I’ve wrote in some previous thread, and I’ve place, as you said,  the following code:

Code: [Select]

SimpleVector ray=Interact2D.reproject2D3D(camera, buffer, mouseX, mouseY);
                     int[] res=Interact2D.pickPolygon(theWorld.getVisibilityList(), ray);

                     if (res!=null) {
                         Object3D pickedObjs=theWorld.getObject(Interact2D.getObjectID(res));
                     }
                     
                     feritoID = Interact2D.getObjectID(res);
                     
                     System.out.println("ID: "+feritoID);


after:

Code: [Select]

 theWorld.renderScene(buffer);


When I run my applet and look in Java Console, I see that it repeats many times the string ID: 120 when I click in the applet on a non-selectable objs (I guess this code is a default code for non-selectable objs) or the string ID: with the selectable obj code. Why it repeats many times this string instead that just one time?
Second question: I need that this string appears on the java console just when I make a click on a obj; I’ve experimented that if I place the mouse’s arrow on the applet window and I use the keyboard keys to move in my scene, when the arrow passes on a selectable obj (without pressing a mouse’s button) appears the string ID: in the java console. Is it possible to prevent this behaviour making string appears just when I press a mouse button?

Bye and thanks a lot
 :)

12
Support / Using mouse in jPCT applet version
« on: May 14, 2004, 12:02:03 pm »
Hi,

I’m experimenting on using mouse in my jPCT applet following, as trace, your way to map keys in your Bounce applet example; so I’ve initialized a variable:

private boolean click=false;

I’ve definited the following method:

public boolean mouseClick(Event e, int key) {
        ProcessKey(key,true);
        return (true);
 }

in ProcessKey I’ve added the following “case”:

case (MouseEvent.MOUSE_CLICKED):     {wire=event; break;}


where ‘wire’ is the the wireframe mode, here just as example. At last, I’ve added the following ‘if’ in the timer():

if (wire) {
                         wireframe=!wireframe;
                }

but, running the applet, nothing happens (using the 1 key, for example, the wireframe mode works, so the problem is just on the mouse event).
I’ve to add a mouse listener….. or something else?

Bye and thanks
 :)

13
Support / Selectable objects
« on: May 12, 2004, 05:08:42 pm »
Hi,

I’d want to have three selectable objs in my jpct’s scene applet and I need, when I do a mouse’s click on one of these, that some text appears, for example showing his id, on the applet area.
I’ve read the Selection Mode thread where you’ve posted the following code:

SimpleVector ray=Interact2D.reproject2D3D(camera, buffer, mouseX, mouseY);
int[] res=Interact2D.pickPolygon(theWorld.getVisibilityList(), ray);

if (res!=null) {
   Object3D pickedObj=theWorld.getObject(Interact2D.getObjectID(res));
}


I’ve made my objs selectable using the following code:

ferito1.setSelectable(ferito1.MOUSE_SELECTABLE); (where ferito1 is an Object3D).

First question: mouseX, mouseY should contain the x,y value of the mouse on the applet area; I guess I’ve to get these values, isn’t so? If it’s so, using which method?

Second question: pickedObj contains the obj that I’ve selected by a mouse’s click? If it’s so, using the method, getID(), I get this obj’s id?


Bye and thanks  :)

14
Support / Switching renderer in an applet context
« on: May 10, 2004, 04:36:53 pm »
Hi,

Is possible to use the fps’s switching renderer option in a applet context? If it’s so, in which way I can fit the dos command line:

java -Djava.library.path=..\..\lib\lwjgl-0.8\ -cp ..\..\lib\lwjgl-0.8\lwjgl.jar;fps.jar -Xmx100000000 JPCTDemo

into the “html code” that loads the applet?

Bye and thanks for any answers
 :)

15
Support / Problem importing 3ds files into applet
« on: April 29, 2004, 12:02:17 pm »
Hi all,

I'm using jPCT to create an University 3d simulation for medical porpouse; I've created a world using Maya and I've converted the Maya's file into a 3DS file using FBX Converter.
When I load the 3DS file using an stand-alone application, such as FPS, the file is loaded without any problem; Problems occur when I try to load the 3DS scene in a applet, such as Bounce; in fact the Sun Java Console shows the following message:

[ Thu Apr 29 11:20:24 CEST 2004 ] - ERROR: Couldn't read file 3ds\prova.3ds
[ Thu Apr 29 11:20:24 CEST 2004 ] - ERROR: Not a valid 3DS file!
Created 0 triangle-strips for object2 in 1 pass(es)
[ Thu Apr 29 11:20:24 CEST 2004 ] - ERROR: Couldn't build() object! Check if the object is assigned to a world and if the TextureManager has all required textures loaded.

Do you have any explaination about this behaviour? Is it possible that 3DS files don't fit in a web application? If it's so, what other file format should I try? Thanks for any help  :)

Pages: [1]