mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 14:39:18 +02:00
Reorganize source files into logical subdirectories
Co-authored-by: Hirek193 <23196899+Hirek193@users.noreply.github.com>
This commit is contained in:
64
model/vertex.cpp
Normal file
64
model/vertex.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "vertex.h"
|
||||
#include "sn_utils.h"
|
||||
|
||||
void
|
||||
world_vertex::serialize( std::ostream &s ) const {
|
||||
|
||||
sn_utils::ls_float64( s, position.x );
|
||||
sn_utils::ls_float64( s, position.y );
|
||||
sn_utils::ls_float64( s, position.z );
|
||||
|
||||
sn_utils::ls_float32( s, normal.x );
|
||||
sn_utils::ls_float32( s, normal.y );
|
||||
sn_utils::ls_float32( s, normal.z );
|
||||
|
||||
sn_utils::ls_float32( s, texture.x );
|
||||
sn_utils::ls_float32( s, texture.y );
|
||||
}
|
||||
|
||||
void
|
||||
world_vertex::deserialize( std::istream &s ) {
|
||||
|
||||
position.x = sn_utils::ld_float64( s );
|
||||
position.y = sn_utils::ld_float64( s );
|
||||
position.z = sn_utils::ld_float64( s );
|
||||
|
||||
normal.x = sn_utils::ld_float32( s );
|
||||
normal.y = sn_utils::ld_float32( s );
|
||||
normal.z = sn_utils::ld_float32( s );
|
||||
|
||||
texture.x = sn_utils::ld_float32( s );
|
||||
texture.y = sn_utils::ld_float32( s );
|
||||
}
|
||||
|
||||
template <>
|
||||
world_vertex &
|
||||
world_vertex::operator+=( world_vertex const &Right ) {
|
||||
|
||||
position += Right.position;
|
||||
normal += Right.normal;
|
||||
texture += Right.texture;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <>
|
||||
world_vertex &
|
||||
world_vertex::operator*=( world_vertex const &Right ) {
|
||||
|
||||
position *= Right.position;
|
||||
normal *= Right.normal;
|
||||
texture *= Right.texture;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user