|
Hello Friends
Do anyone of you know about material(.mtl) file?
Do anyone of you read it?
I read most of the file but some option are not getting through java classes like map_ka(ambient textures),map_ks(specular textures).
Thanks In Advance.
Regards
Yogesh
|
|
|
|
|
hi all
as u know java is using call by reference with objects
how can i instead call by value for objects??
thanks in advance
|
|
|
|
|
Hi,
You can't pass an object by value. The best approximation would be to pass a clone of the object.
And why would you need to pass by value?
|
|
|
|
|
i have arraylist of objects <schedules>
and i wrote a method that take one object <schedule> from the arraylist
and return a modified object <another schedule="">
the problem is after calling the method all objects in the arraylist changed to the new value!!!
when i debuge my program i realized that all objects (in the array list and the returning object) have the same id (i'm using eclipse), which is suppose to be unique
and because of that any changes to object are applied to all version
i don't know way
can you help please??
|
|
|
|
|
from what you told, but did not show, it sounds like you are only creating a single object, and have a loop that (1) modifies it somehow and (2) adds its reference to the arraylist, resulting in a large number of identical references to the single object in its final state.
Check: is the "new Whatever(...)" inside or outside your loop?
If that does not help, then I suggest you show the relevant code.
|
|
|
|
|
my code is very long, that's why i don't write it before
i'm writing a program for multiprocessor using genetic algorithm
<br />
ArrayList <schedule> POP=new ArrayList <schedule>(); <br />
for(int i=0;i<10;i++)<br />
POP.add(generate_schedule());<br />
<br />
ArrayList <schedule> TMP=new ArrayList <schedule> ();<br />
<br />
<br />
for(int j=0;j < NPOP.size()/2;j++)<br />
{<br />
schedule s1=NPOP.get(j);<br />
<br />
schedule s2=NPOP.get(j+(POP.size()/2));<br />
<br />
Random rand=new Random();<br />
double r=rand.nextDouble();<br />
if(r<=CrossOver_prob)<br />
{<br />
ArrayList <schedule> result=new ArrayList <schedule>();<br />
result=crossover(s1,s2);<br />
TMP.add(result.get(0));<br />
TMP.add(result.get(1));<br />
}<br />
else<br />
{<br />
TMP.add(s1);<br />
TMP.add(s2);<br />
}<br />
<br />
}<br />
<br />
for(int j=0;j < TMP.size();j++)<br />
{<br />
System.out.println("schedule"+j);<br />
Random rand=new Random();<br />
double r=rand.nextDouble();<br />
if(r<=Mutation_prob)<br />
POP.add(Mutation(TMP.get(j)););<br />
else<br />
POP.add(TMP.get(j));<br />
}
my problem is on the bold line when calling mutation all schedules in TMP is changed
hope its clear now
|
|
|
|
|
Sorry, that code is hardly readable; please use PRE tags, not CODE tags, so we get indentation and good contrast. You can still edit the existing message.
Furthermore, what needs to be checked is how the values or objects get created that you are adding to the arraylist, hence one has to inspect Mutation(), and whatever is used to create the entries in NPOP (as those will end up in TMP).
|
|
|
|
|
Your question is still not very clear because you didn't provide the function prototype (we can only see the content of the function, not the parameters which are passed).
Anyway, in Java whenever you manipulate an object, it is similar as using a pointer to the object. So, when you pass the object to a function, you pass the pointer and not a copy of the object. If you really need to make changes in a copy of the object, then you have to create a new instance of the object yourself.
There's no such thing as passing by value in java.
|
|
|
|
|
Luc Pattyn
Cédric Moonen
thank u all for your reply
its clear now that's my problem was i don't create a new insantce of my objects
but i referenced to existing object
schedule s = POP.get(i);
where POP is arraylist of schedules
again thank u for ur help
|
|
|
|
|
1.in the same class, you can not directly create objects
2.in other classes, you must create an object to call by value for objects
3.the class can be defined as static ,or you can directly call the class' name
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 8:52am.
|
|
|
|
|
Hello Friends
I m reading a .mtl file(material file) by using Java 3D API.
I am setting the ambient,diffuse and specular color in material.
but when I m loading object without any textures then illumination is coming right.But If I load an Oject with Textures by using TextureLoader then Illumination is not coming.
And I m also enabling material.setLightingEnable while setting Illumination.
Any ideas???
Thanks & Regards
Yogesh
|
|
|
|
|
is ti correct order? first load object, then illumination?
I never finish anyth...
|
|
|
|
|
Obviously,first of all I m loading object then m reading mtl file and as i came to across different tokens in mtl file I am reading tht.First I m applying color to material,then illumination then textures.
Any Ideas??
|
|
|
|
|
Hello friends
I m trying to read a .mtl(material file).For that I m using TextureLoader.
I am able to load diffuse Texture Using:
TextureLoader textureLoader = new TextureLoader(textureImage, TextureLoader.GENERATE_MIPMAP);
currentAppearance.setTexture(textureLoader.getTexture());
textureImage is BufferedImage.
Now ,I want to load ambient map,opacity map and specular map.
So is there any other flag in same class TextureLoader or do i need to use diferent class?
Thanks iN advance
Regards
Yogesh
|
|
|
|
|
After getting TextureLoader,we need to apply TextureAttributes and then TransparenyAtttributes to Appearance.
Anyway,Thanks foe viewing My question.
Regards
Yogesh
|
|
|
|
|
I have GWT application. When i run this application ,the following error occurs,
java.security.AccessControlException: access denied (java.util.PropertyPermission networkaddress.cache.ttl write)
why it is coming?
|
|
|
|
|
a firewall preventing network access?
I never finish anyth...
|
|
|
|
|
Hello Friends
I m creating a canvas3d by using createuniverse() on Initialization.
After tht on open I m adding a scene to it by using addbranchgraph(GroupScene scene).
Now one object is loaded means a scene is added.When Again I tries to open a new file or object then it is also added.I want to clear the old file from scene.I tried cleanup() fn also.But no Luck.
Is there any other Idea to clear the old scene?
Thanks In Advance.
Regards
Yogesh
|
|
|
|
|
|
Hi everybody !
How can i get all url of a site(the input parameter is domain name) using Java.
Thanks !
|
|
|
|
|
Here, I've started it for you:
package NeedsCode;
public class Main {
public static void main(String[] args) {
throw new UnsupportedOperationException(
"The program code needs to be implemented.");
}
}
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Hello Friends
I m creating a swing based application that loads some 3d Object.
When I run that thru NetViewer then It is working properly .Its opening and when I m loading any file it is coming Fine.
But If I Executes Jar file separately then Its opening but when I tries to open file then It is not opening.
Is it bcoz of some heap size that doesnt get load at run time?Or some other thing?
Any Ideas??
Thanks & Regards
Yogesh
|
|
|
|
|
yogeshs wrote: But If I Executes Jar file separately then Its opening but when I tries to open file then It is not opening.
Do you get any error messages or status codes in your code?
|
|
|
|
|
No,I didnt get any error messages
When I open any file thru openfile dialog then tht dialog just get off and nothing happens.
|
|
|
|
|
yogeshs wrote: When I open any file thru openfile dialog then tht dialog just get off and nothing happens.
I cannot begin to guess from your description what may be happening. Look at your code and see what it is doing after the Open call. You may need to run it through the debugger to check variable values etc.
|
|
|
|