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
Labels:
3d opengl c#
Subscribe to:
Post Comments (Atom)
This comment has been removed by a blog administrator.
ReplyDeleteHi, are you there??? How can i get this code.
ReplyDeleteI will upload it tomorrow
ReplyDeleteHi..can you tell me something more about this project?and about your ShadowEngine?
ReplyDeleteShadow 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!!!
ReplyDeleteso...i can't change something in a house and textures, yes?
ReplyDelete"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?
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.
ReplyDeleteHere 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
ok..i want to know how works this:
ReplyDelete"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.
when the application loads, you tell to the class contentmanager where will be your texture folder
ReplyDeleteContentManager.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?
Also it will help my blog if you become a follower
ReplyDeleteThank you)
ReplyDeleteam, yes..but i have to do something. there are some requirements to the project..like textures or lighting. so..hope NeHe will help me)
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
ReplyDeleteIf you want to do something like txtures you can doenload the source code from shadowengine a play a little with opengl code
ReplyDeletehire you?))..i want to do it myself.
ReplyDeletei want to do something like fog,transparency..zoom
you will find fog on the laberinth demo and transparency on the 3d field demo
ReplyDeleteenjoy it!!! about zoom i dont know what do youi mean
i saw that projects, but i couldn't download them
ReplyDeletezoom..it's like scale..approximation image.
if you tell me what do you want to add to the project i can send you the code!!! for free
ReplyDeletenononono..)you're very cute but i really want to do it myself)you've helped me a lot)thanks
ReplyDeletehasta la vista entonces!!!
ReplyDeleteбувай)
ReplyDeletehello) it's me again)
ReplyDeletecan 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?
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
ReplyDeleteyou forgot to become a follower of my blog it is the least you can do
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeletehm..maybe i didn't understand what you want..look now
ReplyDeletehello were you able to do something
ReplyDeletewant a little help
it wont kill you!!!!
i'm not afraid
ReplyDeletewhat did you want?
ReplyDeletehause 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?
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
Deletepublic void DibujarEscena()
{
here------->
casa.Dibujar();
cielo.Dibujar();
DebugMode.WriteCamaraPos(200, 200);
Collision.DrawColissions();
}
the code that will upload textures? are you writing about this, about changing color?
Deleteno that code is for transparency
Deletebut..ok...look.
Deleteif (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
))))))))))yes! it works))...sory)
Delete"hello were you able to do something
ReplyDeletewant a little help
it wont kill you!!!!"
what did you want???
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
ReplyDeletesorry...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..
ReplyDeleteand i was angry that you said that it wouldn't kill me..so answered ..mm..
ReplyDeleteyes..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
ReplyDeletecheck 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
ReplyDeletehey you impress me you had achieved a lot in this project, not bad for a girl
ReplyDeleteps
the last sentence was a joke dont get me too serious
public static void CenterMouse()
ReplyDelete{
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..?
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
ReplyDeletethis.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
i don't know how to do this..ok.i'll try
ReplyDeletewhat do you mean "to make an article"?here?
yes, if you can
ReplyDeletei don't know how..and maybe not now?..after thursday
ReplyDeleteis there in project stencil?
ReplyDeleteno stencil is used in shadows and in CSG,
Deleteabout the article you dont have to do it if you dont like
)))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)))
ReplyDeleteexplain me what do you want me to do
ok..the last..))
ReplyDeleteis 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?
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.
ReplyDeleteabout 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
moving quickly..not slowly..
ReplyDeletebut 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
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
ReplyDeleteabout stencil, i have a project with stencil but is quite dificult and i doubt you will be going to integrate with your project
ReplyDeleteit works))))))
ReplyDeletebut 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
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
ReplyDeletei have 50 points for project!)it's maximum)))
ReplyDeletewhat did you mean writting about article?
Its a paper where you explain every thing you did in your project and how works every part of it
ReplyDeletearen't you happy for my result??..((..
ReplyDeletewhy do you want me to do this?
of course i am, but 20,000 km of distance do not allow me to buy you a drink to celebrate
ReplyDeleteabout 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?
ha-ha)
ReplyDelete))))))))))
mm..you didn't explain me how to do this article)
and..i'm 18))))
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
ReplyDeletehi) i wrote it..what now?
ReplyDeletehey..where are you??
ReplyDeletelook at me at facebook vasily tserekh
ReplyDeletehello add me on vk.com
ReplyDeleteHello I would like to contact for a job, how can I do?
ReplyDeletehello my mail is vtserej@gmail.com
Deletesend there what you want to do
how can i download the code...??.....
ReplyDeleteExcelente aporte para ir entrando en contacto con el 3D + C# =)
ReplyDeleteParece interesante ShadowEngine, gracias por compartirlo!
Wiserlander.
Hi! It's veeeeeery good! Can I see source code of the Shadowengine?
ReplyDeletebrother 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 :)
ReplyDeleteThis comment has been removed by the author.
ReplyDelete