Pages

Wednesday, August 17, 2011

3d house with sources


In this example I have loaded a 3ds file. Shadows are pre-rendered on the texture, so they run fast on video cards.

collisions are implemented in a very easy way. I used line collisions, that means that in order the camera not to go through a wall yo most provide the 2d coordinates of both ends, they form a line and camera always calculate the distance to that line and if is less than some precalcuated value, then there is a collision and the camera will not go in that direction. There is also in one room a fan working, Ive calculated the pivot point so I can rotate it. If you have any questions regarding this, post it here, anonymous comments are enabled.

here is the download link
http://fbe.am/2ND

72 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. Hi, are you there??? How can i get this code.

    ReplyDelete
  3. Hi..can you tell me something more about this project?and about your ShadowEngine?

    ReplyDelete
  4. Shadow engine is a very lightweight graphic framework for opengl and C# it has a content manager which load models textures sounds, some helper classes and a small collision algorithm all is made in a very easy way, If you see the code you will find it very simple. About the project its just a house created in 3d max and exported in 3ds format. If you want to know more or have something in mind, let me know!!!

    ReplyDelete
  5. so...i can't change something in a house and textures, yes?
    "Mesh aspa"??and Lighting..how it works? mmm..what else.."ventilado0" - it is a separate detail?or was also made in 3d max? how you rotate it?in this part of code, or not ? -"aspa.CalcCenterPoint(); m.RemoveMeshByName("ventilado0");" - functions from aspa?

    ReplyDelete
  6. aspa is the mesh on the house corresponding with the fan i separate it from the model because i am going to rotate it and when i call to the function aspa.CalcCenterPoint() it calcutes the pivot point on the center of the mesh.

    Here is how i rotate the mesh

    Gl.glTranslatef(aspa.CenterPoint.X, aspa.CenterPoint.Y, aspa.CenterPoint.Z);
    Gl.glRotatef(-anguloAspa, 0, 0, 1);
    Gl.glTranslatef(-aspa.CenterPoint.X, -aspa.CenterPoint.Y, -aspa.CenterPoint.Z);

    anguloAspa translated to english is ange of the fan i increment it every frame.

    about lighting is a default lighting i apply to the scene.
    . I just saw your profile is amazing a girl likes these topics, by the way my father is from ukraine like you i speak a little russsian

    ReplyDelete
  7. ok..i want to know how works this:
    "Gl.glBindTexture(Gl.GL_TEXTURE_2D, ContentManager.GetTextureByName(aspa.Name + ".jpg")); "
    there is a folder "texturas". it takes pictures from it..but how it distinguishes texturas..i mean in right order..?

    )..mm..Applied Mathematics,..subject Computer Graphics)i need to know it.

    ReplyDelete
  8. when the application loads, you tell to the class contentmanager where will be your texture folder

    ContentManager.SetTextureList("texturas\\");
    ContentManager.LoadTextures();

    opengl identifies a texture by a number not a string and then i create a dicctionary internally the binds the texture name with his opengl number and when i call gettexture by name it returns the opengl number of the texture.
    Also I exported the meshes with the same name as the texture associated with it. Thats why I request the texture with the mesh name + jpg, are you going to present my demo, do you want more explanations?

    ReplyDelete
  9. Also it will help my blog if you become a follower

    ReplyDelete
  10. Thank you)
    am, yes..but i have to do something. there are some requirements to the project..like textures or lighting. so..hope NeHe will help me)

    ReplyDelete
  11. I work freelance if you like you can hire me in vworker.com and i will do all the work, or if in your class someone wants to hire me to get the job done let me know

    ReplyDelete
  12. If you want to do something like txtures you can doenload the source code from shadowengine a play a little with opengl code

    ReplyDelete
  13. hire you?))..i want to do it myself.
    i want to do something like fog,transparency..zoom

    ReplyDelete
  14. you will find fog on the laberinth demo and transparency on the 3d field demo
    enjoy it!!! about zoom i dont know what do youi mean

    ReplyDelete
  15. i saw that projects, but i couldn't download them
    zoom..it's like scale..approximation image.

    ReplyDelete
  16. if you tell me what do you want to add to the project i can send you the code!!! for free

    ReplyDelete
  17. nononono..)you're very cute but i really want to do it myself)you've helped me a lot)thanks

    ReplyDelete
  18. hello) it's me again)
    can you tell me where are Light Positions and can i change them? and about transparency..i wrote a code and i can turn on and off it..but i can't make dissapiaring of the house slowly..i mean..to make transparency step by step. why? because it's building in 3ds?
    and..can i open and close louver?)i think that it's possible..but i need open casa file like 3ds file?

    ReplyDelete
  19. about the lights remember that the shadows are prerendered on the textures, there is a line at the begining lighting.enabledefaultlighting or something like that, you should uncomment it and place the light were you want with your own code, about open and close the door, you need the name of the door, take a look at how i move the fan. About to dissapear the house slowly yo ned to place that code on the draw function and decremente that alpha value until it reaches 0

    ReplyDelete
  20. you forgot to become a follower of my blog it is the least you can do

    ReplyDelete
  21. This comment has been removed by a blog administrator.

    ReplyDelete
  22. hm..maybe i didn't understand what you want..look now

    ReplyDelete
  23. hello were you able to do something
    want a little help
    it wont kill you!!!!

    ReplyDelete
  24. what did you want?

    hause is black outside...can i change this? in what program did you create it?
    and about dissapearing..i place code in draw function, decremente alpha value until it reaches 0, but..the house doesn't dissapear slowly..the grass, and all around the house dissapear, but house not. why?

    ReplyDelete
    Replies
    1. yes you can change the house color but you have to edit the textures in photoshop and that is a little difficult about the house where are you placing that code, if you want help i have to see the source code you should place it here

      public void DibujarEscena()
      {
      here------->

      casa.Dibujar();
      cielo.Dibujar();
      DebugMode.WriteCamaraPos(200, 200);
      Collision.DrawColissions();
      }

      Delete
    2. the code that will upload textures? are you writing about this, about changing color?

      Delete
    3. no that code is for transparency

      Delete
    4. but..ok...look.
      if (MainForm.trans == true)
      {
      Gl.glEnable(Gl.GL_COLOR_MATERIAL);
      Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
      Gl.glEnable(Gl.GL_ALPHA_TEST);
      Gl.glEnable(Gl.GL_BLEND);
      // Gl.glDisable(Gl.GL_DEPTH_TEST);
      Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
      Gl.glColor4d(1, 1, 1, MainForm.transdensity);
      }
      else

      {
      Gl.glDisable(Gl.GL_COLOR_MATERIAL);
      Gl.glDisable(Gl.GL_BLEND);
      //Gl.glEnable(Gl.GL_DEPTH_TEST);
      Gl.glDisable(Gl.GL_ALPHA_TEST);}
      this part of code is in Casa.cs
      and in MainForm:
      if (e.KeyCode == Keys.T)
      {
      if (trans)
      {
      trans = false;
      }
      else
      {
      trans = true;
      }
      }

      if ((e.KeyCode == Keys.O) && (trans == true))
      {
      if (transdensity < 1f) transdensity = transdensity + 0.02f;
      }

      if ((e.KeyCode == Keys.P) && (trans == true))
      {
      if (transdensity > 0.0f) transdensity = transdensity - 0.02f;
      }

      and it works..but not for house. if i'll place it from Casa to where you told it wouldn't work

      Delete
    5. ))))))))))yes! it works))...sory)

      Delete
  25. "hello were you able to do something
    want a little help
    it wont kill you!!!!"

    what did you want???

    ReplyDelete
  26. i just was asking if you were able to get your work done, i am exited someone i using my code and someone from the motherland. there is no need to be rude

    ReplyDelete
  27. sorry...i didn't mind to be rude. i didn't understand you. "want a little help" - i thought that YOU want a little help, and that the fact that i'll help you wouldn't kill me..i'm so sory for that..

    ReplyDelete
  28. and i was angry that you said that it wouldn't kill me..so answered ..mm..

    ReplyDelete
  29. yes..what have i done...i can go out of the house, there is a fog, and i can change density of it..transparency also with changing. pictures))..lighting..what else...added AboutBox..and now i want to add one more form. ..i want ..to make a menu on that form. when i call it..and press some keys or what there must be some changes in main form..do you understand?)))but there is a problem..when i call About box, or another form it appears..but mouse is still responsible for movement..and i don't know yet what is wrong

    ReplyDelete
  30. check out on the function that center the mouse, ask first if the active property of the form is on true and then center the mouse otherwise not

    ReplyDelete
  31. hey you impress me you had achieved a lot in this project, not bad for a girl
    ps
    the last sentence was a joke dont get me too serious

    ReplyDelete
  32. public static void CenterMouse()
    {
    MainForm mf;
    mf = new MainForm();
    if (mf.Enabled==true)
    Winapi.SetCursorPos(MainForm.FormPos.X + 512, MainForm.FormPos.Y + 384);

    }

    it doesn't work..it causes an error - "An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
    Additional information: An item with the same key has already been added."
    am i doing something wrong..?

    ReplyDelete
  33. no, no , no you are building an instance of a form each time you draw a scene, you should refer to the instance of the form that contains the scene
    this.Activated not Enabled
    BTW can you make an article of the project so i can publish it here, you tell what you want how did you learned the skills and stuff like that

    ReplyDelete
  34. i don't know how to do this..ok.i'll try

    what do you mean "to make an article"?here?

    ReplyDelete
  35. i don't know how..and maybe not now?..after thursday

    ReplyDelete
  36. Replies
    1. no stencil is used in shadows and in CSG,
      about the article you dont have to do it if you dont like

      Delete
  37. )))i don't know how to make an article..and now i don't have enough time)))i wrote after thursday because on that day i must show project and after it i can make that article.i have to study a lot..and pass different tests..mm then i'll have exams.it's session time)))
    explain me what do you want me to do

    ReplyDelete
  38. ok..the last..))
    is there material and what kind..and where?

    and with instances. i'm doing something wrong..there is a little progress)))-because when i call another form and it appears i can click on it..and make some changes, but (!!) camera on mainform is very strange..it rotates very quickly.how can i stop it??
    "if ((!SKA_About.ActiveForm.Enabled) && (!Menu.ActiveForm.Enabled))
    Winapi.SetCursorPos(...); "..hm..i know why it rotates..because at the begining the cursor isn't determined, yes?but i don't know how to change this. SKA_About and Menu are my new forms. can you tell me how to do it correct?

    ReplyDelete
  39. first it is best to check for the activated property, because when a form is enabled if you desire to switch to another application the mouse will still stuck in the middle of the screen.
    about camera moving very slowly i think that happens when you dont center it in the very middle of the screen, debug the update function of the camera an check if when you dont move the mouse the is a delta X or delta Y greater than zerom if so you will have to make changes there

    ReplyDelete
  40. moving quickly..not slowly..
    but there is no activated property.
    ok...hmm..look. how to stop camera? when mainform is enable(or active) mouse is responsible for moving..yes?but when i call another form. what must happen..stop moving and mouse is responsible for making changes in new form. you told to make changes in the function that center the mouse..i tried to make it. i want to set the cursor when new form is disable and to stop moving mose when new form is enabled..and you explained me something another

    ReplyDelete
  41. you should not update your scene when you are opening other form, try to put the enabled property of the timer to false when drawing another form and when the mainform is activated place the timer on, also consider to show your form with showdialgog not show

    ReplyDelete
  42. about stencil, i have a project with stencil but is quite dificult and i doubt you will be going to integrate with your project

    ReplyDelete
  43. it works))))))
    but the changes which i make on new form appear on the mainform only after closing new form)))it's very funny..really)

    stencil..i asked only..and about material

    ReplyDelete
  44. of course they should appear when you close it, because the scene will begin to update again, and there is when you see the changes ;also showing a form with showdialgog is sinlge threaded

    ReplyDelete
  45. i have 50 points for project!)it's maximum)))
    what did you mean writting about article?

    ReplyDelete
  46. Its a paper where you explain every thing you did in your project and how works every part of it

    ReplyDelete
  47. aren't you happy for my result??..((..
    why do you want me to do this?

    ReplyDelete
  48. of course i am, but 20,000 km of distance do not allow me to buy you a drink to celebrate
    about the article you dont have to do anything but an article will improve my blog and somehow will show some gratitude to the person who helped you to get tah score
    happy celebration
    ps
    by the you seem like a 15 year old girl, how old are you?

    ReplyDelete
  49. ha-ha)
    ))))))))))
    mm..you didn't explain me how to do this article)
    and..i'm 18))))

    ReplyDelete
  50. there is no explanation, you should only write about what you havedone step by step and trying not to be boring one sheet will enough, also a printscreen will be useful too

    ReplyDelete
  51. look at me at facebook vasily tserekh

    ReplyDelete
  52. Hello I would like to contact for a job, how can I do?

    ReplyDelete
    Replies
    1. hello my mail is vtserej@gmail.com
      send there what you want to do

      Delete
  53. how can i download the code...??.....

    ReplyDelete
  54. Excelente aporte para ir entrando en contacto con el 3D + C# =)
    Parece interesante ShadowEngine, gracias por compartirlo!

    Wiserlander.

    ReplyDelete
  55. Hi! It's veeeeeery good! Can I see source code of the Shadowengine?

    ReplyDelete
  56. brother u did an excellent job , i m a beginner to this , ur code helped me alot , keep up the good job and GOD bless u for helping others , thanks alot , lots of prayers from ur sister :)

    ReplyDelete
  57. This comment has been removed by the author.

    ReplyDelete