Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
w3d_util.cpp
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/***********************************************************************************************
20 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21 ***********************************************************************************************
22 * *
23 * Project Name : WW3D *
24 * *
25 * $Archive:: /Commando/Code/ww3d2/w3d_util.cpp $*
26 * *
27 * Author:: Greg Hjelstrom *
28 * *
29 * $Modtime:: 7/23/01 5:31p $*
30 * *
31 * $Revision:: 5 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36
37
38#include "w3d_util.h"
39#include "vector3.h"
40#include "vector4.h"
41#include "quat.h"
42#include "shader.h"
43
44
46{
47 set->X = v.X;
48 set->Y = v.Y;
49 set->Z = v.Z;
50}
51
53{
54 set->X = v.X;
55 set->Y = v.Y;
56 set->Z = v.Z;
57}
58
60{
61 set->X = q.Q[0];
62 set->Y = q.Q[1];
63 set->Z = q.Q[2];
64 set->W = q.Q[3];
65}
66
68{
69 set->Q[0] = q.X;
70 set->Q[1] = q.Y;
71 set->Q[2] = q.Z;
72 set->Q[3] = q.W;
73}
74
76{
77 set->X = (float)rgb.R / 255.0f;
78 set->Y = (float)rgb.G / 255.0f;
79 set->Z = (float)rgb.B / 255.0f;
80}
81
83{
84 color->R = (uint8)(255.0f * v.X);
85 color->G = (uint8)(255.0f * v.Y);
86 color->B = (uint8)(255.0f * v.Z);
87 color->pad = 0;
88}
89
91{
92 set->X = (float)rgb.R / 255.0f;
93 set->Y = (float)rgb.G / 255.0f;
94 set->Z = (float)rgb.B / 255.0f;
95 set->W = (float)rgb.A / 255.0f;
96}
97
99{
100 color->R = (uint8)(255.0f * v.X);
101 color->G = (uint8)(255.0f * v.Y);
102 color->B = (uint8)(255.0f * v.Z);
103 color->A = (uint8)(255.0f * v.W);
104}
105
107{
118// Jani: No cull mode settings for w3d shader - problem?
119// set->Set_Dither_Mask (ShaderClass::DITHER_ENABLE);
120 // The tools do not enable setting post-detail stuff, and in any case we probably wouldn't
121 // want to confuse the artists with the distinction between detail and post-detail settings at
122 // this point, so we just copy the detail settings into the post-detail settings.
123// set->Set_Post_Detail_Color_Func ((ShaderClass::DetailColorFuncType) W3d_Shader_Get_Post_Detail_Color_Func (&shader));
124// set->Set_Post_Detail_Alpha_Func ((ShaderClass::DetailAlphaFuncType) W3d_Shader_Get_Post_Detail_Alpha_Func (&shader));
127}
128
int W3d_Shader_Get_Depth_Compare(const W3dPS2ShaderStruct *s)
Definition w3d_file.h:975
void W3d_Shader_Reset(W3dShaderStruct *s)
Definition w3d_file.h:925
int W3d_Shader_Get_Pri_Gradient(const W3dPS2ShaderStruct *s)
Definition w3d_file.h:977
int W3d_Shader_Get_Src_Blend_Func(const W3dShaderStruct *s)
Definition w3d_file.h:987
int W3d_Shader_Get_Detail_Alpha_Func(const W3dShaderStruct *s)
Definition w3d_file.h:990
void W3d_Shader_Set_Dest_Blend_Func(W3dShaderStruct *s, int val)
Definition w3d_file.h:946
void W3d_Shader_Set_Texturing(W3dShaderStruct *s, int val)
Definition w3d_file.h:950
void W3d_Shader_Set_Depth_Mask(W3dShaderStruct *s, int val)
Definition w3d_file.h:945
int W3d_Shader_Get_Detail_Color_Func(const W3dShaderStruct *s)
Definition w3d_file.h:989
void W3d_Shader_Set_Pri_Gradient(W3dShaderStruct *s, int val)
Definition w3d_file.h:947
void W3d_Shader_Set_Src_Blend_Func(W3dShaderStruct *s, int val)
Definition w3d_file.h:949
void W3d_Shader_Set_Post_Detail_Color_Func(W3dShaderStruct *s, int val)
Definition w3d_file.h:954
void W3d_Shader_Set_Post_Detail_Alpha_Func(W3dShaderStruct *s, int val)
Definition w3d_file.h:955
int W3d_Shader_Get_Alpha_Test(const W3dPS2ShaderStruct *s)
Definition w3d_file.h:979
int W3d_Shader_Get_Depth_Mask(const W3dPS2ShaderStruct *s)
Definition w3d_file.h:976
int W3d_Shader_Get_Sec_Gradient(const W3dShaderStruct *s)
Definition w3d_file.h:986
void W3d_Shader_Set_Depth_Compare(W3dShaderStruct *s, int val)
Definition w3d_file.h:944
int W3d_Shader_Get_Dest_Blend_Func(const W3dShaderStruct *s)
Definition w3d_file.h:984
int W3d_Shader_Get_Texturing(const W3dPS2ShaderStruct *s)
Definition w3d_file.h:978
void W3d_Shader_Set_Alpha_Test(W3dShaderStruct *s, int val)
Definition w3d_file.h:953
void W3d_Shader_Set_Sec_Gradient(W3dShaderStruct *s, int val)
Definition w3d_file.h:948
unsigned char uint8
Definition bittype.h:44
float X
Definition quat.h:60
float Z
Definition quat.h:62
float Y
Definition quat.h:61
float W
Definition quat.h:63
void Set_Texturing(TexturingType x)
Definition shader.h:335
DepthCompareType Get_Depth_Compare(void) const
Definition shader.h:308
DetailColorFuncType
Definition shader.h:138
void Set_Src_Blend_Func(SrcBlendFuncType x)
Definition shader.h:334
void Set_Post_Detail_Alpha_Func(DetailAlphaFuncType x)
Definition shader.h:326
DetailColorFuncType Get_Post_Detail_Color_Func(void) const
Definition shader.h:312
@ FOG_DISABLE
Definition shader.h:183
void Set_Depth_Compare(DepthCompareType x)
Definition shader.h:323
void Set_Depth_Mask(DepthMaskType x)
Definition shader.h:324
@ COLOR_WRITE_ENABLE
Definition shader.h:124
DetailAlphaFuncType
Definition shader.h:129
void Set_Primary_Gradient(PriGradientType x)
Definition shader.h:332
DetailAlphaFuncType Get_Post_Detail_Alpha_Func(void) const
Definition shader.h:311
TexturingType Get_Texturing(void) const
Definition shader.h:320
SecGradientType Get_Secondary_Gradient(void) const
Definition shader.h:318
void Set_Fog_Func(FogFuncType x)
Definition shader.h:331
DepthMaskType Get_Depth_Mask(void) const
Definition shader.h:309
PriGradientType Get_Primary_Gradient(void) const
Definition shader.h:317
void Set_Post_Detail_Color_Func(DetailColorFuncType x)
Definition shader.h:327
SrcBlendFuncType Get_Src_Blend_Func(void) const
Definition shader.h:319
void Set_Dst_Blend_Func(DstBlendFuncType x)
Definition shader.h:330
DstBlendFuncType Get_Dst_Blend_Func(void) const
Definition shader.h:315
void Set_Alpha_Test(AlphaTestType x)
Definition shader.h:328
AlphaTestType Get_Alpha_Test(void) const
Definition shader.h:313
void Set_Color_Mask(ColorMaskType x)
Definition shader.h:325
void Set_Secondary_Gradient(SecGradientType x)
Definition shader.h:333
float X
Definition vector3.h:90
float Z
Definition vector3.h:92
float Y
Definition vector3.h:91
float Y
Definition vector4.h:67
float Z
Definition vector4.h:68
float X
Definition vector4.h:66
float W
Definition vector4.h:69
static void Convert_Quaternion(const W3dQuaternionStruct &q, Quaternion *set)
Definition w3d_util.cpp:59
static void Convert_Vector(const W3dVectorStruct &v, Vector3 *set)
Definition w3d_util.cpp:45
static void Convert_Color(const W3dRGBStruct &rgb, Vector3 *set)
Definition w3d_util.cpp:75
static void Convert_Shader(const W3dShaderStruct &shader, ShaderClass *set)
Definition w3d_util.cpp:106
int q
Definition test1.cpp:94