国外代码
来源:互联网 发布:有魅力的女人 知乎 编辑:程序博客网 时间:2024/06/08 19:42
-------------
I fixed it by replacing (for me, line 174)
TestLight->Direction = pGlobals->Vector(-1.0f,0.0f,0.0f);
with a strict copy of the data members:
TestLight->Direction.x = -1.0f;
TestLight->Direction.y = 0.0f;
TestLight->Direction.z = 0.0f;
As best as I can tell, the "D3DVECTOR"s are just structs, so it should do exactly the same thing:
(from truevision3d.tlh)
struct DxVBLibA::D3DVECTOR Vector (
float x,
float Y,
float Z );
It looks right anyway. If I'm wrong about this, it'd be nice if someone can give us both the heads up. It might be possible to write a quick constructor if you're going to be making this conversion often, but I haven't looked into it at all.
I assume this error:
--------------
#ifndef TV3D_ENGINE_HEADER
#define TV3D_ENGINE_HEADER
#define WIN32_LEAN_AND_MEAN
typedef int DSCAPS;
/*
* Defines
*/
#define tvtrue VARIANT_TRUE
#define tvfalse VARIANT_FALSE
/*
* TV3DEngine declarations
*/
#import <dx8vb.dll> auto_rename named_guids
// Replace with the location of your file:
#import "D:/TV3DSDK/Bin/truevision3d.dll" /*auto_rename*/ named_guids
#include <d3d8.h>
using namespace TrueVision3D;
typedef _TVActor *ITVActor;
typedef _TVActor2 *ITVActor2;
typedef _TVAI *ITVAI;
typedef _TVAtmosphere *ITVAtmosphere;
typedef _TVBitmapParts *ITVBitmapParts;
typedef _TVBSPTree *ITVBSPTree;
typedef _TVCamera *ITVCamera;
typedef _TVCameraFactory *ITVCameraFactory;
typedef _TVCollisionResult *ITVCollisionResult;
typedef _TVDelphiGlobals *ITVGlobals;
typedef _TVEngine *ITVEngine;
typedef _TVForceFeedEffect *ITVForceFeedEffect;
typedef _TVForceFeedEffects *ITVForceFeedEffects;
typedef _TVGameController *ITVGameController;
typedef _TVGameControllers *ITVGameControllers;
typedef _TVGraphicEffect *ITVGraphicEffect;
typedef _TVInputEngine *ITVInputEngine;
typedef _TVInternalObjects *ITVInternalObjects;
typedef _TVKeyFrameAnim *ITVKeyFrameAnim;
typedef _TVLandscape *ITVLandscape;
typedef _TVLightEngine *ITVLightEngine;
typedef _TVMaterialFactory *ITVMaterialFactory;
typedef _TVMesh *ITVMesh;
typedef _TVParticleSystem *ITVParticleSystem;
typedef _TVPath *ITVPath;
typedef _TVRenderSurface *ITVRenderSurface;
typedef _TVScene *ITVScene;
typedef _TVScreen2DImmediate *ITVScreen2DImmediate;
typedef _TVScreen2DText *ITVScreen2DText;
typedef _TVTextureFactory *ITVTextureFactory;
typedef _TVTileMap *ITVTileMap;
typedef _TVViewport *ITVViewport;
/*
* Declaration of the Interface Creating functions
*/
ITVActor CreateTVActor();
ITVActor2 CreateTVActor2();
ITVAI CreateTVAI();
ITVAtmosphere CreateTVAtmosphere();
ITVBitmapParts CreateTVBitmapParts();
ITVBSPTree CreateTVBSPTree();
ITVCamera CreateTVCamera();
ITVCameraFactory CreateTVCameraFactory();
ITVCollisionResult CreateTVCollisionResult();
ITVGlobals CreateTVGlobals();
ITVEngine CreateTVEngine();
ITVForceFeedEffect CreateTVFeedEffect();
ITVForceFeedEffects CreateTVFeedEffects();
ITVGameController CreateTVGameController();
ITVGameControllers CreateTVGameControllers();
ITVGraphicEffect CreateTVGraphicEffect();
ITVInputEngine CreateTVInputEngine();
ITVInternalObjects CreateTVInternalObjects();
ITVKeyFrameAnim CreateTVKeyFrameAnim();
ITVLandscape CreateTVLandscape();
ITVLightEngine CreateTVLightEngine();
ITVMaterialFactory CreateTVMaterialFactory();
ITVParticleSystem CreateTVParticleSystem();
ITVPath CreateTVPath();
ITVScene CreateTVScene();
ITVScreen2DImmediate CreateTVScreen2DImmediate();
ITVScreen2DText CreateTVScreen2DText();
ITVTextureFactory CreateTVTextureFactory();
ITVTileMap CreateTVTileMap();
ITVViewport CreateTVViewport();
#define LIGHT(a) (DxVBLibA::D3DLIGHT8 *)(a)
typedef ::_D3DLIGHT8 TV_LIGHT ;
/*
* Declaration of the Extra/Macro functions
*/
//RGBA returns the color in hex format, the arguments are 0-1
unsigned int RGBA(float r, float g, float b, float a);
//Extracts the path of a file, if you pass the GetModuleFileName path,
//it will return the path where it is existing, the Application Path
void AppPath(char* PathOfFile,char* ret_Path);
// light color
inline _D3DCOLORVALUE LightColor(float r, float g, float b, float a)
{
_D3DCOLORVALUE cv;
cv.r = r;
cv.g = g;
cv.b = b;
cv.a = a;
return cv;
}
// Some strings conversion routines.
// For example when you need to return a string from the TV3D DLL
BSTR ConvertStringToBSTR(const char* pSrc);
char* ConvertBSTRToString(BSTR pSrc);
// Don't forget to free the memory allocated by these functions.
#endif
-------------------------------------
TestLight->Direction = pGlobals->Vector(-1.0f,0.0f,0.0f);
with a strict copy of the data members:
TestLight->Direction.x = -1.0f;
TestLight->Direction.y = 0.0f;
TestLight->Direction.z = 0.0f;
As best as I can tell, the "D3DVECTOR"s are just structs, so it should do exactly the same thing:
(from truevision3d.tlh)
struct DxVBLibA::D3DVECTOR Vector (
float x,
float Y,
float Z );
---------------------------------------
extern "C" __declspec(dllexport) DWORD tvPictureThingy(TV_PICTURE *picture, void *argument1)
{
return picture->thingy(argument1);
}
---------------------------------------
ITVCollisionResult CollisionResult;
CollisionResult = CreateTVCollisionResult();
...
...
if(CollisionResult->IsCollision())
{
// do something
}
CollisionResult.hascollided = Scene.AdvancedCollision(OldPlayerPosition, NewPlayerPosition,CollisionResult, 0, TV_TESTTYPE_ACCURATETESTING, True)
--------------------------------------------
#include "Header.h"
// Declare TrueVision
ITVEngine TV;
ITVGlobals Globals;
ITVInputEngine Input;
ITVScene Scene;
ITVLandscape Land;
ITVTextureFactory TexFactory;
ITVCollisionResult CollisionResult;
ITVScreen2DText Text;
void InitializeEngine(HWND hWnd)
{
ShowCursor(false);
// Create Everything
TV = CreateTVEngine();
Globals = CreateTVGlobals();
Input = CreateTVInputEngine();
Scene = CreateTVScene();
Land = CreateTVLandscape();
TexFactory = CreateTVTextureFactory();
CollisionResult = CreateTVCollisionResult();
Text = CreateTVScreen2DText();
// Initialize
TV->Init3DWindowedMode((long)hWnd,tvtrue); // windowed mode, support TnL
TV->put_DisplayFPS(tvfalse); // don't display fps
TV->SetSearchDirectory("."); // set current directory
Scene->SetSceneBackGround(0,0,1); // clear background with blue
Scene->LoadCursor("..//media//pointer.bmp",TV_COLORKEY_BLACK,32,16); // load in-game cursor
Scene->SetCamera(0,50,550,150,100,550);
Land->GenerateHugeTerrain("..//media//heightmap.jpg",TV_PRECISION_LOW,8,8,0,0,tvtrue); // generate landscape
TexFactory->LoadTexture("..//media//sand.jpg","tex_sand",-1,-1,TV_COLORKEY_NO,tvtrue,tvtrue); // load landscape texture
Land->SetTexture(Globals->GetTex("tex_sand"),-1); // set landscape texture
long font = Text->TextureFont_Create("def_font","Arial",16,tvtrue,tvfalse,tvfalse,tvfalse); // create Arial font
}
void ShutdownEngine()
{
// Release All
Text->Release();
CollisionResult->Release();
TexFactory->Release();
Land->Release();
Scene->Release();
Input->Release();
Globals->Release();
TV->Release();
Text = NULL;
CollisionResult = NULL;
TexFactory = NULL;
Land = NULL;
Scene = NULL;
Input = NULL;
Globals = NULL;
TV = NULL;
}
void RenderScenes()
{
if(Input->IsKeyPressed(TV_KEY_ESCAPE)) // check if user press escape key
PostQuitMessage(0); // then quit the app
TV->Clear(tvfalse); // clear backbuffer (not z-buffer only)
long mX,mY;
short button;
Input->GetAbsMouseState(&mX,&mY,&button,&button,&button); // get mouse state
CollisionResult = Scene->MousePicking(mX,mY,TV_COLLIDE_LANDSCAPE,TV_TESTTYPE_ACCURATETESTING);
if(CollisionResult->IsCollision()) // BUG !!!!!!!!!!!!!!!!!!!!!!!!!!!
{
char buff[256];
sprintf(buff,"X : %.2f Y : %.2f Z : %.2f",CollisionResult->GetImpactPoint().x,CollisionResult->GetImpactPoint().y,CollisionResult->GetImpactPoint().z);
Text->TextureFont_DrawText(buff,5,5,RGBA(1,1,1,1),"");
}
Land->Render(tvtrue,tvtrue); // render landscape
TV->RenderToScreen(); // render scene
}
TrueVision3D::_TVCollisionResultPtr pCollisionResult;
ITVCollisionResult CollisionResult;
CollisionResult = CreateTVCollisionResult;
D3DVECTOR OldPos;
D3DVECTOR NewPos;
TV_COLLISIONRESULT CollisionResult;
...
if(pScene->AdvancedCollision(&OldPos, &NewPos, &CollisionResult, TV_OBJECT_MESH, TV_TESTTYPE_ACCURATETESTING, FALSE))
{
//Collision has occurred!
}
----------------------------------------
pLand->SetWaterEffect(tvfalse, 0.5, tvtrue, (enum DxVBLibA::CONST_D3DBLEND)D3DBLEND_SRCALPHA, (enum DxVBLibA::CONST_D3DBLEND)D3DBLEND_INVSRCALPHA, tvfalse, 0);
--------------------------------------------
if(tmpMouseB1)
{
pCollision = pScene->MousePicking(tmpMouseX, tmpMouseY, TV_COLLIDE_MESH ,
TV_TESTTYPE_BOUNDINGBOX);
if(pCollision->IsCollision())
{
MessageBox(NULL, "MousePick", "Collision", MB_OK);
}
}
-------------------------------------------------
if(tmpMouseB1)
{
pCR=pScene->MousePicking(tmp1MouseX, tmp1MouseY, TV_COLLIDE_MESH,
TV_TESTTYPE_ACCURATETESTING);
if(pCR->IsCollision())
{
MessageBox(NULL, "Mousepick", "Info!", MB_OK);
}
}
----------------------------------------------------
I've got a landscape and when I click the mouse I want to retrieve the 3d coordinates I clicked on. Rigth now I have this:
Code:
D3DVECTOR v1,v2;
pGlobals->MousePickVector(tmpMouseX, tmpMouseY, &v1, &v2);
if(tmpMouseB1!=0)
{
TV_COLLISIONRESULT cr;
pScene->AdvancedCollision(&v1, &v2, &cr, TV_COLLIDE_LANDSCAPE, TV_TESTTYPE_ACCURATETESTING, tvtrue);
float ftx = cr.collisionimpact.x;
float ftz = cr.collisionimpact.Z;
}
--------------------------------------------------------
long tmpMouseX = 0; long tmpMouseY = 0;
long tmpMouseB1 = 0; long tmpMouseB2 = 0; long tmpMouseB3 = 0;
long tmpMouseScrollOld = 0; long tmpMouseScrollNew = 0;
//Get the movement of the mouse.
pInput->GetMouseState(&tmpMouseX, &tmpMouseY, (short *)&tmpMouseB1, (short *)&tmpMouseB2, (short *)&tmpMouseB3, &tmpMouseScrollNew);
D3DVECTOR v1,v2;
pGlobals->MousePickVector(tmpMouseX, tmpMouseY, &v1, &v2);
//TVScene.AdvancedCollision( linestart As D3DVECTOR, lineend As D3DVECTOR, ret_CollisionResult As TV_COLLISIONRESULT, objecttocheck As CONST_TV_OBJECT_TYPE, TestType As CONST_TV_TESTTYPE, findclosest As Boolean)
if(tmpMouseB1!=0)
{
TV_COLLISIONRESULT cr ;
pScene->AdvancedCollision(&v1, &v2, &cr, TV_COLLIDE_LANDSCAPE,
TV_TESTTYPE_ACCURATETESTING, tvtrue);
float ftx = cr.collisionimpact.x;
float ftz = cr.collisionimpact.Z;
selGridX = (int)(ftx / GRIDSIZE);
selGridZ = (int)(ftz / GRIDSIZE);
}
-----------------------------------------------------------------
You've got:Code:
pInput->GetMouseState((&tmpMouseX, &tmpMouseY, (short *)&tmpMouseB1, (short *)&tmpMouseB2, (short *)&tmpMouseB3, &tmpMouseScrollNew);
Shouldn't this be:
Code:
pInput->GetAbsMouseState((&tmpMouseX, &tmpMouseY, (short *)&tmpMouseB1, (short *)&tmpMouseB2, (short *)&tmpMouseB3);
This will give you different x,y values and hopefully work.
---------------------------------------------------------------------
*m_pCol = *m_pScene->MousePicking( fMouseX, fMouseY, TV_COLLIDE_MESH, TV_TESTTYPE_BOUNDINGBOX );
---------------------------------------------------------------------
6.5:
If gMouseB3
Local Pick:CTV_CollisionRESULT = PScene.MousePick(gMouseX, gMouseY)
If Pick.bHasCollided
SetGadgetText textfield_r4 , Pick.iMeshID
EndIf
EndIf
- 国外代码
- 国外FlashFxp解密代码
- 国外FlashFxp解密代码
- 国外WEB代码下载站集合
- 国外进程池很好的代码
- 国外开源B2c商城代码
- 贴点国外大神代码,没事瞅瞅
- 国外网站封闭中国的ip访问的代码
- 屏蔽国内或者国外ip的代码 GeoIP
- 国外网站淘来的invocie java代码
- Android 代码实现国内和国外的区分
- 四行代码实现阿里云中转国外vps
- J2ME游戏源代码免费下载——国外Digiment公司商业化代码
- J2ME游戏源代码免费下载——国外Digiment公司商业化代码
- 国外牛人666行汇编代码实现社会化新闻网站
- 国外的一个图像显著区域检测代码及其效果图 saliency region detection
- [转]国外的一个图像显著区域检测代码及其效果图 saliency region detection
- 国外一网站的CSS代码重定义,留着备用
- 读取3DS文件
- Android arm linux kernel启动流程(一)
- 读取MDL文件与骨骼控制
- 僵尸进程解决方法
- 各种碰撞
- 国外代码
- 基本数学函数
- C++代码优化方法总结
- 将x文件绑在mdl手上
- 改变文本控件字体
- VC:CString用法整理(转载)
- 矩阵
- VC的若干实用小技巧 (如何干净的删除一个类)
- 新题库