PDA

View Full Version : گفتگو: تمرین های OpenGL



amin1softco
سه شنبه 24 فروردین 1389, 18:27 عصر
خوب اینجور که پیداست من هر چقدر سوال می پرسم آخرش خودم باید جواب بدم حالا اینجا تاپیک رو ایجاد کردم که سوال ها و تمرین هایی رو که به نظرم می رسه بزارم اگه دوستان هم سوالی دارن که زیاد سخت نیست مطرح کنند بلاخره با هم دیگه حل می کنیم .

و در اصل سوالم این بود که چطور می تونیم گوشه های مکعب را گرد کنیم که حالت تیز بودنش از بین بره؟
یک سوال دیگه داشتم که چطور برنامه دو تا آونگ با هم برخورد می کنندرو بنویسیم؟ یعنی مثل حالت طبیعی دو تا کره به هم دیگه بخورند و بر گشت دده بشند البته با الگوریتم تشخیص برخود؟

سوال دیگه ایی که داشتم اینه که چطوری می شه چندتا ابجکت رو با هم گروه کرد که یعنی به همی دیگه متصل کرد مثل کف و مچ دست با ساعد؟

راحتترین راه لود آبجکت چیه؟

pswin.pooya
سه شنبه 24 فروردین 1389, 20:28 عصر
1. باید یک مش لودر بنویسی (راحترینش obj هست). کتالب هم focus on 3d models

2. ربطی به OpenGL نداره باید با فریم ورکهای فیزیک کار کنی مثل Physix و یا ODE

3. اگر میخوای آبجکت ها بهم متصل باشن مثلا وقتی که کامیون رو حرکت میدی اشیاء داخلش حرکت کنن. باید ماتریس نمامدل شی پدر رو در فزرند ضرب کنی (برای فرزند). توی این حالت باید به صورت درختی نوذهای صحنه رو نگه داری کنی: و اگر میخوای انیمیشن داشته باشی چند راه معمول هستش:



keyframe: هر فریم به صورت داده جدید ذخیره میشه
skeletal: اسکلتی، تمامی ورتکس ها متصل به استخوانهای مالک اونها هستن که با حرکت استخوان ورتکس ها هم حرکت میکنه. بطور خلاصه ماتریس نمامدل استخوان در ورتکسها ضرب میشه و هر استخوان هم یک پدر و تعدادی فرزند داره که ماتریس نما مدل پدر در فرزندها ضرب میشه تا ماتریس نما مدل فرزند بدست بیاد.
morph: ترکیبی میانی یک فریم با فریم دیگه هستش که بیشتر توی انیمیشن صورت استفاده میشه.

انیمیشن اسکلتی نصبت به کی فریم بهتر هستش:


داده کمتر ذخیره میشه.
انعطاف پذیری بیشتر داره.
میتونه با فیزیک ترکیب بشه.
امکان ساخت انیمیشن در اجرای بازی هستش.
امکان موارد مثل جدا کردن و یا چسباندن استخوانهای جدید و ... رو فراهم میکنه.

و البته بدی های خاص خودش رو داره:


امکان ذخیره کردن در سخت افزار رو نداره به جزء حالت skining
هر نوع انیمیشن رو نمیشه باهاش پیاده سازی کرد.
معمولا هزینه ضرب ماتریسیش بالا هستش. (نصب به اونی که قبلا محاسبه شده)

یه باز هم توی تاپیک آموزش OpenGL گفتم: قبل از هر کاری ماتریس ها رو یاد بگیرید. اگر این کار رو نکنید نمی تونید جلو برید. برای شروع هم میتونید از سورس های آماده ماتریسها استفاده بکنید.

sanaz88
یک شنبه 29 فروردین 1389, 19:33 عصر
سلام می خواستم بپرسم شما میتونید 10 تا تابع کمکی gl_ شبیه gl_false یا gl_lighting نام ببرید و کاربردشون رو توضیح بدین
ممنون میشم ازتون

amin1softco
یک شنبه 29 فروردین 1389, 23:16 عصر
من انگلیسیم زیاد تعریفی نیست اما خوب اینها رو خودتون ترجمه کنید:

glEnable and glDisable enable and disable various capabilities. Use glIsEnabled or glGet to determine the current setting of any capability. The initial value for each capability with the exception of GL_DITHER is GL_FALSE. The initial value for GL_DITHER is GL_TRUE.

Both glEnable and glDisable take a single argument, cap, which can assume one of the following values:

GL_ALPHA_TEST
If enabled, do alpha testing. See glAlphaFunc.
GL_AUTO_NORMAL
If enabled, generate normal vectors when either GL_MAP2_VERTEX_3 or GL_MAP2_VERTEX_4 is used to generate vertices. See glMap2.
GL_BLEND
If enabled, blend the incoming RGBA color values with the values in the color buffers. See glBlendFunc.
GL_CLIP_PLANE i
If enabled, clip geometry against user-defined clipping plane i. See glClipPlane.
GL_COLOR_LOGIC_OP
If enabled, apply the currently selected logical operation to the incoming RGBA color and color buffer values. See glLogicOp.
GL_COLOR_MATERIAL
If enabled, have one or more material parameters track the current color. See glColorMaterial.
GL_COLOR_TABLE
If enabled, preform a color table lookup on the incoming RGBA color values. See glColorTable.
GL_CONVOLUTION_1D
If enabled, perform a 1D convolution operation on incoming RGBA color values. See glConvolutionFilter1D.
GL_CONVOLUTION_2D
If enabled, perform a 2D convolution operation on incoming RGBA color values. See glConvolutionFilter2D.
GL_CULL_FACE
If enabled, cull polygons based on their winding in window coordinates. See glCullFace.
GL_DEPTH_TEST
If enabled, do depth comparisons and update the depth buffer. Note that even if the depth buffer exists and the depth mask is non-zero, the depth buffer is not updated if the depth test is disabled. See glDepthFunc and
glDepthRange.

GL_DITHER
If enabled, dither color components or indices before they are written to the color buffer.
GL_FOG
If enabled, blend a fog color into the posttexturing color. See glFog.
GL_HISTOGRAM
If enabled, histogram incoming RGBA color values. See glHistogram.
GL_INDEX_LOGIC_OP
If enabled, apply the currently selected logical operation to the incoming index and color buffer indices. See
glLogicOp.

GL_LIGHT i
If enabled, include light i in the evaluation of the lighting equation. See glLightModel and glLight.
GL_LIGHTING
If enabled, use the current lighting parameters to compute the vertex color or index. Otherwise, simply associate the current color or index with each vertex. See
glMaterial, glLightModel, and glLight.