![]() |
Multimedia »
DirectX »
General
Beginner
License: The Code Project Open License (CPOL)
Interview with the Skull, Under Three Points of View...By aljodav...under the foundations of DirectX and X-directed by MFC, showing multiview in DirectX, with images so scaring that... that... you should skip this article |
C++ (VC7.1), Windows (WinXP), MFC, DirectX, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
This article shows how simple it is to implement multiview in DirectX.
For this purpose, I use the skullocc.x file from the DirectX SDK, and implement three observers for three different viewings: one right in front, another on the right, and the third on the left of the skull.
The result is a scareware as the demonstration program, and because I'm using a skull as the object for the multiview demonstration, I must warn you that the images resulting are very scaring.
Therefore, some people may feel uncomfortable when seeing these images.
I cannot tell if someone is emotionally strong or not to see them, but, you can tell if you are strong enough to stand still when facing these images, by just following this simple algorithm:
1. During Halloween days, do you spend some time under your bed?
Well, I do (under mine).
If you also do (under yours), please, jump to step 5.
2. Do you feel disquieting, as much as me, when seeing some holes on a pumpkin?
Then, please, jump to step 5.
3. Is your stomach covered with stainless steel?
If not, please, jump with me to step 5.
4. You're reading this step because you're 101% approved to see those scaring images.
Please, forget next step and jump to 'Background' section.
5. I am very sorry! I'm afraid you are not ready yet, to see those images.
Please, skip this article; the next C# article is very interesting.
I guess the webmaster will not help you out to get a passport;
he's refused to see those scaring images.
Nevertheless, I cannot condemn him;
the images are so scary that I wrote the code with my eyes closed.
Just very basic DirectX and MFC programming knowledge is needed.
The article's companion program's application class is derived from the MFC7.1 application class CWinApp, as well as from other classes, in a multiple inheritance style, as follows:
class CInterviewwiththeSkullunder...App : protected CWinApp
, protected CD3DDeviceWindowedOnly
, protected CDxXSkull_dark <TEMPL..._DARK >
, protected CDxXSkull_shy <TEMPL..._SHY >
, protected CDxXSkull_full <TEMPL..._FULL >
, protected CDxXSkull_hypnotic <TEMPL..._HYPNOTIC >
, protected CDxXSkull_intense <TEMPL..._INTENSE >
, protected CDxXSkull_intensebig<TEMPL..._INTENSEBIG>
, protected CDxXSkull_scaring <TEMPL..._SCARING >
, protected CDxXSkull_RIP <TEMPL..._RIP >
{
inline BOOL InitInstance(VOID);
inline BOOL OnIdle (LONG);
} theApp;
This program structure plagiarizes, unashamedly, the structure used in the article MFC plays with D3DDevice easily!, and also in the article MFC, YOU, your display TUBE... easily!, whose authors plagiarized without mentioning (at least I am), each other.
The CDx... classes implement, each one, a specific animation; each of these classes is derived from CDxHelper, a helper class that aggregates common variables, methods, structures, typedefs, etc...:
class CDxHelper : protected CTheSpeech
, protected CDirect3DDevice9
{
// ...
protected:
CDxHelper()
: m_pMesh (NULL)
, m_ppTexture (NULL)
, m_pMaterial (NULL)
, m_dwMaterials(0)
{}
virtual ~CDxHelper() { Clean(); }
// ...
};
This CDxHelper helper class contains two methods directly involved in rendering the views:
inline VOID RenderViews(
/* */ IDirect3DTexture9 ** CONST
, CONST BOOL = __noProjection01_
, CONST BOOL = __noAlpha_
);
The helper method above renders the 3D object in the three viewports by calling the method below:
inline VOID RenderView(
CONST UINT
, IDirect3DTexture9 ** CONST
, CONST BOOL = __noProjection01_
, CONST BOOL = __noAlpha_
);
This helper method renders the 3D object in a specific viewport (there are three plus one for the whole screen); the multiview is properly established by setting the viewport, and the view and projection matrixes:
p->SetViewport ( ...);
p->SetTransform(D3DTS_VIEW , ...);
p->SetTransform(D3DTS_PROJECTION, ...);
// where p is a proper IDirect3DDevice9 pointer.
Some of the CDx... classes use only the first helper method, others use only the second one, and both methods are used by other CDx... classes, to produce different visual effects.
A typical CDx... class declaration, for instance, is:
template<...>
class CDxXSkull_dark : protected CDxHelper
{
protected:
inline BOOL Initialize();
inline VOID Animate ();
};
And a typical CDx... class implementation is:
template<...>
inline BOOL CDxXSkull_dark<...>::Initialize()
{
return CDxHelper::LoadSkullMeshFromX(...);
}
template<...>
inline VOID CDxXSkull_dark<...>::Animate()
{
CDxHelper::SetupWorld ();
CDxHelper::RenderViews(CDxHelper::m_ppTexture);
}
DirectX and MFC make multiview implementation easy.
Before running the demonstration program, prepare yourself hard, to not lose your self control to this mean, abject, etc..., skull and its hypnotic cavities.
Interesting, but I heard voices when writing these few lines... thousands... but they are gone now.
Remember, if you vote 1 for this article, it means you're under his control!
If you vote 5, then you're under my control!
Interesting, but I am hearing voices again...
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 4 Nov 2009 Editor: Deeksha Shenoy |
Copyright 2009 by aljodav Everything else Copyright © CodeProject, 1999-2009 Web20 | Advertise on the Code Project |