Removed old code and build target

- removed directory with old target
- changed CMakeLists.txt to new target only and temporarily commented
  out reference to CBot
- updated README
master
Piotr Dziwinski 2012-06-26 23:39:31 +02:00
parent c2a7375788
commit e738c55b73
72 changed files with 39 additions and 39939 deletions

View File

@ -12,10 +12,9 @@ find_package(SDL_image REQUIRED)
# Build with debugging symbols
set(CMAKE_BUILD_TYPE debug)
# Currently compiles only with -fpermissive
set(CMAKE_CXX_FLAGS_RELEASE "-fpermissive -O2")
set(CMAKE_CXX_FLAGS_DEBUG "-fpermissive -w -g -O0")
# Global compile flags
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS_DEBUG "-w -g -O0")
# Subdirectory with sources
add_subdirectory(src bin)

View File

@ -31,8 +31,8 @@ This file outlines the most important things for developers.
The build system is as follows:
/CMakeLists.txt - definition of project, build type setup, general compiler options and reference to src subdirectory
/src/CMakeLists.txt - currently defines two targets: colobot_old - the original game comprised of old sources, compiles and runs only on Windows; colobot_new - new implementation in SDL, compiles and runs on Windows and Linux, for now only "hello world"-like; colobot_old target references also CBot library
/src/CBot/CMakeLists.txt - defines the CBot library target
/src/CMakeLists.txt - defines the colobot target - new implementation in SDL, compiles and runs on Windows and Linux, for now only "hello world"-like
/src/CBot/CMakeLists.txt - defines the CBot library target, currently not referenced by colobot target because it is still WinAPI-dependent
There is also a generated header common/config.h with #defines set by CMake.
@ -59,7 +59,7 @@ This file outlines the most important things for developers.
3. Rewriting modules.
The rewriting rule is the following: every old module/header that needs to be replaced will be moved to src/old and all references to it in the rest of the code shall be changed to src/old as well. In place of the old module, a new one will be created with the new declarations, preferrably enclosing everything in a separate namespace. This way, the new code will be separated from the old one, for the time being, thus making it possible to work on new code and not break anything else. Once the functionality of new code matches the old one, it can be replaced in old code with ease.
The rewriting rule is the following: every old module/header that needs to be replaced by a new one with all declarations either changed to other names or, preferrably, enclosed in a separate namespace. This way, the new code will be separated from the old one, for the time being, thus making it possible to work on new code and not break anything else. Once the functionality of new code matches the old one, it can be replaced in old code with ease.
4. Documentation.

View File

@ -1,132 +1,31 @@
# CBot shared library is built separately
add_subdirectory(CBot)
# add_subdirectory(CBot) -- not yet WinAPI-independent
# Source files for old target (dependent on WinAPI & DirectX)
set(OLD_SOURCES
old/d3dapp.cpp
old/joystick.cpp
old/blitz.cpp
old/camera.cpp
old/cloud.cpp
old/light.cpp
old/model.cpp
old/particule.cpp
old/planet.cpp
old/pyro.cpp
old/terrain.cpp
old/text.cpp
old/water.cpp
old/d3dengine.cpp
old/d3denum.cpp
old/d3dframe.cpp
old/d3dtextr.cpp
old/d3dutil.cpp
old/d3dmath.cpp
old/math3d.cpp
old/modfile.cpp
old/sound.cpp
common/event.cpp
common/iman.cpp
common/metafile.cpp
common/misc.cpp
common/profile.cpp
common/restext.cpp
object/auto/auto.cpp
object/auto/autobase.cpp
object/auto/autoconvert.cpp
object/auto/autoderrick.cpp
object/auto/autodestroyer.cpp
object/auto/autoegg.cpp
object/auto/autoenergy.cpp
object/auto/autofactory.cpp
object/auto/autoflag.cpp
object/auto/autohuston.cpp
object/auto/autoinfo.cpp
object/auto/autojostle.cpp
object/auto/autokid.cpp
object/auto/autolabo.cpp
object/auto/automush.cpp
object/auto/autonest.cpp
object/auto/autonuclear.cpp
object/auto/autopara.cpp
object/auto/autoportico.cpp
object/auto/autoradar.cpp
object/auto/autorepair.cpp
object/auto/autoresearch.cpp
object/auto/autoroot.cpp
object/auto/autosafe.cpp
object/auto/autostation.cpp
object/auto/autotower.cpp
object/brain.cpp
object/mainmovie.cpp
object/motion/motion.cpp
object/motion/motionant.cpp
object/motion/motionbee.cpp
object/motion/motionhuman.cpp
object/motion/motionmother.cpp
object/motion/motionspider.cpp
object/motion/motiontoto.cpp
object/motion/motionvehicle.cpp
object/motion/motionworm.cpp
object/object.cpp
object/robotmain.cpp
object/task/task.cpp
object/task/taskadvance.cpp
object/task/taskbuild.cpp
object/task/taskfire.cpp
object/task/taskfireant.cpp
object/task/taskflag.cpp
object/task/taskgoto.cpp
object/task/taskgungoal.cpp
object/task/taskinfo.cpp
object/task/taskmanager.cpp
object/task/taskmanip.cpp
object/task/taskpen.cpp
object/task/taskrecover.cpp
object/task/taskreset.cpp
object/task/tasksearch.cpp
object/task/taskshield.cpp
object/task/taskspiderexplo.cpp
object/task/tasktake.cpp
object/task/taskterraform.cpp
object/task/taskturn.cpp
object/task/taskwait.cpp
physics/physics.cpp
script/cbottoken.cpp
script/cmdtoken.cpp
script/script.cpp
ui/button.cpp
ui/check.cpp
ui/color.cpp
ui/compass.cpp
ui/control.cpp
ui/displayinfo.cpp
ui/displaytext.cpp
ui/edit.cpp
ui/editvalue.cpp
ui/gauge.cpp
ui/group.cpp
ui/image.cpp
ui/interface.cpp
ui/key.cpp
ui/label.cpp
ui/list.cpp
ui/maindialog.cpp
ui/mainmap.cpp
ui/mainshort.cpp
ui/map.cpp
ui/scroll.cpp
ui/shortcut.cpp
ui/slider.cpp
ui/studio.cpp
ui/target.cpp
ui/window.cpp
)
# Configure options
option(DEBUG "Enable debug output" ON)
# Source files for new target (dependent on SDL & OpenGL)
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(PLATFORM_WINDOWS 1)
set(PLATFORM_LINUX 0)
set(PLATFORM_OTHER 0)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(PLATFORM_WINDOWS 0)
set(PLATFORM_LINUX 1)
set(PLATFORM_OTHER 0)
else()
set(PLATFORM_WINDOWS 0)
set(PLATFORM_LINUX 0)
set(PLATFORM_OTHER 1)
endif()
# Configure file
configure_file(common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h)
# Source files
# Commented out files are still dependent on DirectX or WinAPI
set(NEW_SOURCES
set(SOURCES
app/app.cpp
app/main.cpp
app/system.cpp
@ -247,51 +146,17 @@ sound/sound.cpp
# ui/window.cpp
)
# Change to DirectX SDK directory
set(DXSDK_DIR "c:/dxsdk")
set(LIBS
${SDL_LIBRARY}
${SDLIMAGE_LIBRARY}
${OPENGL_LIBRARY}
#CBot -- not yet WinAPI-independent
)
# Configure options
option(DEBUG "Enable debug output" ON)
include_directories(. ${CMAKE_CURRENT_BINARY_DIR})
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(PLATFORM_WINDOWS 1)
set(PLATFORM_LINUX 0)
set(PLATFORM_OTHER 0)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(PLATFORM_WINDOWS 0)
set(PLATFORM_LINUX 1)
set(PLATFORM_OTHER 0)
else()
set(PLATFORM_WINDOWS 0)
set(PLATFORM_LINUX 0)
set(PLATFORM_OTHER 1)
endif()
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/CBot)
# Configure file
configure_file(common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h)
add_executable(colobot ${SOURCES})
# #defines needed for old target
add_definitions(-DSTRICT -DD3D_OVERLOADS)
include_directories(${DXSDK_DIR}/include . ${CMAKE_CURRENT_BINARY_DIR})
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/CBot ${DXSDK_DIR}/lib)
# Old target
set(OLD_LIBS -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32
-ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32
-lodbccp32 -lwinmm
${DXSDK_DIR}/lib/ddraw.lib ${DXSDK_DIR}/lib/dinput.lib ${DXSDK_DIR}/lib/dxguid.lib ${DXSDK_DIR}/lib/d3d8.lib ${DXSDK_DIR}/lib/dsound.lib)
add_executable(colobot_old ${OLD_SOURCES})
target_link_libraries(colobot_old CBot ${OLD_LIBS})
# New target
set(NEW_LIBS ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${OPENGL_LIBRARY})
add_executable(colobot_new ${NEW_SOURCES})
target_link_libraries(colobot_new ${NEW_LIBS})
target_link_libraries(colobot ${LIBS})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,3 +0,0 @@
Contains old files that will be removed:
- old code modules - will be replaced by new implementation
- resources (cursors, etc.) - will be included in .dat files

View File

@ -1,5 +0,0 @@
!"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^
_abcdefghijklmnopqrstuvwxyz{|}~
晾履们扇仕吞蜗延以终谫圮
徉怃沌殍觌盱铒耋螋鲺<EFBFBD><EFBFBD>

View File

@ -1,475 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
#include "math/const.h"
#include "math/geometry.h"
#include "math/conv.h"
#include "old/d3dengine.h"
#include "old/d3dmath.h"
#include "old/d3dutil.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
#include "old/terrain.h"
#include "old/math3d.h"
#include "object/object.h"
#include "old/camera.h"
#include "object/auto/auto.h"
#include "object/auto/autopara.h"
#include "old/sound.h"
#include "old/blitz.h"
// Constructor of the terrain.
CBlitz::CBlitz(CInstanceManager* iMan, CD3DEngine* engine)
{
m_iMan = iMan;
m_iMan->AddInstance(CLASS_BLITZ, this);
m_engine = engine;
m_terrain = 0;
m_camera = 0;
m_sound = 0;
Flush();
}
// Destructor of the terrain.
CBlitz::~CBlitz()
{
}
// Removes lightning.
void CBlitz::Flush()
{
int i;
m_bBlitzExist = false;
m_time = 0.0f;
m_phase = BPH_WAIT;
m_speed = 0.0f;
m_progress = 0.0f;
for ( i=0 ; i<BLITZMAX ; i++ )
{
m_shift[i] = Math::Point(0.0f, 0.0f);
m_width[i] = 1.0f;
}
}
// Management of an event
bool CBlitz::EventProcess(const Event &event)
{
if ( event.event == EVENT_FRAME )
{
return EventFrame(event);
}
return true;
}
// Evolved lightning.
bool CBlitz::EventFrame(const Event &event)
{
CObject* pObj;
CAutoPara* automat;
ObjectType type;
Math::Vector eye, pos;
float dist, deep, max;
int i;
if ( m_engine->RetPause() ) return true;
if ( m_engine->RetMovieLock() ) return true;
m_time += event.rTime;
m_progress += event.rTime*m_speed;
if ( m_phase == BPH_WAIT )
{
if ( m_progress >= 1.0f )
{
#if 1
m_pos.x = (Math::Rand()-0.5f)*(3200.0f-200.0f);
m_pos.z = (Math::Rand()-0.5f)*(3200.0f-200.0f);
#else
m_pos.x = (Math::Rand()-0.5f)*(3200.0f-2800.0f);
m_pos.z = (Math::Rand()-0.5f)*(3200.0f-2800.0f);
#endif
m_pos.y = 0.0f;
pObj = SearchObject(m_pos);
if ( pObj == 0 )
{
m_terrain->MoveOnFloor(m_pos, true);
}
else
{
m_pos = pObj->RetPosition(0);
m_terrain->MoveOnFloor(m_pos, true);
type = pObj->RetType();
if ( type == OBJECT_BASE )
{
m_pos.y += 120.0f; // top of the rocket
}
else if ( type == OBJECT_PARA )
{
automat = (CAutoPara*)pObj->RetAuto();
if ( automat != 0 )
{
automat->StartBlitz();
}
m_pos.y += 67.0f; // top of lightning rod
}
else
{
pObj->ExploObject(EXPLO_BOUM, 1.0f);
}
}
eye = m_engine->RetEyePt();
dist = Math::Distance(m_pos, eye);
deep = m_engine->RetDeepView();
if ( dist < deep )
{
pos = eye+((m_pos-eye)*0.2f); // like so close!
m_sound->Play(SOUND_BLITZ, pos);
m_camera->StartOver(OE_BLITZ, m_pos, 1.0f);
m_phase = BPH_BLITZ;
m_progress = 0.0f;
m_speed = 1.0f/1.0f;
}
}
}
if ( m_phase == BPH_BLITZ )
{
if ( m_progress < 1.0f )
{
max = 5.0f;
for ( i=0 ; i<BLITZMAX ; i++ )
{
max += 0.4f;
m_shift[i].x += (Math::Rand()-0.5f)*max*2.0f;
if ( m_shift[i].x < -max ) m_shift[i].x = -max;
if ( m_shift[i].x > max ) m_shift[i].x = max;
m_shift[i].y += (Math::Rand()-0.5f)*max*2.0f;
if ( m_shift[i].y < -max ) m_shift[i].y = -max;
if ( m_shift[i].y > max ) m_shift[i].y = max;
m_width[i] += (Math::Rand()-0.5f)*2.0f;
if ( m_width[i] < 1.0f ) m_width[i] = 1.0f;
if ( m_width[i] > 6.0f ) m_width[i] = 6.0f;
}
m_shift[0].x = 0.0f;
m_shift[0].y = 0.0f;
m_width[0] = 0.0f;
}
else
{
m_phase = BPH_WAIT;
m_progress = 0.0f;
m_speed = 1.0f/(1.0f+Math::Rand()*m_delay);
}
}
return true;
}
// Draw lightning.
void CBlitz::Draw()
{
LPDIRECT3DDEVICE7 device;
D3DVERTEX2 vertex[4]; // 2 triangles
Math::Vector corner[4], eye, n, p, p1, p2;
Math::Matrix matrix;
Math::Point texInf, texSup, rot;
float a;
int i;
if ( !m_bBlitzExist ) return;
if ( m_phase != BPH_BLITZ ) return;
device = m_engine->RetD3DDevice();
device->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false);
matrix.LoadIdentity();
{
D3DMATRIX mat = MAT_TO_D3DMAT(matrix);
device->SetTransform(D3DTRANSFORMSTATE_WORLD, &mat);
}
m_engine->SetTexture("effect00.tga");
m_engine->SetState(D3DSTATETTb);
texInf.x = 64.5f/256.0f;
texInf.y = 33.0f/256.0f;
texSup.x = 95.5f/256.0f;
texSup.y = 34.0f/256.0f; // blank
p1 = m_pos;
eye = m_engine->RetEyePt();
a = Math::RotateAngle(eye.x-p1.x, eye.z-p1.z);
n = Normalize(p1-eye);
for ( i=0 ; i<BLITZMAX-1 ; i++ )
{
p2 = p1;
p2.y += 8.0f+0.2f*i;
p = p1;
p.x += m_width[i];
rot = Math::RotatePoint(Math::Point(p1.x, p1.z), a+Math::PI/2.0f, Math::Point(p.x, p.z));
corner[0].x = rot.x+m_shift[i].x;
corner[0].y = p1.y;
corner[0].z = rot.y+m_shift[i].y;
rot = Math::RotatePoint(Math::Point(p1.x, p1.z), a-Math::PI/2.0f, Math::Point(p.x, p.z));
corner[1].x = rot.x+m_shift[i].x;
corner[1].y = p1.y;
corner[1].z = rot.y+m_shift[i].y;
p = p2;
p.x += m_width[i+1];
rot = Math::RotatePoint(Math::Point(p2.x, p2.z), a+Math::PI/2.0f, Math::Point(p.x, p.z));
corner[2].x = rot.x+m_shift[i+1].x;
corner[2].y = p2.y;
corner[2].z = rot.y+m_shift[i+1].y;
rot = Math::RotatePoint(Math::Point(p2.x, p2.z), a-Math::PI/2.0f, Math::Point(p.x, p.z));
corner[3].x = rot.x+m_shift[i+1].x;
corner[3].y = p2.y;
corner[3].z = rot.y+m_shift[i+1].y;
if ( p2.y < p1.y )
{
vertex[0] = D3DVERTEX2(corner[1], n, texSup.x, texSup.y);
vertex[1] = D3DVERTEX2(corner[0], n, texInf.x, texSup.y);
vertex[2] = D3DVERTEX2(corner[3], n, texSup.x, texInf.y);
vertex[3] = D3DVERTEX2(corner[2], n, texInf.x, texInf.y);
}
else
{
vertex[0] = D3DVERTEX2(corner[0], n, texSup.x, texSup.y);
vertex[1] = D3DVERTEX2(corner[1], n, texInf.x, texSup.y);
vertex[2] = D3DVERTEX2(corner[2], n, texSup.x, texInf.y);
vertex[3] = D3DVERTEX2(corner[3], n, texInf.x, texInf.y);
}
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 4, NULL);
m_engine->AddStatisticTriangle(2);
p1 = p2;
}
device->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true);
}
// Triggers lightning.
bool CBlitz::Create(float sleep, float delay, float magnetic)
{
m_bBlitzExist = true;
if ( sleep < 1.0f ) sleep = 1.0f;
m_sleep = sleep;
m_delay = delay;
m_magnetic = magnetic;
m_phase = BPH_WAIT;
m_progress = 0.0f;
m_speed = 1.0f/m_sleep;
if ( m_terrain == 0 )
{
m_terrain = (CTerrain*)m_iMan->SearchInstance(CLASS_TERRAIN);
}
if ( m_camera == 0 )
{
m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA);
}
if ( m_sound == 0 )
{
m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND);
}
return false;
}
// Gives the status of lightning.
bool CBlitz::GetStatus(float &sleep, float &delay, float &magnetic, float &progress)
{
if ( !m_bBlitzExist ) return false;
sleep = m_sleep;
delay = m_delay;
magnetic = m_magnetic;
progress = m_progress;
return true;
}
// Specifies the status of lightning.
bool CBlitz::SetStatus(float sleep, float delay, float magnetic, float progress)
{
m_bBlitzExist = true;
m_sleep = sleep;
m_delay = delay;
m_magnetic = magnetic;
m_progress = progress;
m_phase = BPH_WAIT;
m_speed = 1.0f/m_sleep;
return true;
}
// Seeking the object closest to the lightning.
CObject* CBlitz::SearchObject(Math::Vector pos)
{
CObject *pObj, *pBest, *pObjPara[100];
Math::Vector oPos, pPos[100];
ObjectType type;
float min, dist, detect;
int i, nbPara;
// Seeking the object closest to the point of impact of lightning.
pBest = 0;
min = 100000.0f;
nbPara = 0;
for ( i=0 ; i<1000000 ; i++ )
{
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
if ( pObj == 0 ) break;
if ( !pObj->RetActif() ) continue; // inactive object?
if ( pObj->RetTruck() != 0 ) continue; // object transported?
type = pObj->RetType();
if ( type == OBJECT_BASE ||
type == OBJECT_PARA ) // building a lightning effect?
{
pObjPara[nbPara] = pObj;
pPos[nbPara] = pObj->RetPosition(0);
nbPara ++;
}
detect = 0.0f;
if ( type == OBJECT_BASE ||
type == OBJECT_DERRICK ||
type == OBJECT_FACTORY ||
type == OBJECT_REPAIR ||
type == OBJECT_DESTROYER||
type == OBJECT_STATION ||
type == OBJECT_CONVERT ||
type == OBJECT_TOWER ||
type == OBJECT_RESEARCH ||
type == OBJECT_RADAR ||
type == OBJECT_INFO ||
type == OBJECT_ENERGY ||
type == OBJECT_LABO ||
type == OBJECT_NUCLEAR ||
type == OBJECT_PARA ||
type == OBJECT_SAFE ||
type == OBJECT_HUSTON )
{
detect = m_magnetic;
}
if ( type == OBJECT_METAL ||
type == OBJECT_POWER ||
type == OBJECT_ATOMIC )
{
detect = m_magnetic*0.3f;
}
if ( type == OBJECT_MOBILEfa ||
type == OBJECT_MOBILEta ||
type == OBJECT_MOBILEwa ||
type == OBJECT_MOBILEia ||
type == OBJECT_MOBILEfc ||
type == OBJECT_MOBILEtc ||
type == OBJECT_MOBILEwc ||
type == OBJECT_MOBILEic ||
type == OBJECT_MOBILEfi ||
type == OBJECT_MOBILEti ||
type == OBJECT_MOBILEwi ||
type == OBJECT_MOBILEii ||
type == OBJECT_MOBILEfs ||
type == OBJECT_MOBILEts ||
type == OBJECT_MOBILEws ||
type == OBJECT_MOBILEis ||
type == OBJECT_MOBILErt ||
type == OBJECT_MOBILErc ||
type == OBJECT_MOBILErr ||
type == OBJECT_MOBILErs ||
type == OBJECT_MOBILEsa ||
type == OBJECT_MOBILEft ||
type == OBJECT_MOBILEtt ||
type == OBJECT_MOBILEwt ||
type == OBJECT_MOBILEit ||
type == OBJECT_MOBILEdr )
{
detect = m_magnetic*0.5f;
}
if ( detect == 0.0f ) continue;
oPos = pObj->RetPosition(0);
dist = Math::DistanceProjected(oPos, pos);
if ( dist > detect ) continue;
if ( dist < min )
{
min = dist;
pBest = pObj;
}
}
if ( pBest == 0 ) return 0; // nothing found
// Under the protection of a lightning conductor?
oPos = pBest->RetPosition(0);
for ( i=nbPara-1 ; i>=0 ; i-- )
{
dist = Math::DistanceProjected(oPos, pPos[i]);
if ( dist <= BLITZPARA )
{
return pObjPara[i];
}
}
return pBest;
}

View File

@ -1,83 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// blitz.h
#pragma once
#include "common/misc.h"
#include "math/point.h"
#include "old/d3dengine.h"
class CObject;
class CInstanceManager;
class CD3DEngine;
class CTerrain;
class CCamera;
class CSound;
const float BLITZPARA = 200.0f; // radius of lightning protection
const int BLITZMAX = 50;
enum BlitzPhase
{
BPH_WAIT,
BPH_BLITZ,
};
class CBlitz
{
public:
CBlitz(CInstanceManager* iMan, CD3DEngine* engine);
~CBlitz();
void Flush();
bool EventProcess(const Event &event);
bool Create(float sleep, float delay, float magnetic);
bool GetStatus(float &sleep, float &delay, float &magnetic, float &progress);
bool SetStatus(float sleep, float delay, float magnetic, float progress);
void Draw();
protected:
bool EventFrame(const Event &event);
CObject* SearchObject(Math::Vector pos);
protected:
CInstanceManager* m_iMan;
CD3DEngine* m_engine;
CTerrain* m_terrain;
CCamera* m_camera;
CSound* m_sound;
bool m_bBlitzExist;
float m_sleep;
float m_delay;
float m_magnetic;
BlitzPhase m_phase;
float m_time;
float m_speed;
float m_progress;
Math::Vector m_pos;
Math::Point m_shift[BLITZMAX];
float m_width[BLITZMAX];
};

View File

@ -1,94 +0,0 @@
void CD3DApplication::StepSimul(float rTime)
{
Event event;
if ( m_pRobotMain == 0 ) return;
if ( rTime > 0.5f ) rTime = 0.5f; // jamais plus de 0.5s !
ZeroMemory(&event, sizeof(Event));
event.event = EVENT_FRAME;
event.rTime = rTime;
event.axeX = AxeLimit(m_axeKey.x + m_axeJoy.x);
event.axeY = AxeLimit(m_axeKey.y + m_axeJoy.y);
event.axeZ = AxeLimit(m_axeKey.z + m_axeJoy.z);
event.keyState = m_keyState;
//?char s[100];
//?sprintf(s, "StepSimul %.3f\n", event.rTime);
//?OutputDebugString(s);
m_pRobotMain->EventProcess(event);
}
1347: void CD3DApplication::StepSimul(float rTime)
1348: {
0041E950 sub esp,24h
0041E953 push esi
0041E954 mov esi,ecx
1349: Event event;
1350:
1351: if ( m_pRobotMain == 0 ) return;
0041E956 mov eax,dword ptr [esi+0ECh]
0041E95C test eax,eax
0041E95E je CD3DApplication::StepSimul(0x0041ea08)+0B8h
1352:
1353: if ( rTime > 0.5f ) rTime = 0.5f; // jamais plus de 0.5s !
0041E964 fld dword ptr [esp+2Ch]
0041E968 fcomp dword ptr [??_7CControl@@6B@(0x004b9ed4)+94h]
0041E96E push edi
0041E96F fnstsw ax
0041E971 test ah,41h
0041E974 jne CD3DApplication::StepSimul(0x0041e97e)+2Eh
0041E976 mov dword ptr [esp+30h],3F000000h
1354:
1355: ZeroMemory(&event, sizeof(Event));
1356: event.event = EVENT_FRAME;
1357: event.rTime = rTime;
1358: event.axeX = AxeLimit(m_axeKey.x + m_axeJoy.x);
0041E97E fld dword ptr [esi+0F8h]
0041E984 fadd dword ptr [esi+104h]
0041E98A mov eax,dword ptr [esp+30h]
0041E98E mov ecx,9
0041E993 mov dword ptr [esp+28h],eax
0041E997 push ecx
0041E998 xor eax,eax
0041E99A lea edi,dword ptr [esp+0Ch]
0041E99E fstp dword ptr [esp]
0041E9A1 rep stos dword ptr es:[edi]
0041E9A3 mov dword ptr [esp+0Ch],2
0041E9AB call AxeLimit(0x0041cae0)
1359: event.axeY = AxeLimit(m_axeKey.y + m_axeJoy.y);
0041E9B0 fld dword ptr [esi+0FCh]
0041E9B6 fadd dword ptr [esi+108h]
0041E9BC fxch st(1)
0041E9BE fstp dword ptr [esp+1Ch]
0041E9C2 fstp dword ptr [esp]
0041E9C5 call AxeLimit(0x0041cae0)
1360: event.axeZ = AxeLimit(m_axeKey.z + m_axeJoy.z);
0041E9CA fld dword ptr [esi+100h]
0041E9D0 fadd dword ptr [esi+10Ch]
0041E9D6 fxch st(1)
0041E9D8 fstp dword ptr [esp+20h]
0041E9DC fstp dword ptr [esp]
0041E9DF call AxeLimit(0x0041cae0)
1361: event.keyState = m_keyState;
1362:
1363: //?char s[100];
1364: //?sprintf(s, "StepSimul %.3f\n", event.rTime);
1365: //?OutputDebugString(s);
1366: m_pRobotMain->EventProcess(event);
0041E9E4 mov dx,word ptr [esi+0F4h]
0041E9EB mov ecx,dword ptr [esi+0ECh]
0041E9F1 fstp dword ptr [esp+24h]
0041E9F5 add esp,4
0041E9F8 lea eax,dword ptr [esp+8]
0041E9FC mov word ptr [esp+24h],dx
0041EA01 push eax
0041EA02 call CRobotMain::EventProcess(0x0047fba0)
0041EA07 pop edi
1367: }
0041EA08 pop esi
0041EA09 add esp,24h
0041EA0C ret 4

View File

@ -1,68 +0,0 @@
extern void object::Solution( )
{
while ( true )
{
object left, right;
left = Radar(TypeMarkPath, -45, 120, 100);
right = Radar(TypeMarkPath, 45, 120, 100);
if ( left == null && right == null )
{
}
}
}
CBotString::CBotString(const CBotString &)
CBotVar::GivName()
CBotStack::FindVar(CBotToken * &, int, int)
CBotStack::FindVar(CBotToken &, int, int)
CBotStack::CopyVar(CBotToken &, int)
CBotExpression::Execute(CBotStack * &)
CBotListInstr::Execute(CBotStack * &)
CBotWhile::Execute(CBotStack * &)
CBotListInstr::Execute(CBotStack * &)
CBotFunction::Execute(CBotVar * *, CBotStack * &)
CBotProgram::Run(void *)
CScript::Continue(const Event &)
CBotString::CBotString(const CBotString &) :
m_token = 0xdddddddd
CBotVar::GivName() :
return m_token->GivString();
CBotStack::FindVar(CBotToken * &, int, int) :
CBotStack* p = this;
CBotString name = pToken->GivString();
while (p != NULL)
{
CBotVar* pp = p->m_listVar;
while ( pp != NULL)
{
if (pp->GivName() == name) <- paf
avec :
pp->__vfprt = 0xdddddddd
pp->m_token = 0xdddddddd
pp->m_next = 0xdddddddd
pp->m_type = -572662307
pp->m_binit = -572662307
pp->m_pMyThis = 0xdddddddd
pp->m_pUserPtr = 0xdddddddd
pp->m_InitExpr = 0xdddddddd
CBotStack::FindVar(CBotToken &, int, int) :
CBotToken* pt = &Token;
pt->m_next = 0
pt->m_prev = 0
pt->m_type = 4
pt->m_IdKeyWord = -1
pt->m_Text = "right"
pt->m_Sep = " "
pt->m_start = 124
pt->m_end = 129

File diff suppressed because it is too large Load Diff

View File

@ -1,269 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// camera.h
#pragma once
#include "common/event.h"
#include "math/point.h"
#include "old/d3dengine.h"
class CInstanceManager;
class CD3DEngine;
class CTerrain;
class CWater;
class CObject;
enum CameraType
{
CAMERA_NULL = 0, // camera undefined
CAMERA_FREE = 1, // camera free (never in principle)
CAMERA_EDIT = 2, // camera while editing a program
CAMERA_ONBOARD = 3, // camera on board a robot
CAMERA_BACK = 4, // camera behind a robot
CAMERA_FIX = 5, // static camera following robot
CAMERA_EXPLO = 6, // camera steady after explosion
CAMERA_SCRIPT = 7, // camera during a film script
CAMERA_INFO = 8, // camera for displaying information
CAMERA_VISIT = 9, // visit instead of an error
CAMERA_DIALOG = 10, // camera for dialogue
CAMERA_PLANE = 11, // static camera height
};
enum CameraSmooth
{
CS_NONE = 0, // sharp
CS_NORM = 1, // normal
CS_HARD = 2, // hard
CS_SPEC = 3, // special
};
enum CenteringPhase
{
CP_NULL = 0,
CP_START = 1,
CP_WAIT = 2,
CP_STOP = 3,
};
enum CameraEffect
{
CE_NULL = 0, // no effect
CE_TERRAFORM = 1, // digging in
CE_CRASH = 2, // Vehicle driving is severely
CE_EXPLO = 3, // explosion
CE_SHOT = 4, // not mortal shot
CE_VIBRATION = 5, // vibration during construction
CE_PET = 6, // spleen reactor
};
enum OverEffect
{
OE_NULL = 0, // no effect
OE_BLOOD = 1, // flash red
OE_FADEINw = 2, // white -> nothing
OE_FADEOUTw = 3, // nothing -> white
OE_FADEOUTb = 4, // nothing -> blue
OE_BLITZ = 5, // lightning
};
class CCamera
{
public:
CCamera(CInstanceManager* iMan);
~CCamera();
bool EventProcess(const Event &event);
void Init(Math::Vector eye, Math::Vector lookat, float delay);
void SetObject(CObject* object);
CObject* RetObject();
void SetType(CameraType type);
CameraType RetType();
void SetSmooth(CameraSmooth type);
CameraSmooth RetSmoth();
void SetDist(float dist);
float RetDist();
void SetFixDirection(float angle);
float RetFixDirection();
void SetRemotePan(float value);
float RetRemotePan();
void SetRemoteZoom(float value);
float RetRemoteZoom();
void StartVisit(Math::Vector goal, float dist);
void StopVisit();
void RetCamera(Math::Vector &eye, Math::Vector &lookat);
bool StartCentering(CObject *object, float angleH, float angleV, float dist, float time);
bool StopCentering(CObject *object, float time);
void AbortCentering();
void FlushEffect();
void StartEffect(CameraEffect effect, Math::Vector pos, float force);
void FlushOver();
void SetOverBaseColor(D3DCOLORVALUE color);
void StartOver(OverEffect effect, Math::Vector pos, float force);
void FixCamera();
void SetScriptEye(Math::Vector eye);
void SetScriptLookat(Math::Vector lookat);
void SetEffect(bool bEnable);
void SetCameraScroll(bool bScroll);
void SetCameraInvertX(bool bInvert);
void SetCameraInvertY(bool bInvert);
float RetMotorTurn();
D3DMouse RetMouseDef(Math::Point pos);
protected:
bool EventMouseMove(const Event &event);
void EventMouseWheel(int dir);
bool EventFrame(const Event &event);
bool EventFrameFree(const Event &event);
bool EventFrameEdit(const Event &event);
bool EventFrameDialog(const Event &event);
bool EventFrameBack(const Event &event);
bool EventFrameFix(const Event &event);
bool EventFrameExplo(const Event &event);
bool EventFrameOnBoard(const Event &event);
bool EventFrameInfo(const Event &event);
bool EventFrameVisit(const Event &event);
bool EventFrameScript(const Event &event);
void SetViewTime(const Math::Vector &vEyePt, const Math::Vector &vLookatPt, float rTime);
bool IsCollision(Math::Vector &eye, Math::Vector lookat);
bool IsCollisionBack(Math::Vector &eye, Math::Vector lookat);
bool IsCollisionFix(Math::Vector &eye, Math::Vector lookat);
Math::Vector ExcludeTerrain(Math::Vector eye, Math::Vector lookat, float &angleH, float &angleV);
Math::Vector ExcludeObject(Math::Vector eye, Math::Vector lookat, float &angleH, float &angleV);
void SetViewParams(const Math::Vector &eye, const Math::Vector &lookat, const Math::Vector &up);
void EffectFrame(const Event &event);
void OverFrame(const Event &event);
protected:
CInstanceManager* m_iMan;
CD3DEngine* m_engine;
CTerrain* m_terrain;
CWater* m_water;
CameraType m_type; // the type of camera (CAMERA *)
CameraSmooth m_smooth; // type of smoothing
CObject* m_cameraObj; // object linked to the camera
float m_eyeDistance; // distance between the eyes
float m_initDelay; // time of initial centering
Math::Vector m_actualEye; // current eye
Math::Vector m_actualLookat; // aim current
Math::Vector m_finalEye; // final eye
Math::Vector m_finalLookat; // aim final
Math::Vector m_normEye; // normal eye
Math::Vector m_normLookat; // aim normal
float m_focus;
bool m_bRightDown;
Math::Point m_rightPosInit;
Math::Point m_rightPosCenter;
Math::Point m_rightPosMove;
Math::Vector m_eyePt; // CAMERA_FREE: eye
float m_directionH; // CAMERA_FREE: horizontal direction
float m_directionV; // CAMERA_FREE: vertical direction
float m_heightEye; // CAMERA_FREE: height above the ground
float m_heightLookat; // CAMERA_FREE: height above the ground
float m_speed; // CAMERA_FREE: speed of movement
float m_backDist; // CAMERA_BACK: distance
float m_backMin; // CAMERA_BACK: distance minimal
float m_addDirectionH; // CAMERA_BACK: additional direction
float m_addDirectionV; // CAMERA_BACK: additional direction
bool m_bTransparency;
float m_fixDist; // CAMERA_FIX: distance
float m_fixDirectionH; // CAMERA_FIX: direction
float m_fixDirectionV; // CAMERA_FIX: direction
Math::Vector m_visitGoal; // CAMERA_VISIT: target position
float m_visitDist; // CAMERA_VISIT: distance
float m_visitTime; // CAMERA_VISIT: relative time
CameraType m_visitType; // CAMERA_VISIT: initial type
float m_visitDirectionH; // CAMERA_VISIT: direction
float m_visitDirectionV; // CAMERA_VISIT: direction
float m_editHeight; // CAMERA_EDIT: height
float m_remotePan;
float m_remoteZoom;
Math::Point m_mousePos;
float m_mouseDirH;
float m_mouseDirV;
float m_mouseMarging;
float m_motorTurn;
CenteringPhase m_centeringPhase;
float m_centeringAngleH;
float m_centeringAngleV;
float m_centeringDist;
float m_centeringCurrentH;
float m_centeringCurrentV;
float m_centeringTime;
float m_centeringProgress;
CameraEffect m_effectType;
Math::Vector m_effectPos;
float m_effectForce;
float m_effectProgress;
Math::Vector m_effectOffset;
OverEffect m_overType;
float m_overForce;
float m_overTime;
D3DCOLORVALUE m_overColorBase;
D3DCOLORVALUE m_overColor;
int m_overMode;
float m_overFadeIn;
float m_overFadeOut;
Math::Vector m_scriptEye;
Math::Vector m_scriptLookat;
bool m_bEffect; // shocks if explosion?
bool m_bCameraScroll; // scroll in the edges?
bool m_bCameraInvertX; // X inversion in the edges?
bool m_bCameraInvertY; // Y inversion in the edges?
};

View File

@ -1,66 +0,0 @@
[Directory]
scene=scene
savegame=savegame
public=program
user=user
files=files
[Setup]
TotoMode=1
Tooltips=1
InterfaceGlint=1
NiceMouse=0
Movies=1
NiceReset=1
HimselfDamage=1
CameraScroll=0
CameraInvertX=0
InterfaceEffect=1
GroundShadow=1
GroundSpot=1
ObjectDirty=1
FogMode=1
LensMode=1
SkyMode=1
PlanetMode=1
LightMode=1
UseJoystick=0
ParticuleDensity=1.00
ClippingDistance=1.00
ObjectDetail=2.00
GadgetQuantity=1.00
TextureQuality=1
AudioVolume=4
MidiVolume=15
Sound3D=0
EditIndentMode=1
EditIndentValue=4
KeyMap=37+0 39+0 38+0 40+0 16+0 17+0 32+258 96+262 13+257 107+261 109+260 9+259 36+263 27+0 112+0 113+0 110+0 115+0 116+0 117+0
DeleteGamer=1
Soluce4=1
[Engine]
AlphaMode=1
StateColor=-1
BlackSrcBlend=0
BlackDestBlend=0
WhiteSrcBlend=0
WhiteDestBlend=0
DiffuseSrcBlend=0
DiffuseDestBlend=0
AlphaSrcBlend=0
AlphaDestBlend=0
[Gamer]
LastName=Linda
[Edit]
FontSize=9.00
WindowPos.x=0.09
WindowPos.y=0.08
WindowDim.x=0.69
WindowDim.y=0.84
IOPos.x=0.36
IOPos.y=0.15
IODim.x=0.50
IODim.y=0.55
[Device]
Name=Direct3D HAL
Mode=1600 x 1200 x 32
FullScreen=0

View File

@ -1,338 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
#include "math/geometry.h"
#include "math/conv.h"
#include "old/d3dengine.h"
#include "old/d3dmath.h"
#include "old/d3dutil.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
#include "old/math3d.h"
#include "old/terrain.h"
#include "object/object.h"
#include "old/cloud.h"
const int DIMEXPAND = 4; // extension of the dimensions
// Constructor of clouds.
CCloud::CCloud(CInstanceManager* iMan, CD3DEngine* engine)
{
m_iMan = iMan;
m_iMan->AddInstance(CLASS_CLOUD, this);
m_engine = engine;
m_terrain = 0;
m_level = 0.0f;
m_wind = Math::Vector(0.0f, 0.0f, 0.0f);
m_subdiv = 8;
m_filename[0] = 0;
m_bEnable = true;
}
// Destructor of clouds.
CCloud::~CCloud()
{
}
bool CCloud::EventProcess(const Event &event)
{
if ( event.event == EVENT_FRAME )
{
return EventFrame(event);
}
return true;
}
// Makes the clouds evolve.
bool CCloud::EventFrame(const Event &event)
{
if ( m_engine->RetPause() ) return true;
m_time += event.rTime;
if ( m_level == 0.0f ) return true;
if ( m_time-m_lastTest < 0.2f ) return true;
m_lastTest = m_time;
return true;
}
// Adjusts the position to normal, to imitate the clouds
// at movement.
void CCloud::AdjustLevel(Math::Vector &pos, Math::Vector &eye, float deep,
Math::Point &uv1, Math::Point &uv2)
{
float dist, factor;
uv1.x = (pos.x+20000.0f)/1280.0f;
uv1.y = (pos.z+20000.0f)/1280.0f;
uv1.x -= m_time*(m_wind.x/100.0f);
uv1.y -= m_time*(m_wind.z/100.0f);
uv2.x = 0.0f;
uv2.y = 0.0f;
dist = Math::DistanceProjected(pos, eye);
factor = powf(dist/deep, 2.0f);
pos.y -= m_level*factor*10.0f;
}
inline DWORD F2DW( FLOAT f )
{
return *((DWORD*)&f);
}
// Draw the clouds.
void CCloud::Draw()
{
LPDIRECT3DDEVICE7 device;
D3DVERTEX2* vertex;
Math::Matrix* matView;
D3DMATERIAL7 material;
Math::Matrix matrix;
Math::Vector n, pos, p, eye;
Math::Point uv1, uv2;
float iDeep, deep, size, fogStart, fogEnd;
int i, j, u;
if ( !m_bEnable ) return;
if ( m_level == 0.0f ) return;
if ( m_lineUsed == 0 ) return;
vertex = (D3DVERTEX2*)malloc(sizeof(D3DVERTEX2)*(m_brick+2)*2);
iDeep = m_engine->RetDeepView();
deep = (m_brick*m_size)/2.0f;
m_engine->SetDeepView(deep);
m_engine->SetFocus(m_engine->RetFocus());
m_engine->UpdateMatProj(); // increases the depth of view
//? fogStart = deep*0.10f;
//? fogEnd = deep*0.16f;
fogStart = deep*0.15f;
fogEnd = deep*0.24f;
device = m_engine->RetD3DDevice();
device->SetRenderState(D3DRENDERSTATE_AMBIENT, 0x00000000);
device->SetRenderState(D3DRENDERSTATE_LIGHTING, false);
device->SetRenderState(D3DRENDERSTATE_ZENABLE, false);
//? device->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true);
device->SetRenderState(D3DRENDERSTATE_FOGENABLE, true);
device->SetRenderState(D3DRENDERSTATE_FOGSTART, F2DW(fogStart));
device->SetRenderState(D3DRENDERSTATE_FOGEND, F2DW(fogEnd));
matView = m_engine->RetMatView();
{
D3DMATRIX mat = MAT_TO_D3DMAT(*matView);
device->SetTransform(D3DTRANSFORMSTATE_VIEW, &mat);
}
ZeroMemory( &material, sizeof(D3DMATERIAL7) );
material.diffuse = m_diffuse;
material.ambient = m_ambient;
m_engine->SetMaterial(material);
m_engine->SetTexture(m_filename, 0);
m_engine->SetTexture(m_filename, 1);
//? m_engine->SetState(D3DSTATETTb|D3DSTATEDUALw|D3DSTATEWRAP);
m_engine->SetState(D3DSTATETTb|D3DSTATEFOG|D3DSTATEWRAP);
//? m_engine->SetState(D3DSTATEWRAP);
matrix.LoadIdentity();
{
D3DMATRIX mat = MAT_TO_D3DMAT(matrix);
device->SetTransform(D3DTRANSFORMSTATE_WORLD, &mat);
}
size = m_size/2.0f;
eye = m_engine->RetEyePt();
n = Math::Vector(0.0f, -1.0f, 0.0f);
// Draws all the lines.
for ( i=0 ; i<m_lineUsed ; i++ )
{
pos.y = m_level;
pos.z = m_line[i].pz;
pos.x = m_line[i].px1;
u = 0;
p.x = pos.x-size;
p.z = pos.z+size;
p.y = pos.y;
AdjustLevel(p, eye, deep, uv1, uv2);
vertex[u++] = D3DVERTEX2(p, n, uv1.x,uv1.y, uv2.x,uv2.y);
p.x = pos.x-size;
p.z = pos.z-size;
p.y = pos.y;
AdjustLevel(p, eye, deep, uv1, uv2);
vertex[u++] = D3DVERTEX2(p, n, uv1.x,uv1.y, uv2.x,uv2.y);
for ( j=0 ; j<m_line[i].len ; j++ )
{
p.x = pos.x+size;
p.z = pos.z+size;
p.y = pos.y;
AdjustLevel(p, eye, deep, uv1, uv2);
vertex[u++] = D3DVERTEX2(p, n, uv1.x,uv1.y, uv2.x,uv2.y);
p.x = pos.x+size;
p.z = pos.z-size;
p.y = pos.y;
AdjustLevel(p, eye, deep, uv1, uv2);
vertex[u++] = D3DVERTEX2(p, n, uv1.x,uv1.y, uv2.x,uv2.y);
pos.x += size*2.0f;
}
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, u, NULL);
m_engine->AddStatisticTriangle(u-2);
}
m_engine->SetDeepView(iDeep);
m_engine->SetFocus(m_engine->RetFocus());
m_engine->UpdateMatProj(); // gives depth to initial
free(vertex);
}
// Updates the positions, relative to the ground.
bool CCloud::CreateLine(int x, int y, int len)
{
float offset;
m_line[m_lineUsed].x = x;
m_line[m_lineUsed].y = y;
m_line[m_lineUsed].len = len;
offset = m_brick*m_size/2.0f - m_size/2.0f;
m_line[m_lineUsed].px1 = m_size* m_line[m_lineUsed].x - offset;
m_line[m_lineUsed].px2 = m_size*(m_line[m_lineUsed].x+m_line[m_lineUsed].len) - offset;
m_line[m_lineUsed].pz = m_size* m_line[m_lineUsed].y - offset;
m_lineUsed ++;
return ( m_lineUsed < MAXCLOUDLINE );
}
// Creates all areas of cloud.
bool CCloud::Create(const char *filename,
D3DCOLORVALUE diffuse, D3DCOLORVALUE ambient,
float level)
{
int y;
m_diffuse = diffuse;
m_ambient = ambient;
m_level = level;
m_time = 0.0f;
m_lastTest = 0.0f;
strcpy(m_filename, filename);
if ( m_filename[0] != 0 )
{
m_engine->LoadTexture(m_filename, 0);
m_engine->LoadTexture(m_filename, 1);
}
if ( m_terrain == 0 )
{
m_terrain = (CTerrain*)m_iMan->SearchInstance(CLASS_TERRAIN);
}
m_wind = m_terrain->RetWind();
m_brick = m_terrain->RetBrick()*m_terrain->RetMosaic()*DIMEXPAND;
m_size = m_terrain->RetSize();
m_brick /= m_subdiv*DIMEXPAND;
m_size *= m_subdiv*DIMEXPAND;
if ( m_level == 0.0f ) return true;
m_lineUsed = 0;
for ( y=0 ; y<m_brick ; y++ )
{
CreateLine(0, y, m_brick);
}
return true;
}
// Removes all the clouds.
void CCloud::Flush()
{
m_level = 0.0f;
}
// Modifies the cloud level.
bool CCloud::SetLevel(float level)
{
m_level = level;
return Create(m_filename, m_diffuse, m_ambient,
m_level);
}
// Returns the current level of clouds.
float CCloud::RetLevel()
{
return m_level;
}
// Activate management of clouds.
void CCloud::SetEnable(bool bEnable)
{
m_bEnable = bEnable;
}
bool CCloud::RetEnable()
{
return m_bEnable;
}

View File

@ -1,88 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// cloud.h
#pragma once
#include "common/event.h"
#include "math/point.h"
#include "old/d3dengine.h"
class CInstanceManager;
class CD3DEngine;
class CTerrain;
const int MAXCLOUDLINE = 100;
struct CloudLine
{
short x, y; // beginning
short len; // in length x
float px1, px2, pz;
};
class CCloud
{
public:
CCloud(CInstanceManager* iMan, CD3DEngine* engine);
~CCloud();
bool EventProcess(const Event &event);
void Flush();
bool Create(const char *filename, D3DCOLORVALUE diffuse, D3DCOLORVALUE ambient, float level);
void Draw();
bool SetLevel(float level);
float RetLevel();
void SetEnable(bool bEnable);
bool RetEnable();
protected:
bool EventFrame(const Event &event);
void AdjustLevel(Math::Vector &pos, Math::Vector &eye, float deep, Math::Point &uv1, Math::Point &uv2);
bool CreateLine(int x, int y, int len);
protected:
CInstanceManager* m_iMan;
CD3DEngine* m_engine;
CTerrain* m_terrain;
char m_filename[100];
float m_level; // overall level
Math::Point m_speed; // feedrate (wind)
D3DCOLORVALUE m_diffuse; // diffuse color
D3DCOLORVALUE m_ambient; // ambient color
float m_time;
float m_lastTest;
int m_subdiv;
Math::Vector m_wind; // wind speed
int m_brick; // brick mosaic
float m_size; // size of a brick element
int m_lineUsed;
CloudLine m_line[MAXCLOUDLINE];
bool m_bEnable;
};

View File

@ -1,75 +0,0 @@
[Gamer]
LastName=Joueur
[Setup]
TotoMode=1
Tooltips=1
InterfaceGlint=1
NiceMouse=0
Movies=1
NiceReset=1
HimselfDamage=1
CameraScroll=1
CameraInvertX=0
InterfaceEffect=1
GroundShadow=1
GroundSpot=1
ObjectDirty=1
FogMode=1
LensMode=1
SkyMode=1
PlanetMode=1
LightMode=1
UseJoystick=0
ParticuleDensity=1.00
ClippingDistance=1.00
ObjectDetail=2.00
GadgetQuantity=1.00
TextureQuality=1
AudioVolume=15
MidiVolume=20
Sound3D=0
EditIndentMode=1
EditIndentValue=4
KeyMap=37+0 39+0 38+0 40+0 16+0 17+0 32+258 96+262 13+257 107+261 109+260 9+259 36+263 27+0 112+0 113+0 110+0 115+0 116+0 117+0
FullScreenActivateEnable=0
AccessMission=1
AccessUser=1
DeleteGamer=1
Soluce4=1
[Engine]
StateColor=-1
BlackSrcBlend=0
BlackDestBlend=0
WhiteSrcBlend=0
WhiteDestBlend=0
DiffuseSrcBlend=0
DiffuseDestBlend=0
AlphaSrcBlend=0
AlphaDestBlend=0
AlphaMode=1
[Device]
Name=Direct3D HAL
Mode=1600 x 1200 x 32
FullScreen=0
[Edit]
WindowPos.x=0.19
WindowPos.y=0.15
WindowDim.x=0.66
WindowDim.y=0.69
FontSize=9.00
IOPos.x=0.29
IOPos.y=0.34
IODim.x=0.50
IODim.y=0.55
IOPublic=0
[Directory]
scene=scene
savegame=savegame
public=program
user=user
files=files

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

File diff suppressed because it is too large Load Diff

View File

@ -1,166 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// d3dapp.h
#pragma once
#define D3D_OVERLOADS
#include <d3d.h>
#include "math/vector.h"
#include "old/d3dengine.h"
#include "old/d3dframe.h"
#include "old/d3denum.h"
#include "old/d3dutil.h"
#include "old/d3dres.h"
#include "common/misc.h"
#include "common/struct.h"
class CInstanceManager;
class CEvent;
class CRobotMain;
class CSound;
class CD3DApplication
{
public:
CD3DApplication();
~CD3DApplication();
protected:
LRESULT OnQuerySuspend( DWORD dwFlags );
LRESULT OnResumeSuspend( DWORD dwData );
public:
Error RegQuery();
Error AudioQuery();
Error CheckMistery(char *strCmdLine);
int GetVidMemTotal();
bool IsVideo8MB();
bool IsVideo32MB();
HRESULT Create( HINSTANCE, TCHAR* );
INT Run();
LRESULT MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
VOID Pause( bool bPause );
Math::Point ConvPosToInterface(HWND hWnd, LPARAM lParam);
void SetMousePos(Math::Point pos);
void StepSimul(float rTime);
char* RetCDpath();
void SetShowStat(bool bShow);
bool RetShowStat();
void SetDebugMode(bool bMode);
bool RetDebugMode();
bool RetSetupMode();
bool EnumDevices(char *bufDevices, int lenDevices, char *bufModes, int lenModes, int &totalDevices, int &selectDevices, int &totalModes, int &selectModes);
bool RetFullScreen();
bool ChangeDevice(char *device, char *mode, bool bFull);
void FlushPressKey();
void ResetKey();
void SetKey(int keyRank, int option, int key);
int RetKey(int keyRank, int option);
void SetJoystick(bool bEnable);
bool RetJoystick();
void SetMouseType(D3DMouse type);
void SetNiceMouse(bool bNice);
bool RetNiceMouse();
bool RetNiceMouseCap();
bool WriteScreenShot(char *filename, int width, int height);
bool GetRenderDC(HDC &hDC);
bool ReleaseRenderDC(HDC &hDC);
PBITMAPINFO CreateBitmapInfoStruct(HBITMAP hBmp);
bool CreateBMPFile(LPTSTR pszFile, PBITMAPINFO pbi, HBITMAP hBMP, HDC hDC);
protected:
HRESULT ConfirmDevice( DDCAPS* pddDriverCaps, D3DDEVICEDESC7* pd3dDeviceDesc );
HRESULT Initialize3DEnvironment();
HRESULT Change3DEnvironment();
HRESULT CreateZBuffer(GUID* pDeviceGUID);
HRESULT Render3DEnvironment();
VOID Cleanup3DEnvironment();
VOID DeleteDeviceObjects();
VOID DisplayFrameworkError( HRESULT, DWORD );
void InitText();
void DrawSuppl();
VOID ShowStats();
VOID OutputText( DWORD x, DWORD y, TCHAR* str );
protected:
CInstanceManager* m_iMan;
CEvent* m_event;
HINSTANCE m_instance;
HWND m_hWnd;
D3DEnum_DeviceInfo* m_pDeviceInfo;
LPDIRECTDRAW7 m_pDD;
LPDIRECT3D7 m_pD3D;
LPDIRECT3DDEVICE7 m_pD3DDevice;
LPDIRECTDRAWSURFACE7 m_pddsRenderTarget;
DDSURFACEDESC2 m_ddsdRenderTarget;
LPDIRECTDRAWSURFACE7 m_pddsDepthBuffer;
HANDLE m_thread;
DWORD m_threadId;
char m_CDpath[100];
CD3DFramework7* m_pFramework;
bool m_bActive;
bool m_bActivateApp;
bool m_bReady;
bool m_bJoystick;
DWORD m_vidMemTotal;
TCHAR* m_strWindowTitle;
bool m_bAppUseZBuffer;
bool m_bAppUseStereo;
bool m_bShowStats;
bool m_bDebugMode;
bool m_bAudioState;
bool m_bAudioTrack;
bool m_bNiceMouse;
bool m_bSetupMode;
HRESULT (*m_fnConfirmDevice)(DDCAPS*, D3DDEVICEDESC7*);
public:
CD3DEngine* m_pD3DEngine;
CRobotMain* m_pRobotMain;
CSound* m_pSound;
int m_keyState;
Math::Vector m_axeKey;
Math::Vector m_axeJoy;
bool m_bJoyButton[32];
Math::Point m_mousePos;
DWORD m_mshMouseWheel;
float m_aTime;
DWORD m_key[50][2];
};

File diff suppressed because it is too large Load Diff

View File

@ -1,678 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// d3dengine.h
#pragma once
#include <d3d.h>
#include "math/point.h"
#include "math/vector.h"
#include "math/matrix.h"
#include "common/struct.h"
class CD3DApplication;
class CInstanceManager;
class CObject;
class CLight;
class CText;
class CParticule;
class CWater;
class CCloud;
class CBlitz;
class CPlanet;
class CSound;
class CTerrain;
const int D3DMAXOBJECT = 1200;
const int D3DMAXSHADOW = 500;
const int D3DMAXGROUNDSPOT = 100;
enum D3DTypeObj
{
TYPENULL = 0, // object doesn't exist
TYPETERRAIN = 1, // terrain
TYPEFIX = 2, // fixed object
TYPEVEHICULE = 3, // moving object
TYPEDESCENDANT = 4, // part of a moving object
TYPEQUARTZ = 5, // fixed object type quartz
TYPEMETAL = 6, // fixed object type metal
};
enum D3DTypeTri
{
D3DTYPE6T = 1, // triangles
D3DTYPE6S = 2, // surfaces
};
enum D3DMaping
{
D3DMAPPINGX = 1,
D3DMAPPINGY = 2,
D3DMAPPINGZ = 3,
D3DMAPPING1X = 4,
D3DMAPPING1Y = 5,
D3DMAPPING1Z = 6,
};
enum D3DMouse
{
D3DMOUSEHIDE = 0, // no mouse
D3DMOUSENORM = 1,
D3DMOUSEWAIT = 2,
D3DMOUSEEDIT = 3,
D3DMOUSEHAND = 4,
D3DMOUSECROSS = 5,
D3DMOUSESHOW = 6,
D3DMOUSENO = 7,
D3DMOUSEMOVE = 8, // +
D3DMOUSEMOVEH = 9, // -
D3DMOUSEMOVEV = 10, // |
D3DMOUSEMOVED = 11, // /
D3DMOUSEMOVEI = 12, // \ //
D3DMOUSESCROLLL = 13, // <<
D3DMOUSESCROLLR = 14, // >>
D3DMOUSESCROLLU = 15, // ^
D3DMOUSESCROLLD = 16, // v
D3DMOUSETARGET = 17,
};
enum D3DShadowType
{
D3DSHADOWNORM = 0,
D3DSHADOWWORM = 1,
};
const int D3DSTATENORMAL = 0; // normal opaque materials
const int D3DSTATETTb = (1<<0); // the transparent texture (black = no)
const int D3DSTATETTw = (1<<1); // the transparent texture (white = no)
const int D3DSTATETD = (1<<2); // the transparent diffuse color
const int D3DSTATEWRAP = (1<<3); // texture wrappe
const int D3DSTATECLAMP = (1<<4); // texture borders with solid color
const int D3DSTATELIGHT = (1<<5); // light texture (ambient max)
const int D3DSTATEDUALb = (1<<6); // double black texturing
const int D3DSTATEDUALw = (1<<7); // double white texturing
const int D3DSTATEPART1 = (1<<8); // part 1 (no change in. MOD!)
const int D3DSTATEPART2 = (1<<9); // part 2
const int D3DSTATEPART3 = (1<<10); // part 3
const int D3DSTATEPART4 = (1<<11); // part 4
const int D3DSTATE2FACE = (1<<12); // double-sided face
const int D3DSTATEALPHA = (1<<13); // image using alpha channel
const int D3DSTATESECOND = (1<<14); // always use 2nd floor texturing
const int D3DSTATEFOG = (1<<15); // causes the fog
const int D3DSTATETCb = (1<<16); // the transparent color (black = no)
const int D3DSTATETCw = (1<<17); // the transparent color (white = no)
struct D3DTriangle
{
D3DVERTEX2 triangle[3];
D3DMATERIAL7 material;
int state;
char texName1[20];
char texName2[20];
};
struct D3DObjLevel6
{
int totalPossible;
int totalUsed;
D3DMATERIAL7 material;
int state;
D3DTypeTri type; // D3DTYPE6x
D3DVERTEX2 vertex[1];
};
struct D3DObjLevel5
{
int totalPossible;
int totalUsed;
int reserve;
D3DObjLevel6* table[1];
};
struct D3DObjLevel4
{
int totalPossible;
int totalUsed;
float min, max;
D3DObjLevel5* table[1];
};
struct D3DObjLevel3
{
int totalPossible;
int totalUsed;
int objRank;
D3DObjLevel4* table[1];
};
struct D3DObjLevel2
{
int totalPossible;
int totalUsed;
char texName1[20];
char texName2[20];
D3DObjLevel3* table[1];
};
struct D3DObjLevel1
{
int totalPossible;
int totalUsed;
D3DObjLevel2* table[1];
};
struct D3DObject
{
char bUsed; // true -> object exists
char bVisible; // true -> visible object
char bDrawWorld; // true -> shape behind the interface
char bDrawFront; // true -> shape before the interface
int totalTriangle; // number of triangles used
D3DTypeObj type; // type of the object (TYPE*)
Math::Matrix transform; // transformation matrix
float distance; // distance point of view - original
Math::Vector bboxMin; // bounding box of the object
Math::Vector bboxMax; // (the origin 0, 0, 0 is always included)
float radius; // radius of the sphere at the origin
int shadowRank; // rank of the associated shadow
float transparency; // transparency of the object (0 .. 1)
};
struct D3DShadow
{
char bUsed; // true -> object exists
char bHide; // true -> invisible shadow (object carried by ex.)
int objRank; // rank of the object
D3DShadowType type; // type of shadow
Math::Vector pos; // position for the shadow
Math::Vector normal; // normal terrain
float angle; // angle of the shadow
float radius; // radius of the shadow
float intensity; // intensity of the shadow
float height; // height from the ground
};
struct D3DGroundSpot
{
char bUsed; // true -> object exists
D3DCOLORVALUE color; // color of the shadow
float min, max; // altitudes min / max
float smooth; // transition area
Math::Vector pos; // position for the shadow
float radius; // radius of the shadow
Math::Vector drawPos; // drawn to position the shade
float drawRadius; // radius of the shadow drawn
};
struct D3DGroundMark
{
char bUsed; // true -> object exists
char bDraw; // true -> drawn mark
int phase; // 1 = increase, 2 = fixed, 3 = decrease
float delay[3]; // time for 3 phases
float fix; // fixed time
Math::Vector pos; // position for marks
float radius; // radius of marks
float intensity; // color intensity
Math::Vector drawPos; // drawn in position marks
float drawRadius; // radius marks drawn
float drawIntensity; // current drawn
int dx, dy; // dimensions table
char* table; // pointer to the table
};
class CD3DEngine
{
public:
CD3DEngine(CInstanceManager *iMan, CD3DApplication *app);
~CD3DEngine();
void SetD3DDevice(LPDIRECT3DDEVICE7 device);
LPDIRECT3DDEVICE7 RetD3DDevice();
void SetTerrain(CTerrain* terrain);
bool WriteProfile();
void SetPause(bool bPause);
bool RetPause();
void SetMovieLock(bool bLock);
bool RetMovieLock();
void SetShowStat(bool bShow);
bool RetShowStat();
void SetRenderEnable(bool bEnable);
HRESULT OneTimeSceneInit();
HRESULT InitDeviceObjects();
HRESULT DeleteDeviceObjects();
HRESULT RestoreSurfaces();
HRESULT Render();
HRESULT FrameMove(float rTime);
void StepSimul(float rTime);
HRESULT FinalCleanup();
void AddStatisticTriangle(int nb);
int RetStatisticTriangle();
void SetHiliteRank(int *rankList);
bool GetHilite(Math::Point &p1, Math::Point &p2);
bool GetSpriteCoord(int &x, int &y);
void SetInfoText(int line, char* text);
char* RetInfoText(int line);
LRESULT MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
void FirstExecuteAdapt(bool bFirst);
int GetVidMemTotal();
bool IsVideo8MB();
bool IsVideo32MB();
bool EnumDevices(char *bufDevices, int lenDevices, char *bufModes, int lenModes, int &totalDevices, int &selectDevices, int &totalModes, int &selectModes);
bool RetFullScreen();
bool ChangeDevice(char *device, char *mode, bool bFull);
Math::Matrix* RetMatView();
Math::Matrix* RetMatLeftView();
Math::Matrix* RetMatRightView();
void TimeInit();
void TimeEnterGel();
void TimeExitGel();
float TimeGet();
int RetRestCreate();
int CreateObject();
void FlushObject();
bool DeleteObject(int objRank);
bool SetDrawWorld(int objRank, bool bDraw);
bool SetDrawFront(int objRank, bool bDraw);
bool AddTriangle(int objRank, D3DVERTEX2* vertex, int nb, const D3DMATERIAL7 &mat, int state, char* texName1, char* texName2, float min, float max, bool bGlobalUpdate);
bool AddSurface(int objRank, D3DVERTEX2* vertex, int nb, const D3DMATERIAL7 &mat, int state, char* texName1, char* texName2, float min, float max, bool bGlobalUpdate);
bool AddQuick(int objRank, D3DObjLevel6* buffer, char* texName1, char* texName2, float min, float max, bool bGlobalUpdate);
D3DObjLevel6* SearchTriangle(int objRank, const D3DMATERIAL7 &mat, int state, char* texName1, char* texName2, float min, float max);
void ChangeLOD();
bool ChangeSecondTexture(int objRank, char* texName2);
int RetTotalTriangles(int objRank);
int GetTriangles(int objRank, float min, float max, D3DTriangle* buffer, int size, float percent);
bool GetBBox(int objRank, Math::Vector &min, Math::Vector &max);
bool ChangeTextureMapping(int objRank, const D3DMATERIAL7 &mat, int state, char* texName1, char* texName2, float min, float max, D3DMaping mode, float au, float bu, float av, float bv);
bool TrackTextureMapping(int objRank, const D3DMATERIAL7 &mat, int state, char* texName1, char* texName2, float min, float max, D3DMaping mode, float pos, float factor, float tl, float ts, float tt);
bool SetObjectTransform(int objRank, const Math::Matrix &transform);
bool GetObjectTransform(int objRank, Math::Matrix &transform);
bool SetObjectType(int objRank, D3DTypeObj type);
D3DTypeObj RetObjectType(int objRank);
bool SetObjectTransparency(int objRank, float value);
bool ShadowCreate(int objRank);
void ShadowDelete(int objRank);
bool SetObjectShadowHide(int objRank, bool bHide);
bool SetObjectShadowType(int objRank, D3DShadowType type);
bool SetObjectShadowPos(int objRank, const Math::Vector &pos);
bool SetObjectShadowNormal(int objRank, const Math::Vector &n);
bool SetObjectShadowAngle(int objRank, float angle);
bool SetObjectShadowRadius(int objRank, float radius);
bool SetObjectShadowIntensity(int objRank, float intensity);
bool SetObjectShadowHeight(int objRank, float h);
float RetObjectShadowRadius(int objRank);
void GroundSpotFlush();
int GroundSpotCreate();
void GroundSpotDelete(int rank);
bool SetObjectGroundSpotPos(int rank, const Math::Vector &pos);
bool SetObjectGroundSpotRadius(int rank, float radius);
bool SetObjectGroundSpotColor(int rank, D3DCOLORVALUE color);
bool SetObjectGroundSpotMinMax(int rank, float min, float max);
bool SetObjectGroundSpotSmooth(int rank, float smooth);
int GroundMarkCreate(Math::Vector pos, float radius, float delay1, float delay2, float delay3, int dx, int dy, char* table);
bool GroundMarkDelete(int rank);
void Update();
void SetViewParams(const Math::Vector &vEyePt, const Math::Vector &vLookatPt, const Math::Vector &vUpVec, FLOAT fEyeDistance);
bool FreeTexture(char* name);
bool LoadTexture(char* name, int stage=0);
bool LoadAllTexture();
void SetLimitLOD(int rank, float limit);
float RetLimitLOD(int rank, bool bLast=false);
void SetTerrainVision(float vision);
void SetGroundSpot(bool bMode);
bool RetGroundSpot();
void SetShadow(bool bMode);
bool RetShadow();
void SetDirty(bool bMode);
bool RetDirty();
void SetFog(bool bMode);
bool RetFog();
bool RetStateColor();
void SetSecondTexture(int texNum);
int RetSecondTexture();
void SetRankView(int rank);
int RetRankView();
void SetDrawWorld(bool bDraw);
void SetDrawFront(bool bDraw);
void SetAmbiantColor(D3DCOLOR color, int rank=0);
D3DCOLOR RetAmbiantColor(int rank=0);
void SetWaterAddColor(D3DCOLORVALUE color);
D3DCOLORVALUE RetWaterAddColor();
void SetFogColor(D3DCOLOR color, int rank=0);
D3DCOLOR RetFogColor(int rank=0);
void SetDeepView(float length, int rank=0, bool bRef=false);
float RetDeepView(int rank=0);
void SetFogStart(float start, int rank=0);
float RetFogStart(int rank=0);
void SetBackground(char *name, D3DCOLOR up=0, D3DCOLOR down=0, D3DCOLOR cloudUp=0, D3DCOLOR cloudDown=0, bool bFull=false, bool bQuarter=false);
void RetBackground(char *name, D3DCOLOR &up, D3DCOLOR &down, D3DCOLOR &cloudUp, D3DCOLOR &cloudDown, bool &bFull, bool &bQuarter);
void SetFrontsizeName(char *name);
void SetOverFront(bool bFront);
void SetOverColor(D3DCOLOR color=0, int mode=D3DSTATETCb);
void SetParticuleDensity(float value);
float RetParticuleDensity();
float ParticuleAdapt(float factor);
void SetClippingDistance(float value);
float RetClippingDistance();
void SetObjectDetail(float value);
float RetObjectDetail();
void SetGadgetQuantity(float value);
float RetGadgetQuantity();
void SetTextureQuality(int value);
int RetTextureQuality();
void SetTotoMode(bool bPresent);
bool RetTotoMode();
void SetLensMode(bool bPresent);
bool RetLensMode();
void SetWaterMode(bool bPresent);
bool RetWaterMode();
void SetBlitzMode(bool bPresent);
bool RetBlitzMode();
void SetSkyMode(bool bPresent);
bool RetSkyMode();
void SetBackForce(bool bPresent);
bool RetBackForce();
void SetPlanetMode(bool bPresent);
bool RetPlanetMode();
void SetLightMode(bool bPresent);
bool RetLightMode();
void SetEditIndentMode(bool bAuto);
bool RetEditIndentMode();
void SetEditIndentValue(int value);
int RetEditIndentValue();
void SetSpeed(float speed);
float RetSpeed();
void SetTracePrecision(float factor);
float RetTracePrecision();
void SetFocus(float focus);
float RetFocus();
Math::Vector RetEyePt();
Math::Vector RetLookatPt();
float RetEyeDirH();
float RetEyeDirV();
POINT RetDim();
void UpdateMatProj();
void ApplyChange();
void FlushPressKey();
void ResetKey();
void SetKey(int keyRank, int option, int key);
int RetKey(int keyRank, int option);
void SetJoystick(bool bEnable);
bool RetJoystick();
void SetDebugMode(bool bMode);
bool RetDebugMode();
bool RetSetupMode();
bool IsVisiblePoint(const Math::Vector &pos);
int DetectObject(Math::Point mouse);
void SetState(int state, D3DCOLOR color=0xffffffff);
void SetTexture(char *name, int stage=0);
void SetMaterial(const D3DMATERIAL7 &mat);
void MoveMousePos(Math::Point pos);
void SetMousePos(Math::Point pos);
Math::Point RetMousePos();
void SetMouseType(D3DMouse type);
D3DMouse RetMouseType();
void SetMouseHide(bool bHide);
bool RetMouseHide();
void SetNiceMouse(bool bNice);
bool RetNiceMouse();
bool RetNiceMouseCap();
CText* RetText();
bool ChangeColor(char *name, D3DCOLORVALUE colorRef1, D3DCOLORVALUE colorNew1, D3DCOLORVALUE colorRef2, D3DCOLORVALUE colorNew2, float tolerance1, float tolerance2, Math::Point ts, Math::Point ti, Math::Point *pExclu=0, float shift=0.0f, bool bHSV=false);
bool OpenImage(char *name);
bool CopyImage();
bool LoadImage();
bool ScrollImage(int dx, int dy);
bool SetDot(int x, int y, D3DCOLORVALUE color);
bool CloseImage();
bool WriteScreenShot(char *filename, int width, int height);
bool GetRenderDC(HDC &hDC);
bool ReleaseRenderDC(HDC &hDC);
PBITMAPINFO CreateBitmapInfoStruct(HBITMAP hBmp);
bool CreateBMPFile(LPTSTR pszFile, PBITMAPINFO pbi, HBITMAP hBMP, HDC hDC);
protected:
void MemSpace1(D3DObjLevel1 *&p, int nb);
void MemSpace2(D3DObjLevel2 *&p, int nb);
void MemSpace3(D3DObjLevel3 *&p, int nb);
void MemSpace4(D3DObjLevel4 *&p, int nb);
void MemSpace5(D3DObjLevel5 *&p, int nb);
void MemSpace6(D3DObjLevel6 *&p, int nb);
D3DObjLevel2* AddLevel1(D3DObjLevel1 *&p1, char* texName1, char* texName2);
D3DObjLevel3* AddLevel2(D3DObjLevel2 *&p2, int objRank);
D3DObjLevel4* AddLevel3(D3DObjLevel3 *&p3, float min, float max);
D3DObjLevel5* AddLevel4(D3DObjLevel4 *&p4, int reserve);
D3DObjLevel6* AddLevel5(D3DObjLevel5 *&p5, D3DTypeTri type, const D3DMATERIAL7 &mat, int state, int nb);
bool IsVisible(int objRank);
bool DetectBBox(int objRank, Math::Point mouse);
bool DetectTriangle(Math::Point mouse, D3DVERTEX2 *triangle, int objRank, float &dist);
bool TransformPoint(Math::Vector &p2D, int objRank, Math::Vector p3D);
void ComputeDistance();
void UpdateGeometry();
void RenderGroundSpot();
void DrawShadow();
void DrawBackground();
void DrawBackgroundGradient(D3DCOLOR up, D3DCOLOR down);
void DrawBackgroundImageQuarter(Math::Point p1, Math::Point p2, char *name);
void DrawBackgroundImage();
void DrawPlanet();
void DrawFrontsize();
void DrawOverColor();
bool GetBBox2D(int objRank, Math::Point &min, Math::Point &max);
void DrawHilite();
void DrawMouse();
void DrawSprite(Math::Point pos, Math::Point dim, int icon);
protected:
CInstanceManager* m_iMan;
CD3DApplication* m_app;
LPDIRECT3DDEVICE7 m_pD3DDevice;
CText* m_text;
CLight* m_light;
CParticule* m_particule;
CWater* m_water;
CCloud* m_cloud;
CBlitz* m_blitz;
CPlanet* m_planet;
CSound* m_sound;
CTerrain* m_terrain;
int m_blackSrcBlend[2];
int m_blackDestBlend[2];
int m_whiteSrcBlend[2];
int m_whiteDestBlend[2];
int m_diffuseSrcBlend[2];
int m_diffuseDestBlend[2];
int m_alphaSrcBlend[2];
int m_alphaDestBlend[2];
Math::Matrix m_matProj;
Math::Matrix m_matLeftView;
Math::Matrix m_matRightView;
Math::Matrix m_matView;
float m_focus;
Math::Matrix m_matWorldInterface;
Math::Matrix m_matProjInterface;
Math::Matrix m_matViewInterface;
DWORD m_baseTime;
DWORD m_stopTime;
float m_absTime;
float m_lastTime;
float m_speed;
bool m_bPause;
bool m_bRender;
bool m_bMovieLock;
POINT m_dim;
POINT m_lastDim;
D3DObjLevel1* m_objectPointer;
int m_objectParamTotal;
D3DObject* m_objectParam;
int m_shadowTotal;
D3DShadow* m_shadow;
D3DGroundSpot* m_groundSpot;
D3DGroundMark m_groundMark;
Math::Vector m_eyePt;
Math::Vector m_lookatPt;
float m_eyeDirH;
float m_eyeDirV;
int m_rankView;
D3DCOLOR m_ambiantColor[2];
D3DCOLOR m_backColor[2];
D3DCOLOR m_fogColor[2];
float m_deepView[2];
float m_fogStart[2];
D3DCOLORVALUE m_waterAddColor;
int m_statisticTriangle;
bool m_bUpdateGeometry;
char m_infoText[10][200];
int m_alphaMode;
bool m_bStateColor;
bool m_bForceStateColor;
bool m_bGroundSpot;
bool m_bShadow;
bool m_bDirty;
bool m_bFog;
bool m_bFirstGroundSpot;
int m_secondTexNum;
char m_backgroundName[50];
D3DCOLOR m_backgroundColorUp;
D3DCOLOR m_backgroundColorDown;
D3DCOLOR m_backgroundCloudUp;
D3DCOLOR m_backgroundCloudDown;
bool m_bBackgroundFull;
bool m_bBackgroundQuarter;
bool m_bOverFront;
D3DCOLOR m_overColor;
int m_overMode;
char m_frontsizeName[50];
bool m_bDrawWorld;
bool m_bDrawFront;
float m_limitLOD[2];
float m_particuleDensity;
float m_clippingDistance;
float m_lastClippingDistance;
float m_objectDetail;
float m_lastObjectDetail;
float m_terrainVision;
float m_gadgetQuantity;
int m_textureQuality;
bool m_bTotoMode;
bool m_bLensMode;
bool m_bWaterMode;
bool m_bSkyMode;
bool m_bBackForce;
bool m_bPlanetMode;
bool m_bLightMode;
bool m_bEditIndentMode;
int m_editIndentValue;
float m_tracePrecision;
int m_hiliteRank[100];
bool m_bHilite;
Math::Point m_hiliteP1;
Math::Point m_hiliteP2;
int m_lastState;
D3DCOLOR m_lastColor;
char m_lastTexture[2][50];
D3DMATERIAL7 m_lastMaterial;
Math::Point m_mousePos;
D3DMouse m_mouseType;
bool m_bMouseHide;
bool m_bNiceMouse;
LPDIRECTDRAWSURFACE7 m_imageSurface;
DDSURFACEDESC2 m_imageDDSD;
WORD* m_imageCopy;
int m_imageDX;
int m_imageDY;
};

View File

@ -1,620 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
//-----------------------------------------------------------------------------
// File: D3DEnum.cpp
//
// Desc: Functions to enumerate DDraw/D3D drivers, devices, and modes.
//
// Copyright (c) 1997-1999 Microsoft Corporation. All rights reserved
//-----------------------------------------------------------------------------
#include <windowsx.h>
#include <stdio.h>
#include <tchar.h>
#include "old/d3denum.h"
#include "old/d3dutil.h" // For DEBUG_MSG
#include "old/d3dres.h" // For dialog controls
//-----------------------------------------------------------------------------
// Global data for the enumerator functions
//-----------------------------------------------------------------------------
static HRESULT (*g_fnAppConfirmFn)(DDCAPS*, D3DDEVICEDESC7*) = NULL;
static D3DEnum_DeviceInfo g_pDeviceList[20];
static DWORD g_dwNumDevicesEnumerated = 0L;
static DWORD g_dwNumDevices = 0L;
//-----------------------------------------------------------------------------
// Name: SortModesCallback()
// Desc: Callback function for sorting display modes.
//-----------------------------------------------------------------------------
int SortModesCallback( const VOID* arg1, const VOID* arg2 )
{
DDSURFACEDESC2* p1 = (DDSURFACEDESC2*)arg1;
DDSURFACEDESC2* p2 = (DDSURFACEDESC2*)arg2;
if( p1->dwWidth < p2->dwWidth )
return -1;
if( p1->dwWidth > p2->dwWidth )
return +1;
if( p1->dwHeight < p2->dwHeight )
return -1;
if( p1->dwHeight > p2->dwHeight )
return +1;
if( p1->ddpfPixelFormat.dwRGBBitCount < p2->ddpfPixelFormat.dwRGBBitCount )
return -1;
if( p1->ddpfPixelFormat.dwRGBBitCount > p2->ddpfPixelFormat.dwRGBBitCount )
return +1;
return 0;
}
//-----------------------------------------------------------------------------
// Name: ModeEnumCallback()
// Desc: Callback function for enumerating display modes.
//-----------------------------------------------------------------------------
static HRESULT WINAPI ModeEnumCallback( DDSURFACEDESC2* pddsd,
VOID* pParentInfo )
{
D3DEnum_DeviceInfo* pDevice = (D3DEnum_DeviceInfo*)pParentInfo;
// Reallocate storage for the modes
DDSURFACEDESC2* pddsdNewModes = new DDSURFACEDESC2[pDevice->dwNumModes+1];
memcpy( pddsdNewModes, pDevice->pddsdModes,
pDevice->dwNumModes * sizeof(DDSURFACEDESC2) );
delete pDevice->pddsdModes;
pDevice->pddsdModes = pddsdNewModes;
// Add the new mode
pDevice->pddsdModes[pDevice->dwNumModes++] = (*pddsd);
return DDENUMRET_OK;
}
//-----------------------------------------------------------------------------
// Name: DeviceEnumCallback()
// Desc: Callback function for enumerating devices
//-----------------------------------------------------------------------------
static HRESULT WINAPI DeviceEnumCallback( TCHAR* strDesc, TCHAR* strName,
D3DDEVICEDESC7* pDesc,
VOID* pParentInfo )
{
DWORD i;
// Keep track of # of devices that were enumerated
g_dwNumDevicesEnumerated++;
D3DEnum_DeviceInfo* pDriverInfo = (D3DEnum_DeviceInfo*)pParentInfo;
D3DEnum_DeviceInfo* pDeviceInfo = &g_pDeviceList[g_dwNumDevices];
ZeroMemory( pDeviceInfo, sizeof(D3DEnum_DeviceInfo) );
// Select either the HAL or HEL device desc:
pDeviceInfo->bHardware = pDesc->dwDevCaps & D3DDEVCAPS_HWRASTERIZATION;
memcpy( &pDeviceInfo->ddDeviceDesc, pDesc, sizeof(D3DDEVICEDESC7) );
// Set up device info for this device
pDeviceInfo->bDesktopCompatible = pDriverInfo->bDesktopCompatible;
pDeviceInfo->ddDriverCaps = pDriverInfo->ddDriverCaps;
pDeviceInfo->ddHELCaps = pDriverInfo->ddHELCaps;
pDeviceInfo->guidDevice = pDesc->deviceGUID;
pDeviceInfo->pDeviceGUID = &pDeviceInfo->guidDevice;
pDeviceInfo->pddsdModes = new DDSURFACEDESC2[pDriverInfo->dwNumModes];
// Copy the driver GUID and description for the device
if( pDriverInfo->pDriverGUID )
{
pDeviceInfo->guidDriver = pDriverInfo->guidDriver;
pDeviceInfo->pDriverGUID = &pDeviceInfo->guidDriver;
lstrcpyn( pDeviceInfo->strDesc, pDriverInfo->strDesc, 39 );
}
else
{
pDeviceInfo->pDriverGUID = NULL;
lstrcpyn( pDeviceInfo->strDesc, strName, 39 );
}
//? if( strstr(strName, "T&L") != 0 ) return D3DENUMRET_OK;
// Avoid duplicates: only enum HW devices for secondary DDraw drivers.
if( NULL != pDeviceInfo->pDriverGUID && false == pDeviceInfo->bHardware )
return D3DENUMRET_OK;
// Give the app a chance to accept or reject this device.
if( g_fnAppConfirmFn )
if( FAILED( g_fnAppConfirmFn( &pDeviceInfo->ddDriverCaps,
&pDeviceInfo->ddDeviceDesc ) ) )
return D3DENUMRET_OK;
// Build list of supported modes for the device
for( i=0; i<pDriverInfo->dwNumModes; i++ )
{
DDSURFACEDESC2 ddsdMode = pDriverInfo->pddsdModes[i];
DWORD dwRenderDepths = pDeviceInfo->ddDeviceDesc.dwDeviceRenderBitDepth;
DWORD dwDepth = ddsdMode.ddpfPixelFormat.dwRGBBitCount;
// Accept modes that are compatable with the device
if( ( ( dwDepth == 32 ) && ( dwRenderDepths & DDBD_32 ) ) ||
( ( dwDepth == 24 ) && ( dwRenderDepths & DDBD_24 ) ) ||
( ( dwDepth == 16 ) && ( dwRenderDepths & DDBD_16 ) ) )
{
// Copy compatible modes to the list of device-supported modes
pDeviceInfo->pddsdModes[pDeviceInfo->dwNumModes++] = ddsdMode;
// Record whether the device has any stereo modes
if( ddsdMode.ddsCaps.dwCaps2 & DDSCAPS2_STEREOSURFACELEFT )
pDeviceInfo->bStereoCompatible = true;
}
}
// Bail if the device has no supported modes
if( 0 == pDeviceInfo->dwNumModes )
return D3DENUMRET_OK;
// Find a 640x480x16 mode for the default fullscreen mode
for( i=0; i<pDeviceInfo->dwNumModes; i++ )
{
if( ( pDeviceInfo->pddsdModes[i].dwWidth == 640 ) &&
( pDeviceInfo->pddsdModes[i].dwHeight == 480 ) &&
( pDeviceInfo->pddsdModes[i].ddpfPixelFormat.dwRGBBitCount == 16 ) )
{
pDeviceInfo->ddsdFullscreenMode = pDeviceInfo->pddsdModes[i];
pDeviceInfo->dwCurrentMode = i;
}
}
// Select whether the device is initially windowed
pDeviceInfo->bWindowed = pDeviceInfo->bDesktopCompatible;
// Accept the device and return
g_dwNumDevices++;
return D3DENUMRET_OK;
}
//-----------------------------------------------------------------------------
// Name: DriverEnumCallback()
// Desc: Callback function for enumerating drivers.
//-----------------------------------------------------------------------------
static bool WINAPI DriverEnumCallback( GUID* pGUID, TCHAR* strDesc,
TCHAR* strName, VOID*, HMONITOR )
{
D3DEnum_DeviceInfo d3dDeviceInfo;
LPDIRECTDRAW7 pDD;
LPDIRECT3D7 pD3D;
HRESULT hr;
// Use the GUID to create the DirectDraw object
hr = DirectDrawCreateEx( pGUID, (VOID**)&pDD, IID_IDirectDraw7, NULL );
if( FAILED(hr) )
{
DEBUG_MSG( _T("Can't create DDraw during enumeration!") );
return D3DENUMRET_OK;
}
// Create a D3D object, to enumerate the d3d devices
hr = pDD->QueryInterface( IID_IDirect3D7, (VOID**)&pD3D );
if( FAILED(hr) )
{
pDD->Release();
DEBUG_MSG( _T("Can't query IDirect3D7 during enumeration!") );
return D3DENUMRET_OK;
}
// Copy data to a device info structure
ZeroMemory( &d3dDeviceInfo, sizeof(d3dDeviceInfo) );
lstrcpyn( d3dDeviceInfo.strDesc, strDesc, 39 );
d3dDeviceInfo.ddDriverCaps.dwSize = sizeof(DDCAPS);
d3dDeviceInfo.ddHELCaps.dwSize = sizeof(DDCAPS);
pDD->GetCaps( &d3dDeviceInfo.ddDriverCaps, &d3dDeviceInfo.ddHELCaps );
if( pGUID )
{
d3dDeviceInfo.guidDriver = (*pGUID);
d3dDeviceInfo.pDriverGUID = &d3dDeviceInfo.guidDriver;
}
// Record whether the device can render into a desktop window
if( d3dDeviceInfo.ddDriverCaps.dwCaps2 & DDCAPS2_CANRENDERWINDOWED )
if( NULL == d3dDeviceInfo.pDriverGUID )
d3dDeviceInfo.bDesktopCompatible = true;
// Enumerate the fullscreen display modes.
pDD->EnumDisplayModes( 0, NULL, &d3dDeviceInfo, ModeEnumCallback );
// Sort list of display modes
qsort( d3dDeviceInfo.pddsdModes, d3dDeviceInfo.dwNumModes,
sizeof(DDSURFACEDESC2), SortModesCallback );
// Now, enumerate all the 3D devices
pD3D->EnumDevices( DeviceEnumCallback, &d3dDeviceInfo );
// Clean up and return
SAFE_DELETE( d3dDeviceInfo.pddsdModes );
pD3D->Release();
pDD->Release();
return DDENUMRET_OK;
}
//-----------------------------------------------------------------------------
// Name: D3DEnum_EnumerateDevices()
// Desc: Enumerates all drivers, devices, and modes. The callback function is
// called each device, to confirm that the device supports the feature
// set required by the app.
//-----------------------------------------------------------------------------
HRESULT D3DEnum_EnumerateDevices( HRESULT (*AppConfirmFn)(DDCAPS*, D3DDEVICEDESC7*) )
{
// Store the device enumeration callback function
g_fnAppConfirmFn = AppConfirmFn;
// Enumerate drivers, devices, and modes
DirectDrawEnumerateEx( DriverEnumCallback, NULL,
DDENUM_ATTACHEDSECONDARYDEVICES |
DDENUM_DETACHEDSECONDARYDEVICES |
DDENUM_NONDISPLAYDEVICES );
// Make sure devices were actually enumerated
if( 0 == g_dwNumDevicesEnumerated )
{
DEBUG_MSG( _T("No devices and/or modes were enumerated!") );
return D3DENUMERR_ENUMERATIONFAILED;
}
if( 0 == g_dwNumDevices )
{
DEBUG_MSG( _T("No enumerated devices were accepted!") );
DEBUG_MSG( _T("Try enabling the D3D Reference Rasterizer.") );
return D3DENUMERR_SUGGESTREFRAST;
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: D3DEnum_FreeResources()
// Desc: Cleans up any memory allocated during device enumeration
//-----------------------------------------------------------------------------
VOID D3DEnum_FreeResources()
{
for( DWORD i=0; i<g_dwNumDevices; i++ )
{
SAFE_DELETE( g_pDeviceList[i].pddsdModes );
}
}
//-----------------------------------------------------------------------------
// Name: D3DEnum_GetDevices()
// Desc: Returns a ptr to the array of D3DEnum_DeviceInfo structures.
//-----------------------------------------------------------------------------
VOID D3DEnum_GetDevices( D3DEnum_DeviceInfo** ppDevices, DWORD* pdwCount )
{
if( ppDevices )
(*ppDevices) = g_pDeviceList;
if( pdwCount )
(*pdwCount) = g_dwNumDevices;
}
//-----------------------------------------------------------------------------
// Name: UpdateDialogControls()
// Desc: Builds the list of devices and modes for the combo boxes in the device
// select dialog box.
//-----------------------------------------------------------------------------
static VOID UpdateDialogControls( HWND hDlg, D3DEnum_DeviceInfo* pCurrentDevice,
DWORD dwCurrentMode, bool bWindowed,
bool bStereo )
{
// Get access to the enumerated device list
D3DEnum_DeviceInfo* pDeviceList;
DWORD dwNumDevices;
D3DEnum_GetDevices( &pDeviceList, &dwNumDevices );
// Access to UI controls
HWND hwndDevice = GetDlgItem( hDlg, IDC_DEVICE_COMBO );
HWND hwndMode = GetDlgItem( hDlg, IDC_MODE_COMBO );
HWND hwndWindowed = GetDlgItem( hDlg, IDC_WINDOWED_CHECKBOX );
HWND hwndStereo = GetDlgItem( hDlg, IDC_STEREO_CHECKBOX );
HWND hwndFullscreenText = GetDlgItem( hDlg, IDC_FULLSCREEN_TEXT );
// Reset the content in each of the combo boxes
ComboBox_ResetContent( hwndDevice );
ComboBox_ResetContent( hwndMode );
// Don't let non-GDI devices be windowed
if( false == pCurrentDevice->bDesktopCompatible )
bWindowed = false;
// Add a list of devices to the device combo box
for( DWORD device = 0; device < dwNumDevices; device++ )
{
D3DEnum_DeviceInfo* pDevice = &pDeviceList[device];
// Add device name to the combo box
DWORD dwItem = ComboBox_AddString( hwndDevice, pDevice->strDesc );
// Set the remaining UI states for the current device
if( pDevice == pCurrentDevice )
{
// Set the combobox selection on the current device
ComboBox_SetCurSel( hwndDevice, dwItem );
// Enable/set the fullscreen checkbox, as appropriate
if( hwndWindowed )
{
EnableWindow( hwndWindowed, pDevice->bDesktopCompatible );
Button_SetCheck( hwndWindowed, bWindowed );
}
// Enable/set the stereo checkbox, as appropriate
if( hwndStereo )
{
EnableWindow( hwndStereo, pDevice->bStereoCompatible && !bWindowed );
Button_SetCheck( hwndStereo, bStereo );
}
// Enable/set the fullscreen modes combo, as appropriate
EnableWindow( hwndMode, !bWindowed );
EnableWindow( hwndFullscreenText, !bWindowed );
// Build the list of fullscreen modes
for( DWORD mode = 0; mode < pDevice->dwNumModes; mode++ )
{
DDSURFACEDESC2* pddsdMode = &pDevice->pddsdModes[mode];
// Skip non-stereo modes, if the device is in stereo mode
if( 0 == (pddsdMode->ddsCaps.dwCaps2&DDSCAPS2_STEREOSURFACELEFT) )
if( bStereo )
continue;
TCHAR strMode[80];
wsprintf( strMode, _T("%ld x %ld x %ld"),
pddsdMode->dwWidth, pddsdMode->dwHeight,
pddsdMode->ddpfPixelFormat.dwRGBBitCount );
// Add mode desc to the combo box
DWORD dwItem = ComboBox_AddString( hwndMode, strMode );
// Set the item data to identify this mode
ComboBox_SetItemData( hwndMode, dwItem, mode );
// Set the combobox selection on the current mode
if( mode == dwCurrentMode )
ComboBox_SetCurSel( hwndMode, dwItem );
// Since not all modes support stereo, select a default mode in
// case none was chosen yet.
if( bStereo && ( CB_ERR == ComboBox_GetCurSel( hwndMode ) ) )
ComboBox_SetCurSel( hwndMode, dwItem );
}
}
}
}
//-----------------------------------------------------------------------------
// Name: ChangeDeviceProc()
// Desc: Windows message handling function for the device select dialog
//-----------------------------------------------------------------------------
static INT_PTR CALLBACK ChangeDeviceProc( HWND hDlg, UINT uiMsg, WPARAM wParam,
LPARAM lParam )
{
static D3DEnum_DeviceInfo** ppDeviceArg;
static D3DEnum_DeviceInfo* pCurrentDevice;
static DWORD dwCurrentMode;
static bool bCurrentWindowed;
static bool bCurrentStereo;
// Get access to the enumerated device list
D3DEnum_DeviceInfo* pDeviceList;
DWORD dwNumDevices;
D3DEnum_GetDevices( &pDeviceList, &dwNumDevices );
// Handle the initialization message
if( WM_INITDIALOG == uiMsg )
{
// Get the app's current device, passed in as an lParam argument
ppDeviceArg = (D3DEnum_DeviceInfo**)lParam;
if( NULL == ppDeviceArg )
return false;
// Setup temp storage pointers for dialog
pCurrentDevice = (*ppDeviceArg);
dwCurrentMode = pCurrentDevice->dwCurrentMode;
bCurrentWindowed = pCurrentDevice->bWindowed;
bCurrentStereo = pCurrentDevice->bStereo;
UpdateDialogControls( hDlg, pCurrentDevice, dwCurrentMode,
bCurrentWindowed, bCurrentStereo );
return true;
}
else if( WM_COMMAND == uiMsg )
{
HWND hwndDevice = GetDlgItem( hDlg, IDC_DEVICE_COMBO );
HWND hwndMode = GetDlgItem( hDlg, IDC_MODE_COMBO );
HWND hwndWindowed = GetDlgItem( hDlg, IDC_WINDOWED_CHECKBOX );
HWND hwndStereo = GetDlgItem( hDlg, IDC_STEREO_CHECKBOX );
// Get current UI state
DWORD dwDevice = ComboBox_GetCurSel( hwndDevice );
DWORD dwModeItem = ComboBox_GetCurSel( hwndMode );
DWORD dwMode = ComboBox_GetItemData( hwndMode, dwModeItem );
bool bWindowed = hwndWindowed ? Button_GetCheck( hwndWindowed ) : 0;
bool bStereo = hwndStereo ? Button_GetCheck( hwndStereo ) : 0;
D3DEnum_DeviceInfo* pDevice = &pDeviceList[dwDevice];
if( IDOK == LOWORD(wParam) )
{
// Handle the case when the user hits the OK button. Check if any
// of the options were changed
if( pDevice != pCurrentDevice || dwMode != dwCurrentMode ||
bWindowed != bCurrentWindowed || bStereo != bCurrentStereo )
{
// Return the newly selected device and its new properties
(*ppDeviceArg) = pDevice;
pDevice->bWindowed = bWindowed;
pDevice->bStereo = bStereo;
pDevice->dwCurrentMode = dwMode;
pDevice->ddsdFullscreenMode = pDevice->pddsdModes[dwMode];
EndDialog( hDlg, IDOK );
}
else
EndDialog( hDlg, IDCANCEL );
return true;
}
else if( IDCANCEL == LOWORD(wParam) )
{
// Handle the case when the user hits the Cancel button
EndDialog( hDlg, IDCANCEL );
return true;
}
else if( CBN_SELENDOK == HIWORD(wParam) )
{
if( LOWORD(wParam) == IDC_DEVICE_COMBO )
{
// Handle the case when the user chooses the device combo
dwMode = pDeviceList[dwDevice].dwCurrentMode;
bWindowed = pDeviceList[dwDevice].bWindowed;
bStereo = pDeviceList[dwDevice].bStereo;
}
}
// Keep the UI current
UpdateDialogControls( hDlg, &pDeviceList[dwDevice], dwMode, bWindowed, bStereo );
return true;
}
return false;
}
//-----------------------------------------------------------------------------
// Name: D3DEnum_UserChangeDevice()
// Desc: Pops up a dialog which allows the user to select a new device.
//-----------------------------------------------------------------------------
HRESULT D3DEnum_UserChangeDevice( D3DEnum_DeviceInfo** ppDevice )
{
if( IDOK == DialogBoxParam( (HINSTANCE)GetModuleHandle(NULL),
MAKEINTRESOURCE(IDD_CHANGEDEVICE),
GetForegroundWindow(),
ChangeDeviceProc, (LPARAM)ppDevice ) )
return S_OK;
return E_FAIL;
}
//-----------------------------------------------------------------------------
// Name: D3DEnum_SelectDefaultDevice()
// Desc: Pick a default device, preferably hardware and desktop compatible.
//-----------------------------------------------------------------------------
HRESULT D3DEnum_SelectDefaultDevice( D3DEnum_DeviceInfo** ppDevice,
DWORD dwFlags )
{
// Check arguments
if( NULL == ppDevice )
return E_INVALIDARG;
// Get access to the enumerated device list
D3DEnum_DeviceInfo* pDeviceList;
DWORD dwNumDevices;
D3DEnum_GetDevices( &pDeviceList, &dwNumDevices );
// Look for windowable software, hardware, and hardware TnL devices
D3DEnum_DeviceInfo* pRefRastDevice = NULL;
D3DEnum_DeviceInfo* pSoftwareDevice = NULL;
D3DEnum_DeviceInfo* pHardwareDevice = NULL;
D3DEnum_DeviceInfo* pHardwareTnLDevice = NULL;
for( DWORD i=0; i<dwNumDevices; i++ )
{
if( pDeviceList[i].bDesktopCompatible )
{
if( pDeviceList[i].bHardware )
{
if( (*pDeviceList[i].pDeviceGUID) == IID_IDirect3DTnLHalDevice )
pHardwareTnLDevice = &pDeviceList[i];
else
pHardwareDevice = &pDeviceList[i];
}
else
{
if( (*pDeviceList[i].pDeviceGUID) == IID_IDirect3DRefDevice )
pRefRastDevice = &pDeviceList[i];
else
pSoftwareDevice = &pDeviceList[i];
}
}
}
// Prefer a hardware non-TnL device first, then a TnL hardware device, and
// finally, a software device.
if( 0 == ( dwFlags & D3DENUM_SOFTWAREONLY ) && pHardwareDevice )
(*ppDevice) = pHardwareDevice;
else if( 0 == ( dwFlags & D3DENUM_SOFTWAREONLY ) && pHardwareTnLDevice )
(*ppDevice) = pHardwareTnLDevice;
else if( pSoftwareDevice )
(*ppDevice) = pSoftwareDevice;
else if( pRefRastDevice )
(*ppDevice) = pRefRastDevice;
else
return D3DENUMERR_NOCOMPATIBLEDEVICES;
// Set the windowed state of the newly selected device
(*ppDevice)->bWindowed = true;
return S_OK;
}

View File

@ -1,133 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
//-----------------------------------------------------------------------------
// File: D3DEnum.h
//
// Desc: Functions to enumerate DDraw/D3D drivers, devices, and modes.
//
// Copyright (c) 1997-1999 Microsoft Corporation. All rights reserved
//-----------------------------------------------------------------------------
#pragma once
#include <d3d.h>
//-----------------------------------------------------------------------------
// Flag and error definitions
//-----------------------------------------------------------------------------
#define D3DENUM_SOFTWAREONLY 0x00000001 // Software-devices only flag
#define D3DENUMERR_NODIRECTDRAW 0x81000001 // Could not create DDraw
#define D3DENUMERR_ENUMERATIONFAILED 0x81000002 // Enumeration failed
#define D3DENUMERR_SUGGESTREFRAST 0x81000003 // Suggest using the RefRast
#define D3DENUMERR_NOCOMPATIBLEDEVICES 0x81000004 // No devices were found that
// meet the app's desired
// capabilities
#define D3DENUMERR_ENGINE 0x81000005 // 3D engine error
#define D3DENUMERR_ROBOT 0x81000006 // robot error
#define D3DENUMERR_SOUND 0x81000007 // sound error
//-----------------------------------------------------------------------------
// Name: struct D3DEnum_DeviceInfo
// Desc: Structure to hold info about the enumerated Direct3D devices.
//-----------------------------------------------------------------------------
struct D3DEnum_DeviceInfo
{
// D3D Device info
TCHAR strDesc[40];
GUID* pDeviceGUID;
D3DDEVICEDESC7 ddDeviceDesc;
bool bHardware;
// DDraw Driver info
GUID* pDriverGUID;
DDCAPS ddDriverCaps;
DDCAPS ddHELCaps;
// DDraw Mode Info
DDSURFACEDESC2 ddsdFullscreenMode;
bool bWindowed;
bool bStereo;
// For internal use (apps should not need to use these)
GUID guidDevice;
GUID guidDriver;
DDSURFACEDESC2* pddsdModes;
DWORD dwNumModes;
DWORD dwCurrentMode;
bool bDesktopCompatible;
bool bStereoCompatible;
};
// For code not yet switched to new struct name
typedef D3DEnum_DeviceInfo D3DDEVICEINFO;
//-----------------------------------------------------------------------------
// Name: D3DEnum_EnumerateDevices()
// Desc: Enumerates all drivers, devices, and modes. The callback function is
// called each device, to confirm that the device supports the feature
// set required by the app.
//-----------------------------------------------------------------------------
HRESULT D3DEnum_EnumerateDevices( HRESULT (*fn)(DDCAPS*, D3DDEVICEDESC7*) );
//-----------------------------------------------------------------------------
// Name: D3DEnum_FreeResources()
// Desc: Cleans up any memory allocated during device enumeration
//-----------------------------------------------------------------------------
VOID D3DEnum_FreeResources();
//-----------------------------------------------------------------------------
// Name: D3DEnum_GetDevices()
// Desc: Returns a ptr to the array of enumerated D3DDEVICEINFO structures.
//-----------------------------------------------------------------------------
VOID D3DEnum_GetDevices( D3DEnum_DeviceInfo** ppDevices, DWORD* pdwCount );
//-----------------------------------------------------------------------------
// Name: D3DEnum_SelectDefaultDevice()
// Desc: Picks a driver based on a set of passed in criteria. The
// D3DENUM_SOFTWAREONLY flag can be used to pick a software device.
//-----------------------------------------------------------------------------
HRESULT D3DEnum_SelectDefaultDevice( D3DEnum_DeviceInfo** pDevice,
DWORD dwFlags = 0L );
//-----------------------------------------------------------------------------
// Name: D3DEnum_UserChangeDevice()
// Desc: Pops up a dialog which allows the user to select a new device.
//-----------------------------------------------------------------------------
HRESULT D3DEnum_UserChangeDevice( D3DEnum_DeviceInfo** ppDevice );

View File

@ -1,622 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
//-----------------------------------------------------------------------------
// File: D3DFrame.cpp
//
// Desc: Class functions to implement a Direct3D app framework.
//
// Copyright (c) 1995-1999 by Microsoft, all rights reserved
//-----------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include "old/d3dframe.h"
#include "old/d3dutil.h"
//-----------------------------------------------------------------------------
// Name: CD3DFramework7()
// Desc: The constructor. Clears static variables
//-----------------------------------------------------------------------------
CD3DFramework7::CD3DFramework7()
{
m_hWnd = NULL;
m_bIsFullscreen = false;
m_bIsStereo = false;
m_dwRenderWidth = 0L;
m_dwRenderHeight = 0L;
m_pddsFrontBuffer = NULL;
m_pddsBackBuffer = NULL;
m_pddsBackBufferLeft = NULL;
m_pddsZBuffer = NULL;
m_pd3dDevice = NULL;
m_pDD = NULL;
m_pD3D = NULL;
m_dwDeviceMemType = NULL;
}
//-----------------------------------------------------------------------------
// Name: ~CD3DFramework7()
// Desc: The destructor. Deletes all objects
//-----------------------------------------------------------------------------
CD3DFramework7::~CD3DFramework7()
{
DestroyObjects();
}
//-----------------------------------------------------------------------------
// Name: DestroyObjects()
// Desc: Cleans everything up upon deletion. This code returns an error
// if any of the objects have remaining reference counts.
//-----------------------------------------------------------------------------
HRESULT CD3DFramework7::DestroyObjects()
{
LONG nDD = 0L; // Number of outstanding DDraw references
LONG nD3D = 0L; // Number of outstanding D3DDevice references
if( m_pDD )
{
HRESULT err = m_pDD->SetCooperativeLevel( m_hWnd, DDSCL_NORMAL );
char s[100];
sprintf(s, "SetCooperativeLevel error=%d\n", err);
OutputDebugString(s);
}
// Do a safe check for releasing the D3DDEVICE. RefCount must be zero.
if( m_pd3dDevice )
if( 0 < ( nD3D = m_pd3dDevice->Release() ) )
DEBUG_MSG( _T("Error: D3DDevice object is still referenced!") );
m_pd3dDevice = NULL;
SAFE_RELEASE( m_pddsBackBuffer );
SAFE_RELEASE( m_pddsBackBufferLeft );
SAFE_RELEASE( m_pddsZBuffer );
SAFE_RELEASE( m_pddsFrontBuffer );
SAFE_RELEASE( m_pD3D );
if( m_pDD )
{
// Do a safe check for releasing DDRAW. RefCount must be zero.
if( 0 < ( nDD = m_pDD->Release() ) )
DEBUG_MSG( _T("Error: DDraw object is still referenced!") );
}
m_pDD = NULL;
// Return successful, unless there are outstanding DD or D3DDevice refs.
return ( nDD==0 && nD3D==0 ) ? S_OK : D3DFWERR_NONZEROREFCOUNT;
}
//-----------------------------------------------------------------------------
// Name: Initialize()
// Desc: Creates the internal objects for the framework
//-----------------------------------------------------------------------------
HRESULT CD3DFramework7::Initialize( HWND hWnd, GUID* pDriverGUID,
GUID* pDeviceGUID, DDSURFACEDESC2* pMode,
DWORD dwFlags )
{
HRESULT hr;
// Check params. Note: A NULL mode is valid for windowed modes only.
if( ( NULL==hWnd ) || ( NULL==pDeviceGUID ) ||
( NULL==pMode && (dwFlags&D3DFW_FULLSCREEN) ) )
return E_INVALIDARG;
// Setup state for windowed/fullscreen mode
m_hWnd = hWnd;
m_bIsStereo = false;
m_bIsFullscreen = ( dwFlags & D3DFW_FULLSCREEN ) ? true : false;
// Support stereoscopic viewing for fullscreen modes which support it
if( ( dwFlags & D3DFW_STEREO ) && ( dwFlags & D3DFW_FULLSCREEN ) )
if( pMode->ddsCaps.dwCaps2 & DDSCAPS2_STEREOSURFACELEFT )
m_bIsStereo = true;
// Create the D3D rendering environment (surfaces, device, viewport, etc.)
if( FAILED( hr = CreateEnvironment( pDriverGUID, pDeviceGUID, pMode,
dwFlags ) ) )
{
DestroyObjects();
return hr;
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: CreateEnvironment()
// Desc: Creates the internal objects for the framework
//-----------------------------------------------------------------------------
HRESULT CD3DFramework7::CreateEnvironment( GUID* pDriverGUID, GUID* pDeviceGUID,
DDSURFACEDESC2* pMode, DWORD dwFlags )
{
HRESULT hr;
// Select the default memory type, for whether the device is HW or SW
if( IsEqualIID( *pDeviceGUID, IID_IDirect3DHALDevice) )
m_dwDeviceMemType = DDSCAPS_VIDEOMEMORY;
else if( IsEqualIID( *pDeviceGUID, IID_IDirect3DTnLHalDevice) )
m_dwDeviceMemType = DDSCAPS_VIDEOMEMORY;
else
m_dwDeviceMemType = DDSCAPS_SYSTEMMEMORY;
// Create the DDraw object
hr = CreateDirectDraw( pDriverGUID, dwFlags );
if( FAILED( hr ) )
return hr;
// Create the front and back buffers, and attach a clipper
if( dwFlags & D3DFW_FULLSCREEN )
hr = CreateFullscreenBuffers( pMode );
else
hr = CreateWindowedBuffers();
if( FAILED( hr ) )
return hr;
// Create the Direct3D object and the Direct3DDevice object
hr = CreateDirect3D( pDeviceGUID );
if( FAILED( hr ) )
return hr;
// Create and attach the zbuffer
if( dwFlags & D3DFW_ZBUFFER )
hr = CreateZBuffer( pDeviceGUID );
if( FAILED( hr ) )
return hr;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: EnumZBufferFormatsCallback()
// Desc: Simply returns the first matching enumerated z-buffer format
//-----------------------------------------------------------------------------
static HRESULT WINAPI EnumZBufferFormatsCallback( DDPIXELFORMAT* pddpf,
VOID* pContext )
{
DDPIXELFORMAT* pddpfOut = (DDPIXELFORMAT*)pContext;
if( pddpfOut->dwRGBBitCount == pddpf->dwRGBBitCount )
{
(*pddpfOut) = (*pddpf);
return D3DENUMRET_CANCEL;
}
return D3DENUMRET_OK;
}
//-----------------------------------------------------------------------------
// Name: CreateDirectDraw()
// Desc: Create the DirectDraw interface
//-----------------------------------------------------------------------------
HRESULT CD3DFramework7::CreateDirectDraw( GUID* pDriverGUID, DWORD dwFlags )
{
// Create the DirectDraw interface, and query for the DD7 interface
if( FAILED( DirectDrawCreateEx( pDriverGUID, (VOID**)&m_pDD,
IID_IDirectDraw7, NULL ) ) )
{
DEBUG_MSG( _T("Could not create DirectDraw") );
return D3DFWERR_NODIRECTDRAW;
}
// Set the Windows cooperative level
DWORD dwCoopFlags = DDSCL_NORMAL;
if( m_bIsFullscreen )
dwCoopFlags = DDSCL_ALLOWREBOOT|DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN;
// By defualt, set the flag to allow D3D to optimize floating point calcs
if( 0L == ( dwFlags & D3DFW_NO_FPUSETUP ) )
dwCoopFlags |= DDSCL_FPUSETUP;
if( FAILED( m_pDD->SetCooperativeLevel( m_hWnd, dwCoopFlags ) ) )
{
DEBUG_MSG( _T("Couldn't set coop level") );
return D3DFWERR_COULDNTSETCOOPLEVEL;
}
// Check that we are NOT in a palettized display. That case will fail,
// since the framework doesn't use palettes.
DDSURFACEDESC2 ddsd;
ddsd.dwSize = sizeof(ddsd);
m_pDD->GetDisplayMode( &ddsd );
if( ddsd.ddpfPixelFormat.dwRGBBitCount <= 8 )
return D3DFWERR_INVALIDMODE;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: CreateFullscreenBuffers()
// Desc: Creates the primary and (optional) backbuffer for rendering.
// Windowed mode and fullscreen mode are handled differently.
//-----------------------------------------------------------------------------
HRESULT CD3DFramework7::CreateFullscreenBuffers( DDSURFACEDESC2* pddsd )
{
HRESULT hr;
// Get the dimensions of the screen bounds
// Store the rectangle which contains the renderer
SetRect( &m_rcScreenRect, 0, 0, pddsd->dwWidth, pddsd->dwHeight );
m_dwRenderWidth = m_rcScreenRect.right - m_rcScreenRect.left;
m_dwRenderHeight = m_rcScreenRect.bottom - m_rcScreenRect.top;
// Set the display mode to the requested dimensions. Check for
// 320x200x8 modes, and set flag to avoid using ModeX
DWORD dwModeFlags = 0;
if( (320==m_dwRenderWidth) && (200==m_dwRenderHeight) &&
(8==pddsd->ddpfPixelFormat.dwRGBBitCount) )
dwModeFlags |= DDSDM_STANDARDVGAMODE;
if( FAILED( m_pDD->SetDisplayMode( m_dwRenderWidth, m_dwRenderHeight,
pddsd->ddpfPixelFormat.dwRGBBitCount,
pddsd->dwRefreshRate, dwModeFlags ) ) )
{
DEBUG_MSG( _T("Can't set display mode") );
return D3DFWERR_BADDISPLAYMODE;
}
// Setup to create the primary surface w/backbuffer
DDSURFACEDESC2 ddsd;
ZeroMemory( &ddsd, sizeof(ddsd) );
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS|DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE |
DDSCAPS_FLIP | DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 1;
// Support for stereoscopic viewing
if( m_bIsStereo )
{
ddsd.ddsCaps.dwCaps |= DDSCAPS_VIDEOMEMORY;
ddsd.ddsCaps.dwCaps2 |= DDSCAPS2_STEREOSURFACELEFT;
}
// Create the primary surface
if( FAILED( hr = m_pDD->CreateSurface( &ddsd, &m_pddsFrontBuffer, NULL ) ) )
{
DEBUG_MSG( _T("Error: Can't create primary surface") );
if( hr != DDERR_OUTOFVIDEOMEMORY )
return D3DFWERR_NOPRIMARY;
DEBUG_MSG( _T("Error: Out of video memory") );
return DDERR_OUTOFVIDEOMEMORY;
}
// Get the backbuffer, which was created along with the primary.
DDSCAPS2 ddscaps = { DDSCAPS_BACKBUFFER, 0, 0, 0 };
if( FAILED( hr = m_pddsFrontBuffer->GetAttachedSurface( &ddscaps,
&m_pddsBackBuffer ) ) )
{
DEBUG_ERR( hr, _T("Error: Can't get the backbuffer") );
return D3DFWERR_NOBACKBUFFER;
}
// Increment the backbuffer count (for consistency with windowed mode)
m_pddsBackBuffer->AddRef();
// Support for stereoscopic viewing
if( m_bIsStereo )
{
// Get the left backbuffer, which was created along with the primary.
DDSCAPS2 ddscaps = { 0, DDSCAPS2_STEREOSURFACELEFT, 0, 0 };
if( FAILED( hr = m_pddsBackBuffer->GetAttachedSurface( &ddscaps,
&m_pddsBackBufferLeft ) ) )
{
DEBUG_ERR( hr, _T("Error: Can't get the left backbuffer") );
return D3DFWERR_NOBACKBUFFER;
}
m_pddsBackBufferLeft->AddRef();
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: CreateWindowedBuffers()
// Desc: Creates the primary and (optional) backbuffer for rendering.
// Windowed mode and fullscreen mode are handled differently.
//-----------------------------------------------------------------------------
HRESULT CD3DFramework7::CreateWindowedBuffers()
{
HRESULT hr;
// Get the dimensions of the viewport and screen bounds
GetClientRect( m_hWnd, &m_rcScreenRect );
ClientToScreen( m_hWnd, (POINT*)&m_rcScreenRect.left );
ClientToScreen( m_hWnd, (POINT*)&m_rcScreenRect.right );
m_dwRenderWidth = m_rcScreenRect.right - m_rcScreenRect.left;
m_dwRenderHeight = m_rcScreenRect.bottom - m_rcScreenRect.top;
// Create the primary surface
DDSURFACEDESC2 ddsd;
ZeroMemory( &ddsd, sizeof(ddsd) );
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
if( FAILED( hr = m_pDD->CreateSurface( &ddsd, &m_pddsFrontBuffer, NULL ) ) )
{
DEBUG_MSG( _T("Error: Can't create primary surface") );
if( hr != DDERR_OUTOFVIDEOMEMORY )
return D3DFWERR_NOPRIMARY;
DEBUG_MSG( _T("Error: Out of video memory") );
return DDERR_OUTOFVIDEOMEMORY;
}
// If in windowed-mode, create a clipper object
LPDIRECTDRAWCLIPPER pcClipper;
if( FAILED( hr = m_pDD->CreateClipper( 0, &pcClipper, NULL ) ) )
{
DEBUG_MSG( _T("Error: Couldn't create clipper") );
return D3DFWERR_NOCLIPPER;
}
// Associate the clipper with the window
pcClipper->SetHWnd( 0, m_hWnd );
m_pddsFrontBuffer->SetClipper( pcClipper );
SAFE_RELEASE( pcClipper );
// Create a backbuffer
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
ddsd.dwWidth = m_dwRenderWidth;
ddsd.dwHeight = m_dwRenderHeight;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
if( FAILED( hr = m_pDD->CreateSurface( &ddsd, &m_pddsBackBuffer, NULL ) ) )
{
DEBUG_ERR( hr, _T("Error: Couldn't create the backbuffer") );
if( hr != DDERR_OUTOFVIDEOMEMORY )
return D3DFWERR_NOBACKBUFFER;
DEBUG_MSG( _T("Error: Out of video memory") );
return DDERR_OUTOFVIDEOMEMORY;
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: CreateDirect3D()
// Desc: Create the Direct3D interface
//-----------------------------------------------------------------------------
HRESULT CD3DFramework7::CreateDirect3D( GUID* pDeviceGUID )
{
// Query DirectDraw for access to Direct3D
if( FAILED( m_pDD->QueryInterface( IID_IDirect3D7, (VOID**)&m_pD3D ) ) )
{
DEBUG_MSG( _T("Couldn't get the Direct3D interface") );
return D3DFWERR_NODIRECT3D;
}
// Create the device
if( FAILED( m_pD3D->CreateDevice( *pDeviceGUID, m_pddsBackBuffer,
&m_pd3dDevice) ) )
{
DEBUG_MSG( _T("Couldn't create the D3DDevice") );
return D3DFWERR_NO3DDEVICE;
}
// Finally, set the viewport for the newly created device
D3DVIEWPORT7 vp = { 0, 0, m_dwRenderWidth, m_dwRenderHeight, 0.0f, 1.0f };
if( FAILED( m_pd3dDevice->SetViewport( &vp ) ) )
{
DEBUG_MSG( _T("Error: Couldn't set current viewport to device") );
return D3DFWERR_NOVIEWPORT;
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: CreateZBuffer()
// Desc: Internal function called by Create() to make and attach a zbuffer
// to the renderer
//-----------------------------------------------------------------------------
HRESULT CD3DFramework7::CreateZBuffer( GUID* pDeviceGUID )
{
HRESULT hr;
// Check if the device supports z-bufferless hidden surface removal. If so,
// we don't really need a z-buffer
D3DDEVICEDESC7 ddDesc;
m_pd3dDevice->GetCaps( &ddDesc );
if( ddDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ZBUFFERLESSHSR )
return S_OK;
// Get z-buffer dimensions from the render target
DDSURFACEDESC2 ddsd;
ddsd.dwSize = sizeof(ddsd);
m_pddsBackBuffer->GetSurfaceDesc( &ddsd );
// Setup the surface desc for the z-buffer.
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
ddsd.ddsCaps.dwCaps = DDSCAPS_ZBUFFER | m_dwDeviceMemType;
ddsd.ddpfPixelFormat.dwSize = 0; // Tag the pixel format as unitialized
// Get an appropiate pixel format from enumeration of the formats. On the
// first pass, we look for a zbuffer dpeth which is equal to the frame
// buffer depth (as some cards unfornately require this).
m_pD3D->EnumZBufferFormats( *pDeviceGUID, EnumZBufferFormatsCallback,
(VOID*)&ddsd.ddpfPixelFormat );
if( 0 == ddsd.ddpfPixelFormat.dwSize )
{
// Try again, just accepting any 16-bit zbuffer
ddsd.ddpfPixelFormat.dwRGBBitCount = 16;
m_pD3D->EnumZBufferFormats( *pDeviceGUID, EnumZBufferFormatsCallback,
(VOID*)&ddsd.ddpfPixelFormat );
if( 0 == ddsd.ddpfPixelFormat.dwSize )
{
DEBUG_MSG( _T("Device doesn't support requested zbuffer format") );
return D3DFWERR_NOZBUFFER;
}
}
// Create and attach a z-buffer
if( FAILED( hr = m_pDD->CreateSurface( &ddsd, &m_pddsZBuffer, NULL ) ) )
{
DEBUG_MSG( _T("Error: Couldn't create a ZBuffer surface") );
if( hr != DDERR_OUTOFVIDEOMEMORY )
return D3DFWERR_NOZBUFFER;
DEBUG_MSG( _T("Error: Out of video memory") );
return DDERR_OUTOFVIDEOMEMORY;
}
if( FAILED( m_pddsBackBuffer->AddAttachedSurface( m_pddsZBuffer ) ) )
{
DEBUG_MSG( _T("Error: Couldn't attach zbuffer to render surface") );
return D3DFWERR_NOZBUFFER;
}
// For stereoscopic viewing, attach zbuffer to left surface as well
if( m_bIsStereo )
{
if( FAILED( m_pddsBackBufferLeft->AddAttachedSurface( m_pddsZBuffer ) ) )
{
DEBUG_MSG( _T("Error: Couldn't attach zbuffer to left render surface") );
return D3DFWERR_NOZBUFFER;
}
}
// Finally, this call rebuilds internal structures
if( FAILED( m_pd3dDevice->SetRenderTarget( m_pddsBackBuffer, 0L ) ) )
{
DEBUG_MSG( _T("Error: SetRenderTarget() failed after attaching zbuffer!") );
return D3DFWERR_NOZBUFFER;
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: RestoreSurfaces()
// Desc: Checks for lost surfaces and restores them if lost. Note: Don't
// restore render surface, since it's just a duplicate ptr.
//-----------------------------------------------------------------------------
HRESULT CD3DFramework7::RestoreSurfaces()
{
// Restore all surfaces (including video memory vertex buffers)
m_pDD->RestoreAllSurfaces();
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: Move()
// Desc: Moves the screen rect for windowed renderers
//-----------------------------------------------------------------------------
VOID CD3DFramework7::Move( INT x, INT y )
{
if( true == m_bIsFullscreen )
return;
SetRect( &m_rcScreenRect, x, y, x + m_dwRenderWidth, y + m_dwRenderHeight );
}
//-----------------------------------------------------------------------------
// Name: FlipToGDISurface()
// Desc: Puts the GDI surface in front of the primary, so that dialog
// boxes and other windows drawing funcs may happen.
//-----------------------------------------------------------------------------
HRESULT CD3DFramework7::FlipToGDISurface( bool bDrawFrame )
{
if( m_pDD && m_bIsFullscreen )
{
m_pDD->FlipToGDISurface();
if( bDrawFrame )
{
DrawMenuBar( m_hWnd );
RedrawWindow( m_hWnd, NULL, NULL, RDW_FRAME );
}
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: ShowFrame()
// Desc: Show the frame on the primary surface, via a blt or a flip.
//-----------------------------------------------------------------------------
HRESULT CD3DFramework7::ShowFrame()
{
if( NULL == m_pddsFrontBuffer )
return D3DFWERR_NOTINITIALIZED;
if( m_bIsFullscreen )
{
// We are in fullscreen mode, so perform a flip.
if( m_bIsStereo )
return m_pddsFrontBuffer->Flip( NULL, DDFLIP_WAIT | DDFLIP_STEREO );
else
return m_pddsFrontBuffer->Flip( NULL, DDFLIP_WAIT );
}
else
{
// We are in windowed mode, so perform a blit.
return m_pddsFrontBuffer->Blt( &m_rcScreenRect, m_pddsBackBuffer,
NULL, DDBLT_WAIT, NULL );
}
}

View File

@ -1,141 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
//-----------------------------------------------------------------------------
// File: D3DFrame.h
//
// Desc: Class to manage the Direct3D environment objects such as buffers,
// viewports, and 3D devices.
//
// The class is initialized with the Initialize() function, after which
// the Get????() functions can be used to access the objects needed for
// rendering. If the device or display needs to be changed, the
// ChangeDevice() function can be called. If the display window is moved
// the changes need to be reported with the Move() function.
//
// After rendering a frame, the ShowFrame() function filps or blits the
// backbuffer contents to the primary. If surfaces are lost, they can be
// restored with the RestoreSurfaces() function. Finally, if normal
// Windows output is needed, the FlipToGDISurface() provides a GDI
// surface to draw on.
//
// Copyright (c) 1997-1999 Microsoft Corporation. All rights reserved
//-----------------------------------------------------------------------------
#pragma once
#include <ddraw.h>
#include <d3d.h>
//-----------------------------------------------------------------------------
// Name: CD3DFramework7
// Desc: The Direct3D sample framework class for DX7. Maintains the D3D
// surfaces and device used for 3D rendering.
//-----------------------------------------------------------------------------
class CD3DFramework7
{
// Internal variables for the framework class
HWND m_hWnd; // The window object
bool m_bIsFullscreen; // Fullscreen vs. windowed
bool m_bIsStereo; // Stereo view mode
DWORD m_dwRenderWidth; // Dimensions of the render target
DWORD m_dwRenderHeight;
RECT m_rcScreenRect; // Screen rect for window
LPDIRECTDRAW7 m_pDD; // The DirectDraw object
LPDIRECT3D7 m_pD3D; // The Direct3D object
LPDIRECT3DDEVICE7 m_pd3dDevice; // The D3D device
LPDIRECTDRAWSURFACE7 m_pddsFrontBuffer; // The primary surface
LPDIRECTDRAWSURFACE7 m_pddsBackBuffer; // The backbuffer surface
LPDIRECTDRAWSURFACE7 m_pddsBackBufferLeft; // For stereo modes
LPDIRECTDRAWSURFACE7 m_pddsZBuffer; // The zbuffer surface
DWORD m_dwDeviceMemType;
// Internal functions for the framework class
HRESULT CreateZBuffer( GUID* );
HRESULT CreateFullscreenBuffers( DDSURFACEDESC2* );
HRESULT CreateWindowedBuffers();
HRESULT CreateDirectDraw( GUID*, DWORD );
HRESULT CreateDirect3D( GUID* );
HRESULT CreateEnvironment( GUID*, GUID*, DDSURFACEDESC2*, DWORD );
public:
// Access functions for DirectX objects
LPDIRECTDRAW7 GetDirectDraw() { return m_pDD; }
LPDIRECT3D7 GetDirect3D() { return m_pD3D; }
LPDIRECT3DDEVICE7 GetD3DDevice() { return m_pd3dDevice; }
LPDIRECTDRAWSURFACE7 GetFrontBuffer() { return m_pddsFrontBuffer; }
LPDIRECTDRAWSURFACE7 GetBackBuffer() { return m_pddsBackBuffer; }
LPDIRECTDRAWSURFACE7 GetRenderSurface() { return m_pddsBackBuffer; }
LPDIRECTDRAWSURFACE7 GetRenderSurfaceLeft() { return m_pddsBackBufferLeft; }
// Functions to aid rendering
HRESULT RestoreSurfaces();
HRESULT ShowFrame();
HRESULT FlipToGDISurface( bool bDrawFrame = false );
// Functions for managing screen and viewport bounds
bool IsFullscreen() { return m_bIsFullscreen; }
bool IsStereo() { return m_bIsStereo; }
VOID Move( INT x, INT y );
// Creates the Framework
HRESULT Initialize( HWND hWnd, GUID* pDriverGUID, GUID* pDeviceGUID,
DDSURFACEDESC2* pddsd, DWORD dwFlags );
HRESULT DestroyObjects();
CD3DFramework7();
~CD3DFramework7();
};
//-----------------------------------------------------------------------------
// Flags used for the Initialize() method of a CD3DFramework object
//-----------------------------------------------------------------------------
#define D3DFW_FULLSCREEN 0x00000001 // Use fullscreen mode
#define D3DFW_STEREO 0x00000002 // Use stereo-scopic viewing
#define D3DFW_ZBUFFER 0x00000004 // Create and use a zbuffer
#define D3DFW_NO_FPUSETUP 0x00000008 // Don't use default DDSCL_FPUSETUP flag
//-----------------------------------------------------------------------------
// Errors that the Initialize() and ChangeDriver() calls may return
//-----------------------------------------------------------------------------
#define D3DFWERR_INITIALIZATIONFAILED 0x82000000
#define D3DFWERR_NODIRECTDRAW 0x82000001
#define D3DFWERR_COULDNTSETCOOPLEVEL 0x82000002
#define D3DFWERR_NODIRECT3D 0x82000003
#define D3DFWERR_NO3DDEVICE 0x82000004
#define D3DFWERR_NOZBUFFER 0x82000005
#define D3DFWERR_INVALIDZBUFFERDEPTH 0x82000006
#define D3DFWERR_NOVIEWPORT 0x82000007
#define D3DFWERR_NOPRIMARY 0x82000008
#define D3DFWERR_NOCLIPPER 0x82000009
#define D3DFWERR_BADDISPLAYMODE 0x8200000a
#define D3DFWERR_NOBACKBUFFER 0x8200000b
#define D3DFWERR_NONZEROREFCOUNT 0x8200000c
#define D3DFWERR_NORENDERTARGET 0x8200000d
#define D3DFWERR_INVALIDMODE 0x8200000e
#define D3DFWERR_NOTINITIALIZED 0x8200000f

View File

@ -1,343 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
//-----------------------------------------------------------------------------
// File: D3DMath.cpp
//
// Desc: Shortcut macros and functions for using DX objects
//
// Copyright (c) 1997-1999 Microsoft Corporation. All rights reserved
//-----------------------------------------------------------------------------
#define D3D_OVERLOADS
#define STRICT
#include <math.h>
#include <stdio.h>
#include "d3dmath.h"
//-----------------------------------------------------------------------------
// Name: D3DMath_MatrixMultiply()
// Desc: Does the matrix operation: [Q] = [A] * [B]. Note that the order of
// this operation was changed from the previous version of the DXSDK.
//-----------------------------------------------------------------------------
VOID D3DMath_MatrixMultiply( D3DMATRIX& q, D3DMATRIX& a, D3DMATRIX& b )
{
FLOAT* pA = (FLOAT*)&a;
FLOAT* pB = (FLOAT*)&b;
FLOAT pM[16];
ZeroMemory( pM, sizeof(D3DMATRIX) );
for( WORD i=0; i<4; i++ )
for( WORD j=0; j<4; j++ )
for( WORD k=0; k<4; k++ )
pM[4*i+j] += pA[4*i+k] * pB[4*k+j];
memcpy( &q, pM, sizeof(D3DMATRIX) );
}
//-----------------------------------------------------------------------------
// Name: D3DMath_MatrixInvert()
// Desc: Does the matrix operation: [Q] = inv[A]. Note: this function only
// works for matrices with [0 0 0 1] for the 4th column.
//-----------------------------------------------------------------------------
HRESULT D3DMath_MatrixInvert( D3DMATRIX& q, D3DMATRIX& a )
{
if( fabs(a._44 - 1.0f) > .001f)
return E_INVALIDARG;
if( fabs(a._14) > .001f || fabs(a._24) > .001f || fabs(a._34) > .001f )
return E_INVALIDARG;
FLOAT fDetInv = 1.0f / ( a._11 * ( a._22 * a._33 - a._23 * a._32 ) -
a._12 * ( a._21 * a._33 - a._23 * a._31 ) +
a._13 * ( a._21 * a._32 - a._22 * a._31 ) );
q._11 = fDetInv * ( a._22 * a._33 - a._23 * a._32 );
q._12 = -fDetInv * ( a._12 * a._33 - a._13 * a._32 );
q._13 = fDetInv * ( a._12 * a._23 - a._13 * a._22 );
q._14 = 0.0f;
q._21 = -fDetInv * ( a._21 * a._33 - a._23 * a._31 );
q._22 = fDetInv * ( a._11 * a._33 - a._13 * a._31 );
q._23 = -fDetInv * ( a._11 * a._23 - a._13 * a._21 );
q._24 = 0.0f;
q._31 = fDetInv * ( a._21 * a._32 - a._22 * a._31 );
q._32 = -fDetInv * ( a._11 * a._32 - a._12 * a._31 );
q._33 = fDetInv * ( a._11 * a._22 - a._12 * a._21 );
q._34 = 0.0f;
q._41 = -( a._41 * q._11 + a._42 * q._21 + a._43 * q._31 );
q._42 = -( a._41 * q._12 + a._42 * q._22 + a._43 * q._32 );
q._43 = -( a._41 * q._13 + a._42 * q._23 + a._43 * q._33 );
q._44 = 1.0f;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: D3DMath_VectorMatrixMultiply()
// Desc: Multiplies a vector by a matrix
//-----------------------------------------------------------------------------
HRESULT D3DMath_VectorMatrixMultiply( D3DVECTOR& vDest, D3DVECTOR& vSrc,
D3DMATRIX& mat)
{
FLOAT x = vSrc.x*mat._11 + vSrc.y*mat._21 + vSrc.z* mat._31 + mat._41;
FLOAT y = vSrc.x*mat._12 + vSrc.y*mat._22 + vSrc.z* mat._32 + mat._42;
FLOAT z = vSrc.x*mat._13 + vSrc.y*mat._23 + vSrc.z* mat._33 + mat._43;
FLOAT w = vSrc.x*mat._14 + vSrc.y*mat._24 + vSrc.z* mat._34 + mat._44;
if( fabs( w ) < g_EPSILON )
return E_INVALIDARG;
vDest.x = x/w;
vDest.y = y/w;
vDest.z = z/w;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: D3DMath_VertexMatrixMultiply()
// Desc: Multiplies a vertex by a matrix
//-----------------------------------------------------------------------------
HRESULT D3DMath_VertexMatrixMultiply( D3DVERTEX& vDest, D3DVERTEX& vSrc,
D3DMATRIX& mat )
{
HRESULT hr;
D3DVECTOR* pSrcVec = (D3DVECTOR*)&vSrc.x;
D3DVECTOR* pDestVec = (D3DVECTOR*)&vDest.x;
if( SUCCEEDED( hr = D3DMath_VectorMatrixMultiply( *pDestVec, *pSrcVec,
mat ) ) )
{
pSrcVec = (D3DVECTOR*)&vSrc.nx;
pDestVec = (D3DVECTOR*)&vDest.nx;
hr = D3DMath_VectorMatrixMultiply( *pDestVec, *pSrcVec, mat );
}
return hr;
}
//-----------------------------------------------------------------------------
// Name: D3DMath_QuaternionFromRotation()
// Desc: Converts a normalized axis and angle to a unit quaternion.
//-----------------------------------------------------------------------------
VOID D3DMath_QuaternionFromRotation( FLOAT& x, FLOAT& y, FLOAT& z, FLOAT& w,
D3DVECTOR& v, FLOAT fTheta )
{
x = sinf( fTheta/2.0f ) * v.x;
y = sinf( fTheta/2.0f ) * v.y;
z = sinf( fTheta/2.0f ) * v.z;
w = cosf( fTheta/2.0f );
}
//-----------------------------------------------------------------------------
// Name: D3DMath_RotationFromQuaternion()
// Desc: Converts a normalized axis and angle to a unit quaternion.
//-----------------------------------------------------------------------------
VOID D3DMath_RotationFromQuaternion( D3DVECTOR& v, FLOAT& fTheta,
FLOAT x, FLOAT y, FLOAT z, FLOAT w )
{
fTheta = acosf(w) * 2.0f;
v.x = x / sinf( fTheta/2.0f );
v.y = y / sinf( fTheta/2.0f );
v.z = z / sinf( fTheta/2.0f );
}
//-----------------------------------------------------------------------------
// Name: D3DMath_QuaternionFromAngles()
// Desc: Converts euler angles to a unit quaternion.
//-----------------------------------------------------------------------------
VOID D3DMath_QuaternionFromAngles( FLOAT& x, FLOAT& y, FLOAT& z, FLOAT& w,
FLOAT fYaw, FLOAT fPitch, FLOAT fRoll )
{
FLOAT fSinYaw = sinf( fYaw/2.0f );
FLOAT fSinPitch = sinf( fPitch/2.0f );
FLOAT fSinRoll = sinf( fRoll/2.0f );
FLOAT fCosYaw = cosf( fYaw/2.0f );
FLOAT fCosPitch = cosf( fPitch/2.0f );
FLOAT fCosRoll = cosf( fRoll/2.0f );
x = fSinRoll * fCosPitch * fCosYaw - fCosRoll * fSinPitch * fSinYaw;
y = fCosRoll * fSinPitch * fCosYaw + fSinRoll * fCosPitch * fSinYaw;
z = fCosRoll * fCosPitch * fSinYaw - fSinRoll * fSinPitch * fCosYaw;
w = fCosRoll * fCosPitch * fCosYaw + fSinRoll * fSinPitch * fSinYaw;
}
//-----------------------------------------------------------------------------
// Name: D3DMath_MatrixFromQuaternion()
// Desc: Converts a unit quaternion into a rotation matrix.
//-----------------------------------------------------------------------------
VOID D3DMath_MatrixFromQuaternion( D3DMATRIX& mat, FLOAT x, FLOAT y, FLOAT z,
FLOAT w )
{
FLOAT xx = x*x; FLOAT yy = y*y; FLOAT zz = z*z;
FLOAT xy = x*y; FLOAT xz = x*z; FLOAT yz = y*z;
FLOAT wx = w*x; FLOAT wy = w*y; FLOAT wz = w*z;
mat._11 = 1 - 2 * ( yy + zz );
mat._12 = 2 * ( xy - wz );
mat._13 = 2 * ( xz + wy );
mat._21 = 2 * ( xy + wz );
mat._22 = 1 - 2 * ( xx + zz );
mat._23 = 2 * ( yz - wx );
mat._31 = 2 * ( xz - wy );
mat._32 = 2 * ( yz + wx );
mat._33 = 1 - 2 * ( xx + yy );
mat._14 = mat._24 = mat._34 = 0.0f;
mat._41 = mat._42 = mat._43 = 0.0f;
mat._44 = 1.0f;
}
//-----------------------------------------------------------------------------
// Name: D3DMath_QuaternionFromMatrix()
// Desc: Converts a rotation matrix into a unit quaternion.
//-----------------------------------------------------------------------------
VOID D3DMath_QuaternionFromMatrix( FLOAT& x, FLOAT& y, FLOAT& z, FLOAT& w,
D3DMATRIX& mat )
{
if( mat._11 + mat._22 + mat._33 > 0.0f )
{
FLOAT s = sqrtf( mat._11 + mat._22 + mat._33 + mat._44 );
x = (mat._23-mat._32) / (2*s);
y = (mat._31-mat._13) / (2*s);
z = (mat._12-mat._21) / (2*s);
w = 0.5f * s;
}
else
{
}
FLOAT xx = x*x; FLOAT yy = y*y; FLOAT zz = z*z;
FLOAT xy = x*y; FLOAT xz = x*z; FLOAT yz = y*z;
FLOAT wx = w*x; FLOAT wy = w*y; FLOAT wz = w*z;
mat._11 = 1 - 2 * ( yy + zz );
mat._12 = 2 * ( xy - wz );
mat._13 = 2 * ( xz + wy );
mat._21 = 2 * ( xy + wz );
mat._22 = 1 - 2 * ( xx + zz );
mat._23 = 2 * ( yz - wx );
mat._31 = 2 * ( xz - wy );
mat._32 = 2 * ( yz + wx );
mat._33 = 1 - 2 * ( xx + yy );
mat._14 = mat._24 = mat._34 = 0.0f;
mat._41 = mat._42 = mat._43 = 0.0f;
mat._44 = 1.0f;
}
//-----------------------------------------------------------------------------
// Name: D3DMath_QuaternionMultiply()
// Desc: Mulitples two quaternions together as in {Q} = {A} * {B}.
//-----------------------------------------------------------------------------
VOID D3DMath_QuaternionMultiply( FLOAT& Qx, FLOAT& Qy, FLOAT& Qz, FLOAT& Qw,
FLOAT Ax, FLOAT Ay, FLOAT Az, FLOAT Aw,
FLOAT Bx, FLOAT By, FLOAT Bz, FLOAT Bw )
{
FLOAT Dx = Ax*Bw + Ay*Bz - Az*By + Aw*Bx;
FLOAT Dy = -Ax*Bz + Ay*Bw + Az*Bx + Aw*By;
FLOAT Dz = Ax*By - Ay*Bx + Az*Bw + Aw*Bz;
FLOAT Dw = -Ax*Bx - Ay*By - Az*Bz + Aw*Bw;
Qx = Dx; Qy = Dy; Qz = Dz; Qw = Dw;
}
//-----------------------------------------------------------------------------
// Name: D3DMath_SlerpQuaternions()
// Desc: Compute a quaternion which is the spherical linear interpolation
// between two other quaternions by dvFraction.
//-----------------------------------------------------------------------------
VOID D3DMath_QuaternionSlerp( FLOAT& Qx, FLOAT& Qy, FLOAT& Qz, FLOAT& Qw,
FLOAT Ax, FLOAT Ay, FLOAT Az, FLOAT Aw,
FLOAT Bx, FLOAT By, FLOAT Bz, FLOAT Bw,
FLOAT fAlpha )
{
// Compute dot product (equal to cosine of the angle between quaternions)
FLOAT fCosTheta = Ax*Bx + Ay*By + Az*Bz + Aw*Bw;
// Check angle to see if quaternions are in opposite hemispheres
if( fCosTheta < 0.0f )
{
// If so, flip one of the quaterions
fCosTheta = -fCosTheta;
Bx = -Bx; By = -By; Bz = -Bz; Bw = -Bw;
}
// Set factors to do linear interpolation, as a special case where the
// quaternions are close together.
FLOAT fBeta = 1.0f - fAlpha;
// If the quaternions aren't close, proceed with spherical interpolation
if( 1.0f - fCosTheta > 0.001f )
{
FLOAT fTheta = acosf( fCosTheta );
fBeta = sinf( fTheta*fBeta ) / sinf( fTheta);
fAlpha = sinf( fTheta*fAlpha ) / sinf( fTheta);
}
// Do the interpolation
Qx = fBeta*Ax + fAlpha*Bx;
Qy = fBeta*Ay + fAlpha*By;
Qz = fBeta*Az + fAlpha*Bz;
Qw = fBeta*Aw + fAlpha*Bw;
}

View File

@ -1,107 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
//-----------------------------------------------------------------------------
// File: D3DMath.h
//
// Desc: Math functions and shortcuts for Direct3D programming.
//
// Copyright (c) 1997-1999 Microsoft Corporation. All rights reserved
//-----------------------------------------------------------------------------
#pragma once
#include <ddraw.h>
#include <d3d.h>
//-----------------------------------------------------------------------------
// Useful Math constants
//-----------------------------------------------------------------------------
const FLOAT g_PI = 3.14159265358979323846f; // Pi
const FLOAT g_2_PI = 6.28318530717958623200f; // 2 * Pi
const FLOAT g_PI_DIV_2 = 1.57079632679489655800f; // Pi / 2
const FLOAT g_PI_DIV_4 = 0.78539816339744827900f; // Pi / 4
const FLOAT g_INV_PI = 0.31830988618379069122f; // 1 / Pi
const FLOAT g_DEGTORAD = 0.01745329251994329547f; // Degrees to Radians
const FLOAT g_RADTODEG = 57.29577951308232286465f; // Radians to Degrees
const FLOAT g_HUGE = 1.0e+38f; // Huge number for FLOAT
const FLOAT g_EPSILON = 1.0e-5f; // Tolerance for FLOATs
//-----------------------------------------------------------------------------
// Fuzzy compares (within tolerance)
//-----------------------------------------------------------------------------
//>>> func.h IsZero()
inline bool D3DMath_IsZero( FLOAT a, FLOAT fTol = g_EPSILON )
{ return ( a <= 0.0f ) ? ( a >= -fTol ) : ( a <= fTol ); }
//-----------------------------------------------------------------------------
// Matrix functions
//-----------------------------------------------------------------------------
//>>> matrix.h MultiplyMatrices()
VOID D3DMath_MatrixMultiply( D3DMATRIX& q, D3DMATRIX& a, D3DMATRIX& b );
//>>> matrix.h Matrix::Invert()
HRESULT D3DMath_MatrixInvert( D3DMATRIX& q, D3DMATRIX& a );
//-----------------------------------------------------------------------------
// Vector functions
//-----------------------------------------------------------------------------
//>>> matrix.h MatrixVectorMultiply()
HRESULT D3DMath_VectorMatrixMultiply( D3DVECTOR& vDest, D3DVECTOR& vSrc,
D3DMATRIX& mat);
// TODO
HRESULT D3DMath_VertexMatrixMultiply( D3DVERTEX& vDest, D3DVERTEX& vSrc,
D3DMATRIX& mat );
//-----------------------------------------------------------------------------
// Quaternion functions
//-----------------------------------------------------------------------------
// UNUSED
VOID D3DMath_QuaternionFromRotation( FLOAT& x, FLOAT& y, FLOAT& z, FLOAT& w,
D3DVECTOR& v, FLOAT fTheta );
VOID D3DMath_RotationFromQuaternion( D3DVECTOR& v, FLOAT& fTheta,
FLOAT x, FLOAT y, FLOAT z, FLOAT w );
VOID D3DMath_QuaternionFromAngles( FLOAT& x, FLOAT& y, FLOAT& z, FLOAT& w,
FLOAT fYaw, FLOAT fPitch, FLOAT fRoll );
VOID D3DMath_MatrixFromQuaternion( D3DMATRIX& mat, FLOAT x, FLOAT y, FLOAT z,
FLOAT w );
VOID D3DMath_QuaternionFromMatrix( FLOAT &x, FLOAT &y, FLOAT &z, FLOAT &w,
D3DMATRIX& mat );
VOID D3DMath_QuaternionMultiply( FLOAT& Qx, FLOAT& Qy, FLOAT& Qz, FLOAT& Qw,
FLOAT Ax, FLOAT Ay, FLOAT Az, FLOAT Aw,
FLOAT Bx, FLOAT By, FLOAT Bz, FLOAT Bw );
VOID D3DMath_QuaternionSlerp( FLOAT& Qx, FLOAT& Qy, FLOAT& Qz, FLOAT& Qw,
FLOAT Ax, FLOAT Ay, FLOAT Az, FLOAT Aw,
FLOAT Bx, FLOAT By, FLOAT Bz, FLOAT Bw,
FLOAT fAlpha );

View File

@ -1,55 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
//-----------------------------------------------------------------------------
// File: D3DRes.h
//
// Desc: Resource definitions required by the CD3DApplication class.
// Any application using the CD3DApplication class must include resources
// with the following identifiers.
//
// Copyright (c) 1999 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#pragma once
#define IDI_MAIN_ICON 101 // Application icon
#define IDR_MAIN_ACCEL 113 // Keyboard accelerator
#define IDR_MENU 141 // Application menu
#define IDR_POPUP 142 // Popup menu
#define IDD_ABOUT 143 // About dialog box
#define IDD_CHANGEDEVICE 144 // "Change Device" dialog box
#define IDC_CURSORHAND 149
#define IDC_CURSORSCROLLL 150
#define IDC_CURSORSCROLLR 151
#define IDC_CURSORSCROLLU 152
#define IDC_CURSORSCROLLD 153
#define IDC_CURSORTARGET 154
#define IDC_DEVICE_COMBO 1000 // Device combobox for "Change Device" dlg
#define IDC_MODE_COMBO 1001 // Mode combobox for "Change Device" dlg
#define IDC_WINDOWED_CHECKBOX 1012 // Checkbox for windowed-mode
#define IDC_STEREO_CHECKBOX 1013 // Checkbox for stereo modes
#define IDC_FULLSCREEN_TEXT 1014 // Group box text label
#define IDM_ABOUT 40001 // Command to invoke About dlg
#define IDM_CHANGEDEVICE 40002 // Command to invoke "Change Device" dlg
#define IDM_TOGGLEFULLSCREEN 40003 // Command to toggle fullscreen mode
#define IDM_TOGGLESTART 40004 // Command to toggle frame animation
#define IDM_SINGLESTEP 40005 // Command to single step frame animation
#define IDM_EXIT 40006 // Command to exit the application

File diff suppressed because it is too large Load Diff

View File

@ -1,79 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
//-----------------------------------------------------------------------------
// File: D3DTextr.h
//
// Desc: Functions to manage textures, including creating (loading from a
// file), restoring lost surfaces, invalidating, and destroying.
//
// Note: the implementation of these fucntions maintain an internal list
// of loaded textures. After creation, individual textures are referenced
// via their ASCII names.
//
// Copyright (c) 1997-1999 Microsoft Corporation. All rights reserved
//-----------------------------------------------------------------------------
#pragma once
#include <ddraw.h>
#include <d3d.h>
//-----------------------------------------------------------------------------
// Access functions for loaded textures. Note: these functions search
// an internal list of the textures, and use the texture associated with the
// ASCII name.
//-----------------------------------------------------------------------------
LPDIRECTDRAWSURFACE7 D3DTextr_GetSurface( TCHAR* strName );
//-----------------------------------------------------------------------------
// Texture invalidation and restoration functions
//-----------------------------------------------------------------------------
HRESULT D3DTextr_Invalidate( TCHAR* strName );
HRESULT D3DTextr_Restore( TCHAR* strName, LPDIRECT3DDEVICE7 pd3dDevice );
HRESULT D3DTextr_InvalidateAllTextures();
HRESULT D3DTextr_RestoreAllTextures( LPDIRECT3DDEVICE7 pd3dDevice );
//-----------------------------------------------------------------------------
// Texture creation and deletion functions
//-----------------------------------------------------------------------------
#define D3DTEXTR_TRANSPARENTWHITE 0x00000001
#define D3DTEXTR_TRANSPARENTBLACK 0x00000002
#define D3DTEXTR_32BITSPERPIXEL 0x00000004
#define D3DTEXTR_16BITSPERPIXEL 0x00000008
#define D3DTEXTR_CREATEWITHALPHA 0x00000010
HRESULT D3DTextr_CreateTextureFromFile( TCHAR* strName, DWORD dwStage=0L,
DWORD dwFlags=0L );
HRESULT D3DTextr_CreateEmptyTexture( TCHAR* strName, DWORD dwWidth,
DWORD dwHeight, DWORD dwStage,
DWORD dwFlags );
HRESULT D3DTextr_DestroyTexture( TCHAR* strName );
VOID D3DTextr_SetTexturePath( TCHAR* strTexturePath );
void D3DTextr_SetDebugMode(bool bDebug);

View File

@ -1,325 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
//-----------------------------------------------------------------------------
// File: D3DUtil.cpp
//
// Desc: Shortcut macros and functions for using DX objects
//
//
// Copyright (c) 1997-1999 Microsoft Corporation. All rights reserved
//-----------------------------------------------------------------------------
#include <math.h>
#include <stdio.h>
#include <tchar.h>
#include "old/d3dutil.h"
//-----------------------------------------------------------------------------
// Name: D3DUtil_GetDXSDKMediaPath()
// Desc: Returns the DirectX SDK media path, as stored in the system registry
// during the SDK install.
//-----------------------------------------------------------------------------
const TCHAR* D3DUtil_GetDXSDKMediaPath()
{
static TCHAR strNull[2] = _T("");
static TCHAR strPath[512];
HKEY key;
DWORD type, size = 512;
// Open the appropriate registry key
LONG result = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
_T("Software\\Microsoft\\DirectX"),
0, KEY_READ, &key );
if( ERROR_SUCCESS != result )
return strNull;
result = RegQueryValueEx( key, _T("DXSDK Samples Path"), NULL,
&type, (BYTE*)strPath, &size );
RegCloseKey( key );
if( ERROR_SUCCESS != result )
return strNull;
lstrcat( strPath, _T("\\D3DIM\\Media\\") );
return strPath;
}
//-----------------------------------------------------------------------------
// Name: D3DUtil_InitSurfaceDesc()
// Desc: Helper function called to build a DDSURFACEDESC2 structure,
// typically before calling CreateSurface() or GetSurfaceDesc()
//-----------------------------------------------------------------------------
VOID D3DUtil_InitSurfaceDesc( DDSURFACEDESC2& ddsd, DWORD dwFlags,
DWORD dwCaps )
{
ZeroMemory( &ddsd, sizeof(ddsd) );
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = dwFlags;
ddsd.ddsCaps.dwCaps = dwCaps;
ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
}
//-----------------------------------------------------------------------------
// Name: D3DUtil_InitMaterial()
// Desc: Helper function called to build a D3DMATERIAL7 structure
//-----------------------------------------------------------------------------
VOID D3DUtil_InitMaterial( D3DMATERIAL7& mtrl, FLOAT r, FLOAT g, FLOAT b,
FLOAT a )
{
ZeroMemory( &mtrl, sizeof(D3DMATERIAL7) );
mtrl.dcvDiffuse.r = mtrl.dcvAmbient.r = r;
mtrl.dcvDiffuse.g = mtrl.dcvAmbient.g = g;
mtrl.dcvDiffuse.b = mtrl.dcvAmbient.b = b;
mtrl.dcvDiffuse.a = mtrl.dcvAmbient.a = a;
}
//-----------------------------------------------------------------------------
// Name: D3DUtil_InitLight()
// Desc: Initializes a D3DLIGHT7 structure
//-----------------------------------------------------------------------------
VOID D3DUtil_InitLight( D3DLIGHT7& light, D3DLIGHTTYPE ltType,
FLOAT x, FLOAT y, FLOAT z )
{
ZeroMemory( &light, sizeof(D3DLIGHT7) );
light.dltType = ltType;
light.dcvDiffuse.r = 1.0f;
light.dcvDiffuse.g = 1.0f;
light.dcvDiffuse.b = 1.0f;
light.dcvSpecular = light.dcvDiffuse;
light.dvPosition.x = light.dvDirection.x = x;
light.dvPosition.y = light.dvDirection.y = y;
light.dvPosition.z = light.dvDirection.z = z;
light.dvAttenuation0 = 1.0f;
light.dvRange = D3DLIGHT_RANGE_MAX;
}
//-----------------------------------------------------------------------------
// Name: D3DUtil_SetViewMatrix()
// Desc: Given an eye point, a lookat point, and an up vector, this
// function builds a 4x4 view matrix.
//-----------------------------------------------------------------------------
HRESULT D3DUtil_SetViewMatrix( D3DMATRIX& mat, D3DVECTOR& vFrom,
D3DVECTOR& vAt, D3DVECTOR& vWorldUp )
{
// Get the z basis vector, which points straight ahead. This is the
// difference from the eyepoint to the lookat point.
D3DVECTOR vView = vAt - vFrom;
FLOAT fLength = Magnitude( vView );
if( fLength < 1e-6f )
return E_INVALIDARG;
// Normalize the z basis vector
vView /= fLength;
// Get the dot product, and calculate the projection of the z basis
// vector onto the up vector. The projection is the y basis vector.
FLOAT fDotProduct = DotProduct( vWorldUp, vView );
D3DVECTOR vUp = vWorldUp - fDotProduct * vView;
// If this vector has near-zero length because the input specified a
// bogus up vector, let's try a default up vector
if( 1e-6f > ( fLength = Magnitude( vUp ) ) )
{
vUp = D3DVECTOR( 0.0f, 1.0f, 0.0f ) - vView.y * vView;
// If we still have near-zero length, resort to a different axis.
if( 1e-6f > ( fLength = Magnitude( vUp ) ) )
{
vUp = D3DVECTOR( 0.0f, 0.0f, 1.0f ) - vView.z * vView;
if( 1e-6f > ( fLength = Magnitude( vUp ) ) )
return E_INVALIDARG;
}
}
// Normalize the y basis vector
vUp /= fLength;
// The x basis vector is found simply with the cross product of the y
// and z basis vectors
D3DVECTOR vRight = CrossProduct( vUp, vView );
// Start building the matrix. The first three rows contains the basis
// vectors used to rotate the view to point at the lookat point
D3DUtil_SetIdentityMatrix( mat );
mat._11 = vRight.x; mat._12 = vUp.x; mat._13 = vView.x;
mat._21 = vRight.y; mat._22 = vUp.y; mat._23 = vView.y;
mat._31 = vRight.z; mat._32 = vUp.z; mat._33 = vView.z;
// Do the translation values (rotations are still about the eyepoint)
mat._41 = - DotProduct( vFrom, vRight );
mat._42 = - DotProduct( vFrom, vUp );
mat._43 = - DotProduct( vFrom, vView );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: D3DUtil_SetProjectionMatrix()
// Desc: Sets the passed in 4x4 matrix to a perpsective projection matrix built
// from the field-of-view (fov, in y), aspect ratio, near plane (D),
// and far plane (F). Note that the projection matrix is normalized for
// element [3][4] to be 1.0. This is performed so that W-based range fog
// will work correctly.
//-----------------------------------------------------------------------------
HRESULT D3DUtil_SetProjectionMatrix( D3DMATRIX& mat, FLOAT fFOV, FLOAT fAspect,
FLOAT fNearPlane, FLOAT fFarPlane )
{
if( fabs(fFarPlane-fNearPlane) < 0.01f )
return E_INVALIDARG;
if( fabs(sin(fFOV/2)) < 0.01f )
return E_INVALIDARG;
FLOAT w = fAspect * ( cosf(fFOV/2)/sinf(fFOV/2) );
FLOAT h = 1.0f * ( cosf(fFOV/2)/sinf(fFOV/2) );
FLOAT Q = fFarPlane / ( fFarPlane - fNearPlane );
ZeroMemory( &mat, sizeof(D3DMATRIX) );
mat._11 = w;
mat._22 = h;
mat._33 = Q;
mat._34 = 1.0f;
mat._43 = -Q*fNearPlane;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: D3DUtil_SetRotateXMatrix()
// Desc: Create Rotation matrix about X axis
//-----------------------------------------------------------------------------
VOID D3DUtil_SetRotateXMatrix( D3DMATRIX& mat, FLOAT fRads )
{
D3DUtil_SetIdentityMatrix( mat );
mat._22 = cosf( fRads );
mat._23 = sinf( fRads );
mat._32 = -sinf( fRads );
mat._33 = cosf( fRads );
}
//-----------------------------------------------------------------------------
// Name: D3DUtil_SetRotateYMatrix()
// Desc: Create Rotation matrix about Y axis
//-----------------------------------------------------------------------------
VOID D3DUtil_SetRotateYMatrix( D3DMATRIX& mat, FLOAT fRads )
{
D3DUtil_SetIdentityMatrix( mat );
mat._11 = cosf( fRads );
mat._13 = -sinf( fRads );
mat._31 = sinf( fRads );
mat._33 = cosf( fRads );
}
//-----------------------------------------------------------------------------
// Name: D3DUtil_SetRotateZMatrix()
// Desc: Create Rotation matrix about Z axis
//-----------------------------------------------------------------------------
VOID D3DUtil_SetRotateZMatrix( D3DMATRIX& mat, FLOAT fRads )
{
D3DUtil_SetIdentityMatrix( mat );
mat._11 = cosf( fRads );
mat._12 = sinf( fRads );
mat._21 = -sinf( fRads );
mat._22 = cosf( fRads );
}
//-----------------------------------------------------------------------------
// Name: D3DUtil_SetRotationMatrix
// Desc: Create a Rotation matrix about vector direction
//-----------------------------------------------------------------------------
VOID D3DUtil_SetRotationMatrix( D3DMATRIX& mat, D3DVECTOR& vDir, FLOAT fRads )
{
FLOAT fCos = cosf( fRads );
FLOAT fSin = sinf( fRads );
D3DVECTOR v = Normalize( vDir );
mat._11 = ( v.x * v.x ) * ( 1.0f - fCos ) + fCos;
mat._12 = ( v.x * v.y ) * ( 1.0f - fCos ) - (v.z * fSin);
mat._13 = ( v.x * v.z ) * ( 1.0f - fCos ) + (v.y * fSin);
mat._21 = ( v.y * v.x ) * ( 1.0f - fCos ) + (v.z * fSin);
mat._22 = ( v.y * v.y ) * ( 1.0f - fCos ) + fCos ;
mat._23 = ( v.y * v.z ) * ( 1.0f - fCos ) - (v.x * fSin);
mat._31 = ( v.z * v.x ) * ( 1.0f - fCos ) - (v.y * fSin);
mat._32 = ( v.z * v.y ) * ( 1.0f - fCos ) + (v.x * fSin);
mat._33 = ( v.z * v.z ) * ( 1.0f - fCos ) + fCos;
mat._14 = mat._24 = mat._34 = 0.0f;
mat._41 = mat._42 = mat._43 = 0.0f;
mat._44 = 1.0f;
}
//-----------------------------------------------------------------------------
// Name: _DbgOut()
// Desc: Outputs a message to the debug stream
//-----------------------------------------------------------------------------
HRESULT _DbgOut( TCHAR* strFile, DWORD dwLine, HRESULT hr, TCHAR* strMsg )
{
TCHAR buffer[256];
wsprintf( buffer, _T("%s(%ld): "), strFile, dwLine );
OutputDebugString( buffer );
OutputDebugString( strMsg );
if( hr )
{
wsprintf( buffer, _T("(hr=%08lx)\n"), hr );
OutputDebugString( buffer );
}
OutputDebugString( _T("\n") );
return hr;
}

View File

@ -1,113 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
//-----------------------------------------------------------------------------
// File: D3DUtil.h
//
// Desc: Helper functions and typing shortcuts for Direct3D programming.
//
// Copyright (c) 1997-1999 Microsoft Corporation. All rights reserved
//-----------------------------------------------------------------------------
#pragma once
#include <ddraw.h>
#include <d3d.h>
//-----------------------------------------------------------------------------
// Miscellaneous helper functions
//-----------------------------------------------------------------------------
const TCHAR* D3DUtil_GetDXSDKMediaPath();
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
//-----------------------------------------------------------------------------
// Short cut functions for creating and using DX structures
//-----------------------------------------------------------------------------
VOID D3DUtil_InitDeviceDesc( D3DDEVICEDESC7& ddDevDesc );
VOID D3DUtil_InitSurfaceDesc( DDSURFACEDESC2& ddsd, DWORD dwFlags=0,
DWORD dwCaps=0 );
VOID D3DUtil_InitMaterial( D3DMATERIAL7& mtrl, FLOAT r=0.0f, FLOAT g=0.0f,
FLOAT b=0.0f, FLOAT a=1.0f );
VOID D3DUtil_InitLight( D3DLIGHT7& light, D3DLIGHTTYPE ltType,
FLOAT x=0.0f, FLOAT y=0.0f, FLOAT z=0.0f );
//-----------------------------------------------------------------------------
// D3D Matrix functions. For performance reasons, some functions are inline.
//-----------------------------------------------------------------------------
HRESULT D3DUtil_SetViewMatrix( D3DMATRIX& mat, D3DVECTOR& vFrom,
D3DVECTOR& vAt, D3DVECTOR& vUp );
HRESULT D3DUtil_SetProjectionMatrix( D3DMATRIX& mat, FLOAT fFOV = 1.570795f,
FLOAT fAspect = 1.0f,
FLOAT fNearPlane = 1.0f,
FLOAT fFarPlane = 1000.0f );
inline VOID D3DUtil_SetIdentityMatrix( D3DMATRIX& m )
{
m._12 = m._13 = m._14 = m._21 = m._23 = m._24 = 0.0f;
m._31 = m._32 = m._34 = m._41 = m._42 = m._43 = 0.0f;
m._11 = m._22 = m._33 = m._44 = 1.0f;
}
inline VOID D3DUtil_SetTranslateMatrix( D3DMATRIX& m, FLOAT tx, FLOAT ty,
FLOAT tz )
{ D3DUtil_SetIdentityMatrix( m ); m._41 = tx; m._42 = ty; m._43 = tz; }
inline VOID D3DUtil_SetTranslateMatrix( D3DMATRIX& m, D3DVECTOR& v )
{ D3DUtil_SetTranslateMatrix( m, v.x, v.y, v.z ); }
inline VOID D3DUtil_SetScaleMatrix( D3DMATRIX& m, FLOAT sx, FLOAT sy,
FLOAT sz )
{ D3DUtil_SetIdentityMatrix( m ); m._11 = sx; m._22 = sy; m._33 = sz; }
inline VOID SetScaleMatrix( D3DMATRIX& m, D3DVECTOR& v )
{ D3DUtil_SetScaleMatrix( m, v.x, v.y, v.z ); }
VOID D3DUtil_SetRotateXMatrix( D3DMATRIX& mat, FLOAT fRads );
VOID D3DUtil_SetRotateYMatrix( D3DMATRIX& mat, FLOAT fRads );
VOID D3DUtil_SetRotateZMatrix( D3DMATRIX& mat, FLOAT fRads );
VOID D3DUtil_SetRotationMatrix( D3DMATRIX& mat, D3DVECTOR& vDir,
FLOAT fRads );
//-----------------------------------------------------------------------------
// Debug printing support
//-----------------------------------------------------------------------------
HRESULT _DbgOut( TCHAR*, DWORD, HRESULT, TCHAR* );
#if defined(DEBUG) | defined(_DEBUG)
#define DEBUG_MSG(str) _DbgOut( __FILE__, (DWORD)__LINE__, 0, str )
#define DEBUG_ERR(hr,str) _DbgOut( __FILE__, (DWORD)__LINE__, hr, str )
#else
#define DEBUG_MSG(str) (0L)
#define DEBUG_ERR(hr,str) (hr)
#endif

View File

@ -1,244 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// joystick.cpp
#define DIRECTINPUT_VERSION 0x0700
#include <windows.h>
#include <dinput.h>
#include <stdio.h>
#include "old/joystick.h"
// Global variables.
LPDIRECTINPUT7 g_pDI = NULL;
LPDIRECTINPUTDEVICE2 g_pJoystick = NULL;
DIDEVCAPS g_diDevCaps;
// Called once for each enumerated joystick. If we find one, create a
// device interface on it so we can play with it.
bool CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance,
VOID* pContext )
{
HRESULT hr;
// Obtain an interface to the enumerated joystick.
hr = g_pDI->CreateDeviceEx( pdidInstance->guidInstance, IID_IDirectInputDevice2,
(VOID**)&g_pJoystick, NULL );
// If it failed, then we can't use this joystick. (Maybe the user unplugged
// it while we were in the middle of enumerating it.)
if( FAILED(hr) )
return DIENUM_CONTINUE;
// Stop enumeration. Note: we're just taking the first joystick we get. You
// could store all the enumerated joysticks and let the user pick.
return DIENUM_STOP;
}
// Callback function for enumerating the axes on a joystick.
bool CALLBACK EnumAxesCallback( const DIDEVICEOBJECTINSTANCE* pdidoi,
VOID* pContext )
{
DIPROPRANGE diprg;
diprg.diph.dwSize = sizeof(DIPROPRANGE);
diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
diprg.diph.dwHow = DIPH_BYOFFSET;
diprg.diph.dwObj = pdidoi->dwOfs; // Specify the enumerated axis
diprg.lMin = -1000;
diprg.lMax = +1000;
// Set the range for the axis
if( FAILED( g_pJoystick->SetProperty( DIPROP_RANGE, &diprg.diph ) ) )
return DIENUM_STOP;
#ifndef __MINGW32__ // FIXME Doesn't work under MinGW
// Set the UI to reflect what axes the joystick supports
switch( pdidoi->dwOfs )
{
case DIJOFS_X:
OutputDebugString("EnumAxesCallback -x\n");
break;
case DIJOFS_Y:
OutputDebugString("EnumAxesCallback -y\n");
break;
case DIJOFS_Z:
OutputDebugString("EnumAxesCallback -z\n");
break;
case DIJOFS_RX:
OutputDebugString("EnumAxesCallback -rx\n");
break;
case DIJOFS_RY:
OutputDebugString("EnumAxesCallback -ry\n");
break;
case DIJOFS_RZ:
OutputDebugString("EnumAxesCallback -rz\n");
break;
case DIJOFS_SLIDER(0):
OutputDebugString("EnumAxesCallback -s0\n");
break;
case DIJOFS_SLIDER(1):
OutputDebugString("EnumAxesCallback -s1\n");
break;
}
#endif
return DIENUM_CONTINUE;
}
// Initialize the DirectInput variables.
bool InitDirectInput(HINSTANCE hInst, HWND hWnd)
{
HRESULT hr;
// Register with the DirectInput subsystem and get a pointer
// to a IDirectInput interface we can use.
#ifndef __MINGW32__ // FIXME Doesn't work under MinGW
hr = DirectInputCreateEx( hInst, DIRECTINPUT_VERSION,IID_IDirectInput7, (LPVOID*)&g_pDI, NULL );
if( FAILED(hr) ) return false;
#else
return false;
#endif
// Look for a simple joystick we can use for this sample program.
hr = g_pDI->EnumDevices( DIDEVTYPE_JOYSTICK, EnumJoysticksCallback,
NULL, DIEDFL_ATTACHEDONLY );
if( FAILED(hr) ) return false;
// Make sure we got a joystick
if( NULL == g_pJoystick )
{
//? MessageBox( NULL, "Joystick not found", "DInput Sample",
//? MB_ICONERROR | MB_OK );
return false;
}
// Set the data format to "simple joystick" - a predefined data format
//
// A data format specifies which controls on a device we are interested in,
// and how they should be reported. This tells DInput that we will be
// passing a DIJOYSTATE structure to IDirectInputDevice::GetDeviceState().
hr = g_pJoystick->SetDataFormat( &c_dfDIJoystick );
if( FAILED(hr) ) return false;
// Set the cooperative level to let DInput know how this device should
// interact with the system and with other DInput applications.
hr = g_pJoystick->SetCooperativeLevel( hWnd, DISCL_EXCLUSIVE|DISCL_FOREGROUND );
if( FAILED(hr) ) return false;
// Determine how many axis the joystick has (so we don't error out setting
// properties for unavailable axis)
g_diDevCaps.dwSize = sizeof(DIDEVCAPS);
hr = g_pJoystick->GetCapabilities(&g_diDevCaps);
if( FAILED(hr) ) return false;
// Enumerate the axes of the joyctick and set the range of each axis. Note:
// we could just use the defaults, but we're just trying to show an example
// of enumerating device objects (axes, buttons, etc.).
g_pJoystick->EnumObjects( EnumAxesCallback, (VOID*)g_pJoystick, DIDFT_AXIS );
return true;
}
// Acquire or unacquire the keyboard, depending on if the app is active
// Input device must be acquired before the GetDeviceState is called.
bool SetAcquire(bool bActive)
{
if ( g_pJoystick )
{
if( bActive ) g_pJoystick->Acquire();
else g_pJoystick->Unacquire();
}
return true;
}
// Get the input device's state and display it.
bool UpdateInputState( DIJOYSTATE &js )
{
HRESULT hr;
if ( g_pJoystick )
{
do
{
// Poll the device to read the current state
hr = g_pJoystick->Poll();
if ( FAILED(hr) ) return false;
// Get the input's device state
hr = g_pJoystick->GetDeviceState( sizeof(DIJOYSTATE), &js );
if( hr == DIERR_INPUTLOST )
{
// DInput is telling us that the input stream has been
// interrupted. We aren't tracking any state between polls, so
// we don't have any special reset that needs to be done. We
// just re-acquire and try again.
hr = g_pJoystick->Acquire();
if ( FAILED(hr) ) return false;
}
}
while ( DIERR_INPUTLOST == hr );
if ( FAILED(hr) ) return false;
}
return true;
}
// Initialize the DirectInput variables.
bool FreeDirectInput()
{
// Unacquire and release any DirectInputDevice objects.
if( NULL != g_pJoystick )
{
// Unacquire the device one last time just in case
// the app tried to exit while the device is still acquired.
g_pJoystick->Unacquire();
g_pJoystick->Release();
g_pJoystick = NULL;
}
// Release any DirectInput objects.
if( g_pDI )
{
g_pDI->Release();
g_pDI = NULL;
}
return true;
}

View File

@ -1,27 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// joystick.h
#pragma once
extern bool InitDirectInput(HINSTANCE hInst, HWND hWnd);
extern bool SetAcquire(bool bActive);
extern bool UpdateInputState(DIJOYSTATE &js);
extern bool FreeDirectInput();

View File

@ -1,504 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// light.cpp
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
#include "math/const.h"
#include "math/geometry.h"
#include "math/conv.h"
#include "old/d3dengine.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
#include "old/math3d.h"
#include "old/light.h"
// Initializes a progression.
void ProgInit(LightProg &p, float value)
{
p.starting = value;
p.ending = value;
p.current = value;
p.progress = 0.0f;
p.speed = 100.0f;
}
// Makes evolve a progression.
void ProgFrame(LightProg &p, float rTime)
{
if ( p.speed < 100.0f )
{
if ( p.progress < 1.0f )
{
p.progress += p.speed*rTime;
if ( p.progress > 1.0f )
{
p.progress = 1.0f;
}
}
p.current = (p.ending-p.starting)*p.progress + p.starting;
}
else
{
p.current = p.ending;
}
}
// Change the current value.
void ProgSet(LightProg &p, float value)
{
p.starting = p.current;
p.ending = value;
p.progress = 0.0f;
}
// Object's constructor.
CLight::CLight(CInstanceManager* iMan, CD3DEngine* engine)
{
m_iMan = iMan;
m_iMan->AddInstance(CLASS_LIGHT, this);
m_pD3DDevice = 0;
m_engine = engine;
m_lightUsed = 0;
m_lightTable = (Light*)malloc(sizeof(Light)*D3DMAXLIGHT);
ZeroMemory(m_lightTable, sizeof(Light)*D3DMAXLIGHT);
m_time = 0.0f;
}
// Object's destructor.
CLight::~CLight()
{
free(m_lightTable);
m_iMan->DeleteInstance(CLASS_LIGHT, this);
}
void CLight::SetD3DDevice(LPDIRECT3DDEVICE7 device)
{
m_pD3DDevice = device;
}
// Removes all the lights.
void CLight::FlushLight()
{
int i;
for ( i=0 ; i<D3DMAXLIGHT ; i++ )
{
m_lightTable[i].bUsed = false;
m_pD3DDevice->LightEnable(i, false);
}
m_lightUsed = 0;
}
// Creates a new light. Returns its rank or -1 on error.
int CLight::CreateLight()
{
int i;
for ( i=0 ; i<D3DMAXLIGHT ; i++ )
{
if ( m_lightTable[i].bUsed == false )
{
ZeroMemory(&m_lightTable[i], sizeof(Light));
m_lightTable[i].bUsed = true;
m_lightTable[i].bEnable = true;
m_lightTable[i].incluType = TYPENULL;
m_lightTable[i].excluType = TYPENULL;
m_lightTable[i].light.dltType = D3DLIGHT_DIRECTIONAL;
m_lightTable[i].light.dcvDiffuse.r = 0.5f;
m_lightTable[i].light.dcvDiffuse.g = 0.5f;
m_lightTable[i].light.dcvDiffuse.b = 0.5f; // white
m_lightTable[i].light.dvPosition.x =-100.0f;
m_lightTable[i].light.dvPosition.y = 100.0f;
m_lightTable[i].light.dvPosition.z =-100.0f;
m_lightTable[i].light.dvDirection.x = 1.0f;
m_lightTable[i].light.dvDirection.y = -1.0f;
m_lightTable[i].light.dvDirection.z = 1.0f;
ProgInit(m_lightTable[i].intensity, 1.0f); // maximum
ProgInit(m_lightTable[i].colorRed, 0.5f);
ProgInit(m_lightTable[i].colorGreen, 0.5f);
ProgInit(m_lightTable[i].colorBlue, 0.5f); // gray
if ( m_lightUsed < i+1 )
{
m_lightUsed = i+1;
}
return i;
}
}
return -1;
}
// Deletes a light.
bool CLight::DeleteLight(int lightRank)
{
int i;
if ( lightRank < 0 || lightRank >= D3DMAXLIGHT ) return false;
m_lightTable[lightRank].bUsed = false;
m_pD3DDevice->LightEnable(lightRank, false);
m_lightUsed = 0;
for ( i=0 ; i<D3DMAXLIGHT ; i++ )
{
if ( m_lightTable[i].bUsed == true )
{
m_lightUsed = i+1;
}
}
return true;
}
// Specifies a light.
bool CLight::SetLight(int lightRank, const D3DLIGHT7 &light)
{
if ( lightRank < 0 || lightRank >= D3DMAXLIGHT ) return false;
m_lightTable[lightRank].light = light;
ProgInit(m_lightTable[lightRank].colorRed, m_lightTable[lightRank].light.dcvDiffuse.r);
ProgInit(m_lightTable[lightRank].colorGreen, m_lightTable[lightRank].light.dcvDiffuse.g);
ProgInit(m_lightTable[lightRank].colorBlue, m_lightTable[lightRank].light.dcvDiffuse.b);
return true;
}
// Gives the specifications of a light.
bool CLight::GetLight(int lightRank, D3DLIGHT7 &light)
{
if ( lightRank < 0 || lightRank >= D3DMAXLIGHT ) return false;
light = m_lightTable[lightRank].light;
return true;
}
// Lights up or put out a light.
bool CLight::LightEnable(int lightRank, bool bEnable)
{
if ( lightRank < 0 || lightRank >= D3DMAXLIGHT ) return false;
m_lightTable[lightRank].bEnable = bEnable;
return true;
}
// Specifies the type (TYPE *) items included in this light.
// This light does not light up so that this type of objects.
bool CLight::SetLightIncluType(int lightRank, D3DTypeObj type)
{
if ( lightRank < 0 || lightRank >= D3DMAXLIGHT ) return false;
m_lightTable[lightRank].incluType = type;
return true;
}
// Specifies the type (TYPE *) items excluded by this light.
// This light does not illuminate then ever these objects.
bool CLight::SetLightExcluType(int lightRank, D3DTypeObj type)
{
if ( lightRank < 0 || lightRank >= D3DMAXLIGHT ) return false;
m_lightTable[lightRank].excluType = type;
return true;
}
// Management of the position of the light.
bool CLight::SetLightPos(int lightRank, Math::Vector pos)
{
if ( lightRank < 0 || lightRank >= D3DMAXLIGHT ) return false;
m_lightTable[lightRank].light.dvPosition = VEC_TO_D3DVEC(pos);
return true;
}
Math::Vector CLight::RetLightPos(int lightRank)
{
if ( lightRank < 0 || lightRank >= D3DMAXLIGHT ) return Math::Vector(0.0f, 0.0f, 0.0f);
return D3DVEC_TO_VEC(m_lightTable[lightRank].light.dvPosition);
}
// Management direction of the light.
bool CLight::SetLightDir(int lightRank, Math::Vector dir)
{
if ( lightRank < 0 || lightRank >= D3DMAXLIGHT ) return false;
m_lightTable[lightRank].light.dvDirection = VEC_TO_D3DVEC(dir);
return true;
}
Math::Vector CLight::RetLightDir(int lightRank)
{
if ( lightRank < 0 || lightRank >= D3DMAXLIGHT ) return Math::Vector(0.0f, 0.0f, 0.0f);
return D3DVEC_TO_VEC(m_lightTable[lightRank].light.dvDirection);
}
// Specifies the rate of change.
bool CLight::SetLightIntensitySpeed(int lightRank, float speed)
{
if ( lightRank < 0 || lightRank >= D3DMAXLIGHT ) return false;
m_lightTable[lightRank].intensity.speed = speed;
return true;
}
// Management of the intensity of light.
bool CLight::SetLightIntensity(int lightRank, float value)
{
if ( lightRank < 0 || lightRank >= D3DMAXLIGHT ) return false;
ProgSet(m_lightTable[lightRank].intensity, value);
return true;
}
float CLight::RetLightIntensity(int lightRank)
{
if ( lightRank < 0 || lightRank >= D3DMAXLIGHT ) return 0.0f;
return m_lightTable[lightRank].intensity.current;
}
// Specifies the rate of change.
bool CLight::SetLightColorSpeed(int lightRank, float speed)
{
if ( lightRank < 0 || lightRank >= D3DMAXLIGHT ) return false;
m_lightTable[lightRank].colorRed.speed = speed;
m_lightTable[lightRank].colorGreen.speed = speed;
m_lightTable[lightRank].colorBlue.speed = speed;
return true;
}
// Color management for light.
bool CLight::SetLightColor(int lightRank, D3DCOLORVALUE color)
{
if ( lightRank < 0 || lightRank >= D3DMAXLIGHT ) return false;
ProgSet(m_lightTable[lightRank].colorRed, color.r);
ProgSet(m_lightTable[lightRank].colorGreen, color.g);
ProgSet(m_lightTable[lightRank].colorBlue, color.b);
return true;
}
D3DCOLORVALUE CLight::RetLightColor(int lightRank)
{
D3DCOLORVALUE color;
if ( lightRank < 0 || lightRank >= D3DMAXLIGHT )
{
color.r = 0.5f;
color.g = 0.5f;
color.b = 0.5f;
color.a = 0.5f;
return color;
}
color.r = m_lightTable[lightRank].colorRed.current;
color.g = m_lightTable[lightRank].colorGreen.current;
color.b = m_lightTable[lightRank].colorBlue.current;
return color;
}
// Adjusts the color of all lights.
void CLight::AdaptLightColor(D3DCOLORVALUE color, float factor)
{
D3DCOLORVALUE value;
int i;
for ( i=0 ; i<m_lightUsed ; i++ )
{
if ( m_lightTable[i].bUsed == false ) continue;
value.r = m_lightTable[i].colorRed.current;
value.g = m_lightTable[i].colorGreen.current;
value.b = m_lightTable[i].colorBlue.current;
value.r += color.r*factor;
value.g += color.g*factor;
value.b += color.b*factor;
ProgInit(m_lightTable[i].colorRed, value.r);
ProgInit(m_lightTable[i].colorGreen, value.g);
ProgInit(m_lightTable[i].colorBlue, value.b);
}
LightUpdate();
}
// Makes all the lights evolve.
void CLight::FrameLight(float rTime)
{
Math::Vector dir;
float angle;
int i;
if ( m_engine->RetPause() ) return;
m_time += rTime;
for ( i=0 ; i<m_lightUsed ; i++ )
{
if ( m_lightTable[i].bUsed == false ) continue;
ProgFrame(m_lightTable[i].intensity, rTime);
ProgFrame(m_lightTable[i].colorRed, rTime);
ProgFrame(m_lightTable[i].colorGreen, rTime);
ProgFrame(m_lightTable[i].colorBlue, rTime);
if ( m_lightTable[i].incluType == TYPEQUARTZ )
{
m_lightTable[i].light.dvDirection.x = sinf((m_time+i*Math::PI*0.5f)*1.0f);
m_lightTable[i].light.dvDirection.z = cosf((m_time+i*Math::PI*0.5f)*1.1f);
m_lightTable[i].light.dvDirection.y = -1.0f+cosf((m_time+i*Math::PI*0.5f)*2.7f)*0.5f;
}
if ( m_lightTable[i].incluType == TYPEMETAL )
{
dir = m_engine->RetEyePt()-m_engine->RetLookatPt();
angle = Math::RotateAngle(dir.x, dir.z);
angle += Math::PI*0.5f*i;
m_lightTable[i].light.dvDirection.x = sinf(angle*2.0f);
m_lightTable[i].light.dvDirection.z = cosf(angle*2.0f);
}
}
}
// Updates all the lights.
void CLight::LightUpdate()
{
bool bEnable;
float value;
int i;
for ( i=0 ; i<m_lightUsed ; i++ )
{
if ( m_lightTable[i].bUsed == false ) continue;
bEnable = m_lightTable[i].bEnable;
if ( m_lightTable[i].intensity.current == 0.0f ) bEnable = false;
if ( bEnable )
{
value = m_lightTable[i].colorRed.current * m_lightTable[i].intensity.current;
m_lightTable[i].light.dcvDiffuse.r = value;
value = m_lightTable[i].colorGreen.current * m_lightTable[i].intensity.current;
m_lightTable[i].light.dcvDiffuse.g = value;
value = m_lightTable[i].colorBlue.current * m_lightTable[i].intensity.current;
m_lightTable[i].light.dcvDiffuse.b = value;
m_pD3DDevice->SetLight(i, &m_lightTable[i].light);
m_pD3DDevice->LightEnable(i, bEnable);
}
else
{
m_lightTable[i].light.dcvDiffuse.r = 0.0f;
m_lightTable[i].light.dcvDiffuse.g = 0.0f;
m_lightTable[i].light.dcvDiffuse.b = 0.0f;
m_pD3DDevice->LightEnable(i, bEnable);
}
}
}
// Updates the lights for a given type.
void CLight::LightUpdate(D3DTypeObj type)
{
bool bEnable;
int i;
for ( i=0 ; i<m_lightUsed ; i++ )
{
if ( m_lightTable[i].bUsed == false ) continue;
if ( m_lightTable[i].bEnable == false ) continue;
if ( m_lightTable[i].intensity.current == 0.0f ) continue;
if ( m_lightTable[i].incluType != TYPENULL )
{
bEnable = (m_lightTable[i].incluType == type);
m_pD3DDevice->LightEnable(i, bEnable);
}
if ( m_lightTable[i].excluType != TYPENULL )
{
bEnable = (m_lightTable[i].excluType != type);
m_pD3DDevice->LightEnable(i, bEnable);
}
}
}

View File

@ -1,109 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// light.h
#pragma once
#include "old/d3dengine.h"
#include "graphics/common/color.h"
class CInstanceManager;
class CD3DEngine;
const int D3DMAXLIGHT = 100;
struct LightProg
{
float starting;
float ending;
float current;
float progress;
float speed;
};
struct Light
{
char bUsed; // true -> light exists
char bEnable; // true -> light turned on
D3DTypeObj incluType; // type of all objects included
D3DTypeObj excluType; // type of all objects excluded
D3DLIGHT7 light; // configuration of the light
LightProg intensity; // intensity (0 .. 1)
LightProg colorRed;
LightProg colorGreen;
LightProg colorBlue;
};
class CLight
{
public:
CLight(CInstanceManager *iMan, CD3DEngine* engine);
virtual ~CLight();
void SetD3DDevice(LPDIRECT3DDEVICE7 device);
void FlushLight();
int CreateLight();
bool DeleteLight(int lightRank);
bool SetLight(int lightRank, const D3DLIGHT7 &light);
bool GetLight(int lightRank, D3DLIGHT7 &light);
bool LightEnable(int lightRank, bool bEnable);
bool SetLightIncluType(int lightRank, D3DTypeObj type);
bool SetLightExcluType(int lightRank, D3DTypeObj type);
bool SetLightPos(int lightRank, Math::Vector pos);
Math::Vector RetLightPos(int lightRank);
bool SetLightDir(int lightRank, Math::Vector dir);
Math::Vector RetLightDir(int lightRank);
bool SetLightIntensitySpeed(int lightRank, float speed);
bool SetLightIntensity(int lightRank, float value);
float RetLightIntensity(int lightRank);
void AdaptLightColor(D3DCOLORVALUE color, float factor);
bool SetLightColorSpeed(int lightRank, float speed);
bool SetLightColor(int lightRank, D3DCOLORVALUE color);
D3DCOLORVALUE RetLightColor(int lightRank);
void FrameLight(float rTime);
void LightUpdate();
void LightUpdate(D3DTypeObj type);
protected:
protected:
CInstanceManager* m_iMan;
CD3DEngine* m_engine;
LPDIRECT3DDEVICE7 m_pD3DDevice;
float m_time;
int m_lightUsed;
Light* m_lightTable;
};

File diff suppressed because it is too large Load Diff

View File

@ -1,48 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// math3d.h
#pragma once
#include <math.h>
#include "common/struct.h"
// TODO
void MappingObject( D3DVERTEX2* pVertices, int nb, float scale );
// TODO
void SmoothObject( D3DVERTEX2* pVertices, int nb );
// TODO
D3DCOLOR RetColor(float intensity);
// TODO
D3DCOLOR RetColor(D3DCOLORVALUE intensity);
// TODO
D3DCOLORVALUE RetColor(D3DCOLOR intensity);
// TODO
void RGB2HSV(D3DCOLORVALUE src, ColorHSV &dest);
// TODO
void HSV2RGB(ColorHSV src, D3DCOLORVALUE &dest);

View File

@ -1,13 +0,0 @@
\b;Rapport du satellite
\c;
\s;-> SURFACE\c;
\tab;Température: 25.4 degrés
\tab;Atmosphère: oxygène, azote, ammoniaque
\tab;Vent: 0.7 m/s
\tab;Minerai titanium: aucun
\tab;Minerai uranium: aucun
\s;-> SOUS-SOL\c;
\tab;Energie: aucune
\tab;Minerai titanium: aucun
\tab;Minerai uranium: aucun

View File

@ -1,486 +0,0 @@
Several people have asked me for the sample code I use to program
the mixer in Windows. Since it's a fairly short sample and there's
clearly some interest, I thought I'd post it directly to the newsgroup.
Here it is ... enjoy! (?)
Julian
// Example routine that manipulates the mixer controls for Win32
// This code is not a stand-alone application ...
//
// It's also not very pretty ...
//
// But then, neither is the API ...
//
// Julian Bunn, 1998, julianb@altavista.net
#include <windows.h>
#include <mmsystem.h>
MIXERCONTROLDETAILS mixDetailsMic,mixDetailsSpk,mixDetailsLin;
LONG
lMaximumSpk,lMaximumMic,lMaximumLin,lMinimumMic,lMinimumSpk,lMinimumLin;
int nMixerDevs;
int nMicMixID;
LPHMIXER hMixer;
UINT IdMixer;
/****************************************************************************
Function: ProgramInitMixer()
PURPOSE : Initialises the mixer
*****************************************************************************/
LONG WINAPI ProgramInitMixer()
{
UINT iS,iD,iDC,iC, itype;
UINT volume;
MMRESULT mmres;
MIXERCAPS mixCaps;
MIXERLINE mixLine;
MIXERLINECONTROLS mixControls;
MIXERCONTROL mixClist[50];
MIXERCONTROLDETAILS mixDetails;
MIXERCONTROLDETAILS_UNSIGNED mixValue;
MIXERCONTROLDETAILS_BOOLEAN mixMute;
MIXERCONTROLDETAILS_BOOLEAN mixBoolean[50];
MIXERCONTROLDETAILS_LISTTEXT mixList[50];
BOOL bDoneMike = FALSE;
BOOL bDoneSpkr = FALSE;
UINT LineID = 0;
if(!bMixerOpened) {
// check first if we have a mixer
if((nMixerDevs = mixerGetNumDevs()) < 1) {
return (Program_ERROR);
}
// really need to pop up a chooser for which mixer device, in
// cases where there is more than one.
// In the meantime, I select the last one listed
IdMixer = nMixerDevs-1;
mmres = mixerOpen((LPHMIXER) &hMixer, IdMixer, (DWORD) 0, (DWORD)
NULL,
MIXER_OBJECTF_MIXER);
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
bMixerOpened = TRUE;
}
mmres = mixerGetDevCaps(IdMixer, (LPMIXERCAPS) &mixCaps,
sizeof(MIXERCAPS));
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
// Set the manufacturer's name for the mixer ...
SetDlgItemText(hWndDialogBox,IDC_MIXERNAME,mixCaps.szPname);
if(nMixerDevs>1) {
DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INFOMESSAGE1),
hWndDialogBox, DialogBoxCallback);
}
// Loop over the destination mixer lines
for (iD=0;iD<mixCaps.cDestinations;iD++) {
mixLine.cbStruct = sizeof(MIXERLINE);
mixLine.dwDestination = (DWORD) iD;
mixLine.dwSource = (DWORD) 0;
// Get information on this line
mmres = mixerGetLineInfo(hMixer, (LPMIXERLINE) &mixLine,
MIXER_GETLINEINFOF_DESTINATION);
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
// I select types I'm interested in: the speaker output, the input
(voice and wave)
itype = 0;
if(mixLine.dwComponentType == MIXERLINE_COMPONENTTYPE_DST_SPEAKERS)
itype = 1; // Output for speakers ... only allow WAVEOUT
if(mixLine.dwComponentType ==
MIXERLINE_COMPONENTTYPE_DST_VOICEIN) itype = 2; // Input for ADC ...
only allow Microphone (or AUX)
if(mixLine.dwComponentType ==
MIXERLINE_COMPONENTTYPE_DST_WAVEIN) itype = 2; // Input for ADC ...
only allow Microphone (or AUX)
if(itype == 2 && !bMicrophone) {
itype = 3;
}
mixControls.cbStruct = sizeof(MIXERLINECONTROLS);
mixControls.dwLineID = mixLine.dwLineID;
mixControls.cControls = mixLine.cControls;
mixControls.cbmxctrl = sizeof(mixClist[0]);
mixControls.pamxctrl = (LPMIXERCONTROL) &mixClist[0];
// Get the controls for the current destination mixer line
mmres = mixerGetLineControls(hMixer,
(LPMIXERLINECONTROLS) &mixControls,
MIXER_GETLINECONTROLSF_ALL);
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
for (iDC=0;iDC<mixLine.cControls;iDC++) {
// For this control, I make various checks on its type
if(mixClist[iDC].dwControlType == MIXERCONTROL_CONTROLTYPE_MUX ||
mixClist[iDC].dwControlType ==
MIXERCONTROL_CONTROLTYPE_MIXER) {
// This is a control that defines a set of connections ... get all the
types, and the values
// for the connection
mixDetails.cbStruct = sizeof(MIXERCONTROLDETAILS);
mixDetails.dwControlID = mixClist[iDC].dwControlID;
mixDetails.cChannels = 1;//mixLine.cChannels;
mixDetails.hwndOwner = (HWND) mixClist[iDC].cMultipleItems;
mixDetails.cbDetails = sizeof(MIXERCONTROLDETAILS_LISTTEXT);
mixDetails.paDetails = (LPMIXERCONTROLDETAILS_LISTTEXT)
&mixList[0];
mmres = mixerGetControlDetails(hMixer,
(LPMIXERCONTROLDETAILS) &mixDetails,
MIXER_GETCONTROLDETAILSF_LISTTEXT);
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
mixDetails.cbStruct = sizeof(MIXERCONTROLDETAILS);
mixDetails.dwControlID = mixClist[iDC].dwControlID;
mixDetails.cChannels = 1;//mixLine.cChannels;
mixDetails.hwndOwner = (HWND) mixClist[iDC].cMultipleItems;
mixDetails.cbDetails = sizeof(MIXERCONTROLDETAILS_BOOLEAN);
mixDetails.paDetails = (LPMIXERCONTROLDETAILS_BOOLEAN)
&mixBoolean[0];
mmres = mixerGetControlDetails(hMixer,
(LPMIXERCONTROLDETAILS) &mixDetails,
MIXER_GETCONTROLDETAILSF_VALUE);
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
// In this application, I want to set only the microphone or line as
input sources ...
for(iS=0;iS<mixClist[iDC].cMultipleItems;iS++) {
mixBoolean[iS].fValue = FALSE;
if(itype == 2 && mixList[iS].dwParam2
== MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE) {
mixBoolean[iS].fValue = TRUE;
bDoneMike = TRUE;
}
if(itype == 3 && (mixList[iS].dwParam2
== MIXERLINE_COMPONENTTYPE_SRC_LINE ||
mixList[iS].dwParam2 ==
MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY)) {
if(strncmp(mixList[iS].szName,"Line",4) == 0) {
mixBoolean[iS].fValue = TRUE;
bDoneMike = TRUE;
}
}
if(itype == 1 && mixList[iS].dwParam2 ==
MIXERLINE_COMPONENTTYPE_DST_SPEAKERS) {
mixBoolean[iS].fValue = TRUE;
bDoneSpkr = TRUE;
}
}
// I've prepared the settings accordingly ... now I set them in the
mixer
mmres = mixerSetControlDetails(hMixer,
(LPMIXERCONTROLDETAILS) &mixDetails,
MIXER_SETCONTROLDETAILSF_VALUE);
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
}
if(mixClist[iDC].dwControlType == MIXERCONTROL_CONTROLTYPE_VOLUME ||
mixClist[iDC].dwControlType == MIXERCONTROL_CONTROLTYPE_TREBLE ||
mixClist[iDC].dwControlType == MIXERCONTROL_CONTROLTYPE_BASS) {
// This is a control of a volume
volume = 0;
mixDetails.cbStruct = sizeof(MIXERCONTROLDETAILS);
mixDetails.dwControlID = mixClist[iDC].dwControlID;
mixDetails.cChannels = (DWORD) 1;
mixDetails.hwndOwner = NULL;
mixDetails.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
mixDetails.paDetails = (LPMIXERCONTROLDETAILS_UNSIGNED)
&mixValue;
mmres = mixerGetControlDetails(hMixer,
(LPMIXERCONTROLDETAILS) &mixDetails,
MIXER_GETCONTROLDETAILSF_VALUE);
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
// I want to set all volumes to maximum, treble and bass boost to
minimum
if(mixClist[iDC].dwControlType ==
MIXERCONTROL_CONTROLTYPE_VOLUME) {
if(mixValue.dwValue != 0) mixValue.dwValue =
mixClist[iDC].Bounds.lMaximum;
} else {
mixValue.dwValue = mixClist[iDC].Bounds.lMinimum;
}
mmres = mixerSetControlDetails(hMixer,
(LPMIXERCONTROLDETAILS) &mixDetails,
MIXER_SETCONTROLDETAILSF_VALUE);
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
}
if(mixClist[iDC].dwControlType == MIXERCONTROL_CONTROLTYPE_MUTE) {
// A mute control _in principle_ I've already set all these up ...
mixDetails.cbStruct = sizeof(MIXERCONTROLDETAILS);
mixDetails.dwControlID = mixClist[iDC].dwControlID;
mixDetails.cChannels = (DWORD) 1;
mixDetails.hwndOwner = NULL;
mixDetails.cbDetails = sizeof(MIXERCONTROLDETAILS_BOOLEAN);
mixDetails.paDetails = (LPMIXERCONTROLDETAILS_BOOLEAN) &mixMute;
mmres = mixerGetControlDetails(hMixer,
(LPMIXERCONTROLDETAILS) &mixDetails,
MIXER_GETCONTROLDETAILSF_VALUE);
mixMute.fValue = mixClist[iDC].Bounds.lMinimum;
mmres = mixerSetControlDetails(hMixer,
(LPMIXERCONTROLDETAILS) &mixDetails,
MIXER_SETCONTROLDETAILSF_VALUE);
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
}
if(mixClist[iDC].dwControlType == MIXERCONTROL_CONTROLTYPE_ONOFF) {
// An "on-off" control ... sort of like a mute, but different (used e.g
for AGC)
mixDetails.cbStruct = sizeof(MIXERCONTROLDETAILS);
mixDetails.dwControlID = mixClist[iDC].dwControlID;
mixDetails.cChannels = (DWORD) 1;
mixDetails.hwndOwner = NULL;
mixDetails.cbDetails = sizeof(MIXERCONTROLDETAILS_BOOLEAN);
mixDetails.paDetails = (LPMIXERCONTROLDETAILS_BOOLEAN) &mixMute;
mmres = mixerGetControlDetails(hMixer,
(LPMIXERCONTROLDETAILS) &mixDetails,
MIXER_GETCONTROLDETAILSF_VALUE);
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
mixMute.fValue = mixClist[iDC].Bounds.lMinimum;
mmres = mixerSetControlDetails(hMixer,
(LPMIXERCONTROLDETAILS) &mixDetails,
MIXER_SETCONTROLDETAILSF_VALUE);
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
}
}
iDC = mixLine.cConnections;
// Now I start looking over all the source lines coming into this mixer
line ..
for (iS=0;iS<iDC;iS++) {
mixLine.cbStruct = sizeof(MIXERLINE);
mixLine.dwDestination = (DWORD) iD;
mixLine.dwSource = (DWORD) iS;
mmres = mixerGetLineInfo(hMixer, (LPMIXERLINE) &mixLine,
MIXER_GETLINEINFOF_SOURCE);
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
mixControls.cbStruct = sizeof(MIXERLINECONTROLS);
mixControls.dwLineID = mixLine.dwLineID;
mixControls.cControls = mixLine.cControls;
mixControls.cbmxctrl = sizeof(mixClist[0]);
mixControls.pamxctrl = (LPMIXERCONTROL) &mixClist[0];
mmres = mixerGetLineControls(hMixer,
(LPMIXERLINECONTROLS) &mixControls,
MIXER_GETLINECONTROLSF_ALL);
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
// for this source line ... loop over all the control. Very like what
was done above for the
// destination line ...
for(iC=0;iC<mixLine.cControls;iC++) {
if(mixClist[iC].dwControlType ==
MIXERCONTROL_CONTROLTYPE_VOLUME) {
mixDetails.cbStruct = sizeof(MIXERCONTROLDETAILS);
mixDetails.dwControlID = mixClist[iC].dwControlID;
mixDetails.cChannels = (DWORD) 1;
mixDetails.hwndOwner = NULL;
mixDetails.cbDetails =
sizeof(MIXERCONTROLDETAILS_UNSIGNED);
mixDetails.paDetails = (LPMIXERCONTROLDETAILS_UNSIGNED)
&mixValue;
// I want to make a copy of the waveout, microphone, aux and line lines
for later use .... hence memcpy
if(itype == 1 && mixLine.dwComponentType ==
MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT) {
memcpy(&mixDetailsSpk,&mixDetails,sizeof(MIXERCONTROLDETAILS));
lMaximumSpk = mixClist[iC].Bounds.lMaximum;
lMinimumSpk = mixClist[iC].Bounds.lMinimum;
}
if(itype == 2 && mixLine.dwComponentType ==
MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE) {
memcpy(&mixDetailsMic,&mixDetails,sizeof(MIXERCONTROLDETAILS));
lMaximumMic = mixClist[iC].Bounds.lMaximum;
lMinimumMic = mixClist[iC].Bounds.lMinimum;
}
if(itype == 3 &&
(mixLine.dwComponentType == MIXERLINE_COMPONENTTYPE_SRC_LINE ||
mixLine.dwComponentType ==
MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY)) {
// I'm not sure why I had to check the string like this ...
if(strncmp(mixLine.szName,"Line",4) == 0) {
memcpy(&mixDetailsLin,&mixDetails,sizeof(MIXERCONTROLDETAILS));
lMaximumLin = mixClist[iC].Bounds.lMaximum;
lMinimumLin = mixClist[iC].Bounds.lMinimum;
}
}
mmres = mixerGetControlDetails(hMixer,
(LPMIXERCONTROLDETAILS) &mixDetails,
MIXER_GETCONTROLDETAILSF_VALUE);
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
// Now I'm going to set the input levels the way I want them ..
mixValue.dwValue = mixClist[iC].Bounds.lMinimum;
if(itype == 1 && mixLine.dwComponentType ==
MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT) {
mixValue.dwValue = mixClist[iC].Bounds.lMaximum;
}
if(itype == 2 && mixLine.dwComponentType ==
MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE) {
mixValue.dwValue = mixClist[iC].Bounds.lMaximum;
}
if(itype == 3 &&
(mixLine.dwComponentType == MIXERLINE_COMPONENTTYPE_SRC_LINE ||
mixLine.dwComponentType ==
MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY)) {
if(strncmp(mixLine.szName,"Line",4) == 0) {
mixValue.dwValue = mixClist[iC].Bounds.lMaximum;
}
}
mmres = mixerSetControlDetails(hMixer,
(LPMIXERCONTROLDETAILS) &mixDetails,
MIXER_SETCONTROLDETAILSF_VALUE);
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
}
if(mixClist[iC].dwControlType ==
MIXERCONTROL_CONTROLTYPE_MUTE) {
mixDetails.cbStruct = sizeof(MIXERCONTROLDETAILS);
mixDetails.dwControlID = mixClist[iC].dwControlID;
mixDetails.cChannels = (DWORD) 1;
mixDetails.hwndOwner = NULL;
mixDetails.cbDetails =
sizeof(MIXERCONTROLDETAILS_BOOLEAN);
mixDetails.paDetails = (LPMIXERCONTROLDETAILS_BOOLEAN)
&mixMute;
mmres = mixerGetControlDetails(hMixer,
(LPMIXERCONTROLDETAILS) &mixDetails,
MIXER_GETCONTROLDETAILSF_VALUE);
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
// I run the risk of inverting my boolean selections, so jump out if
already done ...
if(itype != 0 && (bDoneSpkr || bDoneMike)) break;
mixMute.fValue = mixClist[iC].Bounds.lMaximum;
if(itype == 1 && mixLine.dwComponentType ==
MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT) {
mixMute.fValue = mixClist[iC].Bounds.lMinimum;
}
if(itype == 2 && mixLine.dwComponentType ==
MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE) {
mixMute.fValue = mixClist[iC].Bounds.lMinimum;
}
if(itype == 3 &&
(mixLine.dwComponentType == MIXERLINE_COMPONENTTYPE_SRC_LINE ||
mixLine.dwComponentType ==
MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY)) {
if(strncmp(mixLine.szName,"Line",4) == 0) {
mixMute.fValue = mixClist[iC].Bounds.lMinimum;
}
}
mmres = mixerSetControlDetails(hMixer,
(LPMIXERCONTROLDETAILS) &mixDetails,
MIXER_SETCONTROLDETAILSF_VALUE);
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
}
if(mixClist[iC].dwControlType == MIXERCONTROL_CONTROLTYPE_ONOFF)
{
mixDetails.cbStruct = sizeof(MIXERCONTROLDETAILS);
mixDetails.dwControlID = mixClist[iC].dwControlID;
mixDetails.cChannels = (DWORD) 1;
mixDetails.hwndOwner = NULL;
mixDetails.cbDetails =
sizeof(MIXERCONTROLDETAILS_BOOLEAN);
mixDetails.paDetails = (LPMIXERCONTROLDETAILS_BOOLEAN)
&mixMute;
mmres = mixerGetControlDetails(hMixer,
(LPMIXERCONTROLDETAILS) &mixDetails,
MIXER_GETCONTROLDETAILSF_VALUE);
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
mixMute.fValue = mixClist[iC].Bounds.lMinimum;
if(itype == 1 && mixLine.dwComponentType ==
MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT) {
mixMute.fValue = mixClist[iC].Bounds.lMaximum;
}
if(itype == 2 && mixLine.dwComponentType ==
MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE) {
mixMute.fValue = mixClist[iC].Bounds.lMaximum;
}
if(itype == 3 &&
(mixLine.dwComponentType == MIXERLINE_COMPONENTTYPE_SRC_LINE ||
mixLine.dwComponentType ==
MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY)) {
if(strncmp(mixLine.szName,"Line",4) == 0) {
mixMute.fValue = mixClist[iC].Bounds.lMaximum;
}
}
mmres = mixerSetControlDetails(hMixer,
(LPMIXERCONTROLDETAILS) &mixDetails,
MIXER_SETCONTROLDETAILSF_VALUE);
if(mmres != MMSYSERR_NOERROR) {
return (Program_ERROR);
}
}
}
}
}
return Program_NOERROR;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,136 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// model.h
#pragma once
#include "common/event.h"
#include "old/modfile.h"
#include "math/point.h"
class CInstanceManager;
class CD3DEngine;
class CModFile;
class CInterface;
class CModel
{
public:
CModel(CInstanceManager* iMan);
~CModel();
void StartUserAction();
void StopUserAction();
bool EventProcess(const Event &event);
void InitView();
void InitViewFromSelect();
void UpdateView();
void ViewMove(const Event &event, float speed);
protected:
bool EventFrame(const Event &event);
bool GetVertex(int rank, D3DVERTEX2 &vertex);
bool SetVertex(int rank, D3DVERTEX2 &vertex);
Math::Vector RetSelectCDG();
Math::Vector RetSelectNormal();
void SmoothSelect();
void PlaneSelect();
void ColorSelect();
void StateSelect();
void MoveSelect(Math::Vector move);
void OperSelect(Math::Vector move, char oper);
void ReadScript(char *filename);
void BBoxCompute(Math::Vector &min, Math::Vector &max);
bool IsMappingSelectPlausible(D3DMaping D3Dmode);
void MappingSelect(int mode, int rotate, bool bMirrorX, bool bMirrorY, Math::Point ti, Math::Point ts, char *texName);
void MappingSelectSpherical(int mode, int rotate, bool bMirrorX, bool bMirrorY, Math::Point ti, Math::Point ts, char *texName);
Math::Vector RetMappingCenter(Math::Vector pos, Math::Vector min);
void MappingSelectCylindrical(int mode, int rotate, bool bMirrorX, bool bMirrorY, Math::Point ti, Math::Point ts, char *texName);
void MappingSelectFace(int mode, int rotate, bool bMirrorX, bool bMirrorY, Math::Point ti, Math::Point ts, char *texName);
void MappingSelect2(int texNum2, int subdiv, int offsetU, int offsetV, bool bMirrorX, bool bMirrorY);
void MappingSelectPlane2(int mode, bool bMirrorX, bool bMirrorY);
void MappingSelectSpherical2(bool bMirrorX, bool bMirrorY);
void MappingSelectMagic2(bool bMirrorX, bool bMirrorY);
int SearchNext(int rank, int step);
int SearchSamePlane(int first, int step);
void CurrentSearchNext(int step, bool bControl);
void CurrentInit();
void CurrentSelect(bool bSelect);
void DeselectAll();
void SelectAll();
void SelectZone(int first, int last);
void SelectTerm();
void DefaultSelect();
void SelectDelete();
void Compress();
void MinMaxSelect();
void MinMaxChange();
void UpdateInfoText();
int* RetTextureTable();
void TexturePartUpdate();
void TextureRankChange(int step);
void TexturePartChange(int step);
void PutTextureValues();
void GetTextureValues();
void GetModelName(char *buffer);
void GetDXFName(char *buffer);
void GetScriptName(char *buffer);
bool IsEditFocus();
protected:
CInstanceManager* m_iMan;
CD3DEngine* m_engine;
CModFile* m_modFile;
CInterface* m_interface;
float m_time;
ModelTriangle* m_triangleTable;
int m_triangleSel1;
int m_triangleSel2;
int m_mode;
int m_textureMode;
int m_textureRotate;
bool m_bTextureMirrorX;
bool m_bTextureMirrorY;
Math::Point m_textureInf;
Math::Point m_textureSup;
int m_texturePart;
int m_textureRank;
char m_textureName[20];
bool m_bDisplayTransparent;
bool m_bDisplayOnlySelection;
float m_viewHeight;
float m_viewDist;
float m_viewAngleH;
float m_viewAngleV;
int m_color;
int m_state;
int m_secondTexNum;
int m_secondSubdiv;
int m_secondOffsetU;
int m_secondOffsetV;
char m_oper;
float m_min;
float m_max;
};

View File

@ -1,695 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// modfile.cpp
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
#include "math/geometry.h"
#include "old/d3dengine.h"
#include "old/d3dmath.h"
#include "common/language.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
#include "old/math3d.h"
#include "modfile.h"
const int MAX_VERTICES = 2000;
// Object's constructor.
CModFile::CModFile(CInstanceManager* iMan)
{
m_iMan = iMan;
m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
m_triangleUsed = 0;
m_triangleTable = (ModelTriangle*)malloc(sizeof(ModelTriangle)*MAX_VERTICES);
ZeroMemory(m_triangleTable, sizeof(ModelTriangle)*MAX_VERTICES);
}
// Object's destructor.
CModFile::~CModFile()
{
free(m_triangleTable);
}
// Creates a triangle in the internal structure.
bool CModFile::CreateTriangle(Math::Vector p1, Math::Vector p2, Math::Vector p3,
float min, float max)
{
Math::Vector n;
int i;
if ( m_triangleUsed >= MAX_VERTICES )
{
OutputDebugString("ERROR: CreateTriangle::Too many triangles\n");
return false;
}
i = m_triangleUsed++;
ZeroMemory(&m_triangleTable[i], sizeof(ModelTriangle));
m_triangleTable[i].bUsed = true;
m_triangleTable[i].bSelect = false;
n = Math::NormalToPlane(p3, p2, p1);
m_triangleTable[i].p1 = D3DVERTEX2( p1, n);
m_triangleTable[i].p2 = D3DVERTEX2( p2, n);
m_triangleTable[i].p3 = D3DVERTEX2( p3, n);
m_triangleTable[i].material.diffuse.r = 1.0f;
m_triangleTable[i].material.diffuse.g = 1.0f;
m_triangleTable[i].material.diffuse.b = 1.0f; // white
m_triangleTable[i].material.ambient.r = 0.5f;
m_triangleTable[i].material.ambient.g = 0.5f;
m_triangleTable[i].material.ambient.b = 0.5f;
m_triangleTable[i].min = min;
m_triangleTable[i].max = max;
return true;
}
// Reads a DXF file.
bool CModFile::ReadDXF(char *filename, float min, float max)
{
FILE* file = NULL;
char line[100];
int command, rankSommet, nbSommet, nbFace;
Math::Vector table[MAX_VERTICES];
bool bWaitNbSommet;
bool bWaitNbFace;
bool bWaitSommetX;
bool bWaitSommetY;
bool bWaitSommetZ;
bool bWaitFaceX;
bool bWaitFaceY;
bool bWaitFaceZ;
float x,y,z;
int p1,p2,p3;
file = fopen(filename, "r");
if ( file == NULL ) return false;
m_triangleUsed = 0;
rankSommet = 0;
bWaitNbSommet = false;
bWaitNbFace = false;
bWaitSommetX = false;
bWaitSommetY = false;
bWaitSommetZ = false;
bWaitFaceX = false;
bWaitFaceY = false;
bWaitFaceZ = false;
while ( fgets(line, 100, file) != NULL )
{
sscanf(line, "%d", &command);
if ( fgets(line, 100, file) == NULL ) break;
if ( command == 66 )
{
bWaitNbSommet = true;
}
if ( command == 71 && bWaitNbSommet )
{
bWaitNbSommet = false;
sscanf(line, "%d", &nbSommet);
if ( nbSommet > MAX_VERTICES ) nbSommet = MAX_VERTICES;
rankSommet = 0;
bWaitNbFace = true;
//? sprintf(s, "Waiting for %d sommets\n", nbSommet);
//? OutputDebugString(s);
}
if ( command == 72 && bWaitNbFace )
{
bWaitNbFace = false;
sscanf(line, "%d", &nbFace);
bWaitSommetX = true;
//? sprintf(s, "Waiting for %d faces\n", nbFace);
//? OutputDebugString(s);
}
if ( command == 10 && bWaitSommetX )
{
bWaitSommetX = false;
sscanf(line, "%f", &x);
bWaitSommetY = true;
}
if ( command == 20 && bWaitSommetY )
{
bWaitSommetY = false;
sscanf(line, "%f", &y);
bWaitSommetZ = true;
}
if ( command == 30 && bWaitSommetZ )
{
bWaitSommetZ = false;
sscanf(line, "%f", &z);
nbSommet --;
if ( nbSommet >= 0 )
{
Math::Vector p(x,z,y); // permutation of Y and Z!
table[rankSommet++] = p;
bWaitSommetX = true;
//? sprintf(s, "Sommet[%d]=%f;%f;%f\n", rankSommet, p.x,p.y,p.z);
//? OutputDebugString(s);
}
else
{
bWaitFaceX = true;
}
}
if ( command == 71 && bWaitFaceX )
{
bWaitFaceX = false;
sscanf(line, "%d", &p1);
if ( p1 < 0 ) p1 = -p1;
bWaitFaceY = true;
}
if ( command == 72 && bWaitFaceY )
{
bWaitFaceY = false;
sscanf(line, "%d", &p2);
if ( p2 < 0 ) p2 = -p2;
bWaitFaceZ = true;
}
if ( command == 73 && bWaitFaceZ )
{
bWaitFaceZ = false;
sscanf(line, "%d", &p3);
if ( p3 < 0 ) p3 = -p3;
nbFace --;
if ( nbFace >= 0 )
{
CreateTriangle( table[p3-1], table[p2-1], table[p1-1], min,max );
bWaitFaceX = true;
//? sprintf(s, "Face=%d;%d;%d\n", p1,p2,p3);
//? OutputDebugString(s);
}
}
}
fclose(file);
return true;
}
struct InfoMOD
{
int rev;
int vers;
int total;
int reserve[10];
};
// Change nom.bmp to nom.tga
void ChangeBMPtoTGA(char *filename)
{
char* p;
p = strstr(filename, ".bmp");
if ( p != 0 ) strcpy(p, ".tga");
}
// Reads a MOD file.
bool CModFile::AddModel(char *filename, int first, bool bEdit, bool bMeta)
{
FILE* file;
InfoMOD info;
float limit[2];
int i, nb, err;
char* p;
if ( m_engine->RetDebugMode() )
{
bMeta = false;
}
if ( bMeta )
{
p = strchr(filename, '\\');
if ( p == 0 )
{
#if _SCHOOL
err = g_metafile.Open("ceebot2.dat", filename);
#else
err = g_metafile.Open("colobot2.dat", filename);
#endif
}
else
{
#if _SCHOOL
err = g_metafile.Open("ceebot2.dat", p+1);
#else
err = g_metafile.Open("colobot2.dat", p+1);
#endif
}
if ( err != 0 ) bMeta = false;
}
if ( !bMeta )
{
file = fopen(filename, "rb");
if ( file == NULL ) return false;
}
if ( bMeta )
{
g_metafile.Read(&info, sizeof(InfoMOD));
}
else
{
fread(&info, sizeof(InfoMOD), 1, file);
}
nb = info.total;
m_triangleUsed += nb;
if ( info.rev == 1 && info.vers == 0 )
{
OldModelTriangle1 old;
for ( i=first ; i<m_triangleUsed ; i++ )
{
if ( bMeta )
{
g_metafile.Read(&old, sizeof(OldModelTriangle1));
}
else
{
fread(&old, sizeof(OldModelTriangle1), 1, file);
}
ZeroMemory(&m_triangleTable[i], sizeof(ModelTriangle));
m_triangleTable[i].bUsed = old.bUsed;
m_triangleTable[i].bSelect = old.bSelect;
m_triangleTable[i].p1.x = old.p1.x;
m_triangleTable[i].p1.y = old.p1.y;
m_triangleTable[i].p1.z = old.p1.z;
m_triangleTable[i].p1.nx = old.p1.nx;
m_triangleTable[i].p1.ny = old.p1.ny;
m_triangleTable[i].p1.nz = old.p1.nz;
m_triangleTable[i].p1.tu = old.p1.tu;
m_triangleTable[i].p1.tv = old.p1.tv;
m_triangleTable[i].p2.x = old.p2.x;
m_triangleTable[i].p2.y = old.p2.y;
m_triangleTable[i].p2.z = old.p2.z;
m_triangleTable[i].p2.nx = old.p2.nx;
m_triangleTable[i].p2.ny = old.p2.ny;
m_triangleTable[i].p2.nz = old.p2.nz;
m_triangleTable[i].p2.tu = old.p2.tu;
m_triangleTable[i].p2.tv = old.p2.tv;
m_triangleTable[i].p3.x = old.p3.x;
m_triangleTable[i].p3.y = old.p3.y;
m_triangleTable[i].p3.z = old.p3.z;
m_triangleTable[i].p3.nx = old.p3.nx;
m_triangleTable[i].p3.ny = old.p3.ny;
m_triangleTable[i].p3.nz = old.p3.nz;
m_triangleTable[i].p3.tu = old.p3.tu;
m_triangleTable[i].p3.tv = old.p3.tv;
m_triangleTable[i].material = old.material;
strcpy(m_triangleTable[i].texName, old.texName);
m_triangleTable[i].min = old.min;
m_triangleTable[i].max = old.max;
}
}
else if ( info.rev == 1 && info.vers == 1 )
{
OldModelTriangle2 old;
for ( i=first ; i<m_triangleUsed ; i++ )
{
if ( bMeta )
{
g_metafile.Read(&old, sizeof(OldModelTriangle2));
}
else
{
fread(&old, sizeof(OldModelTriangle2), 1, file);
}
ZeroMemory(&m_triangleTable[i], sizeof(ModelTriangle));
m_triangleTable[i].bUsed = old.bUsed;
m_triangleTable[i].bSelect = old.bSelect;
m_triangleTable[i].p1.x = old.p1.x;
m_triangleTable[i].p1.y = old.p1.y;
m_triangleTable[i].p1.z = old.p1.z;
m_triangleTable[i].p1.nx = old.p1.nx;
m_triangleTable[i].p1.ny = old.p1.ny;
m_triangleTable[i].p1.nz = old.p1.nz;
m_triangleTable[i].p1.tu = old.p1.tu;
m_triangleTable[i].p1.tv = old.p1.tv;
m_triangleTable[i].p2.x = old.p2.x;
m_triangleTable[i].p2.y = old.p2.y;
m_triangleTable[i].p2.z = old.p2.z;
m_triangleTable[i].p2.nx = old.p2.nx;
m_triangleTable[i].p2.ny = old.p2.ny;
m_triangleTable[i].p2.nz = old.p2.nz;
m_triangleTable[i].p2.tu = old.p2.tu;
m_triangleTable[i].p2.tv = old.p2.tv;
m_triangleTable[i].p3.x = old.p3.x;
m_triangleTable[i].p3.y = old.p3.y;
m_triangleTable[i].p3.z = old.p3.z;
m_triangleTable[i].p3.nx = old.p3.nx;
m_triangleTable[i].p3.ny = old.p3.ny;
m_triangleTable[i].p3.nz = old.p3.nz;
m_triangleTable[i].p3.tu = old.p3.tu;
m_triangleTable[i].p3.tv = old.p3.tv;
m_triangleTable[i].material = old.material;
strcpy(m_triangleTable[i].texName, old.texName);
m_triangleTable[i].min = old.min;
m_triangleTable[i].max = old.max;
m_triangleTable[i].state = old.state;
m_triangleTable[i].reserve2 = old.reserve2;
m_triangleTable[i].reserve3 = old.reserve3;
m_triangleTable[i].reserve4 = old.reserve4;
}
}
else
{
if ( bMeta )
{
g_metafile.Read(m_triangleTable+first, sizeof(ModelTriangle)*nb);
}
else
{
fread(m_triangleTable+first, sizeof(ModelTriangle), nb, file);
}
}
for ( i=first ; i<m_triangleUsed ; i++ )
{
ChangeBMPtoTGA(m_triangleTable[i].texName);
}
if ( !bEdit )
{
limit[0] = m_engine->RetLimitLOD(0); // frontier AB as config
limit[1] = m_engine->RetLimitLOD(1); // frontier BC as config
// Standard frontiers -> config.
for ( i=first ; i<m_triangleUsed ; i++ )
{
if ( m_triangleTable[i].min == 0.0f &&
m_triangleTable[i].max == 100.0f ) // resolution A ?
{
m_triangleTable[i].max = limit[0];
}
else if ( m_triangleTable[i].min == 100.0f &&
m_triangleTable[i].max == 200.0f ) // resolution B ?
{
m_triangleTable[i].min = limit[0];
m_triangleTable[i].max = limit[1];
}
else if ( m_triangleTable[i].min == 200.0f &&
m_triangleTable[i].max == 1000000.0f ) // resolution C ?
{
m_triangleTable[i].min = limit[1];
}
}
}
if ( bMeta )
{
g_metafile.Close();
}
else
{
fclose(file);
}
return true;
}
// Reads a MOD file.
bool CModFile::ReadModel(char *filename, bool bEdit, bool bMeta)
{
m_triangleUsed = 0;
return AddModel(filename, 0, bEdit, bMeta);
}
// Writes a MOD file.
bool CModFile::WriteModel(char *filename)
{
FILE* file;
InfoMOD info;
if ( m_triangleUsed == 0 ) return false;
file = fopen(filename, "wb");
if ( file == NULL ) return false;
ZeroMemory(&info, sizeof(InfoMOD));
info.rev = 1;
info.vers = 2;
info.total = m_triangleUsed;
fwrite(&info, sizeof(InfoMOD), 1, file);
fwrite(m_triangleTable, sizeof(ModelTriangle), m_triangleUsed, file);
fclose(file);
return true;
}
// Creates the object in the 3D engine.
bool CModFile::CreateEngineObject(int objRank, int addState)
{
#if 0
char texName2[20];
int texNum, i, state;
for ( i=0 ; i<m_triangleUsed ; i++ )
{
if ( !m_triangleTable[i].bUsed ) continue;
state = m_triangleTable[i].state;
texName2[0] = 0;
if ( m_triangleTable[i].texNum2 != 0 )
{
if ( m_triangleTable[i].texNum2 == 1 )
{
texNum = m_engine->RetSecondTexture();
}
else
{
texNum = m_triangleTable[i].texNum2;
}
if ( texNum >= 1 && texNum <= 10 )
{
state = m_triangleTable[i].state|D3DSTATEDUALb;
}
if ( texNum >= 11 && texNum <= 20 )
{
state = m_triangleTable[i].state|D3DSTATEDUALw;
}
sprintf(texName2, "dirty%.2d.bmp", texNum);
}
m_engine->AddTriangle(objRank, &m_triangleTable[i].p1, 3,
m_triangleTable[i].material,
state+addState,
m_triangleTable[i].texName, texName2,
m_triangleTable[i].min,
m_triangleTable[i].max, false);
}
return true;
#else
char texName1[20];
char texName2[20];
int texNum, i, state;
for ( i=0 ; i<m_triangleUsed ; i++ )
{
if ( !m_triangleTable[i].bUsed ) continue;
state = m_triangleTable[i].state;
strcpy(texName1, m_triangleTable[i].texName);
texName2[0] = 0;
if ( strcmp(texName1, "plant.tga") == 0 )
{
state |= D3DSTATEALPHA;
}
if ( m_triangleTable[i].texNum2 != 0 )
{
if ( m_triangleTable[i].texNum2 == 1 )
{
texNum = m_engine->RetSecondTexture();
}
else
{
texNum = m_triangleTable[i].texNum2;
}
if ( texNum >= 1 && texNum <= 10 )
{
state |= D3DSTATEDUALb;
}
if ( texNum >= 11 && texNum <= 20 )
{
state |= D3DSTATEDUALw;
}
sprintf(texName2, "dirty%.2d.tga", texNum);
}
m_engine->AddTriangle(objRank, &m_triangleTable[i].p1, 3,
m_triangleTable[i].material,
state+addState,
texName1, texName2,
m_triangleTable[i].min,
m_triangleTable[i].max, false);
}
return true;
#endif
}
// Performs a mirror according to Z.
void CModFile::Mirror()
{
D3DVERTEX2 t;
int i;
for ( i=0 ; i<m_triangleUsed ; i++ )
{
t = m_triangleTable[i].p1;
m_triangleTable[i].p1 = m_triangleTable[i].p2;
m_triangleTable[i].p2 = t;
m_triangleTable[i].p1.z = -m_triangleTable[i].p1.z;
m_triangleTable[i].p2.z = -m_triangleTable[i].p2.z;
m_triangleTable[i].p3.z = -m_triangleTable[i].p3.z;
m_triangleTable[i].p1.nz = -m_triangleTable[i].p1.nz;
m_triangleTable[i].p2.nz = -m_triangleTable[i].p2.nz;
m_triangleTable[i].p3.nz = -m_triangleTable[i].p3.nz;
}
}
// Returns the pointer to the list of triangles.
void CModFile::SetTriangleUsed(int total)
{
m_triangleUsed = total;
}
int CModFile::RetTriangleUsed()
{
return m_triangleUsed;
}
int CModFile::RetTriangleMax()
{
return MAX_VERTICES;
}
ModelTriangle* CModFile::RetTriangleList()
{
return m_triangleTable;
}
// Returns the height according to a position (x - z);
float CModFile::RetHeight(Math::Vector pos)
{
Math::Vector p1, p2, p3;
float limit;
int i;
limit = 5.0f;
for ( i=0 ; i<m_triangleUsed ; i++ )
{
if ( !m_triangleTable[i].bUsed ) continue;
if ( fabs(pos.x-m_triangleTable[i].p1.x) < limit &&
fabs(pos.z-m_triangleTable[i].p1.z) < limit )
{
return m_triangleTable[i].p1.y;
}
if ( fabs(pos.x-m_triangleTable[i].p2.x) < limit &&
fabs(pos.z-m_triangleTable[i].p2.z) < limit )
{
return m_triangleTable[i].p2.y;
}
if ( fabs(pos.x-m_triangleTable[i].p3.x) < limit &&
fabs(pos.z-m_triangleTable[i].p3.z) < limit )
{
return m_triangleTable[i].p3.y;
}
}
return 0.0f;
}

View File

@ -1,115 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// modfile.h
#pragma once
#include "math/vector.h"
#include "old/d3dengine.h"
class CInstanceManager;
struct OldModelTriangle1
{
char bUsed; // true -> using
char bSelect; // true -> selected
D3DVERTEX p1;
D3DVERTEX p2;
D3DVERTEX p3;
D3DMATERIAL7 material;
char texName[20];
float min;
float max;
}; // length = 196 bytes
struct OldModelTriangle2
{
char bUsed; // true -> used
char bSelect; // true -> selected
D3DVERTEX p1;
D3DVERTEX p2;
D3DVERTEX p3;
D3DMATERIAL7 material;
char texName[20];
float min;
float max;
long state;
short reserve1;
short reserve2;
short reserve3;
short reserve4;
};
struct ModelTriangle
{
char bUsed; // true -> used
char bSelect; // true -> selected
D3DVERTEX2 p1;
D3DVERTEX2 p2;
D3DVERTEX2 p3;
D3DMATERIAL7 material;
char texName[20];
float min;
float max;
long state;
short texNum2;
short reserve2;
short reserve3;
short reserve4;
}; // length = 208 bytes
class CModFile
{
public:
CModFile(CInstanceManager* iMan);
~CModFile();
bool ReadDXF(char *filename, float min, float max);
bool AddModel(char *filename, int first, bool bEdit=false, bool bMeta=true);
bool ReadModel(char *filename, bool bEdit=false, bool bMeta=true);
bool WriteModel(char *filename);
bool CreateEngineObject(int objRank, int addState=0);
void Mirror();
void SetTriangleUsed(int total);
int RetTriangleUsed();
int RetTriangleMax();
ModelTriangle* RetTriangleList();
float RetHeight(Math::Vector pos);
protected:
bool CreateTriangle(Math::Vector p1, Math::Vector p2, Math::Vector p3, float min, float max);
protected:
CInstanceManager* m_iMan;
CD3DEngine* m_engine;
ModelTriangle* m_triangleTable;
int m_triangleUsed;
};

File diff suppressed because it is too large Load Diff

View File

@ -1,337 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// particule.h
#pragma once
#include "math/point.h"
#include "old/d3dengine.h"
#include "old/sound.h"
class CInstanceManager;
class CRobotMain;
class CTerrain;
class CWater;
class CObject;
const int MAXPARTICULE = 500;
const int MAXPARTITYPE = 5;
const int MAXTRACK = 100;
const int MAXTRACKLEN = 10;
const int MAXPARTIFOG = 100;
const int MAXWHEELTRACE = 1000;
enum ParticulePlace
{
SH_WORLD = 0, // particle in the world in the interface
SH_FRONT = 1, // particle in the world on the interface
SH_INTERFACE = 2, // particle in the interface
SH_MAX = 3
};
// type == 0 -> triangles
// type == 1 -> effect00 (black background)
// type == 2 -> effect01 (black background)
// type == 3 -> effect02 (black background)
// type == 4 -> text (white background)
enum ParticuleType
{
PARTIEXPLOT = 1, // technology explosion
PARTIEXPLOO = 2, // organic explosion
PARTIMOTOR = 3, // the engine exhaust gas
PARTIGLINT = 4, // reflection
PARTIBLITZ = 5, // lightning recharging battery
PARTICRASH = 6, // dust after fall
PARTIGAS = 7, // gas from the reactor
PARTIFIRE = 9, // fireball shrinks
PARTIFIREZ = 10, // fireball grows
PARTIBLUE = 11, // blue ball
PARTISELY = 12, // yellow selection
PARTISELR = 13, // red selection
PARTIGUN1 = 18, // a bullet (fireball)
PARTIGUN2 = 19, // bullet 2 (ant)
PARTIGUN3 = 20, // bullet 3 (spider)
PARTIGUN4 = 21, // bullet 4 (orgaball)
PARTIFRAG = 22, // triangular fragment
PARTIQUEUE = 23, // inflamed tail
PARTIORGANIC1 = 24, // organic ball mother
PARTIORGANIC2 = 25, // organic ball daughter
PARTISMOKE1 = 26, // black smoke
PARTISMOKE2 = 27, // black smoke
PARTISMOKE3 = 28, // black smoke
PARTISMOKE4 = 29, // black smoke
PARTIBLOOD = 30, // human blood
PARTIBLOODM = 31, // blood laying
PARTIVAPOR = 32, // steam
PARTIVIRUS1 = 33, // virus 1
PARTIVIRUS2 = 34, // virus 2
PARTIVIRUS3 = 35, // virus 3
PARTIVIRUS4 = 36, // virus 4
PARTIVIRUS5 = 37, // virus 5
PARTIVIRUS6 = 38, // virus 6
PARTIVIRUS7 = 39, // virus 7
PARTIVIRUS8 = 40, // virus 8
PARTIVIRUS9 = 41, // virus 9
PARTIVIRUS10 = 42, // virus 10
PARTIRAY1 = 43, // ray 1 (turn)
PARTIRAY2 = 44, // ray 2 (electric arc)
PARTIRAY3 = 45, // ray 3
PARTIRAY4 = 46, // ray 4
PARTIFLAME = 47, // flame
PARTIBUBBLE = 48, // bubble
PARTIFLIC = 49, // circles in the water
PARTIEJECT = 50, // ejection from the reactor
PARTISCRAPS = 51, // waste from the reactor
PARTITOTO = 52, // reactor of tot
PARTIERROR = 53, // toto says no
PARTIWARNING = 54, // foo says blah
PARTIINFO = 54, // toto says yes
PARTIQUARTZ = 55, // reflection crystal
PARTISPHERE0 = 56, // explosion sphere
PARTISPHERE1 = 57, // energy sphere
PARTISPHERE2 = 58, // analysis sphere
PARTISPHERE3 = 59, // shield sphere
PARTISPHERE4 = 60, // information sphere (emit)
PARTISPHERE5 = 61, // botanical sphere (gravity root)
PARTISPHERE6 = 62, // information sphere (receive)
PARTISPHERE7 = 63, // sphere
PARTISPHERE8 = 64, // sphere
PARTISPHERE9 = 65, // sphere
PARTIGUNDEL = 66, // bullet destroyed by shield
PARTIPART = 67, // object part
PARTITRACK1 = 68, // drag 1
PARTITRACK2 = 69, // drag 2
PARTITRACK3 = 70, // drag 3
PARTITRACK4 = 71, // drag 4
PARTITRACK5 = 72, // drag 5
PARTITRACK6 = 73, // drag 6
PARTITRACK7 = 74, // drag 7
PARTITRACK8 = 75, // drag 8
PARTITRACK9 = 76, // drag 9
PARTITRACK10 = 77, // drag 10
PARTITRACK11 = 78, // drag 11
PARTITRACK12 = 79, // drag 12
PARTITRACK13 = 80, // drag 13
PARTITRACK14 = 81, // drag 14
PARTITRACK15 = 82, // drag 15
PARTITRACK16 = 83, // drag 16
PARTITRACK17 = 84, // drag 17
PARTITRACK18 = 85, // drag 18
PARTITRACK19 = 86, // drag 19
PARTITRACK20 = 87, // drag 20
PARTIGLINTb = 88, // blue reflection
PARTIGLINTr = 89, // red reflection
PARTILENS1 = 90, // brilliance 1 (orange)
PARTILENS2 = 91, // brilliance 2 (yellow)
PARTILENS3 = 92, // brilliance 3 (red)
PARTILENS4 = 93, // brilliance 4 (violet)
PARTICONTROL = 94, // reflection on button
PARTISHOW = 95, // shows a place
PARTICHOC = 96, // shock wave
PARTIGFLAT = 97, // shows if the ground is flat
PARTIRECOVER = 98, // blue ball recycler
PARTIROOT = 100, // gravity root smoke
PARTIPLOUF0 = 101, // splash
PARTIPLOUF1 = 102, // splash
PARTIPLOUF2 = 103, // splash
PARTIPLOUF3 = 104, // splash
PARTIPLOUF4 = 105, // splash
PARTIDROP = 106, // drop
PARTIFOG0 = 107, // fog 0
PARTIFOG1 = 108, // fog 1
PARTIFOG2 = 109, // fog 2
PARTIFOG3 = 110, // fog 3
PARTIFOG4 = 111, // fog 4
PARTIFOG5 = 112, // fog 5
PARTIFOG6 = 113, // fog 6
PARTIFOG7 = 114, // fog 7
PARTIFOG8 = 115, // fog 8
PARTIFOG9 = 116, // fog 9
PARTILIMIT1 = 117, // shows the limits 1
PARTILIMIT2 = 118, // shows the limits 2
PARTILIMIT3 = 119, // shows the limits 3
PARTILIMIT4 = 120, // shows the limits 4
PARTIWATER = 121, // drop of water
PARTIEXPLOG1 = 122, // ball explosion 1
PARTIEXPLOG2 = 123, // ball explosion 2
PARTIBASE = 124, // gases of spaceship
PARTITRACE0 = 140, // trace
PARTITRACE1 = 141, // trace
PARTITRACE2 = 142, // trace
PARTITRACE3 = 143, // trace
PARTITRACE4 = 144, // trace
PARTITRACE5 = 145, // trace
PARTITRACE6 = 146, // trace
PARTITRACE7 = 147, // trace
PARTITRACE8 = 148, // trace
PARTITRACE9 = 149, // trace
PARTITRACE10 = 150, // trace
PARTITRACE11 = 151, // trace
PARTITRACE12 = 152, // trace
PARTITRACE13 = 153, // trace
PARTITRACE14 = 154, // trace
PARTITRACE15 = 155, // trace
PARTITRACE16 = 156, // trace
PARTITRACE17 = 157, // trace
PARTITRACE18 = 158, // trace
PARTITRACE19 = 159, // trace
};
enum ParticulePhase
{
PARPHSTART = 0,
PARPHEND = 1,
};
struct Particule
{
char bUsed; // true -> particle used
char bRay; // true -> ray with goal
unsigned short uniqueStamp; // unique mark
short sheet; // sheet (0..n)
ParticuleType type; // type PARTI*
ParticulePhase phase; // phase PARPH*
float mass; // mass of the particle (in rebounding)
float weight; // weight of the particle (for noise)
float duration; // length of life
Math::Vector pos; // absolute position (relative if object links)
Math::Vector goal; // goal position (if bRay)
Math::Vector speed; // speed of displacement
float windSensitivity;
short bounce; // number of rebounds
Math::Point dim; // dimensions of the rectangle
float zoom; // zoom (0..1)
float angle; // angle of rotation
float intensity; // intensity
Math::Point texSup; // coordinated upper texture
Math::Point texInf; // coordinated lower texture
float time; // age of the particle (0..n)
float phaseTime; // age at the beginning of phase
float testTime; // time since last test
CObject* objLink; // father object (for example reactor)
CObject* objFather; // father object (for example reactor)
short objRank; // rank of the object, or -1
short trackRank; // rank of the drag
};
struct Track
{
char bUsed; // true -> drag used
char bDrawParticule;
float step; // duration of not
float last; // increase last not memorized
float intensity; // intensity at starting (0..1)
float width; // tail width
int used; // number of positions in "pos"
int head; // head to write index
Math::Vector pos[MAXTRACKLEN];
float len[MAXTRACKLEN];
};
struct WheelTrace
{
ParticuleType type; // type PARTI*
Math::Vector pos[4]; // rectangle positions
float startTime; // beginning of life
};
class CParticule
{
public:
CParticule(CInstanceManager* iMan, CD3DEngine* engine);
~CParticule();
void SetD3DDevice(LPDIRECT3DDEVICE7 device);
void FlushParticule();
void FlushParticule(int sheet);
int CreateParticule(Math::Vector pos, Math::Vector speed, Math::Point dim, ParticuleType type, float duration=1.0f, float mass=0.0f, float windSensitivity=1.0f, int sheet=0);
int CreateFrag(Math::Vector pos, Math::Vector speed, D3DTriangle *triangle, ParticuleType type, float duration=1.0f, float mass=0.0f, float windSensitivity=1.0f, int sheet=0);
int CreatePart(Math::Vector pos, Math::Vector speed, ParticuleType type, float duration=1.0f, float mass=0.0f, float weight=0.0f, float windSensitivity=1.0f, int sheet=0);
int CreateRay(Math::Vector pos, Math::Vector goal, ParticuleType type, Math::Point dim, float duration=1.0f, int sheet=0);
int CreateTrack(Math::Vector pos, Math::Vector speed, Math::Point dim, ParticuleType type, float duration=1.0f, float mass=0.0f, float length=10.0f, float width=1.0f);
void CreateWheelTrace(const Math::Vector &p1, const Math::Vector &p2, const Math::Vector &p3, const Math::Vector &p4, ParticuleType type);
void DeleteParticule(ParticuleType type);
void DeleteParticule(int channel);
void SetObjectLink(int channel, CObject *object);
void SetObjectFather(int channel, CObject *object);
void SetPosition(int channel, Math::Vector pos);
void SetDimension(int channel, Math::Point dim);
void SetZoom(int channel, float zoom);
void SetAngle(int channel, float angle);
void SetIntensity(int channel, float intensity);
void SetParam(int channel, Math::Vector pos, Math::Point dim, float zoom, float angle, float intensity);
void SetPhase(int channel, ParticulePhase phase, float duration);
bool GetPosition(int channel, Math::Vector &pos);
D3DCOLORVALUE RetFogColor(Math::Vector pos);
void SetFrameUpdate(int sheet, bool bUpdate);
void FrameParticule(float rTime);
void DrawParticule(int sheet);
bool WriteWheelTrace(char *filename, int width, int height, Math::Vector dl, Math::Vector ur);
protected:
void DeleteRank(int rank);
bool CheckChannel(int &channel);
void DrawParticuleTriangle(int i);
void DrawParticuleNorm(int i);
void DrawParticuleFlat(int i);
void DrawParticuleFog(int i);
void DrawParticuleRay(int i);
void DrawParticuleSphere(int i);
void DrawParticuleCylinder(int i);
void DrawParticuleWheel(int i);
CObject* SearchObjectGun(Math::Vector old, Math::Vector pos, ParticuleType type, CObject *father);
CObject* SearchObjectRay(Math::Vector pos, Math::Vector goal, ParticuleType type, CObject *father);
void Play(Sound sound, Math::Vector pos, float amplitude);
bool TrackMove(int i, Math::Vector pos, float progress);
void TrackDraw(int i, ParticuleType type);
protected:
CInstanceManager* m_iMan;
CD3DEngine* m_engine;
LPDIRECT3DDEVICE7 m_pD3DDevice;
CRobotMain* m_main;
CTerrain* m_terrain;
CWater* m_water;
CSound* m_sound;
Particule m_particule[MAXPARTICULE*MAXPARTITYPE];
D3DTriangle m_triangle[MAXPARTICULE]; // triangle if PartiType == 0
Track m_track[MAXTRACK];
int m_wheelTraceTotal;
int m_wheelTraceIndex;
WheelTrace m_wheelTrace[MAXWHEELTRACE];
int m_totalInterface[MAXPARTITYPE][SH_MAX];
bool m_bFrameUpdate[SH_MAX];
int m_fogTotal;
int m_fog[MAXPARTIFOG];
int m_uniqueStamp;
int m_exploGunCounter;
float m_lastTimeGunDel;
float m_absTime;
};

View File

@ -1,10 +0,0 @@
Liste des fichiers pour le patch 1.6
help\cbot.txt (/f)
help\cbot\object.txt
help\cbot\grab.txt
help\cbot\drop.txt
help\cbot\category.txt
help\cbot\extern.txt (/f)
help\object\goal.txt
help\object\atomic.txt

View File

@ -1,247 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// planet.cpp
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
#include "math/const.h"
#include "old/d3dengine.h"
#include "old/d3dmath.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
#include "old/math3d.h"
#include "old/planet.h"
// Constructor of the terrain.
CPlanet::CPlanet(CInstanceManager* iMan, CD3DEngine* engine)
{
m_iMan = iMan;
m_iMan->AddInstance(CLASS_PLANET, this);
m_engine = engine;
Flush();
}
// Destructor of the terrain.
CPlanet::~CPlanet()
{
}
// Removes all the planets.
void CPlanet::Flush()
{
int i, j;
for ( j=0 ; j<2 ; j++ )
{
for ( i=0 ; i<MAXPLANET ; i++ )
{
m_planet[j][i].bUsed = false;
}
}
m_bPlanetExist = false;
m_mode = 0;
m_time = 0.0f;
}
// Management of an event.
bool CPlanet::EventProcess(const Event &event)
{
if ( event.event == EVENT_FRAME )
{
return EventFrame(event);
}
return true;
}
// Makes the planets evolve.
bool CPlanet::EventFrame(const Event &event)
{
float a;
int i;
if ( m_engine->RetPause() ) return true;
m_time += event.rTime;
for ( i=0 ; i<MAXPLANET ; i++ )
{
if ( !m_planet[m_mode][i].bUsed ) continue;
a = m_time*m_planet[m_mode][i].speed;
if ( a < 0.0f )
{
a += Math::PI*1000.0f;
}
m_planet[m_mode][i].angle.x = a+m_planet[m_mode][i].start.x;
m_planet[m_mode][i].angle.y = sinf(a)*sinf(m_planet[m_mode][i].dir)+m_planet[m_mode][i].start.y;
}
return true;
}
// Load all the textures for the planets.
void CPlanet::LoadTexture()
{
int i, j;
for ( j=0 ; j<2 ; j++ )
{
for ( i=0 ; i<MAXPLANET ; i++ )
{
if ( !m_planet[j][i].bUsed ) continue;
m_engine->LoadTexture(m_planet[j][i].name);
}
}
}
// Draws all the planets.
void CPlanet::Draw()
{
LPDIRECT3DDEVICE7 device;
D3DVERTEX2 vertex[4]; // 2 triangles
Math::Vector n;
Math::Point p1, p2;
float eyeDirH, eyeDirV, dp, u1, u2, v1, v2, a;
int i;
device = m_engine->RetD3DDevice();
eyeDirH = m_engine->RetEyeDirH();
eyeDirV = m_engine->RetEyeDirV();
n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
dp = 0.5f/256.0f;
for ( i=0 ; i<MAXPLANET ; i++ )
{
if ( !m_planet[m_mode][i].bUsed ) continue;
m_engine->SetTexture(m_planet[m_mode][i].name);
if ( m_planet[m_mode][i].bTGA )
{
m_engine->SetState(D3DSTATEWRAP|D3DSTATEALPHA);
}
else
{
m_engine->SetState(D3DSTATEWRAP|D3DSTATETTb);
}
a = eyeDirH + m_planet[m_mode][i].angle.x;
p1.x = Math::Mod(a, Math::PI*2.0f)-0.5f;
a = eyeDirV + m_planet[m_mode][i].angle.y;
p1.y = 0.4f+(Math::Mod(a+Math::PI, Math::PI*2.0f)-Math::PI)*(2.0f/Math::PI);
p1.x -= m_planet[m_mode][i].dim/2.0f*0.75f;
p1.y -= m_planet[m_mode][i].dim/2.0f;
p2.x = p1.x+m_planet[m_mode][i].dim*0.75f;
p2.y = p1.y+m_planet[m_mode][i].dim;
u1 = m_planet[m_mode][i].uv1.x + dp;
v1 = m_planet[m_mode][i].uv1.y + dp;
u2 = m_planet[m_mode][i].uv2.x - dp;
v2 = m_planet[m_mode][i].uv2.y - dp;
vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, u1,v2);
vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, u1,v1);
vertex[2] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, u2,v2);
vertex[3] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, u2,v1);
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 4, NULL);
m_engine->AddStatisticTriangle(2);
}
}
// Creates a new planet.
bool CPlanet::Create(int mode, Math::Point start, float dim, float speed,
float dir, char *name, Math::Point uv1, Math::Point uv2)
{
int i;
if ( mode < 0 ) mode = 0;
if ( mode > 1 ) mode = 1;
for ( i=0 ; i<MAXPLANET ; i++ )
{
if ( m_planet[mode][i].bUsed ) continue;
m_planet[mode][i].bUsed = true;
m_planet[mode][i].start = start;
m_planet[mode][i].angle = start;
m_planet[mode][i].dim = dim;
m_planet[mode][i].speed = speed;
m_planet[mode][i].dir = dir;
strcpy(m_planet[mode][i].name, name);
m_planet[mode][i].uv1 = uv1;
m_planet[mode][i].uv2 = uv2;
m_planet[mode][i].bTGA = ( strstr(m_planet[mode][i].name, "planet") != 0 );
m_bPlanetExist = true;
return true;
}
return false;
}
// Indicates if there is at least one planet.
bool CPlanet::PlanetExist()
{
return m_bPlanetExist;
}
// Choice of mode.
void CPlanet::SetMode(int mode)
{
if ( mode < 0 ) mode = 0;
if ( mode > 1 ) mode = 1;
m_mode = mode;
}
int CPlanet::RetMode()
{
return m_mode;
}

View File

@ -1,76 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// planet.h
#pragma once
#include "common/event.h"
#include "math/point.h"
class CInstanceManager;
class CD3DEngine;
const int MAXPLANET = 10;
struct Planet
{
char bUsed; // true -> planet exists
Math::Point start; // initial position in degrees
Math::Point angle; // current position in degrees
float dim; // dimensions (0..1)
float speed; // speed
float dir; // direction in the sky
char name[20]; // name of the texture
Math::Point uv1, uv2; // texture mapping
char bTGA; // texture .TGA
};
class CPlanet
{
public:
CPlanet(CInstanceManager* iMan, CD3DEngine* engine);
~CPlanet();
void Flush();
bool EventProcess(const Event &event);
bool Create(int mode, Math::Point start, float dim, float speed, float dir, char *name, Math::Point uv1, Math::Point uv2);
bool PlanetExist();
void LoadTexture();
void Draw();
void SetMode(int mode);
int RetMode();
protected:
bool EventFrame(const Event &event);
protected:
CInstanceManager* m_iMan;
CD3DEngine* m_engine;
float m_time;
int m_mode;
Planet m_planet[2][MAXPLANET];
bool m_bPlanetExist;
};

File diff suppressed because it is too large Load Diff

View File

@ -1,170 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// pyro.h
#pragma once
#include "old/d3dengine.h"
#include "object/object.h"
#include "common/misc.h"
class CInstanceManager;
class CD3DEngine;
class CTerrain;
class CCamera;
class CParticule;
class CLight;
class CObject;
class CDisplayText;
class CRobotMain;
class CSound;
enum PyroType
{
PT_NULL = 0,
PT_FRAGT = 1, // fragmentation of technical object
PT_FRAGO = 2, // fragmentation of organic object
PT_FRAGW = 4, // fragmentation of object under water
PT_EXPLOT = 5, // explosion of technical object
PT_EXPLOO = 6, // explosion of organic object
PT_EXPLOW = 8, // explosion of object under water
PT_SHOTT = 9, // hit technical object
PT_SHOTH = 10, // hit human
PT_SHOTM = 11, // hit queen
PT_SHOTW = 12, // hit under water
PT_EGG = 13, // break the egg
PT_BURNT = 14, // burning of technical object
PT_BURNO = 15, // burning of organic object
PT_SPIDER = 16, // spider explosion
PT_FALL = 17, // cargo falling
PT_WPCHECK = 18, // indicator reaches
PT_FLCREATE = 19, // flag create
PT_FLDELETE = 20, // flag destroy
PT_RESET = 21, // reset position of the object
PT_WIN = 22, // fireworks
PT_LOST = 23, // black smoke
PT_DEADG = 24, // shooting death
PT_DEADW = 25, // drowning death
PT_FINDING = 26, // object discovered
};
struct PyroBurnPart
{
int part;
Math::Vector initialPos;
Math::Vector finalPos;
Math::Vector initialAngle;
Math::Vector finalAngle;
};
struct PyroLightOper
{
float progress;
float intensity;
D3DCOLORVALUE color;
};
class CPyro
{
public:
CPyro(CInstanceManager* iMan);
~CPyro();
void DeleteObject(bool bAll=false);
bool Create(PyroType type, CObject* pObj, float force=1.0f);
bool EventProcess(const Event &event);
Error IsEnded();
void CutObjectLink(CObject* pObj);
protected:
void DisplayError(PyroType type, CObject* pObj);
bool CreateLight(Math::Vector pos, float height);
void DeleteObject(bool bPrimary, bool bSecondary);
void CreateTriangle(CObject* pObj, ObjectType oType, int part);
void ExploStart();
void ExploTerminate();
void BurnStart();
void BurnAddPart(int part, Math::Vector pos, Math::Vector angle);
void BurnProgress();
bool BurnIsKeepPart(int part);
void BurnTerminate();
void FallStart();
CObject* FallSearchBeeExplo();
void FallProgress(float rTime);
Error FallIsEnded();
void LightOperFlush();
void LightOperAdd(float progress, float intensity, float r, float g, float b);
void LightOperFrame(float rTime);
protected:
CInstanceManager* m_iMan;
CD3DEngine* m_engine;
CTerrain* m_terrain;
CCamera* m_camera;
CParticule* m_particule;
CLight* m_light;
CObject* m_object;
CDisplayText* m_displayText;
CRobotMain* m_main;
CSound* m_sound;
Math::Vector m_pos; // center of the effect
Math::Vector m_posPower; // center of the battery
bool m_bPower; // battery exists?
PyroType m_type;
float m_force;
float m_size;
float m_progress;
float m_speed;
float m_time;
float m_lastParticule;
float m_lastParticuleSmoke;
int m_soundChannel;
int m_lightRank;
int m_lightOperTotal;
PyroLightOper m_lightOper[10];
float m_lightHeight;
ObjectType m_burnType;
int m_burnPartTotal;
PyroBurnPart m_burnPart[10];
int m_burnKeepPart[10];
float m_burnFall;
float m_fallFloor;
float m_fallSpeed;
float m_fallBulletTime;
bool m_bFallEnding;
int m_crashSphereUsed; // number of spheres used
Math::Vector m_crashSpherePos[50];
float m_crashSphereRadius[50];
};

View File

@ -1,872 +0,0 @@
COLOBOT version 1.4 /f
----------------------
COLOBOT est un mélange d'un jeu de stratégie en temps réel et
d'une initiation à la programmation. Le scénario vous place à
la tête d'une expédition spatiale, composée d'un seul humain
(vous) et de quelques robots. Vous devrez explorer et coloniser
différentes planètes, tout en cherchant des matières premières
nécessaires à votre survie.
Petit à petit, vous pourrez construire et programmer de nouveaux
robots, qui vous aideront dans vos tâches. Certaines planètes
sont habitées par des créatures primitives et hostiles qu'il
vous faudra combattre.
Configuration minimale
----------------------
Processeur 300 MHz
64 Mb RAM
Carte graphique 3D avec 16 Mb RAM
100 Mb d'espace libre sur le disque dur
Si ce n'est pas déjà fait, DirectX 8a est installé.
La présence du CD est nécessaire pour jouer.
Missions
--------
Les missions contiennent la partie "aventure" de COLOBOT. Elles
sont au nombre de 36, réparties sur 9 planètes différentes.
Elles doivent être faites dans l'ordre imposé.
Jeu libre
---------
Le mode "jeu libre" vous permet d'agir librement sur une
planète, sans but déterminé. Seuls les planètes déjà visitées et
les recherches effectuées sont disponibles.
Programmation
-------------
Cette partie de COLOBOT permet d'apprendre à programmer, même si
vous n'avez aucune notion dans ce domaine. Différents chapitres
présentent des sujets de plus en plus compliqués. Vous pouvez
effectuer n'importe quel exercice, bien qu'il soit conseillé de
commencer par les plus simples.
Défis
-----
Les défis vous demandent une bonne connaissance de la
programmation. Ils permettent de vérifier si les notions
apprises sous "programmation" sont effectivement comprises.
Autre joueur
------------
Après avoir installé COLOBOT sur un ordinateur, plusieurs
personnes peuvent y jouer. Pour chaque joueur, COLOBOT
enregistre automatiquement la progression dans les missions,
les programmes écrits, etc.
Options
-------
Réglages du jeu, répartis dans 5 pages.
Options - Affichage
-------------------
- Pilotes
Il faut choisir un pilote qui porte la mention HAL (Hardware
Abstraction Layer). Evitez les pilotes ayant la mention
"Emulation" ou "T&L". Il arrive fréquemment que des pilotes
avec des noms différents aient des comportements identiques.
- Résolutions
Les premier et deuxième chiffres indiquent le nombre de pixels
en largeur et en hauteur dans l'écran. Le troisième chiffre
indique le nombre de couleurs affichables (16 pour 65'000
couleurs et 32 pour 4 millions de couleurs).
Plus la résolution est grande et plus le jeu est beau.
Mais il risque de devenir lent. Commencez par mettre
640 x 480 x 16. La plupart des cartes graphiques modernes
supportent 1024 x 768 x 16. A vous d'essayer le meilleur
compromis.
- Plein écran
Normalement, COLOBOT occupe tout l'écran, quelle que soit la
résolution. Si vous enlevez la coche, COLOBOT tournera dans
une fenêtre fixe ayant approximativement 640 x 480 pixels.
- Appliquer les changements
Il faut cliquer ce bouton pour que les changements effectués
dans cette page prennent effet.
Options - Graphique
-------------------
- Ombres
Normalement, tous les objets (robots, bâtiments, titanium,
etc.) projettent une ombre sur le sol. Avec certaines cartes
graphiques anciennes, un carré gris peut apparaître, en plus
de l'ombre. Si cela vous semble inesthétique, supprimez cette
option.
- Marques sur le sol
Les marques accentuent les berges. Elles donnent aussi des
teintes différentes à certains endroits du terrain. Si cette
option est déclenchée, il n'est pas possible de montrer les
zones plates avec le cosmonaute.
- Salissures
Les salissures donnent un effet vieux et sale aux robots et aux
bâtiments.
- Ciel
Avec cette option, le ciel de certaines planètes contient des
nuages poussés par le vent. Sans cela, le ciel est généralement
rempli par un simple dégradé de couleurs.
- Rayons du soleil
Lorsque vous vous tournez en direction du soleil, un reflet
apparaît.
- Planètes et étoiles
Sur certaines planètes, vous voyez dans le ciel des planètes
proches qui bougent lentement.
- Brouillard
Cette option correspond aux nappes de brouillard horizontales
qui sont généralement très proches du sol.
- Lumières dynamiques
Les lumières dynamiques apparaissent lors d'explosions, ou
lorsqu'un robot refait le plein d'énergie.
- Quantité de particules (0% à 200%)
Les particules servent à simuler la poussière, la fumée, les
éclats, les bulles sous l'eau, etc.
- Profondeur de champ (50% à 200%)
La profondeur de champ détermine jusqu'où porte votre regard.
Cette profondeur est de toute façon très différente selon
l'atmosphère de la planète. Une grande valeur (par exemple
200%) permet de voir loin, mais nécessite une bonne carte
graphique 3D.
- Détails des objets (0% à 200%)
Lorsqu'un objet est au loin, il est représenté avec moins de
détails. Une grande valeur éloigne la distance à laquelle le
changement est effectué.
- Nombre d'objets décoratifs (0% à 100%)
Ce nombre détermine la quantité d'objets décoratifs présents,
tels que les plantes, les arbres, les cristaux, etc.
Options - Jeu
-------------
- Séquences cinématiques
Certaines missions commencent ou finissent par un petit film
montrant l'atterrissage ou le décollage du vaisseau. La touche
Esc permet toujours de stopper ces séquences. Si cette option
est supprimée, ces films sont complètement sautés.
- Défilement dans les bords
Lorsque la caméra est derrière le cosmonaute ou derrière un
robot, une rotation est effectuée si la souris s'approche du
bord de l'écran.
- Inversion souris X
Inverse le sens de la rotation lorsque la souris touche le bord
gauche ou le bord droite de l'écran.
- Inversion souris Y
Inverse le sens du mouvement lorsque la souris touche le bord
supérieur ou le bord inférieur de l'écran, dans l'éditeur de
programmes.
- Secousses lors d'explosions
Lors d'une explosion, ou lorsque vous effectuez un atterrissage
brusque, la caméra subit un choc qui se manifeste par une
secousse plus on moins prononcée. Supprimez cette option pour
que la caméra soit toujours parfaitement stable.
- Retour animé
Indique comment la situation est réinitialisée dans les exercices
de programmation et dans les défis.
- Bulles d'aide
Les bulles d'aide vous donnent un petit texte explicatif lorsque
la souris s'arrête sur un bouton ou un objet.
- Reflets sur les boutons
Les reflets sont visibles lorsque la souris survole un bouton.
- Particules dans l'interface
Pluie de particules lorsque la souris bouge dans les écrans
d'interface.
- Souris ombrée
La souris ombrée est gérée par COLOBOT. La souris normale est
dessinée par Windows. Lorsque COLOBOT ne fonctionne pas en mode
"plein écran", la souris est forcément normale.
- Indentation automatique
L'indentation déplace automatiquement le curseur vers la droite
lors de l'édition d'un programme, en fonction des accolades
{ et }.
- Grande indentation
Une grande indentation décale vers la droite d'une distance
égale à 4 espaces. Sinon, le décalage est de 2 espaces.
Options - Commandes
-------------------
- Flèches gauche, droite, haut et bas
Pour faire tourner, avancer ou reculer le cosmonaute ou un
robot. Dans les exercices de programmation, notez que les robots
ne peuvent pas être déplacés ainsi.
- Shirt et Ctrl
Pour faire monter ou descendre le cosmonaute ou un robot volant.
Sur certaines planètes, le vol est impossible.
- Entrée
Cette touche effectue l'action principale du robot sélectionné,
qui correspond au bouton avec un cadre rouge.
- Espace
Change le point de vue de la caméra. Pour la plupart des robots,
la caméra passe alternativement d'une vue arrière à une vue
intérieure.
- . (pavé numérique)
Met le jeu en pause et montre l'endroit correspondant au dernier
message affiché en haut de l'écran. Si plusieurs messages sont
affichés, une nouvelle pression montre le message précédent,
chronologiquement parlant. Esc enlève la pause et le jeu reprend
son cours.
- Tab
Sélectionne l'objet suivant, selon l'ordre des petites icônes
tout en haut de l'écran.
- Home
Sélectionne toujours rapidement le cosmonaute.
- 0 (pavé numérique)
Sélectionne le robot ou le bâtiment qui était sélectionné
précédemment.
- + et - (pavé numérique)
Approche ou éloigne la caméra de l'objet sélectionné.
- F1
Affiche les instructions sur la mission ou l'exercice à l'aide
du SatCom.
- F2
Affiche le glossaire sur la programmation à l'aide du SatCom.
- F3
Pendant l'édition d'un programme, cette touche affiche des
informations complémentaires sur l'instruction en cours de
frappe.
- F4, F5 et F6
Choix de la vitesse du jeu. Le mode normal x1 correspond à la
touche F4. Les modes rapides x1.5 et x2 doivent être utilisés
avec prudence, car les ennemis vont également plus vite !
- Esc
Quitte la mission en cours.
Options - Son
-------------
- Bruitages
Les bruitages sont générés par l'action en cours. Il s'agit de
bruits de moteur, de pas, d'explosions, etc.
- Fond sonore
Le fond sonore dépend de la planète. Il donne une ambiance
générale, indépendamment de l'action en cours. Chaque fond
sonore correspond à une piste audio sur le CD. Dans les
exercices, les défis ainsi que sur la lune, il n'y a pas de
fond sonore.
- Bruitages 3D
Certaines cartes son permettent de localiser un son dans
l'espace à l'aide de 4 haut-parleurs. Le réalisme est alors
superbe. Si votre carte son ne le permet pas, le bouton est
grisé.
Créér des exercices
-------------------
Tous les exercices sont dans le sous-dossier \scene\ :
\scene\trainxyy.txt -> exercices
\scene\defixyy.txt -> défis
\scene\scenexyy.txt -> missions
\scene\freexyy.txt -> jeux libres
Le numéro de 3 chiffres est composé de :
x -> numéro du chapitre (1..9)
yy -> rang dans le chapitre (01..99)
Par exemple, train102.txt est le deuxième exercice du premier
chapitre.
Lorsque le rang dans le chapitre est 00, c'est qu'il s'agit de
la description du chapitre.
Les fichiers doivent avoir des numéros sucessifs. Supposons par
exemple que les fichiers suivants existent :
train600.txt
train601.txt
train602.txt
train605.txt
Le chapitre 6 ne contiendra dans ce cas que 2 exercices, les
numéros 01 et 02. Le numéro 05 n'apparaît pas dans la liste,
car il manque les numéros 03 et 04.
Description
-----------
Un fichier de description d'exercice détermine le relief du
terrain, les textures utilisées, la position initiale des
différents robots, matières premières, plantes, etc.
Couleur
-------
Les couleurs sont spécifiées à l'aide de 4 composantes
rouge/vert/bleu/alpha. Les valeurs sont comprises entre
0 (noir) et 255 (blanc). La composante alpha est généralement
nulle. Par exemple :
color=175;209;215;0 // bleu-sable
Title.E text="Power Cell 1"
Nom court de l'exercice, tel qu'il apparaît dans la liste de
gauche.
Resume.E text="Instruct a bot to change the power cell of a nearby winged shooter."
Résumé de l'exercice, tel qu'il apparaît en dessous des deux
listes.
ScriptName.E text="Spider2"
Nom par défaut donné à un nouveau programme créé.
Instructions name="tcell1.txt"
Nom du fichier qui contient les instructions de l'exercice,
qui seront affichées dans le SatCom.
Le fichier ttit1.txt doit être placé dans le dossier help\.
HelpFile name="cbot.txt"
Non du fichier qui contient les instructions sur la program-
mation, affichées lorsque l'on presse sur F2.
Le fichier cbot.txt doit être placé dans le dossier help\.
Normalement, tous les exercices font référence aux mêmes
instructions générales contenues dans cbot.txt.
EndingFile win=2 lost=0
Scène à utiliser lorsque l'exercice est réussi ou raté.
win=2 signifie qu'il faut utiliser scene\win002.txt.
lost=0 signifie qu'il faut utiliser scene\lost000.txt.
Audio track=0
Numéro de la piste audio du CD à jouer pendant l'exercice.
Normalement, les exercices restent silencieux, en donnant le
numéro de piste 0. Si nécessaire, il est possible de donner
les numéros suivants :
2: Terre
3: Tropica
4: Crystalium
5: Saari
6: Volcano
7: Centaury
8: Orphéon
9: Terranova
AmbiantColor air=102;102;102;102 water=20;20;20;20
Couleur ambiante utilisée lorsqu'on est à l'air libre ou
sous l'eau.
FogColor air=180;222;255;0 water=10;20;100;0
Couleur que prennent les objets lorsqu'ils sont au loin.
VehicleColor color=175;209;215;0
Couleur des robots et des bâtiments.
DeepView air=100.00 water=25.00
Distance en mètres jusqu'où porte la vue. Au delà de cette
distance, plus rien n'est affiché.
FogStart air=0.1 water=0.1
Plus on s'approche de la distance maximale de vue (DeepView)
et plus la couleur des objets fusionne avec la couleur du
brouillard (FogColor), ce qui simule du brouillard. Une valeur
de 0.1 indique un brouillard qui commence proche du point de
vue, donc un brouillard dense. Une valeur de 0.9 indique un
brouillard très peu dense.
Par exemple :
DeepView air=100.00
FogStart air=0.2
Distances à partir de l'observateur :
0 à 20 mètres -> affichage normal
20 à 100 mètres -> affichage de plus en plus brouillardeux
100 mètres et plus -> plus rien n'est affiché
SecondTexture rank=3
Texture utilisée pour salir les robots et les bâtiments. Vous
pouvez utiliser une valeur comprise entre 1 et 8.
Background up=76;105;226;0 down=192;250;255;0
Couleurs du fond d'écran, si aucune texture n'est utilisée.
Un dégradé de couleur passe de "up" tout en haut de l'écran
progressivement jusqu'à "down" en milieu d'écran. La moitié
inférieure de l'écran prend la couleur unie "down". Cette
moitié inférieure n'est en principe jamais visible, puisqu'il
y a toujours une partie de terrain qui la recouvre.
FrontsizeName image="lens5.tga"
Nom de la texture d'avant-plan, qui contient un effet de
"lens flare", plus ou moins visible selon l'orientation.
TerrainRelief image="textures\relief41.bmp" factor=1.0
Le relief du terrain est décrit dans une image BMP à 256
niveaux de gris mesurant exactement 161 x 161 pixels.
La couleur blanche correspond à l'altitude la plus basse.
La couleur noire correspond à l'altitude la plus haute.
Normalement, on utilise "factor=1.0". Dans ce cas, les 256
niveaux permettent de s'élever de 64 mètres. Une différence
d'intensité de gris de 1 correspond donc à une différence
d'altitude de 0.25 mètres.
La coordonnée du pixel central 80;80 de l'image correspond
à la coordonnée 0;0 dans CoLoBoT.
La coordonnée 0;0 du pixel en haut à gauche dans l'image
correspond au point à l'extrème nord-ouest -400;400 dans CoLoBoT.
Un pixel dans l'image correspond à un carré au sol de 5x5
mètres dans CoLoBoT.
Vous pouvez dessiner de nouveaux reliefs avec un logiciel tel
que PaintShop, ou réutiliser les nombreux fichiers reliefxx.bmp
placés dans le dossier textures\.
TerrainResource image="textures\res00.bmp"
Cette image détermine la présence des ressources dans le
sous-sol. Il s'agit d'une image BMP en 256 couleurs de
161 x 161 pixels.
Rouge = 255;0;0 (index=5) -> titanium
Vert = 0;255;0 (index=30) -> énergie
Jaune = 255;255;0 (index=35) -> uranium
Toutes les autres couleurs ou niveaux de gris sont ignorés.
Généralement, un bon truc pour placer les zones de couleur au
bon endroit est de partir de l'image à niveaux de gris du
relief et de la convertir en 256 couleurs.
TerrainWater level=7.5 ...
Cette commande contient plusieurs paramètres, dont seul "level"
nous intéresse ici. "level" indique donc le niveau de l'eau ou
de la lave, par-rapport au niveau zéro qui correspond à la
couleur blanche dans l'image du relief (TerrainResource).
L'altitude des robots est par la suite toujours calculée par-
rapport au niveau de la mer (level). Une altitude négative
indiquera donc que le robot est sous l'eau.
BeginObject
Cette commande doit précéder le premier CreateObject.
CreateObject pos=7;-10 dir=1.5 type=Me
Création d'un objet dans l'exercice. Il peut s'agir d'un robot,
d'un bâtiment, d'une matière première, d'une plante, etc.
Pour déterminer la position d'un objet, un bon moyen consiste
à déplacer le cosmonaute à l'endroit souhaité, puis de taper
les commandes :
Ctrl+Pause showstat Entrée
Ctrl+Pause showpos Entrée
La partie inférieure de l'écran indique alors les coordonnées
de l'objet sélectionné, qu'il n'y a plus qu'à reporter dans le
fichier de description de l'exercice.
La direction est un nombre compris entre 0 et 2.
0.0 -> est
0.5 -> sud
1.0 -> ouest
1.5 -> nord
Le sens de rotation est donc horaire.
Les différents types possibles pour les objets sont :
Base :
type=Me // cosmonaute
type=SpaceShip
Robots :
type=PracticeBot // robot d'entraînement
type=TargetBot // robot cible
type=WheeledGrabber
type=TrackedGrabber
type=WingedGrabber
type=LeggedGrabber
type=WheeledShooter
type=TrackedShooter
type=WingedShooter
type=LeggedShooter
type=WheeledOrgaShooter
type=TrackedOrgaShooter
type=WingedOrgaShooter
type=LeggedOrgaShooter
type=WheeledSniffer
type=TrackedSniffer
type=WingedSniffer
type=LeggedSniffer
type=Thumper
type=PhazerShooter
type=Recycler
type=Shielder
type=Subber
Bâtiments :
type=Derrick
type=BotFactory
type=PowerStation
type=Converter
type=RepairCenter
type=DefenseTower
type=AlienNest
type=ResearchCenter
type=RadarStation
type=ExchangePost
type=PowerPlant
type=AutoLab
type=NuclearPlant
type=PowerCaptor
type=Vault
type=StartArea
type=GoalArea
type=Target1 // pour l'entraînement au vol
type=Target2
type=Houston // centre de contrôle
Objets transportables :
type=TitaniumOre
type=UraniumOre
type=Titanium
type=PowerCell
type=NuclearCell
type=OrgaMatter
type=BlackBox // boîte noire
type=KeyA..D
type=TNT // caisse d'explosif
Plantes et décors :
type=Greenery0..4 // plante standard basse
type=Greenery5..7 // petit trèfle bas
type=Greenery10..14 // plante grasse montante
type=Greenery15..19 // fougère
type=Tree0..3 // arbre haut
type=Mushroom1 // champignon inoffensif
type=Mushroom2 // champignon corrosif
type=MegaStalk0..5 // plante étrange
type=Quartz0..3 // quartz petit..grand
type=Barrier0 // barrière courte
type=Barrier1 // barrière longue
type=ApolloLEM // sur la lune uniquement :
type=ApolloJeep
type=ApolloFlag
type=ApolloModule
type=ApolloAntenna
Epaves de robots recyclables :
type=WreckBotw1..2 // robot à roues
type=WreckBott1..2 // robot à petites chenilles
type=WreckBotr1..2 // robot à grosses chenilles
Bâtiments en ruine :
type=RuinBotFactory
type=RuinDoor // porte de convertisseur
type=RuinSupport // support de radar
type=RuinRadar // socle de radar
type=RuinConvert
type=RuinBaseCamp // socle du vaisseau spatial
type=RuinHeadCamp // coiffe du vaisseau spatial
Ennemis :
type=AlienQueen
type=AlienEgg
type=AlienAnt
type=AlienSpider
type=AlienWasp
type=AlienWorm
Indicateurs :
type=PowerSpot // indique la présence d'énergie en sous-sol
type=TitaniumSpot // indique la présence de titanium en sous-sol
type=UraniumSpot // indique la présence d'uranium en sous-sol
type=KeyA..DSpot // indique la présence de clé en sous-sol
type=WayPoint // croix pour les exercices
type=BlueFlag
type=RedFlag
type=GreenFlag
type=YellowFlag
type=VioletFlag
Divers :
type=Mine // bombe fixe à éviter
type=Portico // portique géant (sur la terre)
type=Bag // sac de survie
type=Home // petite maison sympa (sur terranova)
type=Tech // technicien de Houston
type=Firework // feu d'artifice
La commande CreateObject peut contenir des paramètres
supplémentaires :
CreateObject ... script1="ttit1.txt"
Nom du programme CBOT à charger à la position 1 dans le robot
ou l'insecte. Il est possible de charger jusqu'à 10 programmes
en utilisant les commandes script1 à script10.
Les fichiers .txt des programmes doivent être placés dans le
dossier script\.
CreateObject ... run=1
Numéro du programme à exécuter directement lorsque l'exercice
démarre. Cela peut être utile, par exemple, pour un robot
TargetBot que l'élève devra suivre.
Si plusieurs programmes sont chargés (avec script1, script2,
etc.), un seul pourra être exécuté, bien entendu.
EnableResearch type=WINGER
Liste des recherches déjà effectuées.
DoneResearch type=WINGER
Liste des recherches qu'il est autorisé de faire, en construisant
un centre de recherche (ResearchCenter) ou un laboratoire (AutoLab).
TRACKER Robots Tracked*
WINGER Robots Winged*
THUMPER Robots Thumper
SHOOTER Robots *Shooter
TOWER Bâtiment DefenseTower
PHAZER Robots PhazerShooter
SHIELDER Robots Shielder
ATOMIC Bâtiment NuclearPlant
iPAW Robots Legged*
iGUN Robots *OrgaShooter
RECYCLER Robots recycleurs
SUBBER Robots Subber
SNIFFER Robots *Sniffer
EndMissionTake pos=0.00;0.00 dist=25000.00 type=Me lost=0
EndMissionTake pos=0.00;0.00 dist=25000.00 type=WheeledGrabber lost=0
EndMissionTake pos=0.00;0.00 dist=1000.00 type=Titanium min=1 max=1
Critères pour déterminer à quel moment l'exercice est terminé.
Dossiers et réseau
------------------
Dans une utilisation en réseau, COLOBOT doit être installé
sur chaque machine individuellement. Après cette opération,
les exercices et les missions sont chargés localement,
généralement dans le dossier :
C:\Program Files\Colobot\scene\
Si vous avez créé des exercices spécifiques, il peut être
utile de les charger à partir d'un dossier central commun à
tous les ordinateurs. Pour cela, il faut modifier le fichier
C:\Program Files\Colobot\colobot.ini
sur chaque machine. La section suivante permet de donner le
chemin d'accès :
[Directory]
scene=scene
Ici, il s'agit d'un chemin d'accès relatif. Vous pouvez par
exemple le changer en un chemin absolu sur un serveur :
[Directory]
scene=\\Serveur\c\colobot\scene\
De la même façon, vous pouvez changer le dossier dans lequel
sont placés les programmes lorsque vous utilisez la commande
ouvrir/enregistrer avec le mode "public", dans l'éditeur de
programmes :
[Directory]
public=program
En donnant un chemin d'accès commun à tous les ordinateurs, il
sera possible d'échanger des programmes :
[Directory]
public=\\Serveur\c\colobot\program\
Réglages
--------
Pour afficher le nombre d'images par seconde, il faut appuyer
sur Ctrl+Pause puis taper la commande "showstat" et valider
avec la touche Entrée :
Ctrl+Pause showstat Entrée
La partie supérieure de l'écran affiche alors, par exemple :
32.46 fps T=11558 (640x480x16)
Le premier chiffre correspond au nombre d'images par seconde
(fps = frame per second).
Le deuxième chiffre indique le nombre de triangles affiché dans
la scène.
Les 3 derniers chiffres entre parenthèses sont la résolution
(largeur x hauteur) et le nombre de bits pour les couleurs.
Tous les réglages sont mémorisés dans le fichier colobot.ini,
présent dans le dossier principal où COLOBOT a été installé.
Ce fichier peut être modifié (avec prudence et après en avoir
fait une copie) avec un éditeur de texte, comme par exemple le
bloc-notes de Windows.
Problèmes
---------
Pour résoudre certains problèmes, il est possible de modifier
le fichier colobot.ini avec un éditeur de texte (par exemple
avec le bloc-notes de Windows). N'ajoutez pas de nouvelles
lignes, mais modifiez simplement les valeurs existantes.
Attention à ne pas insérer d'espace. Il faut quitter COLOBOT
avant de modifier le fichier.
Si la végétation s'affiche mal, ou même pas du tout, vous
avez peut-être mis à zéro le nombre d'objets décoratifs dans
les options. Pour remettre 100% :
[Setup]
GadgetQuantity=1.00
Si la végétation ne s'affiche toujours pas, essayez :
[Engine]
AlphaMode=0
ou
[Engine]
AlphaMode=2
Si un carré apparaît autour des ombres, essayez :
[Engine]
WhiteSrcBlend=9
WhiteDestBlend=6
ou
[Engine]
WhiteSrcBlend=6
WhiteDestBlend=3
Si cela ne fonctionne pas, il faut supprimer les ombres :
[Engine]
WhiteSrcBlend=0
WhiteDestBlend=0
[Setup]
GroundShadow=0
Lorsque un objet s'interpose entre l'objet sélectionné et la
caméra, il devient transparent. Si l'objet n'est pas assez
transparent, essayez :
[Engine]
StateColor=0
ou
[Engine]
StateColor=1
Equipe de développement
-----------------------
- Daniel Roux
- Denis Dumoulin
- Otto Kölbl
- Michael Walz
- Didier Gertsch
Beta testeurs
-------------
- Adrien Roux
- Didier Raboud
- Nicolas Beuchat
- Joël Roux
- Michael Jubin
- Daniel Sauthier
- Nicolas Stubi
- Patrick Thévoz
Copyright
---------
La photo de la nébuleuse NGC3603 servant de fond pour la planète
Orphéon a été prise avec le télescope spatial Hubble. Elle est
utilisée avec l'autorisation des auteurs Wolfgang Brandner
(JPL/IPAC), Eva K. Grebel (Université de Washington), You-Hua Chu
(Université d'Illinois Urbana-Champaign) et de la NASA.
Le son de tonnerre de la planète Orphéon est utilisé avec
l'autorisation limitée de CREATIVE moyennant la mention :
Material from products are used by limited permission from CREATIVE.
Développeur
-----------
EPSITEC SA
Mouette 5
CH-1092 Belmont
colobot@epsitec.ch
www.colobot.com
Editeur de la version française
-------------------------------
ALSYD
43, Ch. du vieux Chêne
F-38240 Meylan
www.alsyd.com

View File

@ -1,55 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by winmain.rc
//
#define IDI_MAIN_ICON 101
#define IDR_MAIN_ACCEL 113
#define IDR_MENU 141
#define IDR_POPUP 142
#define IDD_ABOUT 143
#define IDD_CHANGEDEVICE 144
#define IDC_CURSORHAND 149
#define IDC_CURSORSCROLLL 150
#define IDC_CURSORSCROLLR 151
#define IDC_CURSORSCROLLU 152
#define IDC_CURSORSCROLLD 153
#define IDC_CURSORTARGET 154
#define IDC_DEVICE_COMBO 1000
#define IDC_MODE_COMBO 1001
#define IDC_WINDOWED_CHECKBOX 1012
#define IDC_STEREO_CHECKBOX 1013
#define IDC_FULLSCREEN_TEXT 1014
#define IDM_ABOUT 40001
#define IDM_CHANGEDEVICE 40002
#define IDM_TOGGLEFULLSCREEN 40003
#define IDM_TOGGLESTART 40004
#define IDM_SINGLESTEP 40005
#define IDM_EXIT 40006
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 159
#define _APS_NEXT_COMMAND_VALUE 40011
#define _APS_NEXT_CONTROL_VALUE 1015
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,242 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// sound.h
#pragma once
#include <dsound.h>
const int MAXFILES = 200;
const int MAXSOUND = 32;
const int MAXVOLUME = 20;
const int MAXOPER = 4;
class CInstanceManager;
enum Sound
{
SOUND_CLICK = 0,
SOUND_BOUM = 1,
SOUND_EXPLO = 2,
SOUND_FLYh = 3, // human
SOUND_FLY = 4,
SOUND_STEPs = 5, // smooth
SOUND_MOTORw = 6, // wheel
SOUND_MOTORt = 7, // tank
SOUND_MOTORr = 8, // roller
SOUND_ERROR = 9,
SOUND_CONVERT = 10,
SOUND_ENERGY = 11,
SOUND_PLOUF = 12,
SOUND_BLUP = 13,
SOUND_WARNING = 14,
SOUND_DERRICK = 15,
SOUND_LABO = 16,
SOUND_STATION = 17,
SOUND_REPAIR = 18,
SOUND_RESEARCH = 19,
SOUND_INSECTs = 20, // spider
SOUND_BURN = 21,
SOUND_TZOING = 22,
SOUND_GGG = 23,
SOUND_MANIP = 24,
SOUND_FIRE = 25, // shooting with fireball
SOUND_HUMAN1 = 26, // breathing
SOUND_STEPw = 27, // water
SOUND_SWIM = 28,
SOUND_RADAR = 29,
SOUND_BUILD = 30,
SOUND_ALARM = 31, // energy alarm
SOUND_SLIDE = 32,
SOUND_EXPLOi = 33, // insect
SOUND_INSECTa = 34, // ant
SOUND_INSECTb = 35, // bee
SOUND_INSECTw = 36, // worm
SOUND_INSECTm = 37, // mother
SOUND_TREMBLE = 38,
SOUND_PSHHH = 39,
SOUND_NUCLEAR = 40,
SOUND_INFO = 41,
SOUND_OPEN = 42,
SOUND_CLOSE = 43,
SOUND_FACTORY = 44,
SOUND_EGG = 45,
SOUND_MOTORs = 46, // submarine
SOUND_MOTORi = 47, // insect (legs)
SOUND_SHIELD = 48,
SOUND_FIREi = 49, // shooting with orgaball (insect)
SOUND_GUNDEL = 50,
SOUND_PSHHH2 = 51, // shield
SOUND_MESSAGE = 52,
SOUND_BOUMm = 53, // metal
SOUND_BOUMv = 54, // plant
SOUND_BOUMs = 55, // smooth
SOUND_EXPLOl = 56, // little
SOUND_EXPLOlp = 57, // little power
SOUND_EXPLOp = 58, // power
SOUND_STEPh = 59, // hard
SOUND_STEPm = 60, // metal
SOUND_POWERON = 61,
SOUND_POWEROFF = 62,
SOUND_AIE = 63,
SOUND_WAYPOINT = 64,
SOUND_RECOVER = 65,
SOUND_DEADi = 66,
SOUND_JOSTLE = 67,
SOUND_GFLAT = 68,
SOUND_DEADg = 69, // shooting death
SOUND_DEADw = 70, // drowning
SOUND_FLYf = 71, // reactor fail
SOUND_ALARMt = 72, // temperature alarm
SOUND_FINDING = 73, // finds a cache object
SOUND_THUMP = 74,
SOUND_TOUCH = 75,
SOUND_BLITZ = 76,
SOUND_MUSHROOM = 77,
SOUND_FIREp = 78, // shooting with phazer
SOUND_EXPLOg1 = 79, // impact gun 1
SOUND_EXPLOg2 = 80, // impact gun 2
SOUND_MOTORd = 81, // engine friction
};
enum SoundNext
{
SOPER_CONTINUE = 1,
SOPER_STOP = 2,
SOPER_LOOP = 3,
};
struct SoundOper
{
char bUsed;
float finalAmplitude;
float finalFrequency;
float totalTime;
float currentTime;
SoundNext nextOper;
};
struct SoundChannel
{
char bUsed; // buffer used?
char bMute; // silence?
Sound type; // SOUND_*
int priority; // so great -> important
Math::Vector pos; // position in space
unsigned short uniqueStamp; // unique marker
LPDIRECTSOUNDBUFFER soundBuffer;
LPDIRECTSOUND3DBUFFER soundBuffer3D;
float startAmplitude;
float startFrequency;
float changeFrequency;
int initFrequency;
float volume; // 2D: volume 1..0 depending on position
float pan; // 2D: pan -1..+1 depending on position
SoundOper oper[MAXOPER];
};
class CSound
{
public:
CSound(CInstanceManager* iMan);
~CSound();
void SetDebugMode(bool bMode);
bool Create(HWND hWnd, bool b3D);
void CacheAll();
void SetState(bool bState);
bool RetEnable();
void SetCDpath(char *path);
void SetAudioTrack(bool bAudio);
void SetSound3D(bool bMode);
bool RetSound3D();
bool RetSound3DCap();
void SetAudioVolume(int volume);
int RetAudioVolume();
void SetMidiVolume(int volume);
int RetMidiVolume();
void SetListener(Math::Vector eye, Math::Vector lookat);
void FrameMove(float rTime);
int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop=false);
int Play(Sound sound, Math::Vector pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop=false);
bool FlushEnvelope(int channel);
bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper);
bool Position(int channel, Math::Vector pos);
bool Frequency(int channel, float frequency);
bool Stop(int channel);
bool StopAll();
bool MuteAll(bool bMute);
bool PlayMusic(int rank, bool bRepeat);
bool RestartMusic();
void SuspendMusic();
void StopMusic();
bool IsPlayingMusic();
void AdaptVolumeMusic();
protected:
bool CheckChannel(int &channel);
bool CreateSoundBuffer(int channel, DWORD size, DWORD freq, DWORD bitsPerSample, DWORD blkAlign, bool bStereo);
bool ReadData(LPDIRECTSOUNDBUFFER lpDSB, Sound sound, DWORD size);
bool CreateBuffer(int channel, Sound sound);
void ComputeVolumePan2D(int channel, const Math::Vector &pos);
bool ReadFile(Sound sound, char *metaname, char *filename);
int RetPriority(Sound sound);
bool SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded);
void OperNext(int channel);
bool PlayAudioTrack(int rank);
protected:
CInstanceManager* m_iMan;
HWND m_hWnd;
bool m_bEnable;
bool m_bState;
bool m_bAudioTrack;
bool m_ctrl3D;
bool m_bDebugMode;
LPDIRECTSOUND m_lpDS;
LPDIRECTSOUND3DLISTENER m_listener;
SoundChannel m_channel[MAXSOUND];
char* m_files[MAXFILES];
UINT m_MidiDeviceID;
int m_MIDIMusic;
bool m_bRepeatMusic;
int m_audioVolume;
int m_midiVolume;
int m_lastMidiVolume;
Math::Vector m_eye;
Math::Vector m_lookat;
float m_lastTime;
float m_playTime;
int m_uniqueStamp;
int m_maxSound;
char m_CDpath[100];
};

View File

@ -1,11 +0,0 @@
extern void object::Go()
{
//float a = energyLevel;
//message(a);
//object item=energyCell;
//float i = item.energyLevel;
//message(i);
float i = energyCell.energyLevel;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,209 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// terrain.h
#pragma once
#include "common/struct.h"
#include "math/point.h"
#include "old/d3dengine.h"
class CInstanceManager;
class CD3DEngine;
class CWater;
const float FLATLIMIT = (5.0f*Math::PI/180.0f);
enum TerrainRes
{
TR_NULL = 0,
TR_STONE = 1,
TR_URANIUM = 2,
TR_POWER = 3,
TR_KEYa = 4,
TR_KEYb = 5,
TR_KEYc = 6,
TR_KEYd = 7,
};
const int MAXBUILDINGLEVEL = 100;
struct BuildingLevel
{
Math::Vector center;
float factor;
float min;
float max;
float level;
float height;
float bboxMinX;
float bboxMaxX;
float bboxMinZ;
float bboxMaxZ;
};
const int MAXMATTERRAIN = 100;
struct TerrainMaterial
{
short id;
char texName[20];
float u,v;
float hardness;
char mat[4]; // up, right, down, left
};
struct DotLevel
{
short id;
char mat[4]; // up, right, down, left
};
const int MAXFLYINGLIMIT = 10;
struct FlyingLimit
{
Math::Vector center;
float extRadius;
float intRadius;
float maxHeight;
};
class CTerrain
{
public:
CTerrain(CInstanceManager* iMan);
~CTerrain();
bool Generate(int mosaic, int brickP2, float size, float vision, int depth, float hardness);
bool InitTextures(char* baseName, int* table, int dx, int dy);
void LevelFlush();
bool LevelMaterial(int id, char* baseName, float u, float v, int up, int right, int down, int left, float hardness);
bool LevelInit(int id);
bool LevelGenerate(int *id, float min, float max, float slope, float freq, Math::Vector center, float radius);
void FlushRelief();
bool ReliefFromBMP(const char* filename, float scaleRelief, bool adjustBorder);
bool ReliefFromDXF(const char* filename, float scaleRelief);
bool ResFromBMP(const char* filename);
bool CreateObjects(bool bMultiRes);
bool Terraform(const Math::Vector &p1, const Math::Vector &p2, float height);
void SetWind(Math::Vector speed);
Math::Vector RetWind();
float RetFineSlope(const Math::Vector &pos);
float RetCoarseSlope(const Math::Vector &pos);
bool GetNormal(Math::Vector &n, const Math::Vector &p);
float RetFloorLevel(const Math::Vector &p, bool bBrut=false, bool bWater=false);
float RetFloorHeight(const Math::Vector &p, bool bBrut=false, bool bWater=false);
bool MoveOnFloor(Math::Vector &p, bool bBrut=false, bool bWater=false);
bool ValidPosition(Math::Vector &p, float marging);
TerrainRes RetResource(const Math::Vector &p);
void LimitPos(Math::Vector &pos);
void FlushBuildingLevel();
bool AddBuildingLevel(Math::Vector center, float min, float max, float height, float factor);
bool UpdateBuildingLevel(Math::Vector center);
bool DeleteBuildingLevel(Math::Vector center);
float RetBuildingFactor(const Math::Vector &p);
float RetHardness(const Math::Vector &p);
int RetMosaic();
int RetBrick();
float RetSize();
float RetScaleRelief();
void GroundFlat(Math::Vector pos);
float RetFlatZoneRadius(Math::Vector center, float max);
void SetFlyingMaxHeight(float height);
float RetFlyingMaxHeight();
void FlushFlyingLimit();
bool AddFlyingLimit(Math::Vector center, float extRadius, float intRadius, float maxHeight);
float RetFlyingLimit(Math::Vector pos, bool bNoLimit);
protected:
bool ReliefAddDot(Math::Vector pos, float scaleRelief);
void AdjustRelief();
Math::Vector RetVector(int x, int y);
D3DVERTEX2 RetVertex(int x, int y, int step);
bool CreateMosaic(int ox, int oy, int step, int objRank, const D3DMATERIAL7 &mat, float min, float max);
bool CreateSquare(bool bMultiRes, int x, int y);
TerrainMaterial* LevelSearchMat(int id);
void LevelTextureName(int x, int y, char *name, Math::Point &uv);
float LevelRetHeight(int x, int y);
bool LevelGetDot(int x, int y, float min, float max, float slope);
int LevelTestMat(char *mat);
void LevelSetDot(int x, int y, int id, char *mat);
bool LevelIfDot(int x, int y, int id, char *mat);
bool LevelPutDot(int x, int y, int id);
void LevelOpenTable();
void LevelCloseTable();
void AdjustBuildingLevel(Math::Vector &p);
protected:
CInstanceManager* m_iMan;
CD3DEngine* m_engine;
CWater* m_water;
int m_mosaic; // number of mosaics
int m_brick; // number of bricks per mosaics
float m_size; // size of an item in an brick
float m_vision; // vision before a change of resolution
float* m_relief; // table of the relief
int* m_texture; // table of textures
int* m_objRank; // table of rows of objects
bool m_bMultiText;
bool m_bLevelText;
float m_scaleMapping; // scale of the mapping
float m_scaleRelief;
int m_subdivMapping;
int m_depth; // number of different resolutions (1,2,3,4)
char m_texBaseName[20];
char m_texBaseExt[10];
float m_defHardness;
TerrainMaterial m_levelMat[MAXMATTERRAIN+1];
int m_levelMatTotal;
int m_levelMatMax;
int m_levelDotSize;
DotLevel* m_levelDot;
int m_levelID;
int m_buildingUsed;
BuildingLevel m_buildingTable[MAXBUILDINGLEVEL];
unsigned char* m_resources;
Math::Vector m_wind; // wind speed
float m_flyingMaxHeight;
int m_flyingLimitTotal;
FlyingLimit m_flyingLimit[MAXFLYINGLIMIT];
};

File diff suppressed because it is too large Load Diff

View File

@ -1,111 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// text.h
#pragma once
#include "math/point.h"
#include "old/d3dengine.h"
class CInstanceManager;
const float SMALLFONT = 10.0f;
const float BIGFONT = 15.0f;
const float NORMSTRETCH = 0.8f;
enum FontType
{
FONT_COLOBOT = 0,
FONT_COURIER = 1,
FONT_BUTTON = 2,
};
enum FontTitle
{
TITLE_BIG = 0x04,
TITLE_NORM = 0x08,
TITLE_LITTLE = 0x0c,
};
enum FontColor
{
COLOR_LINK = 0x10,
COLOR_TOKEN = 0x20,
COLOR_TYPE = 0x30,
COLOR_CONST = 0x40,
COLOR_REM = 0x50,
COLOR_KEY = 0x60,
COLOR_TABLE = 0x70,
};
const int FONT_MASK = 0x03;
const int TITLE_MASK = 0x0c;
const int COLOR_MASK = 0x70;
const int IMAGE_MASK = 0x80;
class CText
{
public:
CText(CInstanceManager *iMan, CD3DEngine* engine);
~CText();
void SetD3DDevice(LPDIRECT3DDEVICE7 device);
void DrawText(char *string, char *format, int len, Math::Point pos, float width, int justif, float size, float stretch, int eol);
void DrawText(char *string, char *format, Math::Point pos, float width, int justif, float size, float stretch, int eol);
void DrawText(char *string, int len, Math::Point pos, float width, int justif, float size, float stretch, FontType font, int eol);
void DrawText(char *string, Math::Point pos, float width, int justif, float size, float stretch, FontType font, int eol);
void DimText(char *string, char *format, int len, Math::Point pos, int justif, float size, float stretch, Math::Point &start, Math::Point &end);
void DimText(char *string, char *format, Math::Point pos, int justif, float size, float stretch, Math::Point &start, Math::Point &end);
void DimText(char *string, int len, Math::Point pos, int justif, float size, float stretch, FontType font, Math::Point &start, Math::Point &end);
void DimText(char *string, Math::Point pos, int justif, float size, float stretch, FontType font, Math::Point &start, Math::Point &end);
float RetAscent(float size, FontType font);
float RetDescent(float size, FontType font);
float RetHeight(float size, FontType font);
float RetStringWidth(char *string, char *format, int len, float size, float stretch);
float RetStringWidth(char *string, int len, float size, float stretch, FontType font);
float RetCharWidth(int character, float offset, float size, float stretch, FontType font);
int Justif(char *string, char *format, int len, float width, float size, float stretch);
int Justif(char *string, int len, float width, float size, float stretch, FontType font);
int Detect(char *string, char *format, int len, float offset, float size, float stretch);
int Detect(char *string, int len, float offset, float size, float stretch, FontType font);
protected:
void DrawString(char *string, char *format, int len, Math::Point pos, float width, float size, float stretch, int eol);
void DrawString(char *string, int len, Math::Point pos, float width, float size, float stretch, FontType font, int eol);
void DrawColor(Math::Point pos, float size, float width, int color);
void DrawChar(int character, Math::Point pos, float size, float stretch, FontType font);
protected:
CInstanceManager* m_iMan;
CD3DEngine* m_engine;
LPDIRECT3DDEVICE7 m_pD3DDevice;
};

View File

@ -1,17 +0,0 @@
Utilisation des tracks
1: data
2: terre Terre
3: tropica Tropica
4: crystalium Crystalium
5: saari Saari
6: volcano Volcano
7: centaury Centaury
8: orpheon Orphéon
9: terranova Terranova
10: lost perdu
11: win gagné
12: fox fin du jeu
13: shuffle -
DR 12.06.01

View File

@ -1,151 +0,0 @@
Types des objets COLOBOT
------------------------
... // sac de survie
BaseCamp // fusée principale
Derrick // derrick
BotFactory // fabrique de véhicules
PowerStation // station de recharge
Converter // conversion minerai en titanium
RepairCenter // centre de réparation
DefenceTower // tour de défense
AlienNest // nid
ResearchCenter // centre de recherches
RadarStation // radar
PowerPlant // fabrique de piles
AutoLab // analyseur de matières organiques
NuclearPlant // centrale nucléaire
StartArea // départ
GoalArea // arrivée
ExchangePost // borne d'information
TitaniumOre // minerai de titanium
UraniumOre // minerai d'uranium
Titanium // titanium
PowerPack // pile normale
NuclearPack // pile nucléaire
OrgaStuff // matière organique
BlackBox // boîte noire
TNT // explosif
PowerSpot // énergie en sous-sol
TitaniumSpot // titanium en sous-sol
UraniumSpot // uranium en sous-sol
PathSpot // chemin
TrainingRollerBot // véhicule d'entraînement :
TrainingCrawlerBot
TrainingJetBot
TrainingSpiderBot
GrabberRollerBot // véhicule manipulateur :
GrabberCrawlerBot
GrabberJetBot
GrabberSpiderBot
FireballRollerBot // véhicule de défense :
FireballCrawlerBot
FireballJetBot
FireballSpiderBot
OrgaballRollerBot // véhicule de défense :
OrgaballCrawlerBot
OrgaballJetBot
OrgaballSpiderBot
SnifferRollerBot // véhicule sondeur :
SnifferCrawlerBot
SnifferJetBot
SnifferSpiderBot
ThumperBot // véhicule de terrassement
FazerBot // véhicule de défense
RecyclerBot // véhicule de récupération
ShieldBot // véhicule de protection
SubBot // sous-marin
TargetBot // cible d'entraînement
Me // homme
Wiz // toto
AlienBigLady // mère pondeuse
AlienEgg // oeuf
AlienAnt // fourmi
AlienSpider // araignée
AlienWasp // guèpe
AlienWorm // ver
Wreck // épave de véhicule
Ruin // bâtiment en ruine
Firework // feu d'artifice
Mine // mine
Barrier // barrière
Greenery // plante
Tree // arbre
Quartz // quartz
MegaStalk // racine
... // gravi-plante
Fonction du langage CBOT :
Move // avance d'une certaine distance
Turn // tourne d'un certain angle
Goto // va à une coordonnée donnée
Motor // commande directe des moteurs gauche & droite
Jet // commande directe du réacteur
Radar // détecte un objet
Direction // calcule une direction
Distance // calcule la distance entre deux points
Wait // attend
Produce // crée un objet
Message // affiche un message
Grab // prend un objet avec le bras manipulateur
Drop // dépose un objet avec le bras manipulateur
Sniff // sonde le sous-sol
Receive // reçoit une information
Send // envoie une information
Thump // terraforme le terrain
Recycle // récupère une épave
Shield // actionne le bouclier de protection
Fire // tir avec un canon
Aim // hausse du canon
Classes :
point // point avec coordonnées x,y,z
object // descriptif d'un objet
Descripteur d'un objet :
category // catégorie de l'objet
energyPack // object pile
load // objet transporté
position // position x,y,z
direction // orientation
energyLevel // niveau d'énergie
shieldLevel // niveau du bouclier
altitude // hauteur par rapport au sol
Argument de la commande Manip( ) :
InFront // prend ou dépose devant
Behind // prend ou dépose derrière
EnergyPack // prend ou dépose sa propre pile
Filtre pour la commande Radar( ) ;
FilterNone // pas de filtre
FilterOnlyLanding // seulement les robots qui roulent
FilterOnlyFliying // seulement les robots qui volent
DR 14.03.01

View File

@ -1,108 +0,0 @@
1.18 (24.01.08)
- Ne vérifie plus la présence des pistes audio.
1.17 (08.01.08)
- Sound.cpp:InitAudioTrackVolume:mixerGetLineControls ne devrait plus planter
sous Vista, grace à l'abandon de MIXER_GETLINECONTROLSF_ALL.
- CoLoBoT ne joue plus les pistes audio, et le réglage du volume a disparu
- CoLoBoT n'affiche plus Alsyd
- Texte "www.colobot.com" remplacé par "www.ceebot.com"
1.16 (10.11.03)
- Options: si "accès aux solutions" décoché -> Lancer défi,
éditer programme, Esc, Abandonner: plus de bouton "accès à la solution"
1.15 (02.09.03)
- EVENT_INTERFACE_KGUP: plus si CeeBot-Teen !
- EVENT_INTERFACE_KGDOWN: plus si CeeBot-Teen !
- EVENT_INTERFACE_KACTION: plus si CeeBot-Teen !
- EVENT_INTERFACE_KVISIT: plus si CeeBot-Teen !
- EVENT_INTERFACE_KNEXT: plus si CeeBot-Teen !
- EVENT_INTERFACE_KHUMAN: plus si CeeBot-Teen !
- EVENT_INTERFACE_KDESEL: plus si CeeBot-Teen !
- EVENT_INTERFACE_KCBOT: plus si CeeBot-Teen !
1.14 (28.07.03)
- Switch -nosetup -> plus de bouton "Options" pendant jeu
1.8 ()
- instruction shield(1, radius) ok avec radius 10..25
- instruction shield(1, radius) possible si bouclier déjà déployé
1.8 BETA (05.10.01)
- CBOT: public, static, synchronized, private, protected
- CBOT: strlen, strleft, strright, strmid, strval, strfind, strupper, strlower
- CBOT: file, open, close, writeln, readln, eof, deletefile
- extern/public: aide en cliquant dans la ligne d'info de l'éditeur
- ExchangePost: UpdateList si infos reçues
- ok si lien d'un seul caractère: \l;x\u file;
- colobot.ini: [Setup] DeleteGamer=1
- colobot.ini: [Directory] files=files
- studio: nb max de caractères: 10000 -> 20000
- script antt41 (scene904): AlienMother -> AlienQueen
- load: recompilation ok si procédures "public" dans d'autres robots
- si le volume CD est nul, la piste n'est pas du tout jouée
- goto ResearchCenter toujours possible
- meilleure gestion des touches Ctrl et Shift dans l'éditeur
- object.temperature=12 impossible (PR_READ)
- studio: ne plante plus si on tape plus de 100 car. sans espace
- studio: "enregistrer" se rappelle du nom de fichier dans la mission
- studio: Ctrl+A sélectionne tout
- studio: run: si liste < 5 variables -> fond gris
1.7 (13.09.01)
- object.lifeTime
- object.range Winged* idem si camera OnBoard/Back
- float flatground(center, rmax);
- float abstime();
- float receive(name, power);
- void send(name, value, power);
- void deleteinfo(name, power);
- bool testinfo(name, power);
- Le cosmonaute peut construire une borne d'information
1.6 (06.09.01)
- niveaux supplémentaires avec %user%
- fonction "send" plus coloriée
- english help: EnergyPack -> EnergyCell
- english help: energyPack -> energyCell
- english help: FinishArea -> GoalArea
1.5 (24.08.01)
- first execute: prefered first non-T&L, second T&L
- fondus welcome: D3DSTATETTb/w -> D3DSTATETCb/w
1.4 (02.08.01)
- n'importe quelle touche/clic passe les écrans welcome1, 2 et 3
- icône associée au CD dans autorun.inf
- SatCom: icône "Aide à la programmation" présente dans exercices
- welcome: phase "Alsyd" plus longue (8s)
- SaveOneScript quand on quitte le studio par ok, cancel ou run
1.3 (27.07.01)
- goto BotFactory toujours possible
- documentation errmode(0)
- petites corrections anglaises par MW
- enlever pile pendant recherche ne bloque plus
- si human porte qq chose et vaisseau décole -> ne reste plus sur place
- robot sur vaisseau puis sauvegarder-reprendre -> impossible gravir pentes
GoldMaster 1.3 /e envoyé à CD PRESS pour 1000x
1.2
- bouton de fermeture (en haut à droite) supprimé en mode fenêtré
- suppression du réglage "nice reset"
1.1 (20.07.01)
- volume du son non nul après installation
- images logo au démarrage du jeu
- image generic != si français ou anglais
- install: nouvelle clé pour uninstall depuis autorun
GoldMaster 1.1 /f envoyé à Alsyd
1.0
- commande "reset" (exercices) tjrs ok (fichier rechargé)
- nom sauvegarde avec date/heure au format anglais
- ScriptName.F et .E

View File

@ -1,844 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// water.cpp
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
#include "math/geometry.h"
#include "math/conv.h"
#include "old/d3dengine.h"
#include "old/d3dmath.h"
#include "old/d3dutil.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
#include "old/math3d.h"
#include "old/particule.h"
#include "old/terrain.h"
#include "object/object.h"
#include "old/sound.h"
#include "old/water.h"
// Constructor of the terrain.
CWater::CWater(CInstanceManager* iMan, CD3DEngine* engine)
{
m_iMan = iMan;
m_iMan->AddInstance(CLASS_WATER, this);
m_engine = engine;
m_terrain = 0;
m_particule = 0;
m_sound = 0;
m_type[0] = WATER_NULL;
m_type[1] = WATER_NULL;
m_level = 0.0f;
m_bDraw = true;
m_bLava = false;
m_color = 0xffffffff;
m_subdiv = 4;
m_filename[0] = 0;
}
// Destructor of the terrain.
CWater::~CWater()
{
}
bool CWater::EventProcess(const Event &event)
{
if ( event.event == EVENT_FRAME )
{
return EventFrame(event);
}
if ( event.event == EVENT_KEYDOWN )
{
#if 0
if ( event.param == 'S' )
{
if ( m_subdiv == 1 ) m_subdiv = 2;
else if ( m_subdiv == 2 ) m_subdiv = 4;
else if ( m_subdiv == 4 ) m_subdiv = 8;
else if ( m_subdiv == 8 ) m_subdiv = 1;
SetLevel(m_level);
}
if ( event.param == 'M' )
{
SetLevel(m_level+1.0f);
}
if ( event.param == 'D' )
{
SetLevel(m_level-1.0f);
}
if ( event.param == 'H' )
{
m_bDraw = !m_bDraw;
}
if ( event.param == 'C' )
{
if ( m_color == 0xffffffff ) m_color = 0xcccccccc;
else if ( m_color == 0xcccccccc ) m_color = 0x88888888;
else if ( m_color == 0x88888888 ) m_color = 0x44444444;
else if ( m_color == 0x44444444 ) m_color = 0x00000000;
else if ( m_color == 0x00000000 ) m_color = 0xffffffff;
}
if ( event.param == 'Q' )
{
int i;
i = (m_color>>24);
i += 0x44;
i &= 0xff;
i = (i<<24);
m_color &= 0x00ffffff;
m_color |= i;
}
if ( event.param == 'W' )
{
int i;
i = (m_color>>16);
i += 0x44;
i &= 0xff;
i = (i<<16);
m_color &= 0xff00ffff;
m_color |= i;
}
if ( event.param == 'E' )
{
int i;
i = (m_color>>8);
i += 0x44;
i &= 0xff;
i = (i<<8);
m_color &= 0xffff00ff;
m_color |= i;
}
if ( event.param == 'R' )
{
int i;
i = m_color;
i += 0x44;
i &= 0xff;
m_color &= 0xffffff00;
m_color |= i;
}
#endif
}
return true;
}
// Makes water evolve.
bool CWater::EventFrame(const Event &event)
{
if ( m_engine->RetPause() ) return true;
m_time += event.rTime;
if ( m_type[0] == WATER_NULL ) return true;
if ( m_bLava )
{
LavaFrame(event.rTime);
}
return true;
}
// Makes evolve the steam jets on the lava.
void CWater::LavaFrame(float rTime)
{
Math::Vector eye, lookat, dir, perp, pos;
float distance, shift, level;
int i;
if ( m_particule == 0 )
{
m_particule = (CParticule*)m_iMan->SearchInstance(CLASS_PARTICULE);
}
for ( i=0 ; i<MAXWATVAPOR ; i++ )
{
VaporFrame(i, rTime);
}
if ( m_time-m_lastLava >= 0.1f )
{
eye = m_engine->RetEyePt();
lookat = m_engine->RetLookatPt();
distance = Math::Rand()*200.0f;
shift = (Math::Rand()-0.5f)*200.0f;
dir = Normalize(lookat-eye);
pos = eye + dir*distance;
perp.x = -dir.z;
perp.y = dir.y;
perp.z = dir.x;
pos = pos + perp*shift;
level = m_terrain->RetFloorLevel(pos, true);
if ( level < m_level )
{
pos.y = m_level;
level = Math::Rand();
if ( level < 0.8f )
{
if ( VaporCreate(PARTIFIRE, pos, 0.02f+Math::Rand()*0.06f) )
{
m_lastLava = m_time;
}
}
else if ( level < 0.9f )
{
if ( VaporCreate(PARTIFLAME, pos, 0.5f+Math::Rand()*3.0f) )
{
m_lastLava = m_time;
}
}
else
{
if ( VaporCreate(PARTIVAPOR, pos, 0.2f+Math::Rand()*2.0f) )
{
m_lastLava = m_time;
}
}
}
}
}
// Removes all the steam jets.
void CWater::VaporFlush()
{
int i;
for ( i=0 ; i<MAXWATVAPOR ; i++ )
{
m_vapor[i].bUsed = false;
}
}
// Creates a new steam.
bool CWater::VaporCreate(ParticuleType type, Math::Vector pos, float delay)
{
int i;
for ( i=0 ; i<MAXWATVAPOR ; i++ )
{
if ( !m_vapor[i].bUsed )
{
m_vapor[i].bUsed = true;
m_vapor[i].type = type;
m_vapor[i].pos = pos;
m_vapor[i].delay = delay;
m_vapor[i].time = 0.0f;
m_vapor[i].last = 0.0f;
if ( m_vapor[i].type == PARTIFIRE )
{
m_sound->Play(SOUND_BLUP, pos, 1.0f, 1.0f-Math::Rand()*0.5f);
}
if ( m_vapor[i].type == PARTIFLAME )
{
//? m_sound->Play(SOUND_SWIM, pos, 1.0f, 1.0f-Math::Rand()*0.5f);
}
if ( m_vapor[i].type == PARTIVAPOR )
{
m_sound->Play(SOUND_PSHHH, pos, 0.3f, 2.0f);
}
return true;
}
}
return false;
}
// Makes evolve a steam jet,
void CWater::VaporFrame(int i, float rTime)
{
Math::Vector pos, speed;
Math::Point dim;
int j;
m_vapor[i].time += rTime;
if ( m_sound == 0 )
{
m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND);
}
if ( m_vapor[i].time <= m_vapor[i].delay )
{
if ( m_time-m_vapor[i].last >= m_engine->ParticuleAdapt(0.02f) )
{
m_vapor[i].last = m_time;
if ( m_vapor[i].type == PARTIFIRE )
{
for ( j=0 ; j<10 ; j++ )
{
pos = m_vapor[i].pos;
pos.x += (Math::Rand()-0.5f)*2.0f;
pos.z += (Math::Rand()-0.5f)*2.0f;
pos.y -= 1.0f;
speed.x = (Math::Rand()-0.5f)*6.0f;
speed.z = (Math::Rand()-0.5f)*6.0f;
speed.y = 8.0f+Math::Rand()*5.0f;
dim.x = Math::Rand()*1.5f+1.5f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIERROR, 2.0f, 10.0f);
}
}
else if ( m_vapor[i].type == PARTIFLAME )
{
pos = m_vapor[i].pos;
pos.x += (Math::Rand()-0.5f)*8.0f;
pos.z += (Math::Rand()-0.5f)*8.0f;
pos.y -= 2.0f;
speed.x = (Math::Rand()-0.5f)*2.0f;
speed.z = (Math::Rand()-0.5f)*2.0f;
speed.y = 4.0f+Math::Rand()*4.0f;
dim.x = Math::Rand()*2.0f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIFLAME);
}
else
{
pos = m_vapor[i].pos;
pos.x += (Math::Rand()-0.5f)*4.0f;
pos.z += (Math::Rand()-0.5f)*4.0f;
pos.y -= 2.0f;
speed.x = (Math::Rand()-0.5f)*2.0f;
speed.z = (Math::Rand()-0.5f)*2.0f;
speed.y = 8.0f+Math::Rand()*8.0f;
dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIVAPOR);
}
}
}
else
{
m_vapor[i].bUsed = false;
}
}
// Adjusts the position to normal, to imitate reflections on an expanse of water at rest.
void CWater::AdjustLevel(Math::Vector &pos, Math::Vector &norm,
Math::Point &uv1, Math::Point &uv2)
{
#if 0
float t1, t2;
uv1.x = (pos.x+10000.0f)/40.0f;
uv1.y = (pos.z+10000.0f)/40.0f;
t1 = m_time*1.5f + pos.x*0.1f * pos.z*0.2f;
pos.y += sinf(t1)*m_eddy.y;
t1 = m_time*0.6f + pos.x*0.1f * pos.z*0.2f;
t2 = m_time*0.7f + pos.x*0.3f * pos.z*0.4f;
pos.x += sinf(t1)*m_eddy.x;
pos.z += sinf(t2)*m_eddy.z;
//? uv2.x = (pos.x+10000.0f)/40.0f+0.3f;
//? uv2.y = (pos.z+10000.0f)/40.0f+0.4f;
uv2.x = (pos.x+10000.0f)/20.0f;
uv2.y = (pos.z+10000.0f)/20.0f;
t1 = m_time*0.7f + pos.x*5.5f + pos.z*5.6f;
t2 = m_time*0.8f + pos.x*5.7f + pos.z*5.8f;
norm = Math::Vector(sinf(t1)*m_glint, 1.0f, sinf(t2)*m_glint);
#else
float t1, t2;
t1 = m_time*1.5f + pos.x*0.1f * pos.z*0.2f;
pos.y += sinf(t1)*m_eddy.y;
t1 = m_time*1.5f;
uv1.x = (pos.x+10000.0f)/40.0f+sinf(t1)*m_eddy.x*0.02f;
uv1.y = (pos.z+10000.0f)/40.0f-cosf(t1)*m_eddy.z*0.02f;
uv2.x = (pos.x+10010.0f)/20.0f+cosf(-t1)*m_eddy.x*0.02f;
uv2.y = (pos.z+10010.0f)/20.0f-sinf(-t1)*m_eddy.z*0.02f;
t1 = m_time*0.50f + pos.x*2.1f + pos.z*1.1f;
t2 = m_time*0.75f + pos.x*2.0f + pos.z*1.0f;
norm = Math::Vector(sinf(t1)*m_glint, 1.0f, sinf(t2)*m_glint);
#endif
}
// Draw the back surface of the water.
// This surface prevents to see the sky (background) underwater!
void CWater::DrawBack()
{
LPDIRECT3DDEVICE7 device;
D3DVERTEX2 vertex[4]; // 2 triangles
D3DMATERIAL7 material;
Math::Matrix matrix;
Math::Vector eye, lookat, n, p, p1, p2;
Math::Point uv1, uv2;
float deep, dist;
if ( !m_bDraw ) return;
if ( m_type[0] == WATER_NULL ) return;
if ( m_lineUsed == 0 ) return;
eye = m_engine->RetEyePt();
lookat = m_engine->RetLookatPt();
ZeroMemory( &material, sizeof(D3DMATERIAL7) );
material.diffuse = m_diffuse;
material.ambient = m_ambient;
m_engine->SetMaterial(material);
m_engine->SetTexture("", 0);
device = m_engine->RetD3DDevice();
device->SetRenderState(D3DRENDERSTATE_LIGHTING, false);
device->SetRenderState(D3DRENDERSTATE_ZENABLE, false);
device->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false);
m_engine->SetState(D3DSTATENORMAL);
deep = m_engine->RetDeepView(0);
m_engine->SetDeepView(deep*2.0f, 0);
m_engine->SetFocus(m_engine->RetFocus());
m_engine->UpdateMatProj(); // twice the depth of view
matrix.LoadIdentity();
{
D3DMATRIX mat = MAT_TO_D3DMAT(matrix);
device->SetTransform(D3DTRANSFORMSTATE_WORLD, &mat);
}
p.x = eye.x;
p.z = eye.z;
dist = Math::DistanceProjected(eye, lookat);
p.x = (lookat.x-eye.x)*deep*1.0f/dist + eye.x;
p.z = (lookat.z-eye.z)*deep*1.0f/dist + eye.z;
p1.x = (lookat.z-eye.z)*deep*2.0f/dist + p.x;
p1.z = -(lookat.x-eye.x)*deep*2.0f/dist + p.z;
p2.x = -(lookat.z-eye.z)*deep*2.0f/dist + p.x;
p2.z = (lookat.x-eye.x)*deep*2.0f/dist + p.z;
p1.y = -50.0f;
p2.y = m_level;
n.x = (lookat.x-eye.x)/dist;
n.z = (lookat.z-eye.z)/dist;
n.y = 0.0f;
uv1.x = uv1.y = 0.0f;
uv2.x = uv2.y = 0.0f;
vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p2.y, p1.z), n, uv1.x,uv2.y);
vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p1.y, p1.z), n, uv1.x,uv1.y);
vertex[2] = D3DVERTEX2(Math::Vector(p2.x, p2.y, p2.z), n, uv2.x,uv2.y);
vertex[3] = D3DVERTEX2(Math::Vector(p2.x, p1.y, p2.z), n, uv2.x,uv1.y);
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 4, NULL);
m_engine->AddStatisticTriangle(2);
m_engine->SetDeepView(deep, 0);
m_engine->SetFocus(m_engine->RetFocus());
m_engine->UpdateMatProj(); // gives the initial depth of view
device->SetRenderState(D3DRENDERSTATE_LIGHTING, true);
device->SetRenderState(D3DRENDERSTATE_ZENABLE, true);
device->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false);
}
// Draws the flat surface of the water.
void CWater::DrawSurf()
{
LPDIRECT3DDEVICE7 device;
D3DVERTEX2* vertex; // triangles
D3DMATERIAL7 material;
Math::Matrix matrix;
Math::Vector eye, lookat, n, pos, p;
Math::Point uv1, uv2;
bool bUnder;
DWORD flags;
float deep, size, sizez, radius;
int rankview, i, j, u;
if ( !m_bDraw ) return;
if ( m_type[0] == WATER_NULL ) return;
if ( m_lineUsed == 0 ) return;
vertex = (D3DVERTEX2*)malloc(sizeof(D3DVERTEX2)*(m_brick+2)*2);
eye = m_engine->RetEyePt();
lookat = m_engine->RetLookatPt();
rankview = m_engine->RetRankView();
bUnder = ( rankview == 1);
device = m_engine->RetD3DDevice();
//? device->SetRenderState(D3DRENDERSTATE_AMBIENT, 0xffffffff);
//? device->SetRenderState(D3DRENDERSTATE_LIGHTING, true);
//? device->SetRenderState(D3DRENDERSTATE_ZENABLE, false);
device->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false);
matrix.LoadIdentity();
{
D3DMATRIX mat = MAT_TO_D3DMAT(matrix);
device->SetTransform(D3DTRANSFORMSTATE_WORLD, &mat);
}
ZeroMemory( &material, sizeof(D3DMATERIAL7) );
material.diffuse = m_diffuse;
material.ambient = m_ambient;
m_engine->SetMaterial(material);
m_engine->SetTexture(m_filename, 0);
m_engine->SetTexture(m_filename, 1);
if ( m_type[rankview] == WATER_TT )
{
m_engine->SetState(D3DSTATETTb|D3DSTATEDUALw|D3DSTATEWRAP, m_color);
}
if ( m_type[rankview] == WATER_TO )
{
m_engine->SetState(D3DSTATENORMAL|D3DSTATEDUALw|D3DSTATEWRAP);
}
if ( m_type[rankview] == WATER_CT )
{
m_engine->SetState(D3DSTATETTb);
}
if ( m_type[rankview] == WATER_CO )
{
m_engine->SetState(D3DSTATENORMAL);
}
device->SetRenderState(D3DRENDERSTATE_FOGENABLE, true);
size = m_size/2.0f;
if ( bUnder ) sizez = -size;
else sizez = size;
// Draws all the lines.
deep = m_engine->RetDeepView(0)*1.5f;
for ( i=0 ; i<m_lineUsed ; i++ )
{
pos.y = m_level;
pos.z = m_line[i].pz;
pos.x = m_line[i].px1;
// Visible line?
p = pos;
p.x += size*(m_line[i].len-1);
radius = sqrtf(powf(size, 2.0f)+powf(size*m_line[i].len, 2.0f));
if ( Math::Distance(p, eye) > deep+radius ) continue;
D3DVECTOR pD3D = VEC_TO_D3DVEC(p);
device->ComputeSphereVisibility(&pD3D, &radius, 1, 0, &flags);
if ( flags & D3DSTATUS_CLIPINTERSECTIONALL ) continue;
u = 0;
p.x = pos.x-size;
p.z = pos.z-sizez;
p.y = pos.y;
AdjustLevel(p, n, uv1, uv2);
if ( bUnder ) n.y = -n.y;
vertex[u++] = D3DVERTEX2(p, n, uv1.x,uv1.y, uv2.x,uv2.y);
p.x = pos.x-size;
p.z = pos.z+sizez;
p.y = pos.y;
AdjustLevel(p, n, uv1, uv2);
if ( bUnder ) n.y = -n.y;
vertex[u++] = D3DVERTEX2(p, n, uv1.x,uv1.y, uv2.x,uv2.y);
for ( j=0 ; j<m_line[i].len ; j++ )
{
p.x = pos.x+size;
p.z = pos.z-sizez;
p.y = pos.y;
AdjustLevel(p, n, uv1, uv2);
if ( bUnder ) n.y = -n.y;
vertex[u++] = D3DVERTEX2(p, n, uv1.x,uv1.y, uv2.x,uv2.y);
p.x = pos.x+size;
p.z = pos.z+sizez;
p.y = pos.y;
AdjustLevel(p, n, uv1, uv2);
if ( bUnder ) n.y = -n.y;
vertex[u++] = D3DVERTEX2(p, n, uv1.x,uv1.y, uv2.x,uv2.y);
pos.x += size*2.0f;
}
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, u, NULL);
m_engine->AddStatisticTriangle(u-2);
}
free(vertex);
}
// Indicates if there is water in a given position.
bool CWater::RetWater(int x, int y)
{
Math::Vector pos;
float size, offset, level;
int dx, dy;
x *= m_subdiv;
y *= m_subdiv;
size = m_size/m_subdiv;
offset = m_brick*m_size/2.0f;
for ( dy=0 ; dy<=m_subdiv ; dy++ )
{
for ( dx=0 ; dx<=m_subdiv ; dx++ )
{
pos.x = (x+dx)*size - offset;
pos.z = (y+dy)*size - offset;
pos.y = 0.0f;
level = m_terrain->RetFloorLevel(pos, true);
if ( level < m_level+m_eddy.y ) return true;
}
}
return false;
}
// Updates the positions, relative to the ground.
bool CWater::CreateLine(int x, int y, int len)
{
float offset;
m_line[m_lineUsed].x = x;
m_line[m_lineUsed].y = y;
m_line[m_lineUsed].len = len;
offset = m_brick*m_size/2.0f - m_size/2.0f;
m_line[m_lineUsed].px1 = m_size* m_line[m_lineUsed].x - offset;
m_line[m_lineUsed].px2 = m_size*(m_line[m_lineUsed].x+m_line[m_lineUsed].len) - offset;
m_line[m_lineUsed].pz = m_size* m_line[m_lineUsed].y - offset;
m_lineUsed ++;
return ( m_lineUsed < MAXWATERLINE );
}
// Creates all expanses of water.
bool CWater::Create(WaterType type1, WaterType type2, const char *filename,
D3DCOLORVALUE diffuse, D3DCOLORVALUE ambient,
float level, float glint, Math::Vector eddy)
{
int x, y, len;
m_type[0] = type1;
m_type[1] = type2;
m_diffuse = diffuse;
m_ambient = ambient;
m_level = level;
m_glint = glint;
m_eddy = eddy;
m_time = 0.0f;
m_lastLava = 0.0f;
strcpy(m_filename, filename);
VaporFlush();
if ( m_filename[0] != 0 )
{
m_engine->LoadTexture(m_filename, 0);
m_engine->LoadTexture(m_filename, 1);
}
if ( m_terrain == 0 )
{
m_terrain = (CTerrain*)m_iMan->SearchInstance(CLASS_TERRAIN);
}
m_brick = m_terrain->RetBrick()*m_terrain->RetMosaic();
m_size = m_terrain->RetSize();
m_brick /= m_subdiv;
m_size *= m_subdiv;
if ( m_type[0] == WATER_NULL ) return true;
m_lineUsed = 0;
for ( y=0 ; y<m_brick ; y++ )
{
len = 0;
for ( x=0 ; x<m_brick ; x++ )
{
if ( RetWater(x,y) ) // water here?
{
len ++;
if ( len >= 5 )
{
if ( !CreateLine(x-len+1, y, len) ) return false;
len = 0;
}
}
else // dry?
{
if ( len != 0 )
{
if ( !CreateLine(x-len, y, len) ) return false;
len = 0;
}
}
}
if ( len != 0 )
{
if ( !CreateLine(x-len, y, len) ) return false;
}
}
return true;
}
// Removes all the water.
void CWater::Flush()
{
m_type[0] = WATER_NULL;
m_type[1] = WATER_NULL;
m_level = 0.0f;
m_bLava = false;
}
// Changes the level of the water.
bool CWater::SetLevel(float level)
{
m_level = level;
return Create(m_type[0], m_type[1], m_filename, m_diffuse, m_ambient,
m_level, m_glint, m_eddy);
}
// Returns the current level of water.
float CWater::RetLevel()
{
return m_level;
}
// Returns the current level of water for a given object.
float CWater::RetLevel(CObject* object)
{
ObjectType type;
type = object->RetType();
if ( type == OBJECT_HUMAN ||
type == OBJECT_TECH )
{
return m_level-3.0f;
}
if ( type == OBJECT_MOBILEfa ||
type == OBJECT_MOBILEta ||
type == OBJECT_MOBILEwa ||
type == OBJECT_MOBILEia ||
type == OBJECT_MOBILEfc ||
type == OBJECT_MOBILEtc ||
type == OBJECT_MOBILEwc ||
type == OBJECT_MOBILEic ||
type == OBJECT_MOBILEfi ||
type == OBJECT_MOBILEti ||
type == OBJECT_MOBILEwi ||
type == OBJECT_MOBILEii ||
type == OBJECT_MOBILEfs ||
type == OBJECT_MOBILEts ||
type == OBJECT_MOBILEws ||
type == OBJECT_MOBILEis ||
type == OBJECT_MOBILErt ||
type == OBJECT_MOBILErc ||
type == OBJECT_MOBILErr ||
type == OBJECT_MOBILErs ||
type == OBJECT_MOBILEsa ||
type == OBJECT_MOBILEtg ||
type == OBJECT_MOBILEft ||
type == OBJECT_MOBILEtt ||
type == OBJECT_MOBILEwt ||
type == OBJECT_MOBILEit ||
type == OBJECT_MOBILEdr )
{
return m_level-2.0f;
}
return m_level;
}
// Management of the mode of lava/water.
void CWater::SetLava(bool bLava)
{
m_bLava = bLava;
}
bool CWater::RetLava()
{
return m_bLava;
}
// Adjusts the eye of the camera, not to be in the water.
void CWater::AdjustEye(Math::Vector &eye)
{
if ( m_bLava )
{
if ( eye.y < m_level+2.0f )
{
eye.y = m_level+2.0f; // never under the lava
}
}
else
{
if ( eye.y >= m_level-2.0f &&
eye.y <= m_level+2.0f ) // close to the surface?
{
eye.y = m_level+2.0f; // bam, well above
}
}
}

View File

@ -1,130 +0,0 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// water.h
#pragma once
#include "common/event.h"
#include "old/d3dengine.h"
#include "old/particule.h"
class CInstanceManager;
class CTerrain;
class CSound;
const int MAXWATERLINE = 500;
struct WaterLine
{
short x, y; // beginning
short len; // length by x
float px1, px2, pz;
};
const int MAXWATVAPOR = 10;
struct WaterVapor
{
bool bUsed;
ParticuleType type;
Math::Vector pos;
float delay;
float time;
float last;
};
enum WaterType
{
WATER_NULL = 0, // no water
WATER_TT = 1, // transparent texture
WATER_TO = 2, // opaque texture
WATER_CT = 3, // transparent color
WATER_CO = 4, // opaque color
};
class CWater
{
public:
CWater(CInstanceManager* iMan, CD3DEngine* engine);
~CWater();
void SetD3DDevice(LPDIRECT3DDEVICE7 device);
bool EventProcess(const Event &event);
void Flush();
bool Create(WaterType type1, WaterType type2, const char *filename, D3DCOLORVALUE diffuse, D3DCOLORVALUE ambient, float level, float glint, Math::Vector eddy);
void DrawBack();
void DrawSurf();
bool SetLevel(float level);
float RetLevel();
float RetLevel(CObject* object);
void SetLava(bool bLava);
bool RetLava();
void AdjustEye(Math::Vector &eye);
protected:
bool EventFrame(const Event &event);
void LavaFrame(float rTime);
void AdjustLevel(Math::Vector &pos, Math::Vector &norm, Math::Point &uv1, Math::Point &uv2);
bool RetWater(int x, int y);
bool CreateLine(int x, int y, int len);
void VaporFlush();
bool VaporCreate(ParticuleType type, Math::Vector pos, float delay);
void VaporFrame(int i, float rTime);
protected:
CInstanceManager* m_iMan;
CD3DEngine* m_engine;
LPDIRECT3DDEVICE7 m_pD3DDevice;
CTerrain* m_terrain;
CParticule* m_particule;
CSound* m_sound;
WaterType m_type[2];
char m_filename[100];
float m_level; // overall level
float m_glint; // amplitude of reflections
Math::Vector m_eddy; // amplitude of swirls
D3DCOLORVALUE m_diffuse; // diffuse color
D3DCOLORVALUE m_ambient; // ambient color
float m_time;
float m_lastLava;
int m_subdiv;
int m_brick; // number of brick*mosaics
float m_size; // size of a item in an brick
int m_lineUsed;
WaterLine m_line[MAXWATERLINE];
WaterVapor m_vapor[MAXWATVAPOR];
bool m_bDraw;
bool m_bLava;
D3DCOLOR m_color;
};

Binary file not shown.

View File

@ -1,265 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define IDC_STATIC -1
#include <windows.h>
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_MAIN_ICON ICON DISCARDABLE "DirectX.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#define IDC_STATIC -1\r\n"
"#include <windows.h>\r\n"
"\r\n"
"\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_MAIN_ACCEL ACCELERATORS DISCARDABLE
BEGIN
VK_F12, IDM_CHANGEDEVICE, VIRTKEY, SHIFT, NOINVERT
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_ABOUT, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 165
TOPMARGIN, 7
BOTTOMMARGIN, 117
END
IDD_CHANGEDEVICE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 174
TOPMARGIN, 7
BOTTOMMARGIN, 83
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUT DIALOG DISCARDABLE 0, 0, 172, 124
STYLE DS_SYSMODAL | DS_MODALFRAME | DS_NOIDLEMSG | DS_SETFOREGROUND |
DS_3DLOOK | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "About"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,115,103,50,14
ICON IDI_MAIN_ICON,IDC_STATIC,5,5,20,20
LTEXT "Robot Sample",IDC_STATIC,35,5,46,8
LTEXT "Copyright (c) 1999-2000 EPSITEC SA",IDC_STATIC,35,15,
120,8
LTEXT "About",IDC_STATIC,62,52,20,8
LTEXT "Select Driver / Device / Mode",IDC_STATIC,62,62,97,8
CTEXT "<Alt+Enter>",IDC_STATIC,12,72,45,8
LTEXT "Toggle Fullscreen / Windowed",IDC_STATIC,62,72,98,8
LTEXT "Exit",IDC_STATIC,62,82,12,8
CTEXT "<F1>",IDC_STATIC,12,52,45,8
CTEXT "<F2>",IDC_STATIC,12,62,45,8
CTEXT "<ESC>",IDC_STATIC,12,82,45,8
GROUPBOX "Usage",IDC_STATIC,7,42,160,55
LTEXT "Daniel Roux, version 0.1 Janvier 2000",IDC_STATIC,35,26,
121,8
END
IDD_CHANGEDEVICE DIALOG DISCARDABLE 0, 0, 182, 90
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Change device"
FONT 8, "MS Sans Serif"
BEGIN
GROUPBOX "&Device selection",-1,5,5,115,40
COMBOBOX IDC_DEVICE_COMBO,10,15,105,100,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
CONTROL "Use desktop &window",IDC_WINDOWED_CHECKBOX,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,10,30,85,10
GROUPBOX "Fullscreen &modes",IDC_FULLSCREEN_TEXT,5,45,115,40
COMBOBOX IDC_MODE_COMBO,10,55,105,100,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
CONTROL "&Stereoscopic viewing",IDC_STEREO_CHECKBOX,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,10,70,85,9
DEFPUSHBUTTON "OK",IDOK,125,5,50,14
PUSHBUTTON "Cancel",IDCANCEL,125,25,50,14
END
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MENU MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&Go/stop\tEnter", IDM_TOGGLESTART
MENUITEM "&Single step\tSpace", IDM_SINGLESTEP
MENUITEM SEPARATOR
MENUITEM "&About...\tF1", IDM_ABOUT
MENUITEM "&Change device...\tF2", IDM_CHANGEDEVICE
MENUITEM SEPARATOR
MENUITEM "E&xit\tESC", IDM_EXIT
END
END
IDR_POPUP MENU DISCARDABLE
BEGIN
POPUP "Popup"
BEGIN
MENUITEM "&Go/stop", IDM_TOGGLESTART
MENUITEM "&Single step", IDM_SINGLESTEP
MENUITEM SEPARATOR
MENUITEM "&About...", IDM_ABOUT
MENUITEM "&Change device...", IDM_CHANGEDEVICE
MENUITEM SEPARATOR
MENUITEM "E&xit", IDM_EXIT
END
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// French (Switzerland) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRS)
#ifdef _WIN32
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH_SWISS
#pragma code_page(1252)
#endif //_WIN32
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "100c04b0"
BEGIN
VALUE "CompanyName", "www.epsitec.com\0"
VALUE "FileDescription", "CeeBot\0"
VALUE "FileVersion", "Version 1.0\0"
VALUE "InternalName", "CeeBot\0"
VALUE "LegalCopyright", "Copyright © 2001 by EPSITEC SA\0"
VALUE "OriginalFilename", "ceebot.exe\0"
VALUE "ProductName", "EPSITEC CeeBot\0"
VALUE "ProductVersion", "Version 1.0\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x100c, 1200
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// Cursor
//
IDC_CURSORHAND CURSOR DISCARDABLE "cursor1.cur"
IDC_CURSORSCROLLL CURSOR DISCARDABLE "cursorha.cur"
IDC_CURSORSCROLLR CURSOR DISCARDABLE "cursorsc.cur"
IDC_CURSORSCROLLU CURSOR DISCARDABLE "cur00001.cur"
IDC_CURSORSCROLLD CURSOR DISCARDABLE "cur00002.cur"
IDC_CURSORTARGET CURSOR DISCARDABLE "cur00003.cur"
#endif // French (Switzerland) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED