importing new object into

JaiJai
edited December 2015 in Library Questions

Hello there i was playing in Processing2 and found a example that would look very cool with one of my friends objects files but i dont see a tutorial about merging code because the other code or example i would have to merge would have to be the one that allows me to import a object file into Processing2 and altho it looks simple i got several errors when i try to run and then when it did ran after i changed things around i got the normal example to run but the obj imported did not show up but i can tell that it is in there because the example was running a little laggy then before i started to mergea little pointer would go along way fellows.

now i included below the normal example found in Processing, what im asking if someone can tell me where i should be copying and pasting the example that lets me import object files which i think is under OBJloader?

import saito.objloader.*;

OBJModel model ;

float rotX, rotY;

void setup()
{
    size(800, 600, P3D);
    frameRate(30);
    model = new OBJModel(this, "dma.obj", "absolute", TRIANGLES);
    model.enableDebug();    
    model.scale(20);
    model.translateToCenter();    
    stroke(255);
    noStroke();
}

void draw()
{
    background(129);
    lights();
    pushMatrix();
    translate(width/2, height/2, 0);
    rotateX(rotY);
    rotateY(rotX);  
    model.draw();    
    popMatrix();
}

and here is the other one i would like to merge this top one to the one in the bottom

void setup() 
{
  size(1800, 900, P3D);
  cursor(CROSS);
  terrain = new Terrain(this, 60, terrainSize, horizon);
  terrain.usePerlinNoiseMap(0, 40, 0.15f, 0.15f);
  terrain.setTexture("grass2.jpg", 4);
  terrain.tag = "Ground";
  terrain.tagNo = -1;
  terrain.drawMode(S3D.TEXTURE);
  skybox = new Box(this, 1000, 500, 1000);
  skybox.setTexture("back.jpg", Box.FRONT);
  skybox.setTexture("front.jpg", Box.BACK);
  skybox.setTexture("left.jpg", Box.LEFT);
  skybox.setTexture("right.jpg", Box.RIGHT);
  skybox.setTexture("sky.jpg", Box.TOP);
  skybox.visible(false, Box.BOTTOM);
  skybox.drawMode(S3D.TEXTURE);
  skybox.tag = "Skybox";
  skybox.tagNo = -1;

  nbrDroids = 16;
  droids = new Cone[nbrDroids];
  droidDirs = new PVector[nbrDroids];
  for (int i = 0; i < nbrDroids; i++) 
  {
    droids[i] = new Cone(this, 10);
    droids[i].setSize(5, 5, -20);
    droids[i].moveTo(getRandomPosOnTerrain(terrain, terrainSize, 50));
    droids[i].tagNo = 100;
    droids[i].fill(color(random(128, 255), random(128, 255), random(128, 255)));
    droids[i].drawMode(S3D.SOLID);
    droidDirs[i] = getRandomVelocity(random(15, 25));
    terrain.addShape(droids[i]);
  }
  obelisk = new Ellipsoid(this, 4, 20);
  obelisk.setRadius(5, 30, 5);
  obelisk.moveTo(getRandomPosOnTerrain(terrain, terrainSize, 28));
  obelisk.fill(color(0, 255, 0));
  obelisk.tag = "Globe";
  obelisk.tagNo = 1;
  obelisk.setTexture(textures[1]);
  obelisk.drawMode(S3D.TEXTURE);
  tube = new Tube(this, 10, 30);
  tube.setSize(3, 10, 6, 6, 20);
  tube.moveTo(getRandomPosOnTerrain(terrain, terrainSize, 15.5));
  tube.tagNo = 0;
  tube.setTexture(textures[1]);
  tube.drawMode(S3D.TEXTURE);
  tube.fill(color(255, 0, 0), Tube.S_CAP);
  tube.fill(color(0, 255, 0), Tube.E_CAP);
  tube.drawMode(S3D.SOLID, Tube.BOTH_CAP);
  camSpeed = 0;
  cam = new TerrainCam(this);
  cam.adjustToTerrain(terrain, Terrain.WRAP, camHoversAt);
  cam.camera();
  cam.speed(camSpeed);
  cam.forward.set(cam.lookDir());
  terrain.cam = cam;  // Tell the terrain what camera to use
  time = millis();
}

and this is the loop

void draw() 
{
  background(0);
  // Get elapsed time
  long t = millis() - time;
  time = millis();

  update(t/1000.0);  // Update shapes on terrain
  if (mousePressed)   // Update camera speed and direction
    processMousePressed();
  if (keyPressed) 
    processKeyPressed(t);
  if (clicked)  // Clicked on artefact?
    processMouseClick();
  cam.move(t/250.0);  //1000
  // Calculate amount of movement based on velocity and time
  // Adjust the cameras position so we are over the terrain
  // at the given height.
  cam.adjustToTerrain(terrain, Terrain.WRAP, camHoversAt);
  // Set the camera view before drawing
  cam.camera();
  obelisk.draw();
  tube.draw();
  terrain.draw();
  // Get rid of directional lights so skybox is evenly lit.
  skybox.moveTo(cam.eye().x, 0, cam.eye().z);
  skybox.draw();
}
Tagged:

Answers

  • edited December 2015

    it's really not hard to do....

    just copy the stuff from one setup() into the other setup

    and the stuff from one draw() into the other draw

    then make some housecleaning: you must have only one size and only one background normally

    copy also the global variables (the ones before setup()) into the new version

    make sure there are no duplicates

  • @Chrisir i know this is not the question tho i was referring to the whole sub conditional statements in one sketch and merging to the new sketch that night have its own conditionals as well how do one know which sub goes first ?

  • Which is first doesnt matter

    Just do it and debug it

  • but i did lol how you think my ship ended up lost in my code now Chris ? i still cant find it and i hate to give up on this being so dam close this would actually be a nice game specially being my first

  • Post your code

    Entire

  • @Chrisir The second sketch code is an example (S3D4P_Terrain) from the Shapes3D library S3D4P_Terrain so you can get all the code and images from that.@Jai would have to make the model available for download I am sure you could combine them for him.

    In fact I did create a game (January 2010) based on this example that used MD2 models, it was called Gah Invaders :)

  • i am on a journey

    can help you later

    what is the problem

    why is it so hard?

  • i can email you the stuff that arent in the game guy like my elements, well as for whats the big issue the game is hiding my ship i even made it huge in scale and i still cant see it, but if i comment everything else its there so let me know how i can help you guys help me ;)

  • guys what is this ? i was trying to check the reff of a syntax that i thought might help me but i go this, i access this right clicking on that syntax and scrolling down to "find in reference" instead i got this,

    java.io.IOException: Failed to open file:/C:/Program%20Files%20(x86)/processing-2.2.1/modes/java/reference/PVector_mult_.html. Error message: A device attached to the system is not functioning.
    
        at sun.awt.windows.WDesktopPeer.ShellExecute(Unknown Source)
        at sun.awt.windows.WDesktopPeer.browse(Unknown Source)
        at java.awt.Desktop.browse(Unknown Source)
        at processing.app.Platform.openURL(Platform.java:115)
        at processing.app.Base.openURL(Base.java:2030)
        at processing.app.Editor.showReference(Editor.java:1167)
        at processing.app.Editor.handleFindReference(Editor.java:2004)
        at processing.app.Editor$TextAreaPopup$9.actionPerformed(Editor.java:2695)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.AbstractButton.doClick(Unknown Source)
        at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
        at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$200(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(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)
    

    how can i fix this so all my future checks actually direct me to the right html?

  • edited December 2015

    file:/C:/Program%20Files%20(x86)/processing-2.2.1/modes/java/reference/PVector_mult_.html

    It's very advisable to stay away from Windows' system folders like %ProgramFiles% for example!

    Favor uncompressing Processing's installation in some folder you control like %HOMEPATH%/Documents.

  • JaiJai
    edited December 2015

    loop thanks for the input but WTF did you just said ?! lol im lost all i heard was stay away from windows? what! are you talking about the OS ? cuz im sorry but Windows is that shizzle

    Processing nd Arduino i install the same way on to my C drive and their folders to my documents nd i dont have this issue with Arduino

  • The OS is ok

    The path worries him

  • JaiJai
    edited December 2015

    ah ic thanks chris so theres no way to fix this guys?

  • I don't know the issue

    when @gotoloop is right re-install processing on a clean path like c:\programming\ or so

    as for the sketch: I am on a journey and can't take a look now. Why not upload the obj and ressources to drop box and post the link here ? So people can debug it

  • ill send to any of you but open source is not my aim, specially if the same individuals who are going to use arent going to help guys, does this sounds logical and or reasonable ? i dont mind putting the code cuz is not mine tho by the time im finished with it it wont be the same code therefor now mines, but the obj files and everything else is mine and i tend to release it/share with everyone once its completed

  • i dont mind putting the code cuz is not mine tho by the time im finished with it it wont be the same code therefor now mines,

    You only own the modifications, any unmodified code still belongs to the original author. In this case the original code is mine and I put it into the public domain for people to enjoy and learn from. That's not just the example you are trying to modify but also the whole Shapes3D library. Also there is the author of the Object Loader library to consider. The 3D model you intend to use - do you have a right to use it? Have you checked the license agreement?

    ill send to any of you but open source is not my aim, specially if the same individuals who are going to use arent going to help guys,

    Processing is open source. The contributed libraries and tools are open source. The help provided on this forum is freely given. There are very few excuses for for not sharing code, the only reasonable one is if you are writing the code for economic or academic gain.

    It seems that you are quite happy to accept help from others but are not willing to share that help. If you want private help then you should be prepared to pay for it.

    The people posting questions on this forum are on a journey from code that doesn't work to a working solution (hopefully). Providing the solution without showing the journey is not helping others trying to do the same thing.

    As to helping others, there are many users on this forum who would like to help but have not gained enough skills or experience to do so yet. Should we deny them the opportunity to learn from other people's journeys.

    I urge you to think again about making your efforts public domain, after all Processing would not be the success it is if wasn't for public domain software.

    Have a Merry Christmas :)

  • edited December 2015

    I fully agree

    thanks for sending me your code and obj

    I'll take a look later after my journey

  • JaiJai
    edited December 2015

    No you have a point Quark, but nevertheless you misunderstand my input and taking it literal, this is not a conversation about rights this is a conversation about me taking my ideas and sharing it while not fully completed so that not only someone takes one of my dreams/ideas and finish it and make it theirs but defeating the whole self purpose and or motivation which for obvious reasons is not going to happen, further more while libraries being used i never seen any code with 100's of #includes or imports headers files or what not being honor the respect and or credit "you only see that in movies and even that has a whole 5mins of credits because is long" programming wise that would be a dedication of importing every authors name and being the main reason why i never seen this format in ppl source file, taking you for example your original sketch did not contain the authors of the various libraries being used "i think you get my point" which is why i did not when into that whole conversation since this forum like you said is to discuss journey from code that doesn't work to a working solution (hopefully).

    It seems that you are quite happy to accept help from others but are not willing to share that help.

    i think your talking about someone else lol cuz i dont know what does me sharing my idea has to do with me helping or not helping someone else? im all about help specially after you little comment "there are many users on this forum who would like to help but have not gained enough skills or experience to do so yet. " i think what your trying to say is that i should help others replicate my journey and whats original about that and who does that ? i dont see or heard of Ben Fry and Casey Reas helping everyone else get to where they are today YES they do want to help others but they not trying to have someone else recreate THIS very forum its content documentation and so on, i think you get my point, ppl including me are more then willing to help where can tho this does not mean i would help someone achieve my journey cuz duh its my journey lol get your own "jk" dont you worry i will include your name as original creator of where i got the concept example from "the foundation" of which i used to build my whole new project on or the game engine if you will.

    Processing would not be the success it is if wasn't for public domain software. this is exactly what i will be saying about myself one day about myself

    and btw yes i own all rights to my 3D designs, dont you for a second think that im just scavenging everything online to rewrite its algorithms with some better more sophisticated formulas to just make mines "even old un-maintain source files"

    and last but not least i believe theirs 2 types of individuals in the world of the keyboard, one is the one who dont know how to code but has great ideas but does understand syntax and libraries and can actually manage a team of professionals programmers to makes something new and useful, the second programmer is the one who knows his shit but lacks the mentality to innovate and his so good that he actually became the computer being the reason why his nice and just like a computer are made for multitasking but are only good at one thing "programming, running code" this 2 individuals can work together and benefit profit off of each other and help those by their innovations, so going back to your comment "economic or academic gain" yes this can be either or starts of as a educational thing "learning" ends up being the other one profit, so now falling back into the paying for services, well again im more then willing to pay assuming of course those involve lead to success cuz of their work, often ppl care more about the characters in a game plots and graphics quality, this is what im bringing to the physics environment that you made Quark, think of a game company they have lots of departments involved in making a game, well...... your one im the other, your trying get paid? well lets do this! i might not be all that in writing code but i am talented in other fields

    Have a Mmmerry Christmas !

  • when you obj shows up in the one sketch

    and it doesn't in the other/ new sketch, something is wrong here

    your obj might be behind the canvas/ bg image, so either comment out the bg image

    or the fill might be off, so comment out noFill or similar stuff

    see also

    https://forum.processing.org/two/discussion/comment/57628/#Comment_57628

  • because he had the same issue and solved it

  • I may have misunderstood you in which case I am sorry.

    I wasn't asking you to share your ideas but to share the process of solving the problem expressed in this discussion.

  • ill be more then happy to document a walk thru with a link to a video ill make and leave the link for anyone to read/watch and solve their issues Quark, Chris ill take a look thanks

Sign In or Register to comment.