Click here to Skip to main content
6,637,603 members and growing! (18,912 online)
Email Password   helpLost your password?
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
Version:4 (See All)
Posted:4 Nov 2009
Updated:4 Nov 2009
Views:1,387
Bookmarked:2 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
3 votes for this article.
Popularity: 0.95 Rating: 2.00 out of 5
2 votes, 66.7%
1

2

3

4
1 vote, 33.3%
5

Introduction

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. 

Background

Just very basic DirectX and MFC programming knowledge is needed.

Using the Code

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.

Warning

Before running the demonstration program, prepare yourself hard, to not lose your self control to this mean, abject, etc..., skull and its hypnotic cavities.

Points of Interest

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...

History

  • 04/November/2009: Just started scaring away

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

aljodav


Member

Location: Brazil Brazil

Other popular DirectX articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 7 of 7 (Total in Forum: 7) (Refresh)FirstPrevNext
GeneralMy vote of 1 PinmemberThunder Storm23:33 7 Nov '09  
GeneralRe: My vote of 1 Pinmemberaljodav12:53 9 Nov '09  
Generalfatal error C1083: Cannot open include file: 'D3Dx9.h': No such file or directory Pinmemberbemar16:21 5 Nov '09  
GeneralRe: fatal error C1083: Cannot open include file: 'D3Dx9.h': No such file or directory Pinmemberaljodav10:33 6 Nov '09  
GeneralMy vote of 1 PinassociateJim Crafton10:54 5 Nov '09  
GeneralRe: My vote of 1 PinmemberLucky12345620:18 5 Nov '09  
GeneralRe: My vote of 1 Pinmemberaljodav10:43 6 Nov '09  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin 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